/** * Render content */ public function render() { CssLoader::getInstance()->load('profile', 'all'); load_kernel_config('user_profile'); $userData = user_get_properties($this->userId); $pictureUrl = ''; if (get_conf('allow_profile_picture')) { $picturePath = user_get_picture_path($userData); if ($picturePath && file_exists($picturePath)) { $pictureUrl = user_get_picture_url($userData); } else { $pictureUrl = get_icon_url('nopicture'); } } $userFullName = claro_htmlspecialchars(get_lang('%firstName %lastName', array('%firstName' => $userData['firstname'], '%lastName' => $userData['lastname']))); $dock = new ClaroDock('userProfileBox'); $template = new CoreTemplate('user_profilebox.tpl.php'); $template->assign('userId', $this->userId); $template->assign('pictureUrl', $pictureUrl); $template->assign('userFullName', $userFullName); $template->assign('dock', $dock); $template->assign('condensedMode', $this->condensedMode); $template->assign('userData', $userData); return $template->render(); }
$dialogBox = new DialogBox(); if ($cmd == 'exDelete' && $req['uidToEdit']) { $claroline->log('DELETE_USER', array('USER' => $req['uidToEdit'])); if (false !== ($deletionResult = user_delete($req['uidToEdit']))) { $dialogBox->success(get_lang('Deletion of the user was done sucessfully')); } else { switch (claro_failure::get_last_failure()) { case 'user_cannot_remove_himself': $dialogBox->error(get_lang('You can not change your own settings!')); break; default: $dialogBox->error(get_lang('Unable to delete')); } } } elseif ($cmd == 'rqDelete' && $req['uidToEdit']) { $user_properties = user_get_properties($req['uidToEdit']); if (is_array($user_properties)) { $dialogBox->question(get_lang('Are you sure to delete user %firstname %lastname', array('%firstname' => $user_properties['firstname'], '%lastname' => $user_properties['lastname'])) . '<br/><br/>' . "\n" . '<a href="adminuserdeleted.php?cmd=exDelete&uidToEdit=' . $req['uidToEdit'] . '">' . get_lang('Yes') . '</a>' . ' | ' . '<a href="admin_profile.php?uidToEdit=' . $req['uidToEdit'] . '">' . get_lang('No') . '</a>' . "\n"); } } else { $dialogBox->error(get_lang('Unable to delete')); } //------------------------------------ // DISPLAY //------------------------------------ $out = ''; $out .= claro_html_tool_title(get_lang('Delete user')); if (isset($dialogBox)) { $out .= $dialogBox->render(); } $out .= '<p>' . claro_html_menu_horizontal($cmdList) . '</p>';
require_once get_path('incRepositorySys') . '/lib/fileUpload.lib.php'; require_once get_path('incRepositorySys') . '/lib/fileManage.lib.php'; require_once get_path('incRepositorySys') . '/lib/display/dialogBox.lib.php'; // Initialise variables $nameTools = get_lang('User settings'); $dialogBox = new DialogBox(); /*===================================================================== Main Section =====================================================================*/ // see which user we are working with ... if (empty($_REQUEST['uidToEdit'])) { claro_redirect('adminusers.php'); } else { $userId = $_REQUEST['uidToEdit']; } $user_data = user_get_properties($userId); if (empty($user_data)) { claro_die(get_lang('Unable to load user information')); } $user_extra_data = user_get_extra_data($userId); if (count($user_extra_data)) { $dgExtra = new claro_datagrid(user_get_extra_data($userId)); } else { $dgExtra = null; } if (isset($_REQUEST['applyChange'])) { // get params form the form if (isset($_POST['lastname'])) { $user_data['lastname'] = trim($_POST['lastname']); } if (isset($_POST['firstname'])) {
include claro_get_conf_repository() . 'CLMSG.conf.php'; require_once dirname(__FILE__) . '/lib/permission.lib.php'; $userId = isset($_REQUEST['userId']) ? (int) $_REQUEST['userId'] : null; $link_arg = array(); if (!is_null($userId) && !empty($userId)) { $currentUserId = (int) $_REQUEST['userId']; $link_arg['userId'] = $currentUserId; } else { $currentUserId = claro_get_current_user_id(); } if ($currentUserId != claro_get_current_user_id() && !claro_is_platform_admin()) { claro_die(get_lang("Not allowed")); } // user exist ? if ($currentUserId != claro_get_current_user_id()) { $userData = user_get_properties($currentUserId); if ($userData === false) { claro_die(get_lang("User not found")); } else { $title = get_lang('Messages of %firstName %lastName', array('%firstName' => claro_htmlspecialchars($userData['firstname']), '%lastName' => claro_htmlspecialchars($userData['lastname']))); } } else { $title = get_lang('My messages'); } $linkPage = $_SERVER['PHP_SELF']; $acceptedValues = array('inbox', 'outbox', 'trashbox'); if (!isset($_REQUEST['box']) || !in_array($_REQUEST['box'], $acceptedValues)) { $_REQUEST['box'] = "inbox"; } $link_arg['box'] = $_REQUEST['box']; require_once dirname(__FILE__) . '/lib/tools.lib.php';
/** * Exports a CSV file from a list of user id's * @param array $userIdList id of the class * @param array $fields optionnal names for the headers of the generated csv * @return string * @author schampagne <http://forum.claroline.net/memberlist.php?mode=viewprofile&u=45044> */ function csv_export_user_list($userIdList, $fields = array('user_id', 'username', 'lastname', 'firstname', 'email', 'officialCode')) { $csv = new CsvExporter(',', '"'); $csvData = array(); $csvData[0] = $fields; foreach ($userIdList as $userId) { $userInfo = user_get_properties($userId); $row = array(); foreach ($fields as $field) { if (isset($userInfo[$field])) { $row[$field] = $userInfo[$field]; } else { $row[$field] = ''; } } $csvData[] = $row; } return $csv->export($csvData); }
claro_die(get_lang('Not allowed')); } // Filter input $validCmdList = array('unsubscribe', 'rqRmAll'); $cmd = isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $validCmdList) ? $_REQUEST['cmd'] : null; $validRefererList = array('ulist'); $cfrom = isset($_REQUEST['cfrom']) && in_array($_REQUEST['cfrom'], $validRefererList) ? $_REQUEST['cfrom'] : null; $uidToEdit = (int) (isset($_REQUEST['uidToEdit']) ? $_REQUEST['uidToEdit'] : null); $courseId = isset($_REQUEST['courseId']) ? $_REQUEST['courseId'] : null; $do = null; // Filter input for pading/sorting : $offset, $sort, $dir $offset = (int) (!isset($_REQUEST['offset'])) ? 0 : $_REQUEST['offset']; $pagerSortKey = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'name'; $pagerSortDir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : SORT_ASC; // Parse command $userData = user_get_properties($uidToEdit); if (false === $userData || $uidToEdit != $userData['user_id']) { $dialogBox->error(get_lang('Not valid user id')); } if ('unsubscribe' == $cmd) { if (is_null($courseId)) { $dialogBox->error(get_lang('Not valid course code')); } else { $do = 'rem_user'; } } if ('rqRmAll' == $cmd) { $courseList = claro_get_user_course_list($uidToEdit); $ok = true; foreach ($courseList as $course) { if (!user_remove_from_course($uidToEdit, $course['sysCode'], true, false)) {
public function mergeCourseUsers($uidToRemove, $uidToKeep, $courseId) { $error = false; $moduleCourseTbl = get_module_course_tbl(array('bb_posts', 'bb_topics', 'bb_priv_msgs', 'bb_rel_forum_userstonotify', 'bb_rel_topic_userstonotify'), $courseId); $userToKeepProp = user_get_properties($uidToKeep); $sql = "UPDATE `{$moduleCourseTbl['bb_posts']}`\n SET poster_id = " . (int) $uidToKeep . ",\n nom = '" . claro_sql_escape($userToKeepProp['lastname']) . "',\n prenom = '" . claro_sql_escape($userToKeepProp['firstname']) . "'\n WHERE poster_id = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { Console::error("Cannot update bb_posts from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; return !$error; } // Update topic poster, lastname & firstname $sql = "UPDATE `{$moduleCourseTbl['bb_topics']}`\n SET topic_poster = " . (int) $uidToKeep . ",\n nom = '" . claro_sql_escape($userToKeepProp['lastname']) . "',\n prenom = '" . claro_sql_escape($userToKeepProp['firstname']) . "'\n WHERE topic_poster = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { // echo mysql_error(); Console::error("Cannot update bb_topics from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; return !$error; } // Update private messages (from) $sql = "UPDATE `{$moduleCourseTbl['bb_priv_msgs']}`\n SET from_userid = " . (int) $uidToKeep . "\n WHERE from_userid = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { Console::error("Cannot update bb_priv_msgs:recipient from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; return !$error; } // Update private messages (to) $sql = "UPDATE `{$moduleCourseTbl['bb_priv_msgs']}`\n SET to_userid = " . (int) $uidToKeep . "\n WHERE to_userid = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { Console::error("Cannot update bb_priv_msgs:sender from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; return !$error; } // Update topic notification $sql = "SELECT `topic_id`\n FROM `{$moduleCourseTbl['bb_rel_topic_userstonotify']}`\n WHERE `user_id` = " . (int) $uidToRemove; $topicIds = claro_sql_query_fetch_all($sql); if (!empty($topicIds)) { foreach ($topicIds as $_topicId) { $topicId = $_topicId['topic_id']; $sql = "SELECT `notify_id`\n FROM `{$moduleCourseTbl['bb_rel_topic_userstonotify']}`\n WHERE `user_id` = " . (int) $uidToRemove . " AND `topic_id` = " . (int) $topicId . "\n LIMIT 1"; $notify = claro_sql_query_get_single_row($sql); if (!empty($notify)) { // Update notification for userToRemove to userToKeep $sql = "UPDATE `{$moduleCourseTbl['bb_rel_topic_userstonotify']}`\n SET user_id = " . (int) $uidToKeep . "\n WHERE notify_id = " . (int) $notify['notify_id']; if (!claro_sql_query($sql)) { Console::error("Cannot update bb_rel_topic_userstonotify from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; } } // Delete the notification for userToRemove $sql = "DELETE FROM `{$moduleCourseTbl['bb_rel_topic_userstonotify']}` WHERE `user_id` = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { Console::error("Cannot delete bb_rel_topic_userstonotify from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; } } } // Update forum notification $sql = "SELECT `forum_id`\n FROM `{$moduleCourseTbl['bb_rel_forum_userstonotify']}`\n WHERE `user_id` = " . (int) $uidToRemove; $forumIds = claro_sql_query_fetch_all($sql); if (!empty($forumIds)) { foreach ($forumIds as $_forumId) { $forumId = $_forumId['forum_id']; $sql = "SELECT `notify_id`\n FROM `{$moduleCourseTbl['bb_rel_forum_userstonotify']}`\n WHERE `user_id` = " . (int) $uidToRemove . " AND `forum_id` = " . (int) $forumId . "\n LIMIT 1"; $notify = claro_sql_query_get_single_row($sql); if (!empty($notify)) { // Update notification for userToRemove to userToKeep $sql = "UPDATE `{$moduleCourseTbl['bb_rel_forum_userstonotify']}`\n SET user_id = " . (int) $uidToKeep . "\n WHERE notify_id = " . (int) $notify['notify_id']; if (!claro_sql_query($sql)) { Console::error("Cannot update bb_rel_forum_userstonotify from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; } } // Delete the notification for userToRemove $sql = "DELETE FROM `{$moduleCourseTbl['bb_rel_form_userstonotify']}` WHERE `user_id` = " . (int) $uidToRemove; if (!claro_sql_query($sql)) { Console::error("Cannot delete bb_rel_forum_userstonotify from -{$uidToRemove} to +{$uidToKeep} in {$courseId}"); $error = true; } } } return !$error; }
$_SESSION['returnToTrackingUserId'] = (int) $_GET['copyFrom']; $copyError = false; //we could simply copy the requested module progression... //but since we can navigate between modules while completing a module, //we have to copy the whole learning path progression. if (!copyLearnPathProgression((int) $_SESSION['returnToTrackingUserId'], (int) claro_get_current_user_id(), (int) $_SESSION['path_id'])) { $copyError = true; } $dialogBox = new DialogBox(); if ($copyError) { $dialogBox->error(get_lang('An error occured while accessing student module')); $claroline->display->body->appendContent($dialogBox->render()); echo $claroline->display->render(); exit; } else { $user_data = user_get_properties((int) $_SESSION['returnToTrackingUserId']); $dialogBox->success(get_lang('Currently viewing module of ') . $user_data['firstname'] . ' ' . $user_data['lastname']); unset($user_data); } unset($copyError); } else { unset($_SESSION['returnToTrackingUserId']); } // main page // FIRST WE SEE IF USER MUST SKIP THE PRESENTATION PAGE OR NOT // triggers are : if there is no introdution text or no user module progression statistics yet and user is not admin, // then there is nothing to show and we must enter in the module without displaying this page. /* * GET INFOS ABOUT MODULE and LEARNPATH_MODULE */ // check in the DB if there is a comment set for this module in general
if (!user_get_properties($uidToRemove)) { throw new Exception(get_lang('User to remove not found')); } $question = '<p>' . get_lang('Merging users will alter the user data and cannot be undone. Are you sure to want to continue ?') . '</p>' . "\n" . '<form action="' . $_SERVER['PHP_SELF'] . '?cmd=exMerge" method="post">' . "\n" . '<input type="hidden" name="uidToRemove" id="uidToRemove" value="' . $uidToRemove . '" />' . "\n" . '<input type="hidden" name="uidToKeep" id="uidToKeep" value="' . $uidToKeep . '" />' . "\n" . '<input type="submit" name="continue" value="' . get_lang('Yes') . '" />' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '"><input type="button" name="cancel" value="' . get_lang('No') . '" /></a>' . "\n" . '</form>'; $dialogBox->question($question); } if ($cmd == 'exMerge') { $uidToKeep = $userInput->getMandatory('uidToKeep'); $uidToRemove = $userInput->getMandatory('uidToRemove'); if ($uidToKeep == $uidToRemove) { throw new Exception(get_lang('Cannot merge one user account with itself')); } if (!user_get_properties($uidToKeep)) { throw new Exception(get_lang('User to keep not found')); } if (!user_get_properties($uidToRemove)) { throw new Exception(get_lang('User to remove not found')); } $mergeUser = new MergeUser(); $mergeUser->merge($uidToRemove, $uidToKeep); if ($mergeUser->hasError()) { $dialogBox->error(get_lang('Some errors have occured while merging those user account, check the log table in the platform main database for more details')); } else { $dialogBox->success(get_lang('User accounts merged')); } } } catch (Exception $e) { $dialogBox->error(get_lang('Cannot perform the requested action') . ' : <br />' . $e->getMessage()); pushClaroMessage('<pre>' . $e->__toString() . '</pre>'); } ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb'));
if (1 === $size && 1 === $passes) { $checked1 = ' checked="checked"'; $checked2 = ' checked="checked"'; } elseif ($size > 1 && 1 === $passes) { $checked1 = ' checked="checked"'; $checked2 = ''; } elseif ($size > 1 && 2 === $passes) { $checked1 = ''; $checked2 = ' checked="checked"'; } else { $checked1 = ''; $checked2 = ''; } $out .= '<td>' . '<input type="radio" name="old" value="' . $version['id'] . '"' . $checked1 . ' />' . "\n" . '</td>' . "\n"; $out .= '<td>' . '<input type="radio" name="new" value="' . $version['id'] . '"' . $checked2 . ' />' . "\n" . '</td>' . "\n"; $userInfo = user_get_properties($version['editor_id']); if (!empty($userInfo)) { $userStr = $userInfo['firstname'] . " " . $userInfo['lastname']; } else { $userStr = get_lang('Unknown user'); } if (claro_is_course_member()) { $userUrl = '<a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLUSR') . '/userInfo.php?uInfo=' . (int) $version['editor_id'])) . '">' . $userStr . '</a>'; } else { $userUrl = $userStr; } $versionUrl = '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?wikiId=' . (int) $wikiId . '&title=' . rawurlencode($title) . '&action=show' . '&versionId=' . (int) $version['id'])) . '">' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($version['mtime'])) . '</a>'; $out .= '<td>' . sprintf(get_lang('%1\\$s by %2\\$s'), $versionUrl, $userUrl) . '</td>' . "\n"; $out .= '</tr>' . "\n"; } }
} else { $classId = ''; } if (!empty($classId)) { $urlParamList['class_id'] = $classId; } // Breadcrumbs different if we come from admin tool for a CLASS $nameTools = get_lang('Enrol class'); $classinfo = class_get_properties($_SESSION['admin_user_class_id']); } } /*--------------------------------------------------------------------- DB tables initialisation Find info about user we are working with ---------------------------------------------------------------------*/ $userInfo = user_get_properties($userId); if (!$userInfo) { $cmd = ''; switch (claro_failure::get_last_failure()) { case 'user_not_found': $msg = get_lang('User not found'); break; default: $msg = get_lang('User is not valid'); break; } } /*---------------------------------------------------------------------------- Unsubscribe from a course ----------------------------------------------------------------------------*/ if ($cmd == 'exUnreg') {
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; }
if ($displayMode != "viewContentList") { claro_set_display_mode_available(false); } $skypeName = get_user_property($userIdViewed, 'skype'); if ($skypeName) { $skypeStatus = '<a href="skype:' . $skypeName . '?call">' . "\n" . '<img src="http://mystatus.skype.com/smallclassic/' . $skypeName . '" style="border: none;" width="100" height="15" alt="" />' . "\n" . '</a>'; } else { $skypeStatus = '<em>' . get_lang('None') . '</em>'; } ////////////////////////////// // OUTPUT ////////////////////////////// $out = ''; $out .= claro_html_tool_title($nameTools) . '<p>' . "\n" . '<small>' . "\n" . '<a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_entry_url('CLUSR'))) . '">' . '<< ' . get_lang('Back to user list') . '</a>' . "\n" . '</small>' . "\n" . '</p>' . "\n" . claro_html_msg_list($messageList); $userData = user_get_properties($userIdViewed); $picturePath = user_get_picture_path($userData); if ($picturePath && file_exists($picturePath)) { $pictureUrl = user_get_picture_url($userData); } else { $pictureUrl = get_icon_url('nopicture'); } $out .= '<div id="rightSidebar"><img src="' . $pictureUrl . '" alt="' . get_lang('avatar') . '" /></div>'; if ($displayMode == "viewDefEdit") { /* CATEGORIES DEFINITIONS : EDIT */ $out .= '<form method="post" action="' . claro_htmlspecialchars($_SERVER['PHP_SELF'] . '?uInfo=' . $userIdViewed) . '">' . "\n" . claro_form_relay_context() . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . '<input type="hidden" name="id" value="' . $catToEdit['id'] . '" />' . "\n" . '<table>' . "\n" . '<tr>' . "\n" . '<td>' . "\n" . '<label for="title" >' . get_lang('Heading') . '</label> :' . "\n" . '</td>' . "\n" . '<td>' . "\n" . '<input type="text" name="title" id="title" size="80" maxlength="80" value ="' . claro_htmlspecialchars($catToEdit['title']) . '" />' . "\n" . '</td>' . "\n" . '</tr>' . "\n" . '<tr>' . "\n" . '<td>' . "\n" . '<label for="comment" >' . get_lang('Comment') . '</label> :' . "\n" . '</td>' . "\n" . '<td>' . "\n" . '<textarea name="comment" id="comment" cols="60" rows="3" >' . $catToEdit['comment'] . '</textarea>' . "\n" . '</td>' . "\n" . '</tr>' . "\n" . '<tr>' . "\n" . '<td nowrap="nowrap">' . "\n" . '<label for="nbline" >' . get_lang('Line Number') . '</label> :' . "\n" . '' . "\n" . '</td>' . "\n" . '<td>' . "\n" . '<select name="nbline" id="nbline">' . "\n"; if ($catToEdit['nbline'] && $catToEdit['nbline'] != 1) { $out .= '<option value="' . $catToEdit['nbline'] . '" selected>' . $catToEdit['nbline'] . ' ' . get_lang('line(s)') . '</option>' . "\n" . '<option>---</option>' . "\n"; } sort($descSizeToPrupose); $out .= '<option value="1">1 ' . get_lang('line') . '</option>' . "\n";
/** * unsubscribe a specific user to a class * * @author damien Garros <*****@*****.**> * * @param int $user_id user ID from the course_user table * @param int $class_id course code from the class table * * @return boolean TRUE if subscribtion succeed * boolean FALSE otherwise. */ function user_remove_to_class($user_id, $class_id) { $user_id = (int) $user_id; $class_id = (int) $class_id; $tbl_mdb_names = claro_sql_get_main_tbl(); $tbl_class = $tbl_mdb_names['class']; $tbl_course_class = $tbl_mdb_names['rel_course_class']; $tbl_course = $tbl_mdb_names['course']; $tbl_class_user = $tbl_mdb_names['rel_class_user']; // 1. See if there is a user with such ID in the main database $user_data = user_get_properties($user_id); if (!$user_data) { return claro_failure::get_last_failure('USER_NOT_FOUND'); } // 2. See if there is a class with such ID in the main DB $sql = "SELECT `id`\n FROM `" . $tbl_class . "`\n WHERE `id` = '" . $class_id . "' "; $result = claro_sql_query_fetch_all($sql); if (!isset($result[0]['id'])) { return claro_failure::set_failure('CLASS_NOT_FOUND'); // the class doesn't exist } // 3 - Check if user is subscribe to class and if class exist $sql = "SELECT cu.id\n FROM `" . $tbl_class_user . "` cu, `" . $tbl_class . "` c\n WHERE cu.`class_id` = c.`id`\n AND cu.`class_id` = " . (int) $class_id . "\n AND cu.`user_id` = " . (int) $user_id; if (is_null(claro_sql_query_get_single_value($sql))) { return claro_failure::set_failure('USER_NOT_SUSCRIBE_TO_CLASS'); } // 4 - Get the child class from this class and call the fonction recursively $sql = " SELECT `id`\n FROM `" . $tbl_class . "`\n WHERE `class_parent_id` = " . $class_id; $classList = claro_sql_query_fetch_all($sql); foreach ($classList as $class) { if (isset($class['id'])) { user_remove_to_class($user_id, $class['id']); //TODO Bug tracking ? ! } } //3 - remove user to class in rel_class_user $sql = "DELETE FROM `" . $tbl_class_user . "`\n WHERE `user_id` = " . (int) $user_id . "\n AND `class_id` = " . (int) $class_id; claro_sql_query($sql); //4 - Get the list of course whose link with class and unsubscribe user for each $sql = "SELECT c.`code`\n FROM `" . $tbl_course_class . "` cc, `" . $tbl_course . "` c\n WHERE cc.`courseId` = c.`code`\n AND cc.`classId` = " . $class_id; $courseList = claro_sql_query_fetch_all($sql); foreach ($courseList as $course) { if (isset($course['code'])) { //Check the return value of the function. if (!user_remove_from_course($user_id, $course['code'], false, false, $class_id)) { return claro_failure::set_failure('PROBLEM_WITH_COURSE_UNSUSCRIBTION'); //TODO : ameliorer la detection d'erreur } } } return true; }
//end not anonymous user echo $this->topic_subject; ?> </h4> <?php foreach ($this->postList as $thisPost) { ?> <div id="post<?php echo $thisPost['post_id']; ?> " class="threadPost"> <?php if (user_get_picture_path(user_get_properties($thisPost['poster_id'])) && file_exists(user_get_picture_path(user_get_properties($thisPost['poster_id'])))) { ?> <div class="threadPosterPicture"><img src="<?php echo user_get_picture_url(user_get_properties($thisPost['poster_id'])); ?> " alt=" " /></div> <?php } ?> <div class="threadPostInfo"> <span style="font-weight: bold;"><?php echo $thisPost['firstname']; ?> <?php echo $thisPost['lastname']; ?> </span> <br /> <small><?php
$out .= '<p>' . get_lang('No result') . '</p>'; } else { foreach ($searchResultList as $thisPost) { // PREVENT USER TO CONSULT POST FROM A GROUP THEY ARE NOT ALLOWED if (!is_null($thisPost['group_id']) && $is_groupPrivate && !(in_array($thisPost['group_id'], $userGroupList) || in_array($thisPost['group_id'], $tutorGroupList) || claro_is_course_manager())) { continue; } else { // notify if is new message $post_time = datetime_to_timestamp($thisPost['post_time']); if ($post_time < $last_visit) { $class = ' class="item"'; } else { $class = ' class="item hot"'; } // get user picture $userData = user_get_properties($thisPost['poster_id']); $picturePath = user_get_picture_path($userData); if ($picturePath && file_exists($picturePath)) { $pictureUrl = user_get_picture_url($userData); } else { $pictureUrl = null; } $out .= '<div id="post' . $thisPost['post_id'] . '" class="threadPost">' . '<div class="threadPostInfo">' . (!is_null($pictureUrl) ? '<div class="threadPosterPicture"><img src="' . $pictureUrl . '" alt=" " /></div>' : '') . "\n" . '<b>' . $thisPost['firstname'] . ' ' . $thisPost['lastname'] . '</b> ' . '<br />' . '<small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), $post_time) . '</small>' . "\n"; $out .= ' </div>' . "\n" . '<div class="threadPostContent">' . "\n" . '<img src="' . get_icon_url('topic') . '" alt="" />' . '<a href="' . claro_htmlspecialchars(Url::Contextualize(get_module_url('CLFRM') . '/viewtopic.php?topic=' . $thisPost['topic_id'])) . '">' . claro_htmlspecialchars($thisPost['topic_title']) . '</a>' . "\n" . '<span class="threadPostIcon ' . $class . '"><img src="' . get_icon_url('post') . '" alt="" /></span><br />' . "\n" . claro_parse_user_text($thisPost['post_text']) . "\n"; $out .= '</div>' . "\n" . '<div class="spacer"></div>' . "\n\n" . '</div>' . "\n"; } // end else if ( ! is_null($thisPost['group_id']) } } // end for each $claroline->display->body->appendContent($out);
foreach ($platformAdminUidList as $platformAdminUid) { // claro_set_uid_of_platform_contact($platformAdminUid,in_array($platformAdminUid,$contactList)); claro_set_uid_recipient_of_system_notification($platformAdminUid, in_array($platformAdminUid, $notifiedList)); claro_set_uid_recipient_of_request_admin($platformAdminUid, in_array($platformAdminUid, $requestList)); } } // if apply changes /** * PREPARE DISPLAY */ ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb')); $contactUidList = claro_get_uid_of_platform_contact(); $requestUidList = claro_get_uid_of_request_admin(); $notifiedUidList = claro_get_uid_of_system_notification_recipient(); foreach ($platformAdminUidList as $k => $platformAdminUid) { $userData = user_get_properties($platformAdminUid); $userDataGrid[$k]['id'] = $userData['user_id']; $userDataGrid[$k]['name'] = $userData['lastname']; $userDataGrid[$k]['firstname'] = $userData['firstname']; $userDataGrid[$k]['email'] = $userData['email']; $userDataGrid[$k]['authSource'] = $userData['authSource']; //$userDataGrid[$k]['contact_switch'] = '<input name="contactList[]" type="checkbox" value="' . $platformAdminUid . '" ' . ((bool) in_array($platformAdminUid,$contactUidList) ? 'checked="checked" />' : '>'); $userDataGrid[$k]['request_switch'] = '<input name="requestList[]" type="checkbox" value="' . $platformAdminUid . '" ' . ((bool) in_array($platformAdminUid, $requestUidList) ? 'checked="checked" /> ' : '> '); $userDataGrid[$k]['notification_switch'] = '<input name="notifiedList[]" type="checkbox" value="' . $platformAdminUid . '" ' . ((bool) in_array($platformAdminUid, $notifiedUidList) ? 'checked="checked" /> ' : '> '); } $adminDataGrid = new claro_datagrid($userDataGrid); $adminDataGrid->set_idLineType('none'); $adminDataGrid->set_colHead('name'); $adminDataGrid->set_colTitleList(array('user id' => get_lang('User id'), 'name' => get_lang('Last name'), 'firstname' => get_lang('First name'), 'email' => get_lang('Email'), 'authSource' => get_lang('Authentication source'), 'request_switch' => get_lang('Request'), 'notification_switch' => get_lang('Notify'))); $adminDataGrid->set_colAttributeList(array('request_switch' => array('align' => 'left'), 'notification_switch' => array('align' => 'left'), 'authSource' => array('align' => 'center'))); /**
function deleteMessage ( localPath ) { if (confirm("' . get_lang('Are you sure to delete the message?') . '")) { window.location=localPath; return false; } else { return false; } } </script>'; $claroline->display->header->addHtmlHeader($javascriptDelete); foreach ($box as $key => $message) { $userData = user_get_properties($message->getSender()); $content .= '<tr>' . "\n" . '<td class="im_list_selection"><input type="checkbox" name="msg[]" value="' . $message->getId() . '" /></td>' . "\n" . '<td><a href="readmessage.php?messageId=' . $message->getId() . '&type=received">' . claro_htmlspecialchars($message->getSubject()) . '</a></td>' . "\n" . '<td><a href="sendmessage.php?cmd=rqMessageToUser&userId=' . $message->getSender() . '">' . get_lang('%firstName %lastName', array('%firstName' => claro_htmlspecialchars($message->getSenderFirstName()), '%lastName' => claro_htmlspecialchars($message->getSenderLastName()))) . '</a>' . '</td>' . '<td>' . claro_htmlspecialchars($userData['username']) . '</td>' . "\n" . '<td>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($message->getSendTime())) . '</td>' . "\n" . '<td class="im_list_action"><a href="' . $linkDelete . 'cmd=rqDeleteMessage&message_id=' . $message->getId() . '" ' . 'onclick="return deleteMessage(\'' . $linkDelete . 'cmd=exDeleteMessage&message_id=' . $message->getId() . '\')"' . '><img src="' . get_icon_url('delete') . '" alt="" /></a></td>' . "\n" . '</tr>' . "\n\n"; } $content .= '</table>' . '<input type="submit" value="' . get_lang('Delete selected message(s)') . '" />' . "\n\n"; } $content .= '</form>'; // prepare the link to change of page if ($box->getNumberOfPage() > 1) { // number of page to display in the page before and after thecurrent page $nbPageToDisplayBeforeAndAfterCurrentPage = 1; $content .= '<div id="im_paging">'; $arg_paging = makeArgLink($arguments, array('page')); if ($arg_paging == "") { $linkPaging = $_SERVER['PHP_SELF'] . "?page="; } else { $linkPaging = $_SERVER['PHP_SELF'] . "?" . $arg_paging . "&page=";
$dialogBox->error(get_lang('Cannot send email to the following users:') . $failedStudents); } } break; case 'exDelete': if (user_delete($userIdReq)) { $dialogBox->success(get_lang('Deletion of the user was done sucessfully')); } else { $dialogBox->error(get_lang('You can not change your own settings!')); } break; case 'rqDelete': if (empty($userIdReq)) { $dialogBox->error(get_lang('User id missing')); } else { $user_properties = user_get_properties($userIdReq); if (is_array($user_properties)) { $dialogBox->question(get_lang('Are you sure to delete user %firstname %lastname', array('%firstname' => $user_properties['firstname'], '%lastname' => $user_properties['lastname'])) . '<br/><br/>' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exDelete&user_id=' . $userIdReq . '&offset=' . $offset . $addToURL . '">' . get_lang('Yes') . '</a>' . ' | ' . '<a href="' . $_SERVER['PHP_SELF'] . '">' . get_lang('No') . '</a>' . "\n"); } } } $searchInfo = prepare_search(); $isSearched = $searchInfo['isSearched']; $addtoAdvanced = $searchInfo['addtoAdvanced']; if (count($searchInfo['isSearched'])) { $isSearched = array_map('strip_tags', $isSearched); $isSearchedHTML = implode('<br />', $isSearched); } else { $isSearchedHTML = ''; } //get the search keyword, if any
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; } } elseif (!claro_is_allowed_to_create_course() && get_conf('can_request_course_creator_status') && 'exCCstatus' == $cmd) { // send a request for course creator status profile_send_request_course_creator_status($_REQUEST['explanation']); $dialogBox->success(get_lang('Your request to become a course creator has been sent to platform administrator(s).')); } elseif (get_conf('can_request_revoquation') && 'exRevoquation' == $cmd) { // send a request for revoquation if (profile_send_request_revoquation($_REQUEST['explanation'], $_REQUEST['loginToDelete'], $_REQUEST['passwordToDelete'])) { $dialogBox->success(get_lang('Your request to remove your account has been sent'));
/** * Display form to edit or add user to the platform. * * @param $userId int */ function user_html_form($userId = null) { // If the user exists (given user id) if (!empty($userId)) { // Get user's general informations $userData = user_get_properties($userId); // Get user's skype account $userData['skype'] = get_user_property($userId, 'skype'); // Get user's picture $picturePath = user_get_picture_path($userData); if ($picturePath && file_exists($picturePath)) { $pictureUrl = user_get_picture_url($userData); } else { $pictureUrl = ''; } // Get current language $currentLanguage = !empty($userData['language']) ? $userData['language'] : language::current_language(); // A few javascript $htmlHeadXtra[] = '<script type="text/javascript"> function confirmation (name) { if (confirm("' . clean_str_for_javascript(get_lang('Are you sure to delete')) . '"+ name + "?")) {return true;} else {return false;} } $(document).ready(function(){ $("#delete").click(function(){ return confirmation("' . $userData['firstname'] . " " . $userData['lastname'] . '"); }).attr("href","adminuserdeleted.php?uidToEdit=' . $userId . '&cmd=exDelete"); }); </script>'; } else { // Initialize user's data $userData = user_initialise(); // No user's picture $pictureUrl = ''; // Prefered language $currentLanguage = language::current_language(); } // Editable fields if (empty($userId) || claro_is_platform_admin()) { $editableFields = array('name', 'official_code', 'login', 'password', 'email', 'phone', 'language', 'picture', 'skype'); if (claro_is_platform_admin()) { $editableFields[] = 'authSource'; } } else { $editableFields = AuthProfileManager::getUserAuthProfile($userId)->getEditableProfileFields(); // get_conf('profile_editable'); // pushClaroMessage(var_export($editableFields,true), 'debug'); } if (!empty($_SERVER['HTTP_REFERER'])) { $cancelUrl = $_SERVER['HTTP_REFERER']; } else { $cancelUrl = $_SERVER['PHP_SELF']; } // Hack to prevent autocompletion of password fields from browser $htmlHeadXtra[] = '<script type="text/javascript"> $(document).ready( function() { $("#password").val(""); } ); </script>'; $template = new CoreTemplate('user_form.tpl.php'); $template->assign('formAction', $_SERVER['PHP_SELF']); $template->assign('relayContext', claro_form_relay_context()); $template->assign('cancelUrl', claro_htmlspecialchars(Url::Contextualize($cancelUrl))); $template->assign('editableFields', $editableFields); $template->assign('data', $userData); $template->assign('pictureUrl', $pictureUrl); $template->assign('currentLanguage', $currentLanguage); $template->assign('languages', get_language_to_display_list()); return $template->render(); }