Minor - format code

pull/2585/head
Julio 7 years ago
parent f76775a95d
commit 43c501aa6a
  1. 11
      main/admin/user_list.php
  2. 51
      main/inc/lib/CourseChatUtils.php
  3. 6
      main/inc/lib/sessionmanager.lib.php
  4. 2
      main/inc/lib/template.lib.php
  5. 71
      main/inc/lib/usermanager.lib.php
  6. 2
      plugin/olpc_peru_filter/lib/olpc_peru_filter_plugin.class.php

@ -439,7 +439,9 @@ function get_number_of_users()
* @param int Number of users to get * @param int Number of users to get
* @param int Column to sort on * @param int Column to sort on
* @param string Order (ASC,DESC) * @param string Order (ASC,DESC)
* @return array Users list *
* @return array Users list
*
* @see SortableTable#get_table_data($from) * @see SortableTable#get_table_data($from)
*/ */
function get_user_data($from, $number_of_items, $column, $direction) function get_user_data($from, $number_of_items, $column, $direction)
@ -511,7 +513,7 @@ function email_filter($email)
/** /**
* Returns a mailto-link. * Returns a mailto-link.
* *
* @param string $email An email-address * @param string $email An email-address
* @param array $params Deprecated * @param array $params Deprecated
* @param array $row * @param array $row
* *
@ -529,8 +531,9 @@ function user_filter($name, $params, $row)
* @param string URL params to add to table links * @param string URL params to add to table links
* @param array Row of elements to alter * @param array Row of elements to alter
* *
* @return string Some HTML-code with modify-buttons
* @throws Exception * @throws Exception
*
* @return string Some HTML-code with modify-buttons
*/ */
function modify_filter($user_id, $url_params, $row) function modify_filter($user_id, $url_params, $row)
{ {
@ -811,7 +814,9 @@ function active_filter($active, $params, $row)
/** /**
* Instead of displaying the integer of the status, we give a translation for the status. * Instead of displaying the integer of the status, we give a translation for the status.
*
* @param int $status * @param int $status
*
* @return string translation * @return string translation
* *
* @version march 2008 * @version march 2008

@ -704,37 +704,14 @@ class CourseChatUtils
return (int) $number; return (int) $number;
} }
/**
* Format the user data to return it in the user list
*
* @param User $user
* @param int $status
*
* @return array
*/
private function formatUser(User $user, $status)
{
return [
'id' => $user->getId(),
'firstname' => $user->getFirstname(),
'lastname' => $user->getLastname(),
'status' => $status,
'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM),
'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(),
'complete_name' => $user->getCompleteName(),
'username' => $user->getUsername(),
'email' => $user->getEmail(),
'isConnected' => $this->userIsConnected($user->getId()),
];
}
/** /**
* Get the users online data. * Get the users online data.
* *
* @return array
* @throws \Doctrine\ORM\ORMException * @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException * @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException * @throws \Doctrine\ORM\TransactionRequiredException
*
* @return array
*/ */
public function listUsersOnline() public function listUsersOnline()
{ {
@ -763,6 +740,30 @@ class CourseChatUtils
return $usersInfo; return $usersInfo;
} }
/**
* Format the user data to return it in the user list.
*
* @param User $user
* @param int $status
*
* @return array
*/
private function formatUser(User $user, $status)
{
return [
'id' => $user->getId(),
'firstname' => $user->getFirstname(),
'lastname' => $user->getLastname(),
'status' => $status,
'image_url' => UserManager::getUserPicture($user->getId(), USER_IMAGE_SIZE_MEDIUM),
'profile_url' => api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user->getId(),
'complete_name' => $user->getCompleteName(),
'username' => $user->getUsername(),
'email' => $user->getEmail(),
'isConnected' => $this->userIsConnected($user->getId()),
];
}
/** /**
* Get the users subscriptions (SessionRelCourseRelUser array or CourseRelUser array) for chat. * Get the users subscriptions (SessionRelCourseRelUser array or CourseRelUser array) for chat.
* *

@ -2486,8 +2486,10 @@ class SessionManager
* @param bool $removeExistingCoursesWithUsers Whether to unsubscribe * @param bool $removeExistingCoursesWithUsers Whether to unsubscribe
* existing courses and users (true, default) or not (false) * existing courses and users (true, default) or not (false)
* @param bool $copyEvaluation from base course to session course * @param bool $copyEvaluation from base course to session course
* @return bool False on failure, true otherwise *
* @throws Exception * @throws Exception
*
* @return bool False on failure, true otherwise
* */ * */
public static function add_courses_to_session( public static function add_courses_to_session(
$sessionId, $sessionId,
@ -2511,7 +2513,6 @@ class SessionManager
} }
$sessionVisibility = $session->getVisibility(); $sessionVisibility = $session->getVisibility();
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
@ -2743,6 +2744,7 @@ class SessionManager
SET nbr_courses = $nbr_courses SET nbr_courses = $nbr_courses
WHERE id = $sessionId"; WHERE id = $sessionId";
Database::query($sql); Database::query($sql);
return true; return true;
} }

@ -760,7 +760,7 @@ class Template
'bootstrap-select/dist/js/bootstrap-select.min.js', 'bootstrap-select/dist/js/bootstrap-select.min.js',
$selectLink, $selectLink,
'select2/dist/js/select2.min.js', 'select2/dist/js/select2.min.js',
"select2/dist/js/i18n/$isoCode.js", "select2/dist/js/i18n/$isoCode.js"
]; ];
$features = api_get_configuration_value('video_features'); $features = api_get_configuration_value('video_features');

@ -58,6 +58,7 @@ class UserManager
{ {
/** @var UserRepository $userRepository */ /** @var UserRepository $userRepository */
$userRepository = Database::getManager()->getRepository('ChamiloUserBundle:User'); $userRepository = Database::getManager()->getRepository('ChamiloUserBundle:User');
return $userRepository; return $userRepository;
} }
@ -677,10 +678,11 @@ class UserManager
* *
* @param int The ID of th user to be deleted * @param int The ID of th user to be deleted
* *
* @throws Exception
*
* @return bool true if user is successfully deleted, false otherwise * @return bool true if user is successfully deleted, false otherwise
* @assert (null) === false * @assert (null) === false
* @assert ('abc') === false * @assert ('abc') === false
* @throws Exception
*/ */
public static function delete_user($user_id) public static function delete_user($user_id)
{ {
@ -967,6 +969,7 @@ class UserManager
$r = Database::query($sql); $r = Database::query($sql);
if ($r !== false) { if ($r !== false) {
Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $ids); Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $ids);
return true; return true;
} }
@ -1002,6 +1005,7 @@ class UserManager
$r = Database::query($sql); $r = Database::query($sql);
if ($r !== false) { if ($r !== false) {
Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids); Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $ids);
return true; return true;
} }
@ -1034,32 +1038,33 @@ class UserManager
if (Database::query($sql) !== false) { if (Database::query($sql) !== false) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Update user information with all the parameters passed to this function. * Update user information with all the parameters passed to this function.
* *
* @param int $user_id The ID of the user to be updated * @param int $user_id The ID of the user to be updated
* @param string $firstname The user's firstname * @param string $firstname The user's firstname
* @param string $lastname The user's lastname * @param string $lastname The user's lastname
* @param string $username The user's username (login) * @param string $username The user's username (login)
* @param string $password The user's password * @param string $password The user's password
* @param string $auth_source The authentication source (default: "platform") * @param string $auth_source The authentication source (default: "platform")
* @param string $email The user's e-mail address * @param string $email The user's e-mail address
* @param int $status The user's status * @param int $status The user's status
* @param string $official_code The user's official code (usually just an internal institutional code) * @param string $official_code The user's official code (usually just an internal institutional code)
* @param string $phone The user's phone number * @param string $phone The user's phone number
* @param string $picture_uri The user's picture URL (internal to the Chamilo directory) * @param string $picture_uri The user's picture URL (internal to the Chamilo directory)
* @param string $expiration_date The date at which this user will be automatically disabled * @param string $expiration_date The date at which this user will be automatically disabled
* @param int $active Whether this account needs to be enabled (1) or disabled (0) * @param int $active Whether this account needs to be enabled (1) or disabled (0)
* @param int $creator_id The user ID of the person who registered this user (optional, defaults to null) * @param int $creator_id The user ID of the person who registered this user (optional, defaults to null)
* @param int $hr_dept_id The department of HR in which the user is registered (optional, defaults to 0) * @param int $hr_dept_id The department of HR in which the user is registered (optional, defaults to 0)
* @param array $extra A series of additional fields to add to this user as extra fields (optional, defaults to null) * @param array $extra A series of additional fields to add to this user as extra fields (optional, defaults to null)
* @param string $language The language to which the user account will be set * @param string $language The language to which the user account will be set
* @param string $encrypt_method The cipher method. This parameter is deprecated. It will use the system's default * @param string $encrypt_method The cipher method. This parameter is deprecated. It will use the system's default
* @param bool $send_email Whether to send an e-mail to the user after the update is complete * @param bool $send_email Whether to send an e-mail to the user after the update is complete
* @param int $reset_password Method used to reset password (0, 1, 2 or 3 - see usage examples for details) * @param int $reset_password Method used to reset password (0, 1, 2 or 3 - see usage examples for details)
* @param string $address * @param string $address
* *
* @return bool|int False on error, or the user ID if the user information was updated * @return bool|int False on error, or the user ID if the user information was updated
@ -1646,10 +1651,10 @@ class UserManager
/** /**
* Get a list of users of which the given conditions match with a LIKE '%cond%'. * Get a list of users of which the given conditions match with a LIKE '%cond%'.
* *
* @param array $conditions a list of condition (exemple : status=>STUDENT) * @param array $conditions a list of condition (exemple : status=>STUDENT)
* @param array $order_by a list of fields on which sort * @param array $order_by a list of fields on which sort
* @param bool $simple_like Whether we want a simple LIKE 'abc' or a LIKE '%abc%' * @param bool $simple_like Whether we want a simple LIKE 'abc' or a LIKE '%abc%'
* @param string $condition Whether we want the filters to be combined by AND or OR * @param string $condition Whether we want the filters to be combined by AND or OR
* *
* @return array an array with all users of the platform * @return array an array with all users of the platform
* *
@ -2238,7 +2243,7 @@ class UserManager
/** /**
* Returns an array with the user's productions. * Returns an array with the user's productions.
* *
* @param int $user_id User id * @param int $user_id User id
* *
* @return array An array containing the user's productions * @return array An array containing the user's productions
*/ */
@ -4098,8 +4103,10 @@ class UserManager
$sql = "INSERT INTO $table_user_tag_values SET user_id = $user_id, tag_id = $last_insert_id"; $sql = "INSERT INTO $table_user_tag_values SET user_id = $user_id, tag_id = $last_insert_id";
Database::query($sql); Database::query($sql);
} }
return true; return true;
} }
return false; return false;
} }
@ -4354,6 +4361,7 @@ class UserManager
return $whereFilter; return $whereFilter;
} }
return ''; return '';
} }
@ -4362,8 +4370,9 @@ class UserManager
* *
* @param string $query the value of the search box * @param string $query the value of the search box
* *
* @return string HTML form
* @throws Exception * @throws Exception
*
* @return string HTML form
*/ */
public static function get_search_form($query, $defaultParams = []) public static function get_search_form($query, $defaultParams = [])
{ {
@ -4902,7 +4911,7 @@ class UserManager
/** /**
* Register request to assign users to HRM. * Register request to assign users to HRM.
* *
* @param int $hrmId The HRM ID * @param int $hrmId The HRM ID
* @param array $usersId The users IDs * @param array $usersId The users IDs
* *
* @return int * @return int
@ -5098,6 +5107,7 @@ class UserManager
return $row['uid']; return $row['uid'];
} }
return false; return false;
} }
@ -5276,7 +5286,8 @@ class UserManager
} }
/** /**
* Returns an array of the different types of user extra fields [id => title translation] * Returns an array of the different types of user extra fields [id => title translation].
*
* @return array * @return array
*/ */
public static function get_user_field_types() public static function get_user_field_types()
@ -5417,6 +5428,7 @@ class UserManager
} }
} }
} }
return $inserted; return $inserted;
} }
@ -5774,6 +5786,7 @@ SQL;
return Display::tabsOnlyLink($headers, $optionSelected); return Display::tabsOnlyLink($headers, $optionSelected);
} }
return ''; return '';
} }
@ -5933,6 +5946,7 @@ SQL;
* Send user confirmation mail. * Send user confirmation mail.
* *
* @param User $user * @param User $user
*
* @throws Exception * @throws Exception
*/ */
public static function sendUserConfirmationMail(User $user) public static function sendUserConfirmationMail(User $user)
@ -5990,6 +6004,7 @@ SQL;
* *
* @param int $user_id * @param int $user_id
* @param int $active Enable or disable * @param int $active Enable or disable
*
* @return bool True on success, false on failure * @return bool True on success, false on failure
* @assert (-1,0) === false * @assert (-1,0) === false
* @assert (1,1) === true * @assert (1,1) === true

@ -8,7 +8,7 @@
*/ */
/** /**
* Class OLPC_Peru_FilterPlugin * Class OLPC_Peru_FilterPlugin.
*/ */
class OLPC_Peru_FilterPlugin extends Plugin class OLPC_Peru_FilterPlugin extends Plugin
{ {

Loading…
Cancel
Save