From 4cc3a3096a5ad28a070db12424db586c40457243 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 13 Feb 2012 17:15:31 +0100 Subject: [PATCH 0001/1537] Server verhindert beim OSX Client einen Delete --- 3rdparty/Sabre/DAV/Server.php | 2 +- apps/calendar/lib/connector_sabre.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php index 3d76d4f191..28c69188a3 100644 --- a/3rdparty/Sabre/DAV/Server.php +++ b/3rdparty/Sabre/DAV/Server.php @@ -648,7 +648,7 @@ class Sabre_DAV_Server { * @return void */ protected function httpDelete($uri) { - + if (!$this->broadcastEvent('beforeUnbind',array($uri))) return; $this->tree->delete($uri); diff --git a/apps/calendar/lib/connector_sabre.php b/apps/calendar/lib/connector_sabre.php index 263fb7ffde..47bf4f202e 100644 --- a/apps/calendar/lib/connector_sabre.php +++ b/apps/calendar/lib/connector_sabre.php @@ -206,6 +206,10 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract { * @return void */ public function deleteCalendar($calendarId) { + if(preg_match( '=iCal/[1-4]?.*Mac OS X/10.[1-6](.[0-9])?=', $_SERVER['HTTP_USER_AGENT'] )){ + throw new Sabre_DAV_Exception_Forbidden("Action is not possible with OSX 10.6.x", 403); + } + OC_Calendar_Calendar::deleteCalendar($calendarId); } From d049d9bd0c70c929c2116cf7d8d088dfa7f9ae62 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Thu, 29 Mar 2012 23:16:19 +0200 Subject: [PATCH 0002/1537] initial commit for OC_Exception --- config/config.sample.php | 3 +- core/css/styles.css | 3 ++ core/templates/exception.php | 30 +++++++++++++++ lib/exception.php | 74 ++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 core/templates/exception.php create mode 100644 lib/exception.php diff --git a/config/config.sample.php b/config/config.sample.php index 199c9248c5..a5feff509b 100755 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -19,6 +19,7 @@ $CONFIG = array( "knowledgebaseurl" => "", "appstoreenabled" => true, "appstoreurl" => "", -// "datadirectory" => "" +// "datadirectory" => "", +"sysinfoexception" => true ); ?> diff --git a/core/css/styles.css b/core/css/styles.css index f5a181c452..6c00b571ba 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -131,3 +131,6 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff .separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; } a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px } + +.exception{color: #000000;} +.exception textarea{width:95%;height: 200px;background:#ffe;border:0;} diff --git a/core/templates/exception.php b/core/templates/exception.php new file mode 100644 index 0000000000..7f58ce252c --- /dev/null +++ b/core/templates/exception.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/lib/exception.php b/lib/exception.php new file mode 100644 index 0000000000..b4724e7c8c --- /dev/null +++ b/lib/exception.php @@ -0,0 +1,74 @@ +. + * + */ +class OC_Exception extends Exception{ + + function __construct($message = null, $code = 0, $file = null, $line = null){ + parent::__construct($message, $code); + if(!is_null($file)){ + $this->file = $file; + } + if(!is_null($line)){ + $this->line = $line; + } + $this->writelog(); + } + + private function writelog(){ + @OC_Log::write(OC_App::getCurrentApp(), $this->getMessage() . '-' . $this->getFile() . '-' . $this->getLine(), OC_Log::FATAL); + } + + private function generatesysinfo(){ + return array('phpversion' => PHP_VERSION, + 'os' => php_uname('s'), + 'osrelease' => php_uname('r'), + 'osarchitecture' => php_uname('m'), + 'phpserverinterface' => php_sapi_name(), + 'serverprotocol' => $_SERVER['SERVER_PROTOCOL'], + 'requestmethod' => $_SERVER['REQUEST_METHOD'], + 'https' => ($_SERVER['HTTPS']==''?'false':'true'), + 'database'=>(@OC_Config::getValue('dbtype')!=''?@OC_Config::getValue('dbtype'):'') + ); + } + + function __toString(){ + $tmpl = new OC_Template('core', 'exception', 'guest'); + $tmpl->assign('showsysinfo', true); + $tmpl->assign('message', $this->getMessage()); + $tmpl->assign('code', $this->getCode()); + $tmpl->assign('file', $this->getFile()); + $tmpl->assign('line', $this->getLine()); + $tmpl->assign('sysinfo', $this->generatesysinfo()); + $tmpl->printPage(); + } +} + +function oc_exceptionhandler($exception){ + throw new OC_Exception($exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine()); + return true; +} + +function oc_errorhandler(){ + +} +set_exception_handler('oc_exceptionhandler'); +set_error_handler('oc_errorhandler'); +error_reporting(E_ERROR | E_WARNING | E_PARSE); \ No newline at end of file From 926e777061efcc29d293b4af305ca9d0d01f6e22 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 30 Mar 2012 23:37:47 +0200 Subject: [PATCH 0003/1537] filter notice and deprecated errors and write a proper error handler function --- lib/exception.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/exception.php b/lib/exception.php index b4724e7c8c..db516fc12d 100644 --- a/lib/exception.php +++ b/lib/exception.php @@ -62,12 +62,31 @@ class OC_Exception extends Exception{ } function oc_exceptionhandler($exception){ - throw new OC_Exception($exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine()); + switch($exception->getCode()){ + case E_NOTICE: + case E_DEPRECATED: + case E_USER_NOTICE: + case E_USER_DEPRECATED: + break; + default: + throw new OC_Exception($exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine()); + break; + } return true; } -function oc_errorhandler(){ - +function oc_errorhandler($errno , $errstr , $errfile , $errline){ + switch($errno){ + case E_NOTICE: + case E_DEPRECATED: + case E_USER_NOTICE: + case E_USER_DEPRECATED: + break; + default: + throw new OC_Exception($errstr, $errno, $errfile, $errline); + break; + } + return true; } set_exception_handler('oc_exceptionhandler'); set_error_handler('oc_errorhandler'); From f75a7c084f0b52cd3e6fa0123ea753eec74b154b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 1 May 2012 16:16:12 +0200 Subject: [PATCH 0004/1537] add class for repeating events --- apps/calendar/lib/repeat.php | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 apps/calendar/lib/repeat.php diff --git a/apps/calendar/lib/repeat.php b/apps/calendar/lib/repeat.php new file mode 100644 index 0000000000..fe2ba7cfa8 --- /dev/null +++ b/apps/calendar/lib/repeat.php @@ -0,0 +1,41 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +/* + * This class manages the caching of repeating events + * Events will be cached for the current year ± 5 years + */ +class OC_Calendar_Repeat{ + /* + * @brief returns the cache of an event + */ + public static function get(); + /* + * @brief returns the cache of all events of a calendar + */ + public static function getcalendar(); + /* + * @brief generates the cache the first time + */ + public static function generate(); + /* + * @brief updates an event that is already cached + */ + public static function update(); + /* + * @brief checks if an event is already cached + */ + public static function is_cached(); + /* + * @brief removes the cache of an event + */ + public static function clean(); + /* + * @brief removes the cache of all events of a calendar + */ + public static function cleancalendar(); +} \ No newline at end of file From d251f3a994e68830095ebb263ae5fc8d83fc7c68 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 1 May 2012 18:20:32 +0200 Subject: [PATCH 0005/1537] create remote directory --- remote/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 remote/.gitignore diff --git a/remote/.gitignore b/remote/.gitignore new file mode 100644 index 0000000000..c96a04f008 --- /dev/null +++ b/remote/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file From 2ad673b7bd1ceae592eb59c87b066d959ae0401b Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 1 May 2012 18:22:16 +0200 Subject: [PATCH 0006/1537] revert d251f3a994e68830095ebb263ae5fc8d83fc7c68 --- remote/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 remote/.gitignore diff --git a/remote/.gitignore b/remote/.gitignore deleted file mode 100644 index c96a04f008..0000000000 --- a/remote/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file From 640ba1828f3edfdd2e71825828c51b734fb19d1c Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 19 Mar 2012 21:56:07 +0100 Subject: [PATCH 0007/1537] Start of audit app Audit the filesystem action --- apps/admin_audit/appinfo/app.php | 10 +++++++ apps/admin_audit/appinfo/info.xml | 10 +++++++ apps/admin_audit/lib/hooks_handlers.php | 36 +++++++++++++++++++++++++ lib/filesystem.php | 2 +- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 apps/admin_audit/appinfo/app.php create mode 100644 apps/admin_audit/appinfo/info.xml create mode 100644 apps/admin_audit/lib/hooks_handlers.php diff --git a/apps/admin_audit/appinfo/app.php b/apps/admin_audit/appinfo/app.php new file mode 100644 index 0000000000..b1b986fb7b --- /dev/null +++ b/apps/admin_audit/appinfo/app.php @@ -0,0 +1,10 @@ + + + admin_audit + Log audit info + 0.1 + AGPL + Bart Visscher + 2 + Audit user actions in Owncloud + diff --git a/apps/admin_audit/lib/hooks_handlers.php b/apps/admin_audit/lib/hooks_handlers.php new file mode 100644 index 0000000000..924878840a --- /dev/null +++ b/apps/admin_audit/lib/hooks_handlers.php @@ -0,0 +1,36 @@ + Date: Fri, 23 Mar 2012 22:34:55 +0100 Subject: [PATCH 0008/1537] Audit: Add user login/logout logging --- apps/admin_audit/appinfo/app.php | 4 ++++ apps/admin_audit/lib/hooks_handlers.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/apps/admin_audit/appinfo/app.php b/apps/admin_audit/appinfo/app.php index b1b986fb7b..27a72de432 100644 --- a/apps/admin_audit/appinfo/app.php +++ b/apps/admin_audit/appinfo/app.php @@ -2,6 +2,10 @@ OC::$CLASSPATH['OC_Admin_Audit_Hooks_Handlers'] = 'apps/admin_audit/lib/hooks_handlers.php'; +OCP\Util::connectHook('OCP\User', 'pre_login', 'OC_Admin_Audit_Hooks_Handlers', 'pre_login'); +OCP\Util::connectHook('OCP\User', 'post_login', 'OC_Admin_Audit_Hooks_Handlers', 'post_login'); +OCP\Util::connectHook('OCP\User', 'logout', 'OC_Admin_Audit_Hooks_Handlers', 'logout'); + OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, 'OC_Admin_Audit_Hooks_Handlers', 'rename'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, 'OC_Admin_Audit_Hooks_Handlers', 'create'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_Admin_Audit_Hooks_Handlers', 'copy'); diff --git a/apps/admin_audit/lib/hooks_handlers.php b/apps/admin_audit/lib/hooks_handlers.php index 924878840a..8ebabbac7b 100644 --- a/apps/admin_audit/lib/hooks_handlers.php +++ b/apps/admin_audit/lib/hooks_handlers.php @@ -1,6 +1,19 @@ Date: Thu, 29 Mar 2012 11:24:29 +0200 Subject: [PATCH 0009/1537] Audit: Log messages with separate function --- apps/admin_audit/lib/hooks_handlers.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/admin_audit/lib/hooks_handlers.php b/apps/admin_audit/lib/hooks_handlers.php index 8ebabbac7b..4cc3194eaf 100644 --- a/apps/admin_audit/lib/hooks_handlers.php +++ b/apps/admin_audit/lib/hooks_handlers.php @@ -3,47 +3,50 @@ class OC_Admin_Audit_Hooks_Handlers { static public function pre_login($params) { $path = $params['uid']; - OCP\Util::writeLog('admin_audit', 'Trying login '.$user, OCP\Util::INFO); + self::log('Trying login '.$user); } static public function post_login($params) { $path = $params['uid']; - OCP\Util::writeLog('admin_audit', 'Login '.$user, OCP\Util::INFO); + self::log('Login '.$user); } static public function logout($params) { $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Logout '.$user, OCP\Util::INFO); + self::log('Logout '.$user); } static public function rename($params) { $oldpath = $params[OC_Filesystem::signal_param_oldpath]; $newpath = $params[OC_Filesystem::signal_param_newpath]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user, OCP\Util::INFO); + self::log('Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user); } static public function create($params) { $path = $params[OC_Filesystem::signal_param_path]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Create "'.$path.'" by '.$user, OCP\Util::INFO); + self::log('Create "'.$path.'" by '.$user); } static public function copy($params) { $oldpath = $params[OC_Filesystem::signal_param_oldpath]; $newpath = $params[OC_Filesystem::signal_param_newpath]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user, OCP\Util::INFO); + self::log('Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user); } static public function write($params) { $path = $params[OC_Filesystem::signal_param_path]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Write "'.$path.'" by '.$user, OCP\Util::INFO); + self::log('Write "'.$path.'" by '.$user); } static public function read($params) { $path = $params[OC_Filesystem::signal_param_path]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Read "'.$path.'" by '.$user, OCP\Util::INFO); + self::log('Read "'.$path.'" by '.$user); } static public function delete($params) { $path = $params[OC_Filesystem::signal_param_path]; $user = OCP\User::getUser(); - OCP\Util::writeLog('admin_audit', 'Delete "'.$path.'" by '.$user, OCP\Util::INFO); + self::log('Delete "'.$path.'" by '.$user); + } + static protected function log($msg) { + OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO); } } From 2d581c675fb488df0875e4a489821cf88b7679ac Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 13 Apr 2012 19:40:33 +0200 Subject: [PATCH 0010/1537] Audit: Log sharing actions --- apps/admin_audit/appinfo/app.php | 4 ++++ apps/admin_audit/lib/hooks_handlers.php | 20 ++++++++++++++++++++ apps/files_sharing/get.php | 1 + apps/files_sharing/lib_share.php | 2 ++ 4 files changed, 27 insertions(+) diff --git a/apps/admin_audit/appinfo/app.php b/apps/admin_audit/appinfo/app.php index 27a72de432..e52f633cf1 100644 --- a/apps/admin_audit/appinfo/app.php +++ b/apps/admin_audit/appinfo/app.php @@ -12,3 +12,7 @@ OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, 'OC_ OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, 'OC_Admin_Audit_Hooks_Handlers', 'write'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_read, 'OC_Admin_Audit_Hooks_Handlers', 'read'); OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, 'OC_Admin_Audit_Hooks_Handlers', 'delete'); + +OCP\Util::connectHook('OC_Share', 'public', 'OC_Admin_Audit_Hooks_Handlers', 'share_public'); +OCP\Util::connectHook('OC_Share', 'public-download', 'OC_Admin_Audit_Hooks_Handlers', 'share_public_download'); +OCP\Util::connectHook('OC_Share', 'user', 'OC_Admin_Audit_Hooks_Handlers', 'share_user'); diff --git a/apps/admin_audit/lib/hooks_handlers.php b/apps/admin_audit/lib/hooks_handlers.php index 4cc3194eaf..c5aec97d93 100644 --- a/apps/admin_audit/lib/hooks_handlers.php +++ b/apps/admin_audit/lib/hooks_handlers.php @@ -46,6 +46,26 @@ class OC_Admin_Audit_Hooks_Handlers { $user = OCP\User::getUser(); self::log('Delete "'.$path.'" by '.$user); } + static public function share_public($params) { + $path = $params['source']; + $token = $params['token']; + $user = OCP\User::getUser(); + self::log('Shared "'.$path.'" with public, token="'.$token.'" by '.$user); + } + static public function share_public_download($params) { + $path = $params['source']; + $token = $params['token']; + $user = $_SERVER['REMOTE_ADDR']; + self::log('Download of shared "'.$path.'" token="'.$token.'" by '.$user); + } + static public function share_user($params) { + $path = $params['source']; + $permissions = $params['permissions']; + $with = $params['with']; + $user = OCP\User::getUser(); + $rw = $permissions & OC_Share::WRITE ? 'w' : 'o'; + self::log('Shared "'.$path.'" (r'.$rw.') with user "'.$with.'" by '.$user); + } static protected function log($msg) { OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO); } diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php index de3bc5f46d..57ff6b6e20 100755 --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -74,6 +74,7 @@ if ($source !== false) { header("Content-Length: " . OC_Filesystem::filesize($source)); //download the file @ob_clean(); + OCP\Util::emitHook('OC_Share', 'public-download', array('source'=>$source, 'token'=>$token); OC_Filesystem::readfile($source); } } else { diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index d5cf3d0a1b..14c61c620a 100755 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -43,6 +43,7 @@ class OC_Share { $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)"); if ($uid_shared_with == self::PUBLICLINK) { $token = sha1("$uid_shared_with-$source"); + OCP\Util::emitHook('OC_Share', 'public', array('source'=>$source, 'token'=>$token, 'permissions'=>$permissions)); $query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions)); $this->token = $token; } else { @@ -97,6 +98,7 @@ class OC_Share { if (isset($gid)) { $uid = $uid."@".$gid; } + OCP\Util::emitHook('OC_Share', 'user', array('source'=>$source, 'target'=>$target, 'with'=>$uid, 'permissions'=>$permissions)); $query->execute(array($uid_owner, $uid, $source, $target, $permissions)); // Add file to filesystem cache $userDirectory = "/".OCP\USER::getUser()."/files"; From ac2e0cd6e450607585fbac2ec00a952744a4a36b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 8 May 2012 09:07:11 +0200 Subject: [PATCH 0011/1537] Implement default functions in OC_User backend Simplifies calling these functions, and makes code simpler functions: deleteUser getUsers userExists --- apps/user_openid/user_openid.php | 2 +- lib/user.php | 20 ++++++---------- lib/user/backend.php | 40 +++++++++++++++++++++++++------- lib/user/example.php | 30 ------------------------ 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index 8deb42f68c..710d400aa5 100755 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -24,7 +24,7 @@ require_once('class.openid.v3.php'); /** - * Class for user management in a SQL Database (e.g. MySQL, SQLite) + * Class for user OpenId backend */ class OC_USER_OPENID extends OC_User_Backend { /** diff --git a/lib/user.php b/lib/user.php index 816caff8dd..ad5198d037 100644 --- a/lib/user.php +++ b/lib/user.php @@ -161,9 +161,7 @@ class OC_User { if( $run ){ //delete the user from all backends foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_DELETE_USER)){ - $backend->deleteUser($uid); - } + $backend->deleteUser($uid); } // We have to delete the user from all groups foreach( OC_Group::getUserGroups( $uid ) as $i ){ @@ -323,11 +321,9 @@ class OC_User { public static function getUsers(){ $users=array(); foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){ - $backendUsers=$backend->getUsers(); - if(is_array($backendUsers)){ - $users=array_merge($users,$backendUsers); - } + $backendUsers=$backend->getUsers(); + if(is_array($backendUsers)){ + $users=array_merge($users,$backendUsers); } } return $users; @@ -340,11 +336,9 @@ class OC_User { */ public static function userExists($uid){ foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_USER_EXISTS)){ - $result=$backend->userExists($uid); - if($result===true){ - return true; - } + $result=$backend->userExists($uid); + if($result===true){ + return true; } } return false; diff --git a/lib/user/backend.php b/lib/user/backend.php index 4afdf15215..8c954338fb 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -32,11 +32,8 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); * actions that user backends can define */ define('OC_USER_BACKEND_CREATE_USER', 0x000001); -define('OC_USER_BACKEND_DELETE_USER', 0x000010); -define('OC_USER_BACKEND_SET_PASSWORD', 0x000100); -define('OC_USER_BACKEND_CHECK_PASSWORD', 0x001000); -define('OC_USER_BACKEND_GET_USERS', 0x010000); -define('OC_USER_BACKEND_USER_EXISTS', 0x100000); +define('OC_USER_BACKEND_SET_PASSWORD', 0x000010); +define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100); /** @@ -47,11 +44,8 @@ abstract class OC_User_Backend { protected $possibleActions = array( OC_USER_BACKEND_CREATE_USER => 'createUser', - OC_USER_BACKEND_DELETE_USER => 'deleteUser', OC_USER_BACKEND_SET_PASSWORD => 'setPassword', OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword', - OC_USER_BACKEND_GET_USERS => 'getUsers', - OC_USER_BACKEND_USER_EXISTS => 'userExists' ); /** @@ -83,4 +77,34 @@ abstract class OC_User_Backend { public function implementsActions($actions){ return (bool)($this->getSupportedActions() & $actions); } + + /** + * @brief delete a user + * @param $uid The username of the user to delete + * @returns true/false + * + * Deletes a user + */ + public function deleteUser( $uid ){ + return false; + } + + /** + * @brief Get a list of all users + * @returns array with all uids + * + * Get a list of all users. + */ + public function getUsers(){ + return array(); + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return false; + } } diff --git a/lib/user/example.php b/lib/user/example.php index 7481014de7..270b72e389 100644 --- a/lib/user/example.php +++ b/lib/user/example.php @@ -39,17 +39,6 @@ abstract class OC_User_Example extends OC_User_Backend { return OC_USER_BACKEND_NOT_IMPLEMENTED; } - /** - * @brief delete a user - * @param $uid The username of the user to delete - * @returns true/false - * - * Deletes a user - */ - public function deleteUser( $uid ){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - /** * @brief Set password * @param $uid The username @@ -73,23 +62,4 @@ abstract class OC_User_Example extends OC_User_Backend { public function checkPassword($uid, $password){ return OC_USER_BACKEND_NOT_IMPLEMENTED; } - - /** - * @brief Get a list of all users - * @returns array with all uids - * - * Get a list of all users. - */ - public function getUsers(){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @brief check if a user exists - * @param string $uid the username - * @return boolean - */ - public function userExists($uid){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } } From e77ba0280a0ebceef348750f5ff9738012e2b8fb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 8 May 2012 17:46:35 +0200 Subject: [PATCH 0012/1537] Implement default functions in OC_Group backend Simplifies calling these functions, and makes code simpler functions: inGroup getUserGroups getGroups usersInGroup --- lib/group.php | 14 +---------- lib/group/backend.php | 58 +++++++++++++++++++++++++++++++++---------- lib/group/example.php | 7 ++++++ 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/lib/group.php b/lib/group.php index 9b2959d1f7..bc98e877ad 100644 --- a/lib/group.php +++ b/lib/group.php @@ -84,7 +84,7 @@ class OC_Group { OC_Hook::emit( "OC_Group", "pre_createGroup", array( "run" => &$run, "gid" => $gid )); if($run){ - //create the user in the first backend that supports creating users + //create the group in the first backend that supports creating groups foreach(self::$_usedBackends as $backend){ if(!$backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP)) continue; @@ -141,9 +141,6 @@ class OC_Group { */ public static function inGroup( $uid, $gid ){ foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_IN_GROUP)) - continue; - if($backend->inGroup($uid,$gid)){ return true; } @@ -224,9 +221,6 @@ class OC_Group { public static function getUserGroups( $uid ){ $groups=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USER_GROUPS)) - continue; - $groups=array_merge($backend->getUserGroups($uid),$groups); } return $groups; @@ -241,9 +235,6 @@ class OC_Group { public static function getGroups(){ $groups=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)) - continue; - $groups=array_merge($backend->getGroups(),$groups); } return $groups; @@ -270,9 +261,6 @@ class OC_Group { public static function usersInGroup($gid){ $users=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USERS)) - continue; - $users=array_merge($backend->usersInGroup($gid),$users); } return $users; diff --git a/lib/group/backend.php b/lib/group/backend.php index af6c53c803..7984a6a835 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -31,12 +31,8 @@ define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501); */ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); -define('OC_GROUP_BACKEND_IN_GROUP', 0x00000100); -define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00001000); -define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00010000); -define('OC_GROUP_BACKEND_GET_USER_GROUPS', 0x00100000); -define('OC_GROUP_BACKEND_GET_USERS', 0x01000000); -define('OC_GROUP_BACKEND_GET_GROUPS', 0x10000000); +define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); +define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); /** * Abstract base class for user management @@ -45,12 +41,8 @@ abstract class OC_Group_Backend { protected $possibleActions = array( OC_GROUP_BACKEND_CREATE_GROUP => 'createGroup', OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup', - OC_GROUP_BACKEND_IN_GROUP => 'inGroup', OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup', OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup', - OC_GROUP_BACKEND_GET_USER_GROUPS => 'getUserGroups', - OC_GROUP_BACKEND_GET_USERS => 'usersInGroup', - OC_GROUP_BACKEND_GET_GROUPS => 'getGroups' ); /** @@ -83,15 +75,55 @@ abstract class OC_Group_Backend { return (bool)($this->getSupportedActions() & $actions); } + /** + * @brief is user in group? + * @param $uid uid of the user + * @param $gid gid of the group + * @returns true/false + * + * Checks whether the user is member of a group or not. + */ + public static function inGroup($uid, $gid){ + return in_array($gid, $this->getUserGroups($uid)); + } + + /** + * @brief Get all groups a user belongs to + * @param $uid Name of the user + * @returns array with group names + * + * This function fetches all groups a user belongs to. It does not check + * if the user exists at all. + */ + public static function getUserGroups($uid){ + return array(); + } + + /** + * @brief get a list of all groups + * @returns array with group names + * + * Returns a list with all groups + */ + public static function getGroups(){ + return array(); + } + /** * check if a group exists * @param string $gid * @return bool */ public function groupExists($gid){ - if(!$this->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)){ - return false; - } return in_array($gid, $this->getGroups()); } + + /** + * @brief get a list of all users in a group + * @returns array with user ids + */ + public static function usersInGroup($gid){ + return array(); + } + } diff --git a/lib/group/example.php b/lib/group/example.php index a88159f91b..11a14b5e78 100644 --- a/lib/group/example.php +++ b/lib/group/example.php @@ -93,6 +93,13 @@ abstract class OC_Group_Example { */ public static function getGroups(){} + /** + * check if a group exists + * @param string $gid + * @return bool + */ + public function groupExists($gid){} + /** * @brief get a list of all users in a group * @returns array with user ids From b022ccb86371e774b63a8000f7ea2207c2da225e Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 17:40:59 +0200 Subject: [PATCH 0013/1537] Whitespace fixes --- apps/gallery/js/album_cover.js | 16 ++++++++-------- apps/gallery/lib/album.php | 26 ++++++++++++-------------- lib/files.php | 4 ++-- lib/util.php | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index d1809462f2..905034f6fd 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -78,14 +78,14 @@ function albumClickHandler(r) { for (var i in r.photos) { Albums.photos.push(r.photos[i]); } - Albums.shared = r.shared; - if (Albums.shared) { - Albums.recursive = r.recursive; - Albums.token = r.token; - } else { - Albums.recursive = false; - Albums.token = ''; - } + Albums.shared = r.shared; + if (Albums.shared) { + Albums.recursive = r.recursive; + Albums.token = r.token; + } else { + Albums.recursive = false; + Albums.token = ''; + } $(document).ready(function(){ var targetDiv = $('#gallery_list'); targetDiv.html(''); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 27d40cdb91..ac6cacbe01 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -79,7 +79,7 @@ class OC_Gallery_Album { $sql .= ' AND parent_path = ?'; $args[] = $parent; } - $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); + $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); $sql .= ' ORDER BY album_name ' . $order; $stmt = OCP\DB::prepare($sql); @@ -98,19 +98,17 @@ class OC_Gallery_Album { } public static function getAlbumSize($id){ - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; - $stmt = OCP\DB::prepare($sql); - $result=$stmt->execute(array($id))->fetchRow(); - return $result['size']; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; + $stmt = OCP\DB::prepare($sql); + $result=$stmt->execute(array($id))->fetchRow(); + return $result['size']; } - public static function getIntermediateGallerySize($path) { - $path .= '%'; - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; - $stmt = OCP\DB::prepare($sql); - $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); - return $result['size']; - } + public static function getIntermediateGallerySize($path) { + $path .= '%'; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; + $stmt = OCP\DB::prepare($sql); + $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); + return $result['size']; + } } - -?> diff --git a/lib/files.php b/lib/files.php index 5d4d73630e..d837bf7aa2 100644 --- a/lib/files.php +++ b/lib/files.php @@ -32,11 +32,11 @@ class OC_Files { * get the content of a directory * @param dir $directory */ - public static function getDirectoryContent($directory, $mimetype_filter = ''){ + public static function getDirectoryContent($directory, $mimetype_filter = ''){ if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){ $directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY)); } - $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); + $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); foreach($files as &$file){ $file['directory']=$directory; $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; diff --git a/lib/util.php b/lib/util.php index e4546d6ac3..ff11799871 100644 --- a/lib/util.php +++ b/lib/util.php @@ -31,7 +31,7 @@ class OC_Util { // Create root dir. if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){ $success=@mkdir($CONFIG_DATADIRECTORY_ROOT); - if(!$success) { + if(!$success) { $tmpl = new OC_Template( '', 'error', 'guest' ); $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' "))); $tmpl->printPage(); @@ -50,7 +50,6 @@ class OC_Util { self::$rootMounted=true; } if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem - OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT."/$user/$root"; if( !is_dir( OC::$CONFIG_DATADIRECTORY )){ mkdir( OC::$CONFIG_DATADIRECTORY, 0755, true ); From c2230580c14b08877210a9c0bcfe6f4b0a806bf5 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 17:41:44 +0200 Subject: [PATCH 0014/1537] Remove unused OC static variable CONFIG_DATADIRECTORY_ROOT --- lib/base.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index 14f2439ecb..e7ca51740c 100644 --- a/lib/base.php +++ b/lib/base.php @@ -50,10 +50,6 @@ class OC{ * the folder that stores that data files for the filesystem of the user (e.g. /srv/http/owncloud/data/myusername/files) */ public static $CONFIG_DATADIRECTORY = ''; - /** - * the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data) - */ - public static $CONFIG_DATADIRECTORY_ROOT = ''; /** * The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty) */ From 9a66b869c0db189338ccf0333183108bf81a7786 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 22:47:57 +0200 Subject: [PATCH 0015/1537] Gallery: Use App storage instead of contructing our own path --- apps/gallery/ajax/galleryOp.php | 3 ++- apps/gallery/ajax/sharing.php | 6 ++++-- apps/gallery/index.php | 4 ---- apps/gallery/lib/album.php | 5 ++--- apps/gallery/lib/photo.php | 20 ++++++++++---------- apps/gallery/lib/scanner.php | 3 ++- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index 0cd825f3e5..b49e52f0bd 100755 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -42,7 +42,8 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OCP\Response::enableCaching(3600 * 24); // 24 hour - $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png'; + $view = OCP\App::getStorage('gallery'); + $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OCP\Response::sendFile($thumbnail); } diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index 1223320120..304757b9e9 100755 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,8 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; + $view = OCP\App::getStorage('gallery'); + $file = $view->fopen($albumname.'.png', 'r'); $image = new OC_Image($file); if ($image->valid()) { $image->centerCrop(); @@ -93,7 +94,8 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); + $view = OCP\App::getStorage('files'); + $file = $view->fopen(urldecode($photo), 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index e47fb3db5d..a9fe200c4e 100755 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,10 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { - mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); -} - if (!isset($_GET['view'])) { $result = OC_Gallery_Album::find(OCP\USER::getUser()); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index ac6cacbe01..7b9036742a 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -92,9 +92,8 @@ class OC_Gallery_Album { } public static function changeThumbnailPath($oldname, $newname) { - - $thumbpath = OC::$CONFIG_DATADIRECTORY.'/../gallery/'; - rename($thumbpath.$oldname.'.png', $thumbpath.$newname.'.png'); + $view = OCP\App::getStorage('gallery'); + $view->rename($oldname.'.png', $newname.'.png'); } public static function getAlbumSize($id){ diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 99384af621..b4b37236b0 100755 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,17 +68,17 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'; - $save_dir .= dirname($image_name). '/'; - $image_path = $image_name; - $thumb_file = $save_dir . basename($image_name); - if (!is_dir($save_dir)) { - mkdir($save_dir, 0777, true); + $view = OCP\App::getStorage('gallery'); + $save_dir = dirname($image_name); + if (!$view->is_dir($save_dir)) { + $view->mkdir($save_dir); } - if (file_exists($thumb_file)) { - $image = new OC_Image($thumb_file); + $view->chroot($view->getRoot().'/'.$save_dir); + $thumb_file = basename($image_name); + if ($view->file_exists($thumb_file)) { + $image = new OC_Image($view->fopen($thumb_file, 'r')); } else { - $image_path = OC_Filesystem::getLocalFile($image_path); + $image_path = OC_Filesystem::getLocalFile($image_name); if(!file_exists($image_path)) { return null; } @@ -86,7 +86,7 @@ class OC_Gallery_Photo { if ($image->valid()) { $image->centerCrop(200); $image->fixOrientation(); - $image->save($thumb_file); + $image->save($view->getLocalFile($thumb_file)); } } if ($image->valid()) { diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 7a137cb3f5..e11ba1da45 100755 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,8 @@ class OC_Gallery_Scanner { $image->destroy(); } } - imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); + $view = OCP\App::getStorage('gallery'); + imagepng($thumbnail, $view->getLocalFile($albumName.'.png')); imagedestroy($thumbnail); } From 97233b77cd0cfb7671e8914fd047642988ea425b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 11 May 2012 21:31:51 +0200 Subject: [PATCH 0016/1537] Remove DOCUMENTROOT static var, and make SUBURI var private --- lib/base.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/base.php b/lib/base.php index e7ca51740c..f01e1f5be6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -30,10 +30,6 @@ class OC{ * Assoziative array for autoloading. classname => filename */ public static $CLASSPATH = array(); - /** - * $_SERVER['DOCUMENTROOT'] but without symlinks - */ - public static $DOCUMENTROOT = ''; /** * The installation path for owncloud on the server (e.g. /srv/http/owncloud) */ @@ -41,7 +37,7 @@ class OC{ /** * the current request path relative to the owncloud root (e.g. files/index.php) */ - public static $SUBURI = ''; + private static $SUBURI = ''; /** * the owncloud root path for http requests (e.g. owncloud/) */ @@ -122,7 +118,7 @@ class OC{ public static function initPaths(){ // calculate the documentroot - OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); + $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13)); OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT)); $scriptName=$_SERVER["SCRIPT_NAME"]; @@ -138,7 +134,7 @@ class OC{ } OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI)); // try a new way to detect the WEBROOT which is simpler and also works with the app directory outside the owncloud folder. let´s see if this works for everybody -// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen(OC::$DOCUMENTROOT)); +// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen($DOCUMENTROOT)); if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){ From b1cae9651eb1d61b2fe9cc69766c533cb87f46b8 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 12 May 2012 23:00:21 +0200 Subject: [PATCH 0017/1537] add functions get cached events in a specific time period --- apps/calendar/lib/repeat.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/calendar/lib/repeat.php b/apps/calendar/lib/repeat.php index fe2ba7cfa8..af335d4b72 100644 --- a/apps/calendar/lib/repeat.php +++ b/apps/calendar/lib/repeat.php @@ -14,10 +14,18 @@ class OC_Calendar_Repeat{ * @brief returns the cache of an event */ public static function get(); + /* + * @brief returns the cache of an event in a specific peroid + */ + public static function get_inperiod(); /* * @brief returns the cache of all events of a calendar */ public static function getcalendar(); + /* + * @brief returns the cache of all events of a calendar in a specific period + */ + public static function getcalendar_inperiod(); /* * @brief generates the cache the first time */ @@ -38,4 +46,4 @@ class OC_Calendar_Repeat{ * @brief removes the cache of all events of a calendar */ public static function cleancalendar(); -} \ No newline at end of file +} From dfef36ba2fb61ccc56a0840b63ef0782293927f9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sat, 12 May 2012 23:16:11 +0200 Subject: [PATCH 0018/1537] some changes for calendar repeat class --- apps/calendar/lib/repeat.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/calendar/lib/repeat.php b/apps/calendar/lib/repeat.php index af335d4b72..9a43925e27 100644 --- a/apps/calendar/lib/repeat.php +++ b/apps/calendar/lib/repeat.php @@ -15,25 +15,33 @@ class OC_Calendar_Repeat{ */ public static function get(); /* - * @brief returns the cache of an event in a specific peroid - */ + * @brief returns the cache of an event in a specific peroid + */ public static function get_inperiod(); /* - * @brief returns the cache of all events of a calendar + * @brief returns the cache of all repeating events of a calendar */ public static function getcalendar(); /* - * @brief returns the cache of all events of a calendar in a specific period - */ + * @brief returns the cache of all repeating events of a calendar in a specific period + */ public static function getcalendar_inperiod(); /* * @brief generates the cache the first time */ public static function generate(); + /* + * @brief generates the cache the first time for all repeating event of an calendar + */ + public static function generatecalendar(); /* * @brief updates an event that is already cached */ public static function update(); + /* + * @brief updates all repating events of a calendar that are already cached + */ + public static function updatecalendar(); /* * @brief checks if an event is already cached */ From 63a1b066bcebc998bd4a6a4c8cc56f38983b0639 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 13 May 2012 15:05:57 +0200 Subject: [PATCH 0019/1537] add first version of drop import --- apps/calendar/ajax/import/dropimport.php | 74 ++++++++++++++++++++++++ apps/calendar/js/calendar.js | 45 ++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 apps/calendar/ajax/import/dropimport.php diff --git a/apps/calendar/ajax/import/dropimport.php b/apps/calendar/ajax/import/dropimport.php new file mode 100644 index 0000000000..e98c282ef4 --- /dev/null +++ b/apps/calendar/ajax/import/dropimport.php @@ -0,0 +1,74 @@ +true, 'VTODO'=>true, 'VJOURNAL'=>true); +$data = str_replace(array("\r","\n\n"), array("\n","\n"), $data); +$lines = explode("\n", $data); +unset($data); +$comp=$uid=$cal=false; +$cals=$uids=array(); +$i = 0; +foreach($lines as $line) { + if(strpos($line, ':')!==false) { + list($attr, $val) = explode(':', strtoupper($line)); + if ($attr == 'BEGIN' && $val == 'VCALENDAR') { + $cal = $i; + $cals[$cal] = array('first'=>$i,'last'=>$i,'end'=>$i); + } elseif ($attr =='BEGIN' && $cal!==false && isset($comps[$val])) { + $comp = $val; + $beginNo = $i; + } elseif ($attr == 'END' && $cal!==false && $val == 'VCALENDAR') { + if($comp!==false) { + unset($cals[$cal]); // corrupt calendar, unset it + } else { + $cals[$cal]['end'] = $i; + } + $comp=$uid=$cal=false; // reset calendar + } elseif ($attr == 'END' && $comp!==false && $val == $comp) { + if(! $uid) { + $uid = OC_Calendar_Object::createUID(); + } + $uids[$uid][$beginNo] = array('end'=>$i, 'cal'=>$cal); + if ($cals[$cal]['first'] == $cal) { + $cals[$cal]['first'] = $beginNo; + } + $cals[$cal]['last'] = $i; + $comp=$uid=false; // reset component + } elseif ($attr =="UID" && $comp!==false) { + list($attr, $uid) = explode(':', $line); + } + } + $i++; +} +$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), 1); +$id = $calendars[0]['id']; +foreach($uids as $uid) { + $prefix=$suffix=$content=array(); + foreach($uid as $begin=>$details) { + $cal = $details['cal']; + if(!isset($cals[$cal])) { + continue; // from corrupt/incomplete calendar + } + $cdata = $cals[$cal]; + // if we have multiple components from different calendar objects, + // we should really merge their elements (enhancement?) -- 1st one wins for now. + if(! count($prefix)) { + $prefix = array_slice($lines, $cal, $cdata['first'] - $cal); + } + if(! count($suffix)) { + $suffix = array_slice($lines, $cdata['last']+1, $cdata['end'] - $cdata['last']); + } + $content = array_merge($content, array_slice($lines, $begin, $details['end'] - $begin + 1)); + } + if(count($content)) { + $import = join($nl, array_merge($prefix, $content, $suffix)) . $nl; + OC_Calendar_Object::add($id, $import); + } +} +OCP\JSON::success(); +?> \ No newline at end of file diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 80b5dd88c5..8a3f714c5f 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -601,6 +601,50 @@ Calendar={ }); /*var permissions = (this.checked) ? 1 : 0;*/ } + }, + Drop:{ + init:function(){ + if (typeof window.FileReader === 'undefined') { + console.log('The drop-import feature is not supported in your browser :('); + return false; + } + droparea = document.getElementById('calendar_holder'); + droparea.ondrop = function(e){ + e.preventDefault(); + Calendar.UI.Drop.drop(e); + } + console.log('Drop initialized successfully'); + }, + drop:function(e){ + var files = e.dataTransfer.files; + for(var i = 0;i < files.length;i++){ + var file = files[i] + reader = new FileReader(); + reader.onload = function(event){ + if(file.type != 'text/calendar'){ + $('#notification').html('At least one file don\'t seems to be a calendar file. File skipped.'); + $('#notification').slideDown(); + window.setTimeout(function(){$('#notification').slideUp();}, 5000); + return false; + }else{ + Calendar.UI.Drop.import(event.target.result); + } + } + reader.readAsDataURL(file); + } + $('#calendar_holder').fullCalendar('refetchEvents'); + }, + import:function(data){ + $.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) { + if(result.data == 'success'){ + return true; + }else{ + $('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.'); + $('#notification').slideDown(); + window.setTimeout(function(){$('#notification').slideUp();}, 5000); + } + }); + } } } } @@ -858,4 +902,5 @@ $(document).ready(function(){ $('#calendar_holder').fullCalendar('next'); }); Calendar.UI.Share.init(); + Calendar.UI.Drop.init(); }); From 0892abd050afab54e22d7c5516d014ed9145321d Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 13 May 2012 15:08:27 +0200 Subject: [PATCH 0020/1537] some little js fixes for drop import --- apps/calendar/js/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 8a3f714c5f..f2e5071ba3 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -628,15 +628,15 @@ Calendar={ return false; }else{ Calendar.UI.Drop.import(event.target.result); + $('#calendar_holder').fullCalendar('refetchEvents'); } } reader.readAsDataURL(file); } - $('#calendar_holder').fullCalendar('refetchEvents'); }, import:function(data){ $.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) { - if(result.data == 'success'){ + if(result.status == 'success'){ return true; }else{ $('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.'); From 2ad6b5048e05fd5c28600845bbabde3a3f4537f7 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Tue, 15 May 2012 16:24:06 +0100 Subject: [PATCH 0021/1537] fixed 'delete' label so it doesn't break translations --- apps/files/templates/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 72e45d5327..1308645746 100755 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -53,7 +53,7 @@ t( 'Size' ); ?> - t( 'Modified' ); ?>t('Delete all')?> <?php echo $l->t('Delete')?>" /> + t( 'Modified' ); ?>t('Delete')?> <?php echo $l->t('Delete')?>" /> From a00c5ac78ccbd581ba043d173d3f85aaf21b03dd Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Fri, 11 May 2012 13:17:37 +0100 Subject: [PATCH 0022/1537] fixed some include path issues imroved wording of history page revert instructions cleaned up js call to ajax getVersions.php --- apps/files_versions/ajax/getVersions.php | 36 +++-------------- apps/files_versions/appinfo/app.php | 3 -- apps/files_versions/js/versions.js | 47 +++++++++-------------- apps/files_versions/templates/history.php | 2 +- 4 files changed, 25 insertions(+), 63 deletions(-) diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 5949c32ed1..8ef17d5a25 100755 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -1,8 +1,10 @@ diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 0508ab4cde..2c92dfa3c6 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -14,28 +14,17 @@ $(document).ready(function(){ FileActions.register('file','History',function(){return OC.imagePath('core','actions/history')},function(filename){ if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback - + var file = $('#dir').val()+'/'+filename; createVersionsDropdown(filename, file) - $.ajax({ - type: 'GET', - url: OC.linkTo('files_versions', 'ajax/getVersions.php'), - dataType: 'json', - data: {source: file}, - async: false, - success: function(versions) { - if (versions) { - } - } - }); - }); } }); function createVersionsDropdown(filename, files) { + var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); var html = ''; @@ -148,7 +148,7 @@ class TileStack extends TileBase { $r = ''; if(count($this->tiles_array) == 0) { // aint no pictures in this folder... - $r.=''; + $r.=''; } else { for ($i = 0; $i < count($this->tiles_array); $i++) { $top = rand(-5, 5); diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 5cff2c65a0..42ef9f6587 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -9,7 +9,7 @@ div.miniature_border {position:absolute; height: 150px; -moz-transition-duration div.line {display:inline-block; border: 0; width: auto; height: 160px} div.gallery_div img{position:absolute; top: 1; left: 0; -moz-transition-duration: 0.3s; -o-transition-duration:0.3s; -webkit-transition-duration: 0.3s; height:150px; width: auto;} div.gallery_div img.shrinker {width:80px !important;} -div.title { opacity: 0; text-align: center; vertical-align: middle; font-family: Arial; font-size: 12px; border: 0; position: absolute; text-overflow: ellipsis; bottom: 20px; left:5px; height:auto; padding: 5px; width: 140px; background-color: black; color: white; -webkit-transition: opacity 0.5s; z-index:1000; border-radius: 7px} +div.title { opacity: 0; text-align: center; vertical-align: middle; font-family: Arial; font-size: 12px; border: 0; position: absolute; text-overflow: ellipsis; bottom: 20px; right:-5px; height:auto; padding: 5px; width: 140px; background-color: black; color: white; -webkit-transition: opacity 0.5s; z-index:1000; border-radius: 7px} div.visible { opacity: 0.8;} -
-
    - inc("part.contacts"); ?> -
+
+ inc("part.contacts"); ?>
diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php index 5751750540..1e64119c05 100644 --- a/apps/contacts/templates/part.contacts.php +++ b/apps/contacts/templates/part.contacts.php @@ -1,12 +1,45 @@ -'.$addressbook_names[$i]['displayname'].''; + echo '
+
    '; + foreach($contacts[$addressbook_names[$i]['id']] as $contact): + $display = trim($contact['fullname']); + + if(!$display) { + $vcard = OC_Contacts_App::getContactVCard($contact['id']); + if(!is_null($vcard)) { + $struct = OC_Contacts_VCard::structureContact($vcard); + $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]'; + } + } + echo '
  • '.htmlspecialchars($display).'
  • '; + + endforeach; + echo '
'; + } +} ?> -
  • - + From 92e35bd843890eabeb582c5b616354324f332e85 Mon Sep 17 00:00:00 2001 From: Stephan Bergemann Date: Sun, 17 Jun 2012 02:29:35 +0200 Subject: [PATCH 0462/1537] now a little less in template - more in ajax controller --- apps/contacts/ajax/contacts.php | 28 ++++++++++++- apps/contacts/js/contacts.js | 3 +- apps/contacts/templates/index.php | 1 - apps/contacts/templates/part.contacts.php | 51 ++++++++--------------- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index dbc9be5ca5..1edc35709e 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -11,9 +11,33 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); -$contacts = OC_Contacts_VCard::all($ids); +$contacts_alphabet = OC_Contacts_VCard::all($ids); +$active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); + +// Our new array for the contacts sorted by addressbook +$contacts_addressbook = array(); +foreach($contacts_alphabet as $contact): + if(is_null($contacts_addressbook[$contact['addressbookid']])) { + $contacts_addressbook[$contact['addressbookid']] = array(); + } + $contacts_addressbook[$contact['addressbookid']][] = $contact; +endforeach; + +// FIXME: this is kind of ugly - just to replace the keys of the array +// perhaps we could do some magic combine_array() instead... +foreach($contacts_addressbook as $addressbook_id => $contacts): + foreach($active_addressbooks as $addressbook): + if($addressbook_id == $addressbook['id']) { + unset($contacts_addressbook[$addressbook_id]); + $contacts_addressbook[$addressbook['displayname']] = $contacts; + } + endforeach; +endforeach; +// This one should be ok for a small amount of Addressbooks +ksort($contacts_addressbook); + $tmpl = new OCP\Template("contacts", "part.contacts"); -$tmpl->assign('contacts', $contacts, false); +$tmpl->assign('contacts', $contacts_addressbook, false); $page = $tmpl->fetchPage(); OCP\JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 1c5139117d..925dbafe46 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1557,7 +1557,7 @@ $(document).ready(function(){ $('.contacts').click(); } }); - $('.contacts').click(function(event){ + $(document).on("click", ".contacts",function(event){ var $tgt = $(event.target); if ($tgt.is('li') || $tgt.is('a')) { var item = $tgt.is('li')?$($tgt):($tgt).parent(); @@ -1678,3 +1678,4 @@ $(document).ready(function(){ $('#contacts_propertymenu_dropdown a').click(propertyMenuItem); $('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem); }); +Contacts.UI.Contacts.update(); diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 82619601c2..74dcf5149d 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -4,7 +4,6 @@ var lang = '';
    - inc("part.contacts"); ?>
    diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php index 1e64119c05..6c1252debc 100644 --- a/apps/contacts/templates/part.contacts.php +++ b/apps/contacts/templates/part.contacts.php @@ -1,39 +1,22 @@ '.$addressbook_names[$i]['displayname'].''; - echo '
    -
      '; - foreach($contacts[$addressbook_names[$i]['id']] as $contact): - $display = trim($contact['fullname']); - - if(!$display) { - $vcard = OC_Contacts_App::getContactVCard($contact['id']); - if(!is_null($vcard)) { - $struct = OC_Contacts_VCard::structureContact($vcard); - $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]'; - } +foreach($_['contacts'] as $category => $contacts): + echo '

      '.$category.'

      '; + echo '
      '; + echo '
        '; + foreach($contacts as $contact): + $display = trim($contact['fullname']); + if(!$display) { + $vcard = OC_Contacts_App::getContactVCard($contact['id']); + if(!is_null($vcard)) { + $struct = OC_Contacts_VCard::structureContact($vcard); + $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]'; } - echo '
      • '.htmlspecialchars($display).'
      • '; - - endforeach; - echo '
      '; - } -} + } + echo '
    • '.htmlspecialchars($display).'
    • '; + endforeach; + echo '
    '; + echo '
    '; +endforeach; ?> From 5a8f4b87839baaeb3b557895cc89d58e19ad75ce Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 20:23:20 +0200 Subject: [PATCH 0468/1537] Adjustments for inview handler etc. --- apps/contacts/js/contacts.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 925dbafe46..981af6f53a 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1498,23 +1498,34 @@ Contacts={ update:function(){ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){ if(jsondata.status == 'success'){ - $('#leftcontent').html(jsondata.data.page); + $('#leftcontent').html(jsondata.data.page).ready(function() { + setTimeout(function() { + $('.contacts li').unbind('inview'); + $('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { + if (isInView) { + if (!$(this).find('a').attr('style')) { + $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat'); + } + } + })}, 100); + setTimeout(Contacts.UI.Contacts.lazyupdate, 500); + }); Contacts.UI.Card.update(); } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); } }); - setTimeout(function() { + /*setTimeout(function() { $('.contacts li').unbind('inview'); - $('.contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { + $('.contacts li:visible').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { if (isInView) { if (!$(this).find('a').attr('style')) { $(this).find('a').css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+$(this).data('id')+') no-repeat'); } } })}, 500); - setTimeout(Contacts.UI.Contacts.lazyupdate, 500); + setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/ }, // Add thumbnails to the contact list as they become visible in the viewport. lazyupdate:function(){ @@ -1557,7 +1568,7 @@ $(document).ready(function(){ $('.contacts').click(); } }); - $(document).on("click", ".contacts",function(event){ + $(document).on('click', '.contacts', function(event){ var $tgt = $(event.target); if ($tgt.is('li') || $tgt.is('a')) { var item = $tgt.is('li')?$($tgt):($tgt).parent(); @@ -1579,6 +1590,11 @@ $(document).ready(function(){ return false; }); + $(document).on('click', '.addressbook', function(event){ + $(this).next().toggle(); + return false; + }); + $('.contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { if (isInView) { //NOTE: I've kept all conditions for future reference ;-) // element is now visible in the viewport From 9e4a41e9cb672234b3d96fc83c96f93a91a3fb59 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 21:34:56 +0200 Subject: [PATCH 0469/1537] Add effect on addressbook show/hide. --- apps/contacts/css/contacts.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index d617373742..77bfc54663 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -4,7 +4,7 @@ #leftcontent { top: 3.5em !important; padding: 0; margin: 0; } #leftcontent a { padding: 0 0 0 25px; } #rightcontent { top: 3.5em !important; padding-top: 5px; } -#leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; height: 2em; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; } +#leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; } #leftcontent h3:hover { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; } .contacts { background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom:3em; overflow: auto; padding: 0; margin: 0; } .contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; } From fb700de4a40432f26209911548045390a10499b8 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 21:37:13 +0200 Subject: [PATCH 0470/1537] Add effect on addressbook show/hide. --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 981af6f53a..110c383ac7 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1591,7 +1591,7 @@ $(document).ready(function(){ }); $(document).on('click', '.addressbook', function(event){ - $(this).next().toggle(); + $(this).next().slideToggle(300); return false; }); From 46a771d2e6261fae20f2bcadb2355c05954920d4 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 21:47:15 +0200 Subject: [PATCH 0471/1537] Sort addressbooks. --- apps/contacts/ajax/contacts.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index 773f027dc6..beed3f05d5 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -6,6 +6,13 @@ * See the COPYING-README file. */ +function cmp($a, $b) +{ + if ($a['displayname'] == $b['displayname']) { + return 0; + } + return ($a['displayname'] < $b['displayname']) ? -1 : 1; +} OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); @@ -39,6 +46,8 @@ foreach($contacts_addressbook as $addressbook_id => $contacts) { } } +usort($contacts_addressbook, 'cmp'); + $tmpl = new OCP\Template("contacts", "part.contacts"); $tmpl->assign('books', $contacts_addressbook, false); $page = $tmpl->fetchPage(); From 7d84c4741c72e46cf9d07bbae97d515f54f9a2d7 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 21:50:49 +0200 Subject: [PATCH 0472/1537] Use uasort instead of usort. --- apps/contacts/ajax/contacts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index beed3f05d5..bf4d5deb2e 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -46,7 +46,7 @@ foreach($contacts_addressbook as $addressbook_id => $contacts) { } } -usort($contacts_addressbook, 'cmp'); +uasort($contacts_addressbook, 'cmp'); $tmpl = new OCP\Template("contacts", "part.contacts"); $tmpl->assign('books', $contacts_addressbook, false); From 8337b30e433710ce0f9a7d8b24f23e0fab6fe381 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 17 Jun 2012 23:09:25 +0200 Subject: [PATCH 0473/1537] Add thumbnail links so they are loaded when addressbook is expanded. --- apps/contacts/templates/part.contacts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php index d23a249b98..f0b14c8e5f 100644 --- a/apps/contacts/templates/part.contacts.php +++ b/apps/contacts/templates/part.contacts.php @@ -1,9 +1,9 @@ $addressbook) { echo '

    '.$addressbook['displayname'].'

    '; - echo '