public function renderContent() { $personnalCourseList = get_user_course_list(claro_get_current_user_id()); $announcementEventList = announcement_get_items_portlet($personnalCourseList); $output = ''; if ($announcementEventList) { $output .= '<dl id="portletMyAnnouncements">'; foreach ($announcementEventList as $announcementItem) { // Hide hidden and expired elements $isVisible = (bool) ($announcementItem['visibility'] == 'SHOW') ? 1 : 0; $isOffDeadline = (bool) (isset($announcementItem['visibleFrom']) && strtotime($announcementItem['visibleFrom']) > time() || isset($announcementItem['visibleUntil']) && time() >= strtotime($announcementItem['visibleUntil'])) ? 1 : 0; if ($isVisible && !$isOffDeadline) { $output .= '<dt>' . "\n" . '<img class="iconDefinitionList" src="' . get_icon_url('announcement', 'CLANN') . '" alt="" />' . ' <a href="' . $announcementItem['url'] . '">' . $announcementItem['title'] . '</a>' . "\n" . '</dt>' . "\n"; foreach ($announcementItem['eventList'] as $announcementEvent) { // Prepare the render $displayChar = 250; if (strlen($announcementEvent['content']) > $displayChar) { $content = substr($announcementEvent['content'], 0, $displayChar) . '... <a href="' . claro_htmlspecialchars(Url::Contextualize($announcementEvent['url'])) . '">' . '<b>' . get_lang('Read more »') . '</b></a>'; } else { $content = $announcementEvent['content']; } $output .= '<dd>' . '<a href="' . $announcementEvent['url'] . '">' . $announcementItem['courseOfficialCode'] . '</a> : ' . "\n" . (!empty($announcementEvent['title']) ? $announcementEvent['title'] : get_lang('No title')) . "\n" . ' - ' . $content . "\n" . '</dd>' . "\n"; } } } $output .= '</dl>'; } else { $output .= "\n" . '<dl>' . "\n" . '<dt>' . "\n" . '<img class="iconDefinitionList" src="' . get_icon_url('announcement', 'CLANN') . '" alt="" />' . ' ' . get_lang('No announcement to display') . "\n" . '</dt>' . "\n" . '</dl>' . "\n"; } return $output; }
/** * Returns a single resquested announce. * @param array $args must contain 'resID' key with the resource identifier of the requested resource * @throws InvalidArgumentException if one of the paramaters is missing * @webservice{/module/MOBILE/CLANN/getSingleResource/cidReq/resId} * @ws_arg{Method,getSingleResource} * @ws_arg{cidReq,SYSCODE of requested cours} * @ws_arg{resID,Resource Id of requested resource} * @return announce object (can be null if not visible for the current user) */ function getSingleResource($args) { $resourceId = isset($args['resID']) ? $args['resID'] : null; $cid = claro_get_current_course_id(); if ($cid == null || $resourceId == null) { throw new InvalidArgumentException('Missing cid or resourceId argument!'); } $claroNotification = Claroline::getInstance()->notification; $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id()); $d = new DateTime($date); $d->sub(new DateInterval('PT1M')); From::Module('CLANN')->uses('announcement.lib'); if ($announce = $this->announcement_get_item($resourceId, $cid)) { $notified = $claroNotification->isANotifiedRessource($cid, $date, claro_get_current_user_id(), claro_get_current_group_id(), get_tool_id_from_module_label('CLANN'), $announce['id'], false); $announce['visibility'] = $announce['visibility'] != 'HIDE'; $announce['content'] = trim(strip_tags($announce['content'])); $announce['cours']['sysCode'] = $cid; $announce['resourceId'] = $announce['id']; $announce['date'] = $announce['time']; $announce['notifiedDate'] = $notified ? $date : $announce['time']; $announce['seenDate'] = $d->format('Y-m-d H:i'); unset($announce['id']); return claro_is_allowed_to_edit() || $announce['visibility'] ? $announce : null; } else { throw new RuntimeException('Resource not found', 404); } }
function create_wiki($gid = false, $wikiName = 'New wiki') { $creatorId = claro_get_current_user_id(); $tblList = claro_sql_get_course_tbl(); $config = array(); $config["tbl_wiki_properties"] = $tblList["wiki_properties"]; $config["tbl_wiki_pages"] = $tblList["wiki_pages"]; $config["tbl_wiki_pages_content"] = $tblList["wiki_pages_content"]; $config["tbl_wiki_acls"] = $tblList["wiki_acls"]; $con = Claroline::getDatabase(); $acl = array(); if ($gid) { $acl = WikiAccessControl::defaultGroupWikiACL(); } else { $acl = WikiAccessControl::defaultCourseWikiACL(); } $wiki = new Wiki($con, $config); $wiki->setTitle($wikiName); $wiki->setDescription('This is a sample wiki'); $wiki->setACL($acl); $wiki->setGroupId($gid); $wikiId = $wiki->save(); $wikiTitle = $wiki->getTitle(); $mainPageContent = sprintf("This is the main page of the Wiki %s. Click on edit to modify the content.", $wikiTitle); $wikiPage = new WikiPage($con, $config, $wikiId); $wikiPage->create($creatorId, '__MainPage__', $mainPageContent, date("Y-m-d H:i:s"), true); }
/** * create the message in the message table and return the identification of this * * @return int message identification */ private final function addMessage($messageToSend) { //create an array of the name of the table needed $tableName = get_module_main_tbl(array('im_message')); $subject = claro_sql_escape($messageToSend->getSubject()); $message = claro_sql_escape($messageToSend->getMessage()); if (is_null($messageToSend->getSender())) { $sender = claro_get_current_user_id(); } else { $sender = (int) $messageToSend->getSender(); } if (!is_null($messageToSend->getCourseCode())) { $course = "'" . claro_sql_escape($messageToSend->getCourseCode()) . "'"; } else { $course = "NULL"; } if (!is_null($messageToSend->getGroupId())) { $group = (int) $messageToSend->getGroupId(); } else { $group = "NULL"; } if (!is_null($messageToSend->getToolsLabel())) { $tools = "'" . claro_sql_escape($messageToSend->getToolsLabel()) . "'"; } else { $tools = "NULL"; } // add the message in the table of messages and retrieves the ID $addInternalMessageSQL = "INSERT INTO `" . $tableName['im_message'] . "` \n" . "(sender, subject, message, send_time, course, `group` , tools) \n" . "VALUES ({$sender},'" . $subject . "','" . $message . "', '\n" . date("Y-m-d H:i:s", claro_time()) . "'," . $course . "," . $group . "," . $tools . ")\n"; // try to read the last ID inserted if the request pass if (claro_sql_query($addInternalMessageSQL)) { return claro_sql_insert_id(); } else { throw new Exception(claro_sql_errno() . ":" . claro_sql_error()); } }
/** * set the send identification * * @param int $senderId sender identification (optional, default NULL) */ public function setSender($senderId = NULL) { if (is_null($senderId)) { $sender = claro_get_current_user_id(); } else { $this->sender = $senderId; } }
/** * create an object MessageBox for the user in parameters and with strategy * * @param MessageStrategy $strategy strategy to apply * @param int $userId user identification of the message box (optionnal, default: current_user_id()) * */ public function __construct($strategy, $userId = NULL) { if (is_null($userId)) { $userId = claro_get_current_user_id(); } $this->messageFilter = $strategy; $this->index = 0; $this->userId = $userId; }
/** * Add a message to the log. The message will be associated with the current * course_code, user_id, tool_id, date and IP address of the client * @param string $type * @param string $data * @return boolean */ public function log($type, $data) { $cid = claro_get_current_course_id(); $tid = claro_get_current_tool_id(); $uid = claro_get_current_user_id(); $date = claro_date("Y-m-d H:i:s"); $ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; $data = serialize($data); $sql = "INSERT INTO `" . $this->tbl_log . "`\n SET `course_code` = " . (is_null($cid) ? "NULL" : "'" . claro_sql_escape($cid) . "'") . ",\n `tool_id` = " . (is_null($tid) ? "NULL" : "'" . claro_sql_escape($tid) . "'") . ",\n `user_id` = " . (is_null($uid) ? "NULL" : "'" . claro_sql_escape($uid) . "'") . ",\n `ip` = " . (is_null($ip) ? "NULL" : "'" . claro_sql_escape($ip) . "'") . ",\n `date` = '" . $date . "',\n `type` = '" . claro_sql_escape($type) . "',\n `data` = '" . claro_sql_escape($data) . "'"; return claro_sql_query($sql); }
public function __construct() { $this->courseCode = claro_get_current_course_id(); $this->courseId = ClaroCourse::getIdFromCode($this->courseCode); $this->userId = claro_get_current_user_id(); $this->profileId = claro_get_current_user_profile_id_in_course(); $this->viewMode = claro_get_tool_view_mode(); $this->courseObject = new ClaroCourse(); $this->courseObject->load($this->courseCode); $this->currentCourseContext = Claro_Context::getUrlContext(array(CLARO_CONTEXT_COURSE => $this->courseCode)); $this->template = new CoreTemplate('coursetoollist.tpl.php'); }
public function event($type, $args = null) { if (!is_array($args)) { $args = array(); } if (!array_key_exists('cid', $args) && claro_is_in_a_course()) { $args['cid'] = claro_get_current_course_id(); } if (!array_key_exists('gid', $args) && claro_is_in_a_group()) { $args['gid'] = claro_get_current_group_id(); } if (!array_key_exists('tid', $args) && claro_is_in_a_tool()) { $args['tid'] = claro_get_current_tool_id(); // $args['tlabel'] = get_current_module_label(); } if (!array_key_exists('uid', $args) && claro_is_user_authenticated()) { $args['uid'] = claro_get_current_user_id(); } if (!array_key_exists('date', $args)) { $args['date'] = claro_date("Y-m-d H:i:00"); } $this->notifyEvent($type, $args); }
// feedback must be shown after end date and end date is past // OR feedback must be shown directly after a post (from the time a work was uploaded by the student) // there is a prefill_ file or text, so there is something to show $textOrFilePresent = (bool) $assignment->getAutoFeedbackText() != '' || $assignment->getAutoFeedbackFilename() != ''; // feedback must be shown after end date and end date is past $showAfterEndDate = (bool) ($assignment->getAutoFeedbackSubmitMethod() == 'ENDDATE' && $assignment->getEndDate() < time()); // feedback must be shown directly after a post // check if user has already posted a work // do not show to anonymous users because we can't know // if the user already uploaded a work $showAfterPost = (bool) claro_is_user_authenticated() && ($assignment->getAutoFeedbackSubmitMethod() == 'AFTERPOST' && count($assignment->getSubmissionList(claro_get_current_user_id())) > 0); // Command list $cmdList = array(); if ($is_allowedToSubmit && $assignment->getAssignmentType() != 'GROUP') { // Link to create a new assignment $cmdList[] = array('name' => get_lang('Submit a work'), 'url' => claro_htmlspecialchars(Url::Contextualize('user_work.php?authId=' . claro_get_current_user_id() . '&cmd=rqSubWrk' . '&assigId=' . $req['assignmentId']))); } if ($is_allowedToEditAll) { $cmdList[] = array('name' => get_lang('Edit automatic feedback'), 'url' => claro_htmlspecialchars(Url::Contextualize('feedback.php?cmd=rqEditFeedback' . '&assigId=' . $req['assignmentId']))); if (claro_is_platform_admin() || get_conf('allow_download_all_submissions')) { $cmdList[] = array('img' => 'save', 'name' => get_lang('Download submissions'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqDownload' . '&assigId=' . $req['assignmentId']))); } } /** * OUTPUT * * 3 parts in this output * - A detail about the current assignment * - "Command" links to commands * - A list of user relating submission and feedback *
/><label for="courseManager"><?php echo get_lang('Create courses'); ?> (<?php echo get_lang('teacher'); ?> )</label><br /> <?php if (claro_is_platform_admin()) { ?> <span class="adminControl"><input type="radio" name="platformRole" id="platformAdmin" value="platformAdmin"<?php if ($this->data['isPlatformAdmin']) { ?> checked="checked"<?php } elseif (!empty($this->data['user_id']) && $this->data['user_id'] == claro_get_current_user_id()) { ?> disabled="disabled"<?php } ?> /><label for="platformAdmin"><?php echo get_lang('Manage platform'); ?> (<?php echo get_lang('administrator'); ?> )</label></span> <?php } ?> </dd>
} if ($module['startAsset_id'] == 0) { $noStartAsset = true; } else { $noStartAsset = false; } // check if there is a specific comment for this module in this path $sql = "SELECT `specificComment`\n FROM `" . $TABLELEARNPATHMODULE . "`\n WHERE `module_id` = " . (int) $_SESSION['module_id']; $learnpath_module = claro_sql_query_get_single_row($sql); if (empty($learnpath_module['specificComment']) || $learnpath_module['specificComment'] == get_block('blockDefaultModuleAddedComment')) { $noModuleSpecificComment = true; } else { $noModuleSpecificComment = false; } // check in DB if user has already browsed this module $sql = "SELECT `contentType`,\n `total_time`,\n `session_time`,\n `scoreMax`,\n `raw`,\n `lesson_status`\n FROM `" . $TABLEUSERMODULEPROGRESS . "` AS UMP,\n `" . $TABLELEARNPATHMODULE . "` AS LPM,\n `" . $TABLEMODULE . "` AS M\n WHERE UMP.`user_id` = '" . (int) claro_get_current_user_id() . "'\n AND UMP.`learnPath_module_id` = LPM.`learnPath_module_id`\n AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id'] . "\n AND LPM.`module_id` = " . (int) $_SESSION['module_id'] . "\n AND LPM.`module_id` = M.`module_id`\n "; $resultBrowsed = claro_sql_query_get_single_row($sql); // redirect user to the path browser if needed if (!$is_allowedToEdit && (!is_array($resultBrowsed) || !$resultBrowsed || count($resultBrowsed) <= 0) && $noModuleComment && $noModuleSpecificComment && !$noStartAsset) { header("Location: " . Url::Contextualize("./navigation/viewer.php")); exit; } // Back button if (!empty($_SESSION['returnToTrackingUserId'])) { $pathBack = Url::Contextualize(get_path('clarolineRepositoryWeb') . 'tracking/lp_modules_details.php?' . 'uInfo=' . (int) $_SESSION['returnToTrackingUserId'] . '&path_id=' . (int) $_SESSION['path_id']); } elseif ($is_allowedToEdit) { $pathBack = Url::Contextualize("./learningPathAdmin.php"); } else { $pathBack = Url::Contextualize("./learningPath.php"); } // Command list
break; case 2: $anonymity = 'default'; break; default: $anonymity = 'forbidden'; break; } if (get_conf('clfrm_anonymity_enabled', true)) { if ('allowed' == $anonymity) { $displayName .= ' (' . get_lang('anonymity allowed') . ')'; } elseif ('default' == $anonymity) { $displayName .= ' (' . get_lang('anonymous forum') . ')'; } } $itemClass = claro_is_user_authenticated() && $this->claro_notifier->is_a_notified_forum(claro_get_current_course_id(), $this->claro_notifier->get_notification_date(claro_get_current_user_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisForum['forum_id']) ? 'item hot' : 'item'; ?> <tr align="left" valign="top"> <td> <span class="<?php echo $itemClass; ?> "> <img src="<?php echo get_icon_url('forum', 'CLFRM'); ?> " alt="" /> <?php if (!is_null($thisForum['group_id'])) { ?> <?php
/** * Insert a user record as new user in the platform user list * @param stdClass $user (lastname,firstname,username,email,officialCode) */ protected function insertUserAsNew($user) { $this->database->exec("\n INSERT INTO `{$this->tables['user']}`\n SET nom = " . $this->database->quote($user->lastname) . ",\n prenom = " . $this->database->quote($user->firstname) . ",\n username = "******",\n language = '',\n email = " . $this->database->quote($user->email) . ",\n officialCode = " . $this->database->quote($user->officialCode) . ",\n officialEmail = " . $this->database->quote($user->email) . ",\n authSource = 'ldap', \n phoneNumber = '',\n password = '******',\n isCourseCreator = 0,\n isPlatformAdmin = 0,\n creatorId = " . claro_get_current_user_id()); $key = (string) $user->username; $this->userInsertedList[$key] = $this->userSuccessList[$key] = $this->database->insertId(); }
} 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'];
// poses problems on PHP 4.1, when the array contains only // a single element $dspFileName = claro_htmlspecialchars(basename($thisFile['path'])); $cmdFileName = download_url_encode($thisFile['path']); if ($thisFile['visibility'] == 'i') { if ($is_allowedToEdit) { $style = 'invisible '; } else { continue; // skip the display of this file } } else { $style = ''; } //modify style if the file is recently added since last login if (claro_is_user_authenticated() && $claro_notifier->is_a_notified_document(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisFile)) { $classItem = ' hot'; } else { $classItem = ''; } if ($thisFile['type'] == A_FILE) { $image = choose_image($thisFile['path']); $size = format_file_size($thisFile['size']); $date = format_date($thisFile['date']); $urlFileName = claro_htmlspecialchars(claro_get_file_download_url($thisFile['path'])); //$urlFileName = "goto/?doc_url=".rawurlencode($cmdFileName); //format_url($baseServUrl.$courseDir.$curDirPath."/".$fileName)); $target = get_conf('openNewWindowForDoc') ? 'target="_blank"' : ''; } elseif ($thisFile['type'] == A_DIRECTORY) { $image = 'folder'; $size = ' ';
if (claro_is_user_authenticated()) { $date = $claro_notifier->get_notification_date(claro_get_current_user_id()); } $preparedAnnList = array(); $lastPostDate = ''; foreach ($announcementList as $thisAnn) { // Hide hidden and out of deadline elements $isVisible = (bool) ($thisAnn['visibility'] == 'SHOW') ? 1 : 0; $isOffDeadline = (bool) (isset($thisAnn['visibleFrom']) && strtotime($thisAnn['visibleFrom']) > time() || isset($thisAnn['visibleUntil']) && time() > strtotime($thisAnn['visibleUntil']) + 86400) ? 1 : 0; if (!$isVisible || $isOffDeadline) { $thisAnn['visible'] = false; } else { $thisAnn['visible'] = true; } // Flag hot items if (claro_is_user_authenticated() && $claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisAnn['id'])) { $thisAnn['hot'] = true; } else { $thisAnn['hot'] = false; } $thisAnn['content'] = make_clickable($thisAnn['content']); // Post time format in MySQL date format $lastPostDate = isset($thisAnn['visibleFrom']) ? $thisAnn['visibleFrom'] : $thisAnn['time']; // Set the current locator $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => $thisAnn['id'])); $thisAnn['currentLocator'] = $currentLocator; if ($is_allowedToEdit || $isVisible && !$isOffDeadline) { $preparedAnnList[] = $thisAnn; } } $maxMinRanks = clann_get_max_and_min_rank();
$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 { // $error = true; $dialogBox->error(get_lang('Changes have not been applied to the user settings'));
/** * Get the complete course tree of a specific keyword. * * @param string keyword * @return CourseTreeView */ public static function getSearchedCourseTreeView($keyword) { // CourseListIterator $courseList = new SearchedCourseList($keyword); $courseListIterator = $courseList->getIterator(); // User rights $privilegeList = new CourseUserPrivilegesList(claro_get_current_user_id()); $privilegeList->load(); // Course tree $courseTree = new CourseTree($courseListIterator); // View $courseTreeView = new CourseTreeView($courseTree->getRootNode(), $privilegeList, null, null, null, null); return $courseTreeView; }
/** * Send course creation information by mail to all platform administrators * * @param string creator firstName * @param string creator lastname * @param string creator email */ public function mailAdministratorOnCourseCreation($creatorFirstName, $creatorLastName, $creatorEmail) { $subject = get_lang('Course created : %course_name', array('%course_name' => $this->title)); $categoryCodeList = array(); foreach ($this->categories as $category) { $categoryCodeList[] = $category->name; } $body = nl2br(get_block('blockCourseCreationEmailMessage', array('%date' => claro_html_localised_date(get_locale('dateTimeFormatLong')), '%sitename' => get_conf('siteName'), '%user_firstname' => $creatorFirstName, '%user_lastname' => $creatorLastName, '%user_email' => $creatorEmail, '%course_code' => $this->officialCode, '%course_title' => $this->title, '%course_lecturers' => $this->titular, '%course_email' => $this->email, '%course_categories' => !empty($this->categories) ? implode(', ', $categoryCodeList) : get_lang('No category'), '%course_language' => $this->language, '%course_url' => get_path('rootWeb') . 'claroline/course/index.php?cid=' . claro_htmlspecialchars($this->courseId)))); // Get the concerned senders of the email $mailToUidList = claro_get_uid_of_system_notification_recipient(); if (empty($mailToUidList)) { $mailToUidList = claro_get_uid_of_platform_admin(); } $message = new MessageToSend(claro_get_current_user_id(), $subject, $body); $recipient = new UserListRecipient(); $recipient->addUserIdList($mailToUidList); //$message->sendTo($recipient); $recipient->sendMessage($message); }
$sqlClauseString = null; } } else { $sqlClauseString = null; } if ($sqlClauseString) { $tbl_cdb_names = claro_sql_get_course_tbl(); $tbl_posts_text = $tbl_cdb_names['bb_posts_text']; $tbl_posts = $tbl_cdb_names['bb_posts']; $tbl_topics = $tbl_cdb_names['bb_topics']; $tbl_forums = $tbl_cdb_names['bb_forums']; $sql = "SELECT pt.post_id,\n pt.post_text,\n p.nom AS lastname,\n p.prenom AS firstname,\n p.`poster_id`,\n p.post_time,\n t.topic_id,\n t.topic_title,\n f.forum_id,\n f.forum_name,\n f.group_id\n FROM `" . $tbl_posts_text . "` AS pt,\n `" . $tbl_posts . "` AS p,\n `" . $tbl_topics . "` AS t,\n `" . $tbl_forums . "` AS f\n WHERE ( " . $sqlClauseString . ")\n AND pt.post_id = p.post_id\n AND p.topic_id = t.topic_id\n AND t.forum_id = f.forum_id\n ORDER BY p.post_time DESC, t.topic_id"; $searchResultList = claro_sql_query_fetch_all($sql); $userGroupList = get_user_group_list(claro_get_current_user_id()); $userGroupList = array_keys($userGroupList); $tutorGroupList = get_tutor_group_list(claro_get_current_user_id()); } else { $searchResultList = array(); } $pagetype = 'viewsearch'; ClaroBreadCrumbs::getInstance()->prepend(get_lang('Forums'), 'index.php'); CssLoader::getInstance()->load('clfrm', 'screen'); $noPHP_SELF = true; $out = ''; $out .= claro_html_tool_title(get_lang('Forums'), $is_allowedToEdit ? get_help_page_url('blockForumsHelp', 'CLFRM') : false); $out .= claro_html_menu_horizontal(disp_forum_toolbar($pagetype, null)) . disp_forum_breadcrumb($pagetype, null, null, null) . '<h4>' . get_lang('Search result') . ' : ' . (isset($_REQUEST['searchPattern']) ? claro_htmlspecialchars($_REQUEST['searchPattern']) : '') . '</h4>' . "\n"; if (count($searchResultList) < 1) { $out .= '<p>' . get_lang('No result') . '</p>'; } else { foreach ($searchResultList as $thisPost) { // PREVENT USER TO CONSULT POST FROM A GROUP THEY ARE NOT ALLOWED
<td colspan="<?php echo $this->is_allowedToEdit ? 9 : 6; ?> " align="center"> <?php echo $this->forumSettings['forum_access'] == 2 ? get_lang('There are no topics for this forum. You can post one') : get_lang('There are no topics for this forum.'); ?> </td> </tr> <?php } else { foreach ($this->topicList as $thisTopic) { ?> <tr> <?php $itemClass = claro_is_user_authenticated() && $this->claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $this->claro_notifier->get_notification_date(claro_get_current_user_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $this->forumId . "-" . $thisTopic['topic_id'], FALSE) ? 'item hot' : 'item'; $itemLink = claro_htmlspecialchars(Url::Contextualize(get_module_url('CLFRM') . '/viewtopic.php?topic=' . $thisTopic['topic_id'] . (is_null($this->forumSettings['idGroup']) ? '' : '&gidReq =' . $this->forumSettings['idGroup']))); ?> <td> <span class="<?php echo $itemClass; ?> "> <img src="<?php echo get_icon_url('topic'); ?> " alt="" /> <a href="<?php echo $itemLink; ?> "><?php
if ($topicSettingList) { // get post and use pager if (!$viewall) { $postLister = new postLister($topicId, $start, get_conf('posts_per_page')); } else { $postLister = new postLister($topicId, $start, get_total_posts($topicId, 'topic')); $incrementViewCount = false; } // get post and use pager $postList = $postLister->get_post_list(); $totalPosts = $postLister->sqlPager->get_total_item_count(); $pagerUrl = claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?topic=' . $topicId)); //increment topic view count if required if ($incrementViewCount) { increase_topic_view_count($topicId); $claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $claro_notifier->get_notification_date(claro_get_current_user_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $forumId . "-" . $topicId); //$claroline->notifier->event( 'forum_read_topic', array( 'data' => array( 'topic_id' => $topicId ) ) ); } if ($is_postAllowed) { $cmdList = get_forum_toolbar_array('viewtopic', $forumSettingList['forum_id'], $forumSettingList['cat_id'], $topicId); if (count($postList) > 2) { $start_last_message = (ceil($totalPosts / get_conf('posts_per_page')) - 1) * get_conf('posts_per_page'); $lastMsgUrl = Url::Contextualize($_SERVER['PHP_SELF'] . '?forum=' . $forumSettingList['forum_id'] . '&topic=' . $topicId . '&start=' . $start_last_message . '#post' . $topicSettingList['topic_last_post_id']); $cmdList[] = array('name' => get_lang('Last message'), 'url' => claro_htmlspecialchars(Url::Contextualize($lastMsgUrl))); if (!$viewall) { $viewallUrl = Url::Contextualize($_SERVER['PHP_SELF'] . '?forum=' . $forumSettingList['forum_id'] . '&topic=' . $topicId . '&viewall=1'); $cmdList[] = array('name' => get_lang('Full review'), 'url' => claro_htmlspecialchars(Url::Contextualize($viewallUrl))); } } } $out .= $postLister->disp_pager_tool_bar($pagerUrl);
$template = new CoreTemplate('platform_index.tpl.php'); // Languages $template->assign('languages', get_language_to_display_list()); $template->assign('currentLanguage', language::current_language()); // Last user action $lastUserAction = isset($_SESSION['last_action']) && $_SESSION['last_action'] != '1970-01-01 00:00:00' ? $_SESSION['last_action'] : date('Y-m-d H:i:s'); $template->assign('lastUserAction', $lastUserAction); // Manage the search box and search results $searchBox = new CourseSearchBox($_SERVER['REQUEST_URI']); $template->assign('searchBox', $searchBox); if (claro_is_user_authenticated()) { // User course (activated and deactivated) lists and search results (if any) if (empty($_REQUEST['viewCategory'])) { $courseTreeView = CourseTreeNodeViewFactory::getUserCourseTreeView(claro_get_current_user_id()); } else { $courseTreeView = CourseTreeNodeViewFactory::getUserCategoryCourseTreeView(claro_get_current_user_id(), $_REQUEST['viewCategory']); } $template->assign('templateMyCourses', $courseTreeView); // User commands $userCommands = array(); $userCommands[] = '<a href="' . $_SERVER['PHP_SELF'] . '" class="userCommandsItem">' . '<img src="' . get_icon_url('mycourses') . '" alt="" /> ' . get_lang('My course list') . '</a>' . "\n"; // 'Create Course Site' command. Only available for teacher. if (claro_is_allowed_to_create_course()) { $userCommands[] = '<a href="claroline/course/create.php" class="userCommandsItem">' . '<img src="' . get_icon_url('courseadd') . '" alt="" /> ' . get_lang('Create a course site') . '</a>' . "\n"; } elseif ($GLOBALS['currentUser']->isCourseCreator) { $userCommands[] = '<span class="userCommandsItemDisabled">' . '<img src="' . get_icon_url('courseadd') . '" alt="" /> ' . get_lang('Create a course site') . '</span>' . "\n"; } if (get_conf('allowToSelfEnroll', true)) { $userCommands[] = '<a href="claroline/auth/courses.php?cmd=rqReg&categoryId=0" class="userCommandsItem">' . '<img src="' . get_icon_url('enroll') . '" alt="" /> ' . get_lang('Enrol on a new course') . '</a>' . "\n"; $userCommands[] = '<a href="claroline/auth/courses.php?cmd=rqUnreg" class="userCommandsItem">' . '<img src="' . get_icon_url('unenroll') . '" alt="" /> ' . get_lang('Remove course enrolment') . '</a>' . "\n"; }
GET GROUP MEMBER LIST ----------------------------------------------------------------------------*/ $groupMemberList = get_group_user_list(claro_get_current_group_id(), claro_get_current_course_id()); /*---------------------------------------------------------------------------- GET TUTOR(S) DATA ----------------------------------------------------------------------------*/ $sql = "SELECT user_id AS id, nom AS lastName, prenom AS firstName, email\n FROM `" . $tbl_user . "` user\n WHERE user.user_id='" . claro_get_current_group_data('tutorId') . "'"; $tutorDataList = claro_sql_query_fetch_all($sql); /*---------------------------------------------------------------------------- GET FORUM POINTER ----------------------------------------------------------------------------*/ $forumId = claro_get_current_group_data('forumId'); $toolList = get_group_tool_list(); if (claro_is_in_a_course()) { $date = $claro_notifier->get_notification_date(claro_get_current_user_id()); $modified_tools = $claro_notifier->get_notified_tools(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id()); } else { $modified_tools = array(); } $toolLinkList = array(); foreach ($toolList as $thisTool) { if (!array_key_exists($thisTool['label'], $_groupProperties['tools'])) { continue; } // special case when display mode is student and tool invisible doesn't display it if (!claro_is_allowed_to_edit()) { if (!$_groupProperties['tools'][$thisTool['label']]) { continue; } } if (!empty($thisTool['label'])) {
$message = trim($message); // USER $userLastname = claro_get_current_user_data('lastName'); $userFirstname = claro_get_current_user_data('firstName'); $poster_ip = $_SERVER['REMOTE_ADDR']; $time = date('Y-m-d H:i'); // prevent to go further if the fields are actually empty if (strip_tags($message) == '' || $subject == '') { $dialogBox->error(get_lang('You cannot post an empty message')); $error = TRUE; } if (!$error) { // record new topic $topic_id = create_new_topic($subject, $time, $forum_id, claro_get_current_user_id(), $userFirstname, $userLastname); if ($topic_id) { create_new_post($topic_id, $forum_id, claro_get_current_user_id(), $time, $poster_ip, $userLastname, $userFirstname, $message); } // notify eventmanager that a new message has been posted $eventNotifier->notifyCourseEvent('forum_new_topic', claro_get_current_course_id(), claro_get_current_tool_id(), $forum_id . "-" . $topic_id, claro_get_current_group_id(), 0); // notify by mail that a new topic has been created trig_forum_notification($forum_id); /*if( get_conf('clfrm_notification_enabled', true) ) { $courseSender = claro_get_current_user_data('firstName') . ' ' . claro_get_current_user_data('lastName'); $courseOfficialCode = claro_get_current_course_data('officialCode'); $title = get_lang('New topic on the forum %forum', array('%forum' => $forum_name)); $msgContent = get_lang('A new topic called %topic has been created on the forum %forum', array('%topic' => $subject, '%forum' => $forum_name)); // attached resource $body = $msgContent . "\n" . "\n"
$tlabelReq = 'CLLNP'; require '../../inc/claro_init_global.inc.php'; if (claro_is_user_authenticated()) { echo 'User is authenticated'; $spentTime = isset($_GET['spentTime']) ? $_GET['spentTime'] : null; $userModuleProgressId = isset($_GET['userModuleProgressId']) ? (int) $_GET['userModuleProgressId'] : null; $previousTotalTime = isset($_GET['previousTotalTime']) ? $_GET['previousTotalTime'] : null; $date = isset($_GET['date']) ? $_GET['date'] : null; $userId = isset($_GET['userId']) ? (int) $_GET['userId'] : null; $courseCode = isset($_GET['courseCode']) ? $_GET['courseCode'] : null; $learnPathId = isset($_GET['learnPathId']) ? (int) $_GET['learnPathId'] : null; $moduleId = isset($_GET['moduleId']) ? (int) $_GET['moduleId'] : null; if (!is_null($spentTime) && !is_null($userModuleProgressId) && !is_null($previousTotalTime) && !is_null($date) && !is_null($userId) && !is_null($courseCode) && !is_null($learnPathId) && !is_null($moduleId)) { echo 'No null param'; if (claro_get_current_user_id() == $userId && claro_get_current_course_id() == $courseCode) { echo 'user & course : OK'; $sessionTimeHour = (int) ($spentTime / 60); $sessionTimeMin = $spentTime % 60; $sessionTime = ''; if ($sessionTimeHour > 9999) { $sessionTime = '9999:59:59'; } else { if ($sessionTimeHour < 10) { $sessionTime .= 0; } $sessionTime .= $sessionTimeHour . ':'; if ($sessionTimeMin < 10) { $sessionTime .= 0; } $sessionTime .= $sessionTimeMin . ':00';
/** * Render the HTML page header * @return string */ public function render() { $this->_globalVarsCompat(); $this->addInlineJavascript(JavascriptLanguage::getInstance()->buildJavascript()); $titlePage = ''; if (empty($this->_toolName) && !empty($this->_nameTools)) { $titlePage .= $this->_nameTools . ' - '; } elseif (!empty($this->_toolName)) { $titlePage .= $this->_toolName . ' - '; } if (claro_is_in_a_course() && claro_get_current_course_data('officialCode') != '') { $titlePage .= claro_get_current_course_data('officialCode') . ' - '; } $titlePage .= get_conf('siteName'); $this->assign('pageTitle', $titlePage); if (true === get_conf('warnSessionLost', true) && claro_get_current_user_id()) { $this->assign('warnSessionLost', "function claro_session_loss_countdown(sessionLifeTime){\n var chrono = setTimeout('claro_warn_of_session_loss()', sessionLifeTime * 1000);\n}\n\nfunction claro_warn_of_session_loss() {\n alert('" . clean_str_for_javascript(get_lang('WARNING ! You have just lost your session on the server.') . "\n" . get_lang('Copy any text you are currently writing and paste it outside the browser')) . "');\n}\n"); } else { $this->assign('warnSessionLost', ''); } $htmlXtraHeaders = ''; if (!empty($this->_htmlXtraHeaders)) { $htmlXtraHeaders .= implode("\n", $this->_htmlXtraHeaders); } $this->assign('htmlScriptDefinedHeaders', $htmlXtraHeaders); return parent::render() . "\n"; }
foreach ($_REQUEST['extraInfoList'] as $extraInfoName => $extraInfoValue) { set_user_property(claro_get_current_user_id(), $extraInfoName, $extraInfoValue, 'userExtraInfo'); } } } // Initialise $userData['userExtraInfoList'] = get_user_property_list(claro_get_current_user_id()); // Command list $cmdList = array(); switch ($display) { case DISP_PROFILE_FORM: // Display user tracking link $profileText = claro_text_zone::get_content('textzone_edit_profile_form'); if (get_conf('is_trackingEnabled')) { // Display user tracking link $cmdList[] = array('img' => 'statistics', 'name' => get_lang('View my statistics'), 'url' => claro_htmlspecialchars(Url::Contextualize(get_conf('urlAppend') . '/claroline/tracking/userReport.php?userId=' . claro_get_current_user_id()))); } // Display request course creator status if (!claro_is_allowed_to_create_course() && get_conf('can_request_course_creator_status')) { $cmdList[] = array('name' => get_lang('Request course creation status'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=reqCCstatus'))); } // Display user revoquation if (get_conf('can_request_revoquation')) { $cmdList[] = array('img' => 'delete', 'name' => get_lang('Delete my account'), 'url' => claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=reqRevoquation'))); } if (claro_is_platform_admin()) { $dialogBox->info(get_lang('As a platform administrator, you can edit any field you want, even if this field isn\'t editable for other users.<br />You can check the list of editable fields in your platform\'s configuration.')); } break; } // Display
/** * Get the profile id of the current user in a given course * @param string $courseId id (sysCode) of the course * @return int id of the current user's profile in the course */ function claro_get_current_user_profile_id_in_course($courseId = null) { $courseId = empty($courseId) ? claro_get_current_course_id() : $courseId; $userPrivilege = claro_get_course_user_privilege($courseId, claro_get_current_user_id()); return $userPrivilege['_profileId']; }