Example #1
0
     unset($userData['password_conf']);
 }
 if (empty($userData['authSource'])) {
     unset($userData['authSource']);
 }
 if (!get_conf('allowSelfRegProf') && !claro_is_platform_admin()) {
     unset($userData['isCourseCreator']);
 }
 if (!claro_is_platform_admin()) {
     unset($userData['isPlatformAdmin']);
 }
 // Validate form params
 $errorMsgList = user_validate_form_profile($userData, claro_get_current_user_id());
 if (count($errorMsgList) == 0) {
     // if no error update use setting
     user_set_properties(claro_get_current_user_id(), $userData);
     set_user_property(claro_get_current_user_id(), 'skype', $userData['skype']);
     $claroline->log('PROFILE_UPDATE', array('user' => claro_get_current_user_id()));
     // re-init the system to take new settings in account
     $uidReset = true;
     include dirname(__FILE__) . '/../inc/claro_init_local.inc.php';
     $dialogBox->success(get_lang('The information have been modified'));
     // Initialise
     $userData = user_get_properties(claro_get_current_user_id());
 } else {
     // user validate form return error messages
     foreach ($errorMsgList as $errorMsg) {
         $dialogBox->error($errorMsg);
     }
     $error = true;
 }
Example #2
0
         } else {
             // Handle error
             $dialBox->error(get_lang("Invalid file format, use gif, jpg or png"));
         }
     } else {
         // Handle error
         $dialogBox->error(get_lang('Upload failed'));
     }
 }
 // validate forum params
 $messageList = user_validate_form_admin_user_profile($user_data, $userId);
 if (count($messageList) == 0) {
     if (empty($user_data['password'])) {
         unset($user_data['password']);
     }
     user_set_properties($userId, $user_data);
     // if no error update use setting
     if ($userId == claro_get_current_user_id()) {
         $uidReset = true;
         include get_path('incRepositorySys') . '/claro_init_local.inc.php';
     }
     //$classMsg = 'success';
     $dialogBox->success(get_lang('Changes have been applied to the user settings'));
     // set user admin parameter
     if ($user_data['is_admin']) {
         user_set_platform_admin(true, $userId);
     } else {
         user_set_platform_admin(false, $userId);
     }
     //$messageList[] = get_lang('Changes have been applied to the user settings');
 } else {
Example #3
0
 public function importUsers($userList = array(), $class_id, $updateUserProperties, $sendEmail = 0)
 {
     if (empty($this->data)) {
         return false;
     }
     if (empty($userList)) {
         return false;
     }
     $logs = array();
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_user = $tbl_mdb_names['user'];
     $tbl_course_user = $tbl_mdb_names['rel_course_user'];
     $tbl_cdb_names = claro_sql_get_course_tbl();
     $tbl_group_rel_team_user = $tbl_cdb_names['group_rel_team_user'];
     $groupsImported = array();
     $userInfo = array();
     foreach ($userList as $user_id) {
         if (!isset($this->data[$user_id])) {
             $logs['errors'][] = get_lang('Unable to find the user in the csv');
         } else {
             $userInfo['username'] = $this->data[$user_id]['username'];
             $userInfo['firstname'] = $this->data[$user_id]['firstname'];
             $userInfo['lastname'] = $this->data[$user_id]['lastname'];
             $userInfo['email'] = isset($this->data[$user_id]['email']) && !empty($this->data[$user_id]['email']) ? $this->data[$user_id]['email'] : '';
             $userInfo['password'] = isset($this->data[$user_id]['password']) && !empty($this->data[$user_id]['password']) ? $this->data[$user_id]['password'] : mk_password(8);
             $userInfo['officialCode'] = isset($this->data[$user_id]['officialCode']) ? $this->data[$user_id]['officialCode'] : '';
             //check user existe if not create is asked
             $resultSearch = user_search(array('username' => $userInfo['username']), null, true, true);
             if (!empty($resultSearch)) {
                 $userId = $resultSearch[0]['uid'];
                 if (get_conf('update_user_properties') && $updateUserProperties) {
                     //  never update password
                     unset($userInfo['password']);
                     if (user_set_properties($userId, $userInfo)) {
                         $logs['success'][] = get_lang('User profile %username updated successfully', array('%username' => $userInfo['username']));
                     }
                     if ($sendEmail) {
                         user_send_registration_mail($userId, $userInfo);
                     }
                 } else {
                     $logs['errors'][] = get_lang('User %username not created because it already exists in the database', array('%username' => $userInfo['username']));
                 }
             } else {
                 $userId = user_create($userInfo);
                 if ($userId != 0) {
                     $newUserInfo = user_get_properties($userId);
                     if ($newUserInfo['username'] != $userInfo['username']) {
                         // if the username fixed is the csv file is too long -> get correct one before sending
                         $userInfo['username'] = $newUserInfo['username'];
                     }
                     $logs['success'][] = get_lang('User %username created successfully', array('%username' => $userInfo['username']));
                     if ($sendEmail) {
                         user_send_registration_mail($userId, $userInfo);
                     }
                 } else {
                     $logs['errors'][] = get_lang('Unable to create user %username', array('%username' => $userInfo['username']));
                 }
             }
             if ($userId) {
                 //join class if needed
                 if ($class_id) {
                     if (!($return = user_add_to_class($userId, $class_id))) {
                         $logs['errors'][] = get_lang('Unable to add %username in the selected class', array('%username' => $userInfo['username']));
                     } else {
                         $logs['success'][] = get_lang('User %username added in the selected class', array('%username' => $userInfo['username']));
                     }
                 }
             }
         }
     }
     return $logs;
 }
Example #4
0
 case 'rqResetAllPasswords':
     $dialogBox->question(get_lang('Do you really want to reset all the passwords ?') . '<br />' . '<small>' . get_lang('The platform administrators and course creators password will remain unchanged') . '</small>' . '<br />');
     $dialogBox->form(' <form method="post" action="' . claro_htmlspecialchars($_SERVER['PHP_SELF']) . '">' . '<input type="hidden" name="cmd" value="exResetAllPasswords" />' . '<input id="sendEmail" type="checkbox" name="sendEmail" value="yes" checked="checked" />' . '<label for="sendEmail">' . get_lang('send new password by email') . '</label>' . '<br />' . '<small>' . get_lang('Only the users with a valid address will receive their password by email') . '</small>' . '<br />' . '<input type="submit" value="' . get_lang('Yes') . '" />' . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) . '</form>');
     $dialogBox->warning('<em>' . get_lang('This may take some time, please wait until the end of the process...') . '</em>');
     break;
 case 'exResetAllPasswords':
     $userList = getAllStudentUserId();
     $failedMailList = array();
     $failedList = array();
     $sendEmail = isset($_REQUEST['sendEmail']) && $_REQUEST['sendEmail'] ? true : false;
     foreach ($userList as $user) {
         $mailSent = FALSE;
         $userInfo = user_get_properties($user['id']);
         if (!$userInfo['isPlatformAdmin'] && !$userInfo['isCourseCreator']) {
             $userInfo['password'] = mk_password(8);
             if (user_set_properties($user['id'], array('password' => $userInfo['password']))) {
                 if ($sendEmail && user_send_registration_mail($user['id'], $userInfo)) {
                     $mailSent = TRUE;
                 }
             } else {
                 $failedList[] = $userInfo;
             }
         }
         if ($sendEmail && !$mailSent) {
             $failedMailList[] = $userInfo;
         }
     }
     if (empty($failedList)) {
         $dialogBox->success(get_lang('Password changed successfully for all concerned users'));
     } else {
         $failedStudents = '';
Example #5
0
/**
 * Set or unset platform administrator status to a specific user
 *
 * @author Hugues Peeters <*****@*****.**>
 * @param  boolean $status
 * @param  int     $userId
 * @return boolean 'true' if it succeeds, 'false' otherwise
 */
function user_set_platform_admin($status, $userId)
{
    return user_set_properties($userId, array('isPlatformAdmin' => (bool) $status));
}