From: Aldo "xoen" Giambelluca Date: Thu, 15 Jul 2010 17:10:20 +0000 (+0200) Subject: Minor style changes X-Git-Tag: v3.0~332^2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7b84bf5f0e9dd8bbe727f4341f315badd66d25d8;p=nextcloud-server.git Minor style changes * Using camelCase for `$classType` property * Using `self` keyword instead of class name * Added spaces here and there --- diff --git a/inc/User/mod_auth.php b/inc/User/mod_auth.php index 0f44a6fb97e..2ca03cee304 100755 --- a/inc/User/mod_auth.php +++ b/inc/User/mod_auth.php @@ -22,6 +22,7 @@ */ + /** * Class for usermanagement in a SQL Database * eg mysql, sqlite @@ -29,42 +30,44 @@ class OC_USER_MOD_AUTH extends OC_USER { /** - * check if the login button is pressed and logg the user in - * - */ - public static function loginLisener(){ - return(''); + * check if the login button is pressed and logg the user in + * + */ + public static function loginLisener() { + return ''; } /** - * try to create a new user - * - */ - public static function createUser($username,$password){ + * try to create a new user + * + */ + public static function createUser($username, $password) { return false; } /** - * try to login a user - * - */ - public static function login($username,$password){ - if (isset($_SERVER["PHP_AUTH_USER"]) && $_SERVER["PHP_AUTH_USER"] != "") { - $_SESSION['user_id']= $_SERVER["PHP_AUTH_USER"]; - $_SESSION['username']= $_SERVER["PHP_AUTH_USER"]; - $_SESSION['username_clean']= $_SERVER["PHP_AUTH_USER"]; + * try to login a user + * + */ + public static function login($username, $password) { + if ( isset($_SERVER['PHP_AUTH_USER']) AND ('' !== $_SERVER['PHP_AUTH_USER']) ) { + $_SESSION['user_id'] = $_SERVER['PHP_AUTH_USER']; + $_SESSION['username'] = $_SERVER['PHP_AUTH_USER']; + $_SESSION['username_clean'] = $_SERVER['PHP_AUTH_USER']; + return true; } + return false; } /** - * check if the logout button is pressed and logout the user - * - */ - public static function logoutLisener(){ - if(isset($_GET['logoutbutton']) && isset($_SESSION['username'])){ + * check if the logout button is pressed and logout the user + * + */ + public static function logoutLisener() { + if( isset($_GET['logoutbutton']) AND isset($_SESSION['username']) ) { header('WWW-Authenticate: Basic realm="ownCloud"'); header('HTTP/1.0 401 Unauthorized'); die('401 Unauthorized'); @@ -72,108 +75,107 @@ class OC_USER_MOD_AUTH extends OC_USER { } /** - * check if a user is logged in - * - */ - public static function isLoggedIn(){ - if (isset($_SESSION['user_id']) && $_SESSION['user_id']) { + * check if a user is logged in + * + */ + public static function isLoggedIn() { + if ( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ) { return true; - } - else { - if (isset($_SERVER["PHP_AUTH_USER"]) && $_SERVER["PHP_AUTH_USER"] != "") { - $_SESSION['user_id']= $_SERVER["PHP_AUTH_USER"]; - $_SESSION['username']= $_SERVER["PHP_AUTH_USER"]; - $_SESSION['username_clean']= $_SERVER["PHP_AUTH_USER"]; + } else { + if ( isset($_SERVER['PHP_AUTH_USER']) AND ('' !== $_SERVER['PHP_AUTH_USER']) ) { + $_SESSION['user_id'] = $_SERVER['PHP_AUTH_USER']; + $_SESSION['username'] = $_SERVER['PHP_AUTH_USER']; + $_SESSION['username_clean'] = $_SERVER['PHP_AUTH_USER']; + return true;; } } + return false; } /** - * try to create a new group - * - */ - public static function createGroup($groupname){ + * try to create a new group + * + */ + public static function createGroup($groupname) { // does not work with MOD_AUTH (only or some modules) return false; } /** - * get the id of a user - * - */ - public static function getUserId($username,$nocache=false){ + * get the id of a user + * + */ + public static function getUserId($username, $nocache=false) { // does not work with MOD_AUTH (only or some modules) return 0; } /** - * get the id of a group - * - */ - public static function getGroupId($groupname,$nocache=false){ + * get the id of a group + * + */ + public static function getGroupId($groupname, $nocache=false) { // does not work with MOD_AUTH (only or some modules) return 0; } /** - * get the name of a group - * - */ - public static function getGroupName($groupid,$nocache=false){ + * get the name of a group + * + */ + public static function getGroupName($groupid, $nocache=false) { // does not work with MOD_AUTH (only or some modules) return 0; } /** - * check if a user belongs to a group - * - */ - public static function inGroup($username,$groupname){ + * check if a user belongs to a group + * + */ + public static function inGroup($username, $groupname) { // does not work with MOD_AUTH (only or some modules) return false; } /** - * add a user to a group - * - */ - public static function addToGroup($username,$groupname){ + * add a user to a group + * + */ + public static function addToGroup($username, $groupname) { // does not work with MOD_AUTH (only or some modules) return false; } - public static function generatePassword(){ + public static function generatePassword() { return uniqid(); } /** - * get all groups the user belongs to - * - */ - public static function getUserGroups($username){ + * get all groups the user belongs to + * + */ + public static function getUserGroups($username) { // does not work with MOD_AUTH (only or some modules) - $groups=array(); + $groups = array(); return $groups; } /** - * set the password of a user - * - */ - public static function setPassword($username,$password){ + * set the password of a user + * + */ + public static function setPassword($username, $password) { return false; } /** - * check the password of a user - * - */ - public static function checkPassword($username,$password){ + * check the password of a user + * + */ + public static function checkPassword($username, $password) { // does not work with MOD_AUTH (only or some modules) return false; } } - -?> \ No newline at end of file diff --git a/inc/lib_user.php b/inc/lib_user.php index 902c999f0ac..f1cc874a459 100755 --- a/inc/lib_user.php +++ b/inc/lib_user.php @@ -21,175 +21,180 @@ * */ -if(!$CONFIG_INSTALLED){ - $_SESSION['user_id']=false; - $_SESSION['username']=''; - $_SESSION['username_clean']=''; + + +if( !$CONFIG_INSTALLED ) { + $_SESSION['user_id'] = false; + $_SESSION['username'] = ''; + $_SESSION['username_clean'] = ''; } //cache the userid's an groupid's -if(!isset($_SESSION['user_id_cache'])){ - $_SESSION['user_id_cache']=array(); +if( !isset($_SESSION['user_id_cache']) ) { + $_SESSION['user_id_cache'] = array(); } -if(!isset($_SESSION['group_id_cache'])){ - $_SESSION['group_id_cache']=array(); +if( !isset($_SESSION['group_id_cache']) ) { + $_SESSION['group_id_cache'] = array(); } + + /** * Class for usermanagement * */ class OC_USER { - public static $class_type; + public static $classType; /** - * check if the login button is pressed and logg the user in - * - */ - public static function loginLisener(){ - return self::$class_type->loginLisener(); + * check if the login button is pressed and logg the user in + * + */ + public static function loginLisener() { + return self::classType->loginLisener(); } /** - * try to create a new user - * - */ - public static function createUser($username,$password){ - return self::$class_type->createUser($username,$password); + * try to create a new user + * + */ + public static function createUser($username, $password) { + return self::classType->createUser($username, $password); } /** - * try to login a user - * - */ - public static function login($username,$password){ - return self::$class_type->login($username,$password); + * try to login a user + * + */ + public static function login($username, $password) { + return self::classType->login($username, $password); } /** - * check if the logout button is pressed and logout the user - * - */ - public static function logoutLisener(){ - return self::$class_type->logoutLisener(); + * check if the logout button is pressed and logout the user + * + */ + public static function logoutLisener() { + return self::classType->logoutLisener(); } /** - * check if a user is logged in - * - */ - public static function isLoggedIn(){ - return self::$class_type->isLoggedIn(); + * check if a user is logged in + * + */ + public static function isLoggedIn() { + return self::classType->isLoggedIn(); } /** - * try to create a new group - * - */ - public static function createGroup($groupname){ - return self::$class_type->createGroup($groupname); + * try to create a new group + * + */ + public static function createGroup($groupname) { + return self::classType->createGroup($groupname); } /** - * get the id of a user - * - */ - public static function getUserId($username,$nocache=false){ - return self::$class_type->getUserId($username,$nocache=false); + * get the id of a user + * + */ + public static function getUserId($username, $nocache=false) { + return self::classType->getUserId($username, $nocache=false); } /** - * get the id of a group - * - */ - public static function getGroupId($groupname,$nocache=false){ - return self::$class_type->getGroupId($groupname,$nocache=false); + * get the id of a group + * + */ + public static function getGroupId($groupname, $nocache=false) { + return self::classType->getGroupId($groupname, $nocache=false); } /** - * get the name of a group - * - */ - public static function getGroupName($groupid,$nocache=false){ - return self::$class_type->getGroupName($groupid,$nocache=false); + * get the name of a group + * + */ + public static function getGroupName($groupid, $nocache=false) { + return self::classType->getGroupName($groupid, $nocache=false); } /** - * check if a user belongs to a group - * - */ - public static function inGroup($username,$groupname){ - return self::$class_type->inGroup($username,$groupname); + * check if a user belongs to a group + * + */ + public static function inGroup($username, $groupname) { + return self::classType->inGroup($username, $groupname); } /** - * add a user to a group - * - */ - public static function addToGroup($username,$groupname){ - return self::$class_type->addToGroup($username,$groupname); + * add a user to a group + * + */ + public static function addToGroup($username, $groupname) { + return self::classType->addToGroup($username, $groupname); } - public static function generatePassword(){ + public static function generatePassword() { return uniqid(); } /** - * get all groups the user belongs to - * - */ - public static function getUserGroups($username){ - return self::$class_type->getUserGroups($username); + * get all groups the user belongs to + * + */ + public static function getUserGroups($username) { + return self::classType->getUserGroups($username); } /** - * set the password of a user - * - */ - public static function setPassword($username,$password){ - return self::$class_type->setPassword($username,$password); + * set the password of a user + * + */ + public static function setPassword($username, $password) { + return self::classType->setPassword($username, $password); } /** - * check the password of a user - * - */ - public static function checkPassword($username,$password){ - return self::$class_type->checkPassword($username,$password); + * check the password of a user + * + */ + public static function checkPassword($username, $password) { + return self::classType->checkPassword($username, $password); } } -/* + + +/** * Funtion to set the User Authentication Module */ function set_OC_USER() { global $CONFIG_BACKEND; - if (isset($CONFIG_BACKEND)) { - switch($CONFIG_BACKEND) { - case "mysql": - require_once 'User/database.php'; - OC_USER::$class_type = new OC_USER_Database(); - break; - case "sqlite": + + if ( isset($CONFIG_BACKEND) ) { + switch( $CONFIG_BACKEND ) { + case 'mysql': + case 'sqlite': require_once 'User/database.php'; - OC_USER::$class_type = new OC_USER_Database(); - break; - case "ldap": + self::classType = new OC_USER_Database(); + break; + case 'ldap': require_once 'User/ldap.php'; - OC_USER::$class_type = new OC_USER_LDAP(); - break; + self::classType = new OC_USER_LDAP(); + break; default: require_once 'User/database.php'; - OC_USER::$class_type = new OC_USER_Database(); - break; + self::classType = new OC_USER_Database(); + break; } - } - else { + } else { require_once 'User/database.php'; - OC_USER::$class_type = new OC_USER_Database(); + self::classType = new OC_USER_Database(); } } + + + set_OC_USER(); -?> \ No newline at end of file