From cf141983004286328542af77c947bc62a4f9fe1f Mon Sep 17 00:00:00 2001 From: joebordes Date: Sun, 31 Oct 2021 16:48:19 +0100 Subject: [PATCH] cbSR/doc(Users) quotes and function headers --- index.php | 10 ++-- modules/Users/CreateUserPrivilegeFile.php | 34 +++++------ modules/Users/Users.php | 71 +++++++++++------------ 3 files changed, 56 insertions(+), 59 deletions(-) diff --git a/index.php b/index.php index a86671ae51..1f19edeabf 100644 --- a/index.php +++ b/index.php @@ -131,9 +131,9 @@ } // Prevent loading Login again if there is an authenticated user in the session. -if (isset($_SESSION["authenticated_user_id"]) && isset($module) && $module == 'Users' && $action == 'Login') { - $default_action = GlobalVariable::getVariable('Application_Default_Action', 'index', 'Home', $_SESSION["authenticated_user_id"]); - $default_module = GlobalVariable::getVariable('Application_Default_Module', 'Home', 'Home', $_SESSION["authenticated_user_id"]); +if (isset($_SESSION['authenticated_user_id']) && isset($module) && $module == 'Users' && $action == 'Login') { + $default_action = GlobalVariable::getVariable('Application_Default_Action', 'index', 'Home', $_SESSION['authenticated_user_id']); + $default_module = GlobalVariable::getVariable('Application_Default_Module', 'Home', 'Home', $_SESSION['authenticated_user_id']); $result = $adb->pquery('select tabid from vtiger_tab where name=?', array($default_module)); if (!$result || $adb->num_rows($result)==0) { $default_module = 'Home'; @@ -144,7 +144,7 @@ if ($use_current_login) { //getting the internal_mailer flag if (!isset($_SESSION['internal_mailer'])) { - $qry_res = $adb->pquery("select internal_mailer from vtiger_users where id=?", array($_SESSION["authenticated_user_id"])); + $qry_res = $adb->pquery('select internal_mailer from vtiger_users where id=?', array($_SESSION['authenticated_user_id'])); coreBOS_Session::set('internal_mailer', $adb->query_result($qry_res, 0, 'internal_mailer')); } $log->debug('authenticated user: '.$_SESSION['authenticated_user_id']); @@ -152,7 +152,7 @@ include 'modules/Vtiger/maintenance.php'; exit; } -} elseif (isset($action) && isset($module) && $action=="Authenticate" && $module=="Users") { +} elseif (isset($action) && isset($module) && $action=='Authenticate' && $module=='Users') { $log->debug('authenticating user'); } else { if (!isset($_REQUEST['action']) || ($_REQUEST['action'] != 'Logout' && $_REQUEST['action'] != 'Login')) { diff --git a/modules/Users/CreateUserPrivilegeFile.php b/modules/Users/CreateUserPrivilegeFile.php index 96e8a666d3..2b2ea2d22a 100644 --- a/modules/Users/CreateUserPrivilegeFile.php +++ b/modules/Users/CreateUserPrivilegeFile.php @@ -16,7 +16,7 @@ /** Creates a file with all the user, user-role,user-profile, user-groups informations * @param $userid -- user id:: Type integer - * @returns user_privileges_userid file under the user_privileges directory + * @return user_privileges_userid file under the user_privileges directory */ function createUserPrivilegesfile($userid) { global $root_directory; @@ -24,7 +24,7 @@ function createUserPrivilegesfile($userid) { if (empty($userid)) { return false; } - $handle=@fopen($root_directory.'user_privileges/user_privileges_'.$userid.'.php', "w+"); + $handle=@fopen($root_directory.'user_privileges/user_privileges_'.$userid.'.php', 'w+'); if ($handle) { $newbuf=''; @@ -45,9 +45,9 @@ function createUserPrivilegesfile($userid) { if ($user_focus->is_admin == 'on') { $newbuf .= "\$is_admin=true;\n"; $newbuf .="\n"; - $newbuf .= "\$user_info=".constructSingleStringKeyValueArray($userInfo).";\n"; + $newbuf .= '$user_info='.constructSingleStringKeyValueArray($userInfo).";\n"; $newbuf .= "\n"; - $newbuf .= "?>"; + $newbuf .= '?>'; } else { $newbuf .= "\$is_admin=false;\n"; $newbuf .= "\n"; @@ -106,7 +106,7 @@ function createUserSharingPrivilegesfile($userid) { } checkFileAccessForInclusion('user_privileges/user_privileges_'.$userid.'.php'); require 'user_privileges/user_privileges_'.$userid.'.php'; - $handle=@fopen($root_directory.'user_privileges/sharing_privileges_'.$userid.'.php', "w+"); + $handle=@fopen($root_directory.'user_privileges/sharing_privileges_'.$userid.'.php', 'w+'); if ($handle) { $newbuf=''; @@ -852,7 +852,7 @@ function getUserModuleSharingObjects($module, $userid, $def_org_share, $current_ * @param $mod_sharingrule_members -- Sharing Rule Members array:: Type array * @param $$mod_share_read_per -- Sharing Module Read Permission array:: Type array * @param $$mod_share_write_per -- Sharing Module Write Permission array:: Type array - * @returns $related_mod_sharing_permission; -- array which contains the id of roles,group and users related module data to be shared + * @return $related_mod_sharing_permission; -- array which contains the id of roles,group and users related module data to be shared */ function getRelatedModuleSharingArray($par_mod, $share_mod, $mod_sharingrule_members, $mod_share_read_per, $mod_share_write_per, $def_org_share) { global $adb; @@ -989,7 +989,7 @@ function getRelatedModuleSharingArray($par_mod, $share_mod, $mod_sharingrule_mem /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructArray($var) { if (is_array($var)) { @@ -1004,7 +1004,7 @@ function constructArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructSingleStringValueArray($var) { $size = count($var); @@ -1026,7 +1026,7 @@ function constructSingleStringValueArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructSingleStringKeyAndValueArray($var) { $size = count($var); @@ -1048,7 +1048,7 @@ function constructSingleStringKeyAndValueArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructSingleStringKeyValueArray($var) { global $adb; @@ -1073,7 +1073,7 @@ function constructSingleStringKeyValueArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructSingleArray($var) { if (is_array($var)) { @@ -1088,7 +1088,7 @@ function constructSingleArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructSingleCharArray($var) { if (is_array($var)) { @@ -1103,7 +1103,7 @@ function constructSingleCharArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructTwoDimensionalArray($var) { if (is_array($var)) { @@ -1122,7 +1122,7 @@ function constructTwoDimensionalArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructTwoDimensionalValueArray($var) { if (is_array($var)) { @@ -1141,7 +1141,7 @@ function constructTwoDimensionalValueArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructTwoDimensionalCharIntSingleArray($var) { if (is_array($var)) { @@ -1160,7 +1160,7 @@ function constructTwoDimensionalCharIntSingleArray($var) { /** Converts the input array to a single string to facilitate the writing of the input array in a flat file * @param $var -- input array:: Type array - * @returns $code -- contains the whole array in a single string:: Type array + * @return $code -- contains the whole array in a single string:: Type array */ function constructTwoDimensionalCharIntSingleValueArray($var) { if (is_array($var)) { @@ -1346,7 +1346,7 @@ function populateRelatedSharingPrivileges($enttype, $userid, $module, $relmodule } $user_arr=array(); if (count($var_name_arr['ROLE']) > 0) { - $query="insert into ".$table_name." values "; + $query="insert into $table_name values "; $has_values = false; foreach ($var_name_arr['ROLE'] as $roleusers) { foreach ($roleusers as $user_id) { diff --git a/modules/Users/Users.php b/modules/Users/Users.php index 5ef3175c7e..5f28b4dd15 100644 --- a/modules/Users/Users.php +++ b/modules/Users/Users.php @@ -131,9 +131,6 @@ class Users extends CRMEntity { */ private $privileges; - /** constructor function for the main user class - instantiates the Logger class and PearDatabase Class - */ public function __construct() { global $log; $log->debug('> Users'); @@ -148,7 +145,7 @@ public function __construct() { /** * Function to get sort order - * return string $sorder - sortorder string either 'ASC' or 'DESC' + * @return string sort order string either 'ASC' or 'DESC' */ public function getSortOrder() { global $log, $adb; @@ -164,7 +161,7 @@ public function getSortOrder() { /** * Function to get order by - * return string $order_by - fieldname(eg: 'subject') + * @return string order by fieldname (eg: 'subject') */ public function getOrderBy() { global $log, $adb; @@ -185,8 +182,8 @@ public function getOrderBy() { } /** Function to set the user preferences in the session - * @param $name -- name:: Type varchar - * @param $value -- value:: Type varchar + * @param string name + * @param string value */ public function setPreference($name, $value) { if (!isset($this->user_preferences)) { @@ -276,7 +273,7 @@ public function authorization_check($validate, $authkey, $i) { * Checks the User_AuthenticationType global variavle value for login type and forks off to the proper module * * @param string $user_password - The password of the user to authenticate - * @return true if the user is authenticated, false otherwise + * @return boolean true if the user is authenticated, false otherwise */ public function doLogin($user_password) { global $log, $adb; @@ -371,7 +368,7 @@ public static function send2FACode($code, $userid) { /** * Load a user based on the user_name in $this - * @return -- this if load was successul and null if load failed. + * @return mixed Users if load was successul and null if load failed */ public function load_user($user_password) { global $log, $adb; @@ -522,11 +519,11 @@ public function get_user_crypt_type() { } /** - * @param string $user name - Must be non null and at least 1 character. - * @param string $user_password - Must be non null and at least 1 character. - * @param string $new_password - Must be non null and at least 1 character. - * @return boolean - If passwords pass verification and query succeeds, return true, else return false. - * @desc Verify that the current password is correct and write the new password to the DB. + * Verify that the current password is correct and write the new password to the database + * @param string $user name - Must be non null and at least 1 character + * @param string $user_password - Must be non null and at least 1 character + * @param string $new_password - Must be non null and at least 1 character + * @return boolean If passwords pass verification and query succeeds, return true, else return false */ public function change_password($user_password, $new_password, $dieOnError = true) { global $current_user, $log, $adb; @@ -630,8 +627,8 @@ public function is_twofaauthenticated() { } /** gives the user id for the specified user name - * @param $user_name -- user name:: Type varchar - * @returns user id + * @param string user name + * @return integer user id */ public function retrieve_user_id($user_name) { global $adb; @@ -647,7 +644,7 @@ public function retrieve_user_id($user_name) { /** check if given number is a valid and active user ID * @param integer $userid - * @returns boolean + * @return boolean */ public static function is_ActiveUserID($userid) { global $adb; @@ -660,7 +657,7 @@ public static function is_ActiveUserID($userid) { } /** - * @return -- returns a list of all users in the system. + * @return boolean user name exists already or not */ public function verify_data() { global $mod_strings, $log, $adb; @@ -671,7 +668,7 @@ public function verify_data() { $dup_users = $adb->fetchByAssoc($result); $query = "SELECT user_name from vtiger_users where is_admin = 'on' AND deleted=0"; - $result = $adb->pquery($query, array(), true, 'Error selecting possible duplicate vtiger_users: '); + $result = $adb->pquery($query, array(), true, 'Error selecting possible duplicate users: '); $last_admin = $adb->fetchByAssoc($result); $log->debug('last admin length: ' . count($last_admin)); @@ -758,7 +755,7 @@ public function retrieveCurrentUserInfoFromFile($userid) { } /** Function to save the user information into the database - * @param $module -- module name:: Type varchar + * @param string module name */ public function saveentity($module, $fileid = '') { global $adb; @@ -802,8 +799,8 @@ public function createAccessKey() { } /** Function to insert values in the specifed table for the specified module - * @param $table_name -- table name:: Type varchar - * @param $module -- module:: Type varchar + * @param string table name + * @param string module */ public function insertIntoEntityTable($table_name, $module, $fileid = '') { global $log, $app_strings, $adb; @@ -967,8 +964,8 @@ public function insertIntoEntityTable($table_name, $module, $fileid = '') { } /** Function to insert values into the attachment table - * @param $id -- entity id:: Type integer - * @param $module -- module:: Type varchar + * @param integer entity id + * @param string module */ public function insertIntoAttachment($id, $module, $direct_import = false) { global $log; @@ -1048,9 +1045,9 @@ public function retrieve_entity_info($record, $module, $deleted = false, $from_w } /** Function to upload the file to the server and add the file details in the attachments table - * @param $id -- user id:: Type varchar - * @param $module -- module name:: Type varchar - * @param $file_details -- file details array:: Type array + * @param integer user id + * @param string module name + * @param array file details */ public function uploadAndSaveFile($id, $module, $file_details, $attachmentname = '', $direct_import = false, $forfield = '') { global $log, $current_user, $upload_badext, $adb; @@ -1107,7 +1104,7 @@ public function uploadAndSaveFile($id, $module, $file_details, $attachmentname = } /** Function to save the user information into the database - * @param $module -- module name:: Type varchar + * @param string module name */ public function save($module_name, $fileid = '') { global $adb, $current_user, $cbodUserLog; @@ -1188,8 +1185,8 @@ public function save($module_name, $fileid = '') { /** * gives the order in which the modules have to be displayed in the home page for the specified user id - * @param $id -- user id:: Type integer - * @returns the customized home page order in $return_array + * @param integer user id + * @return array the customized home page order */ public function getHomeStuffOrder($id) { global $adb; @@ -1376,7 +1373,7 @@ public function insertUserdetails($inVal) { } /** function to save the order in which the modules have to be displayed in the home page for the specified user id - * @param $id -- user id:: Type integer + * @param integer user id */ public function saveHomeStuffOrder($id) { global $log, $adb; @@ -1402,7 +1399,7 @@ public function saveHomeStuffOrder($id) { /** * Function to reset the Reminder Interval setup and update the time for next reminder interval - * @param $prev_reminder_interval -- Last Reminder Interval on which the reminder popup's were triggered. + * @param integer Last Reminder Interval on which the reminder popup's were triggered */ public function resetReminderInterval($prev_reminder_interval) { global $adb; @@ -1498,7 +1495,7 @@ public function transformOwnerShipAndDelete($userId, $transformToUserId) { $cbmq->sendMessage('coreBOSOnDemandChannel', 'Users', 'CentralSync', 'Data', '1:M', 0, 8640000, 0, 0, serialize($msg)); } - //delete from user vtiger_table; + //delete from user table; $adb->pquery('delete from vtiger_users where id=?', array($userId)); //Delete user extension in asterisk. $adb->pquery('delete from vtiger_asteriskextensions where userid=?', array($userId)); @@ -1506,7 +1503,7 @@ public function transformOwnerShipAndDelete($userId, $transformToUserId) { /** * This function should be overridden in each module. It marks an item as deleted. - * @param $id + * @param integer $id */ public function mark_deleted($id) { global $current_user, $adb; @@ -1517,7 +1514,7 @@ public function mark_deleted($id) { /** * Function to get the user id of the active admin user. - * @return Integer - Active Admin User ID + * @return integer active Admin User ID */ public static function getActiveAdminId() { global $adb; @@ -1533,7 +1530,7 @@ public static function getActiveAdminId() { /** * Function to get the active admin user object - * @return Users - Active Admin User Instance + * @return Users Active Admin User Instance */ public static function getActiveAdminUser() { $adminId = self::getActiveAdminId(); @@ -1581,7 +1578,7 @@ public function create_export_query($where) { /** * Function to get the Headers of Users Information like User ID, Name, Role, Email. - * Returns Header Values like User ID, Email etc in an array format. + * @return array Header Values like User ID, Email etc **/ public function getUserListHeader() { global $log;