/** * Returns all the descriptions of a course. * @throws InvalidArgumentException if the $cid in not provided. * @webservice{/module/MOBILE/GEN/getResourcesList/cidReq} * @ws_arg{method,getResourcesList} * @ws_arg{cidReq,SYSCODE of requested cours} * @return array of Descriptions object */ function getResourcesList($args) { $module = isset($args['module']) ? $args['module'] : null; $cid = claro_get_current_course_id(); if ($cid == null || $module == null) { throw new InvalidArgumentException('Missing cid argument!'); } $list = array(); FromKernel::uses('core/linker.lib'); ResourceLinker::init(); $locator = new ClarolineResourceLocator($cid, $module, null, claro_get_current_group_id()); if (ResourceLinker::$Navigator->isNavigable($locator)) { $resourceList = ResourceLinker::$Navigator->getResourceList($locator); foreach ($resourceList as $lnk) { $inLocator = $lnk->getLocator(); $item['title'] = $lnk->getName(); $item['visibility'] = $lnk->isVisible(); $item['url'] = str_replace(get_path('url'), "", get_path('rootWeb')) . ResourceLinker::$Resolver->resolve($inLocator); if ($inLocator->hasResourceId()) { $item['resourceId'] = $inLocator->getResourceId(); } else { $item['resourceId'] = $item['url']; } if (claro_is_allowed_to_edit() || $item['visibility']) { $list[] = $item; } } } return $list; }
/** * 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); } }
/** * Get the current execution context * @return array */ public static function getCurrentContext() { $context = array(); if (claro_is_in_a_course()) { $context[CLARO_CONTEXT_COURSE] = claro_get_current_course_id(); } if (claro_is_in_a_group()) { $context[CLARO_CONTEXT_GROUP] = claro_get_current_group_id(); } if (claro_is_in_a_tool()) { if (isset($GLOBALS['tlabelReq']) && $GLOBALS['tlabelReq']) { $context[CLARO_CONTEXT_TOOLLABEL] = $GLOBALS['tlabelReq']; } if (claro_get_current_tool_id()) { $context[CLARO_CONTEXT_TOOLINSTANCE] = claro_get_current_tool_id(); } } if (get_current_module_label()) { $context[CLARO_CONTEXT_MODULE] = get_current_module_label(); } return $context; }
/** * return the autorisation of the current user to send a message to the user in parameter * * @param int $userId user id of the recipient * @return bool true if the current user is autorised do send a message to the user in parameter * flase if the current user is not autorised do send a message to the user in parameter */ function current_user_is_allowed_to_send_message_to_user($userId) { if (claro_is_platform_admin()) { return true; } if (claro_is_in_a_group()) { if (claro_is_group_tutor() || claro_is_course_manager()) { $userList = get_group_user_list(claro_get_current_group_id(), claro_get_current_course_id()); for ($count = 0; $count < count($userList); $count++) { if ($userList[$count]['id'] == $userId) { return true; } } } return false; } elseif (claro_is_in_a_course()) { if (claro_is_course_manager()) { $userList = claro_get_course_user_list(); for ($count = 0; $count < count($userList); $count++) { if ($userList[$count]['user_id'] == $userId) { return true; } } } return false; } else { // can answerd to a user $tableName = get_module_main_tbl(array('im_message', 'im_recipient')); $select = "SELECT count(*)\n" . " FROM `" . $tableName['im_message'] . "` as M\n" . " INNER JOIN `" . $tableName['im_recipient'] . "` as R ON R.message_id = M.message_id\n" . " WHERE (R.user_id = " . (int) claro_get_current_user_id() . " OR R.user_id = 0)\n" . " AND M.sender = " . (int) $userId; $nbMessage = claro_sql_query_fetch_single_value($select); if ($nbMessage > 0) { return true; } elseif (get_conf('userCanSendMessage')) { } return true; return false; } }
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); }
<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
$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" ; require_once dirname(__FILE__) . '/../messaging/lib/message/messagetosend.lib.php';
$uploadDateIsOk = $assignment->isUploadDateOk(); if ($assignment->getAssignmentType() == 'INDIVIDUAL') { // user is authed and allowed $userCanPost = (bool) (claro_is_user_authenticated() && claro_is_course_allowed() && claro_is_course_member()); } else { $userGroupList = get_user_group_list(claro_get_current_user_id()); // check if user is member of at least one group $userCanPost = (bool) (!empty($userGroupList)); } $is_allowedToSubmit = (bool) ($assignmentIsVisible && $uploadDateIsOk && $userCanPost) || $is_allowedToEditAll; /*============================================================================ Update notification ============================================================================*/ if (claro_is_user_authenticated()) { // call this function to set the __assignment__ as seen, all the submission as seen $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(), $req['assignmentId']); } /*============================================================================ Prepare List ============================================================================*/ /* Prepare submission and feedback SQL filters - remove hidden item from count */ $submissionConditionList = array(); $feedbackConditionList = array(); $showOnlyVisibleCondition = ''; if (!$is_allowedToEditAll) { if (!get_conf('show_only_author')) { $submissionConditionList[] = "`s`.`visibility` = 'VISIBLE'"; } // not in the if statement to allow to show feedback to the students $feedbackConditionList[] = "(`s`.`visibility` = 'VISIBLE' AND `fb`.`visibility` = 'VISIBLE')"; if (!empty($userGroupList)) {
* Output */ $cssLoader = CssLoader::getInstance(); $cssLoader->load('clchat', 'screen'); //-- Content $out = ''; $nameTools = get_lang('Chat'); $out .= claro_html_tool_title($nameTools); if (claro_is_javascript_enabled() && $_uid) { $jsloader = JavascriptLoader::getInstance(); $jsloader->load('jquery'); $jsloader->load('clchat'); // init var with values from get_conf before including tool library $htmlHeaders = '<script type="text/javascript">' . "\n" . 'var refreshRate = "' . get_conf('msg_list_refresh_rate', 5) * 1000 . '";' . "\n" . 'var userListRefresh = "' . get_conf('user_list_refresh_rate') * 1000 . '";' . "\n" . 'var cidReq = "' . claro_get_current_course_id() . '";' . "\n"; if (claro_is_in_a_group()) { $htmlHeaders .= 'var gidReq = "' . claro_get_current_group_id() . '";' . "\n"; } $htmlHeaders .= 'var lang = new Array();' . "\n" . 'lang["confirmFlush"] = "' . clean_str_for_javascript(get_lang('Are you sure to delete all logs ?')) . '";' . '</script>'; $claroline->display->header->addHtmlHeader($htmlHeaders); // dialog box $out .= '<div id="clchat_user_list"></div>' . "\n" . '<div id="clchat_chatarea">' . "\n" . ' <div id="clchat_log"></div>' . "\n" . ' <div id="clchat_connectTime">' . get_lang('Start of this chat session (%connectTime)', array('%connectTime' => claro_html_localised_date(get_locale('dateTimeFormatLong'), $_SESSION['chat_connectionTime']))) . '</div>' . "\n" . ' <div id="clchat_text"></div>' . "\n" . '</div>' . "\n"; // display form $out .= '<form action="#" id="clchat_form" method="get" >' . "\n" . claro_form_relay_context() . "\n" . '<img src="' . get_module_url('CLCHAT') . '/img/loading.gif" alt="' . get_lang('Loading...') . '" id="clchat_loading" width="16" height="16" />' . "\n" . '<input id="clchat_msg" type="text" name="message" maxlength="200" size="80" />' . "\n" . '<input type="submit" name="Submit" value=" >> " />' . "\n" . '</form>' . "\n" . claro_html_menu_horizontal($cmdMenu) . "\n" . '<p id="clchat_dialogBox"></p>' . "\n"; } else { if (!claro_is_javascript_enabled()) { $dialogBox = new DialogBox(); $dialogBox->error(get_lang('Javascript must be enabled in order to use this tool.')); $out .= $dialogBox->render(); } elseif (!$_uid) { $dialogBox = new DialogBox(); $dialogBox->error(get_lang('Anonymous users cannot use this tool.'));
/** * Return the breadcrumb to display in the header * * @global string $nameTools * @global array $interbredcrump * @global boolean $noPHP_SELF * @global boolean $noQUERY_STRING * * @return string html content */ function claro_html_breadcrumb() { // dirty global to keep value (waiting a refactoring) global $nameTools, $interbredcrump, $noPHP_SELF, $noQUERY_STRING; /****************************************************************************** BREADCRUMB LINE ******************************************************************************/ $htmlBC = ''; if (claro_is_in_a_course() || isset($nameTools) || isset($interbredcrump) && is_array($interbredcrump)) { $htmlBC .= '<div id="breadcrumbLine">' . "\n\n" . '<hr />' . "\n"; $breadcrumbUrlList = array(); $breadcrumbNameList = array(); $breadcrumbUrlList[] = get_path('url') . '/index.php'; $breadcrumbNameList[] = get_conf('siteName'); if (claro_is_in_a_course()) { $breadcrumbUrlList[] = get_path('clarolineRepositoryWeb') . 'course/index.php?cid=' . claro_htmlspecialchars(claro_get_current_course_id()); $breadcrumbNameList[] = claro_get_current_course_data('officialCode'); } if (claro_is_in_a_group()) { $breadcrumbUrlList[] = get_module_url('CLGRP') . '/index.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id()); $breadcrumbNameList[] = get_lang('Groups'); $breadcrumbUrlList[] = get_module_url('CLGRP') . '/group_space.php?cidReq=' . claro_htmlspecialchars(claro_get_current_course_id()) . '&gidReq=' . (int) claro_get_current_group_id(); $breadcrumbNameList[] = claro_get_current_group_data('name'); } if (isset($interbredcrump) && is_array($interbredcrump)) { while (list(, $bredcrumpStep) = each($interbredcrump)) { $breadcrumbUrlList[] = $bredcrumpStep['url']; $breadcrumbNameList[] = $bredcrumpStep['name']; } } if (isset($nameTools)) { $breadcrumbNameList[] = $nameTools; if (isset($noPHP_SELF) && $noPHP_SELF) { $breadcrumbUrlList[] = null; } elseif (isset($noQUERY_STRING) && $noQUERY_STRING) { $breadcrumbUrlList[] = $_SERVER['PHP_SELF']; } else { // set Query string to empty if not exists if (!isset($_SERVER['QUERY_STRING'])) { $_SERVER['QUERY_STRING'] = ''; } $breadcrumbUrlList[] = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } } $htmlBC .= claro_html_breadcrumbtrail($breadcrumbNameList, $breadcrumbUrlList, ' > ', get_icon_url('home')); if (!claro_is_user_authenticated()) { $htmlBC .= "\n" . '<div id="toolViewOption" style="padding-right:10px">' . '<a href="' . get_path('clarolineRepositoryWeb') . 'auth/login.php' . '?sourceUrl=' . urlencode(base64_encode((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])) . '" target="_top">' . get_lang('Login') . '</a>' . '</div>' . "\n"; } elseif (claro_is_in_a_course() && !claro_is_course_member() && claro_get_current_course_data('registrationAllowed') && !claro_is_platform_admin()) { $htmlBC .= '<div id="toolViewOption">' . '<a href="' . get_path('clarolineRepositoryWeb') . 'auth/courses.php?cmd=exReg&course=' . claro_get_current_course_id() . '">' . '<img src="' . get_icon_url('enroll') . '" alt="" /> ' . '<b>' . get_lang('Enrolment') . '</b>' . '</a>' . '</div>' . "\n"; } elseif (claro_is_display_mode_available()) { $htmlBC .= "\n" . '<div id="toolViewOption">' . "\n"; if (isset($_REQUEST['View mode'])) { $htmlBC .= claro_html_tool_view_option($_REQUEST['View mode']); } else { $htmlBC .= claro_html_tool_view_option(); } if (claro_is_platform_admin() && !claro_is_course_member()) { $htmlBC .= ' | <a href="' . get_path('clarolineRepositoryWeb') . 'auth/courses.php?cmd=exReg&course=' . claro_get_current_course_id() . '">'; $htmlBC .= '<img src="' . get_icon_url('enroll') . '" alt="" /> '; $htmlBC .= '<b>' . get_lang('Enrolment') . '</b>'; $htmlBC .= '</a>'; } $htmlBC .= "\n" . '</div>' . "\n"; } $htmlBC .= '<div class="spacer"></div>' . "\n" . '<hr />' . "\n" . '</div>' . "\n"; } else { // $htmlBC .= '<div style="height:1em"></div>'; } return $htmlBC; }
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);
/** * Returns a single resquested topic. * @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!'); } FromKernel::uses('forum.lib'); $claroNotification = Claroline::getInstance()->notification; $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id()); $d = new DateTime($date); $d->sub(new DateInterval('PT1M')); $item = null; foreach (get_forum_list() as $forum) { if ($forum['forum_id'] == $resourceID) { $item = $forum; break; } } if ($item) { $item['resourceId'] = $item['forum_id']; $item['title'] = $item['forum_name']; foreach (get_category_list as $cat) { if ($cat['cat_id'] == $item['cat_id']) { $item['cat_title'] = $cat['cat_title']; $item['cat_order'] = $cat['cat_order']; break; } } $item['topics'] = array(); $topics = new topicLister($item['forum_id'], 0, $item['forum_topics']); foreach ($topics->get_topic_list() as $topic) { $topic['resourceId'] = $topic['topic_id']; $topic['title'] = $topic['topic_title']; $topic['poster_firstname'] = $topic['prenom']; $topic['poster_lastname'] = $topic['nom']; $topic['date'] = $topic['topic_time']; $topic['posts'] = array(); $posts = new postLister($topic['topic_id'], 0, $topic['topic_replies'] + 1); foreach ($posts->get_post_list() as $post) { $notified = $claroNotification->isANotifiedRessource($cid, $date, claro_get_current_user_id(), claro_get_current_group_id(), get_tool_id_from_module_label('CLFRM'), $item['forum_id'] . '-' . $topic['topic_id'] . '-' . $post['post_id'], false); $post['notifiedDate'] = $notified ? $date : $post['post_time']; $post['seenDate'] = $d->format('Y-m-d H:i'); $post['post_text'] = trim(strip_tags($post['post_text'])); $post['resourceId'] = $post['post_id']; $post['date'] = $post['post_time']; unset($post['post_id']); unset($post['topic_id']); unset($post['forum_id']); unset($post['poster_id']); unset($post['post_time']); unset($post['poster_ip']); $topic['posts'][] = $post; } unset($topic['topic_id']); unset($topic['topic_title']); unset($topic['topic_poster']); unset($topic['topic_time']); unset($topic['topic_replies']); unset($topic['topic_last_post_id']); unset($topic['forum_id']); unset($topic['topic_notify']); unset($topic['nom']); unset($topic['prenom']); unset($topic['post_time']); $item['topics'][] = $topic; } unset($item['forum_id']); unset($item['forum_name']); unset($item['forum_moderator']); unset($item['forum_topics']); unset($item['forum_posts']); unset($item['forum_last_post_id']); unset($item['forum_type']); unset($item['group_id']); unset($item['poster_id']); unset($item['post_time']); return $item; } else { throw new RuntimeException('Resource not found', 404); } }
// one, something weird is happening, indeed ... $allowed = FALSE; claro_die(get_lang('Not allowed')); } if (isset($_REQUEST['submit'])) { if (trim(strip_tags($message)) != '') { if (get_conf('allow_html') == 0 || isset($html)) { $message = htmlspecialchars($message); } $lastName = claro_get_current_user_data('lastName'); $firstName = claro_get_current_user_data('firstName'); $poster_ip = $_SERVER['REMOTE_ADDR']; $time = date('Y-m-d H:i'); create_new_post($topic_id, $forum_id, claro_get_current_user_id(), $time, $poster_ip, $lastName, $firstName, $message); // notify eventmanager that a new message has been posted $eventNotifier->notifyCourseEvent("forum_answer_topic", claro_get_current_course_id(), claro_get_current_tool_id(), $forum_id . "-" . $topic_id, claro_get_current_group_id(), "0"); trig_topic_notification($topic_id); } else { $error = TRUE; $dialogBox->error(get_lang('You cannot post an empty message')); } } } } else { // topic doesn't exist $error = 1; $dialogBox->error(get_lang('Not allowed')); } /*================================================================= Display Section =================================================================*/
public function __construct($groupId = null) { $groupId = empty($groupId) ? claro_get_current_group_id() : $groupId; parent::__construct($groupId); }
$exercise->setTimeLimit($_REQUEST['timeLimitMin'] * 60 + $_REQUEST['timeLimitSec']); } else { $exercise->setTimeLimit(0); } $exercise->setAttempts($_REQUEST['attempts']); $exercise->setAnonymousAttempts($_REQUEST['anonymousAttempts']); $exercise->setQuizEndMessage($_REQUEST['quizEndMessage']); if ($exercise->validate()) { if ($insertedId = $exercise->save()) { if (is_null($exId)) { $dialogBox->success(get_lang('Exercise added')); $eventNotifier->notifyCourseEvent("exercise_added", claro_get_current_course_id(), claro_get_current_tool_id(), $insertedId, claro_get_current_group_id(), "0"); $exId = $insertedId; } else { $dialogBox->success(get_lang('Exercise modified')); $eventNotifier->notifyCourseEvent("exercise_updated", claro_get_current_course_id(), claro_get_current_tool_id(), $insertedId, claro_get_current_group_id(), "0"); } $displaySettings = true; } else { // sql error in save() ? $cmd = 'rqEdit'; } } else { if (claro_failure::get_last_failure() == 'exercise_no_title') { $dialogBox->error(get_lang('Field \'%name\' is required', array('%name' => get_lang('Title')))); } elseif (claro_failure::get_last_failure() == 'exercise_incorrect_dates') { $dialogBox->error(get_lang('Start date must be before end date ...')); } $cmd = 'rqEdit'; } }
} if ($anAssignment['visibility'] == "INVISIBLE") { if ($is_allowedToEdit) { $style = ' class="invisible"'; } else { continue; // skip the display of this file } } else { $style = ''; } $out .= '<tr ' . $style . '>' . "\n" . '<td>' . "\n"; $assignmentUrl = Url::Contextualize('work_list.php?assigId=' . $anAssignment['id']); if (isset($_REQUEST['submitGroupWorkUrl']) && !empty($_REQUEST['submitGroupWorkUrl'])) { if (!isset($anAssignment['authorized_content']) || $anAssignment['authorized_content'] != 'TEXT') { $assignmentUrl = Url::Contextualize('work_list.php?cmd=rqSubWrk&assigId=' . $anAssignment['id'] . '&submitGroupWorkUrl=' . urlencode($_REQUEST['submitGroupWorkUrl']) . '&gidReq=' . claro_get_current_group_id()); } } $out .= '<a href="' . claro_htmlspecialchars($assignmentUrl) . '" class="item' . $classItem . '">' . '<img src="' . get_icon_url('assignment') . '" alt="" /> ' . $anAssignment['title'] . '</a>' . "\n" . '</td>' . "\n"; $out .= '<td align="center">'; if ($anAssignment['assignment_type'] == 'INDIVIDUAL') { $out .= '<img src="' . get_icon_url('user') . '" alt="' . get_lang('Individual') . '" />'; } elseif ($anAssignment['assignment_type'] == 'GROUP') { $out .= '<img src="' . get_icon_url('group') . '" alt="' . get_lang('Groups (from groups tool, only group members can post)') . '" />'; } else { $out .= ' '; } $out .= '</td>' . "\n" . '<td><small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), $anAssignment['start_date_unix']) . '</small></td>' . "\n" . '<td><small>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), $anAssignment['end_date_unix']) . '</small></td>' . "\n"; if (isset($_REQUEST['submitGroupWorkUrl']) && !empty($_REQUEST['submitGroupWorkUrl'])) { if (!isset($anAssignment['authorized_content']) || $anAssignment['authorized_content'] != 'TEXT') { $out .= '<td align="center">' . '<a href="' . claro_htmlspecialchars($assignmentUrl) . '">' . '<small>' . get_lang('Publish') . '</small>' . '</a>' . '</td>' . "\n";
$is_allowedToEdit = claro_is_allowed_to_edit() || claro_is_group_tutor() && !claro_is_course_manager(); // ( claro_is_group_tutor() // is added to give admin status to tutor // && !claro_is_course_manager()) // is added to let course admin, tutor of current group, use student mode $postSettingList = get_post_settings($post_id); if ($postSettingList && $is_allowedToEdit) { $topic_id = $postSettingList['topic_id']; $forumSettingList = get_forum_settings($postSettingList['forum_id']); $forum_name = stripslashes($forumSettingList['forum_name']); $forum_cat_id = $forumSettingList['cat_id']; /* * Check if the topic isn't attached to a group, or -- if it is attached --, * check the user is allowed to see the current group forum. */ if (!is_null($forumSettingList['idGroup']) && ($forumSettingList['idGroup'] != claro_get_current_group_id() || !claro_is_group_allowed())) { // NOTE : $forumSettingList['idGroup'] != claro_get_current_group_id() is necessary to prevent any hacking // attempt like rewriting the request without $cidReq. If we are in group // forum and the group of the concerned forum isn't the same as the session // one, something weird is happening, indeed ... $allowed = false; $dialogBox->error(get_lang('Not allowed')); } else { if (isset($_REQUEST['cancel'])) { claro_redirect('viewtopic.php?topic=' . $topic_id); exit; } if (isset($_REQUEST['submit'])) { /*----------------------------------------------------------------- Edit Post -----------------------------------------------------------------*/
/** * Return a list of user and groups of these users * * @param array context * @return array list of users */ function get_group_member_list($context = array()) { $currentCourseId = array_key_exists(CLARO_CONTEXT_COURSE, $context) ? $context['CLARO_CONTEXT_COURSE'] : claro_get_current_course_id(); $currentGroupId = array_key_exists(CLARO_CONTEXT_GROUP, $context) ? $context['CLARO_CONTEXT_GROUP'] : claro_get_current_group_id(); $tblc = claro_sql_get_course_tbl(); $tblm = claro_sql_get_main_tbl(); $sql = "SELECT `ug`.`id` AS id,\n `u`.`user_id` AS user_id,\n `u`.`nom` AS name,\n `u`.`prenom` AS firstname,\n `u`.`email` AS email,\n `u`.`officialEmail` AS officialEmail,\n `cu`.`role` AS `role`\n FROM (`" . $tblm['user'] . "` AS u\n , `" . $tblm['rel_course_user'] . "` AS cu\n , `" . $tblc['group_rel_team_user'] . "` AS ug)\n WHERE `cu`.`code_cours` = '" . $currentCourseId . "'\n AND `cu`.`user_id` = `u`.`user_id`\n AND `ug`.`team` = " . (int) $currentGroupId . "\n AND `ug`.`user` = `u`.`user_id`\n ORDER BY UPPER(`u`.`nom`), UPPER(`u`.`prenom`), `u`.`user_id`"; $result = Claroline::getDatabase()->query($sql); $result->setFetchMode(Database_ResultSet::FETCH_ASSOC); $usersInGroupList = array(); foreach ($result as $member) { $label = claro_htmlspecialchars(ucwords(strtolower($member['name'])) . ' ' . ucwords(strtolower($member['firstname'])) . ($member['role'] != '' ? ' (' . $member['role'] . ')' : '')); $usersInGroupList[$member['user_id']] = $label; } return $usersInGroupList; }
* @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * */ // CLAROLINE INIT $tlabelReq = 'CLCHT'; // required require '../inc/claro_init_global.inc.php'; if (!claro_is_in_a_course() || !claro_is_course_allowed() && !claro_is_user_authenticated()) { die('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' . "\n" . '<html>' . "\n" . '<head>' . "\n" . '<title>' . get_lang('Chat') . '</title>' . "\n" . '</head>' . "\n" . '<body>' . "\n" . "\n" . '<a href="./chat.php" >click</a>' . "\n" . '</body>' . "\n" . "\n"); } /*============================================================================ CONNECTION BLOC ============================================================================*/ $coursePath = get_path('coursesRepositorySys') . claro_get_course_path(); $courseId = claro_get_current_course_id(); $groupId = claro_get_current_group_id(); $_user = claro_get_current_user_data(); $_course = claro_get_current_course_data(); $_group = claro_get_current_group_data(); $is_allowedToManage = claro_is_course_manager(); $is_allowedToStore = claro_is_course_manager(); $is_allowedToReset = claro_is_course_manager(); if ($_user['firstName'] == '' && $_user['lastName'] == '') { $nick = get_lang('Anonymous'); } else { $nick = $_user['firstName'] . ' ' . $_user['lastName']; if (strlen($nick) > get_conf('max_nick_length')) { $nick = $_user['firstName'] . ' ' . $_user['lastName'][0] . '.'; } } // theses line prevent missing config file
function printInit($selection = "*") { global $uidReset, $cidReset, $gidReset, $tidReset, $uidReq, $cidReq, $gidReq, $tidReq, $tlabelReq, $_user, $_course, $_groupUser, $_courseTool, $_SESSION, $_claro_local_run; if ($_claro_local_run) { echo "local init runned"; } else { echo '<font color="red"> local init never runned during this script </font>'; } echo ' <table width="100%" border="1" cellspacing="4" cellpadding="1" bordercolor="#808080" bgcolor="#C0C0C0" lang="en"> <TR>'; if ($selection == "*" or strstr($selection, "u")) { echo ' <TD valign="top" > <strong>User</strong> : (_uid) : ' . var_export(claro_get_current_user_id(), 1) . ' | (session[_uid]) : ' . var_export($_SESSION["_uid"], 1) . ' <br /> reset = ' . var_export($uidReset, 1) . ' | req = ' . var_export($uidReq, 1) . '<br /> _user : <pre>' . var_export($_user, 1) . '</pre> <br />is_platformAdmin :' . var_export(claro_is_platform_admin(), 1) . ' <br />is_allowedCreateCourse :' . var_export(claro_is_allowed_to_create_course(), 1) . ' </TD>'; } if ($selection == "*" or strstr($selection, "c")) { echo "\n <TD valign=\"top\" >\n <strong>Course</strong> : (_cid)" . var_export(claro_get_current_course_id(), 1) . "\n <br />\n reset = " . var_export($cidReset, 1) . " | req = " . var_export($cidReq, 1) . "\n <br />\n _course : <pre>" . var_export($_course, 1) . "</pre>\n <br />\n _groupProperties :\n <PRE>\n " . var_export(claro_get_current_group_properties_data(), 1) . "\n </PRE>\n </TD>"; } echo ' </TR> <TR>'; if ($selection == "*" or strstr($selection, "g")) { echo '<TD valign="top" ><strong>Group</strong> : (_gid) ' . var_export(claro_get_current_group_id(), 1) . '<br /> reset = ' . var_export($GLOBALS['gidReset'], 1) . ' | req = ' . var_export($gidReq, 1) . "<br />\n _group :<pre>" . var_export(claro_get_current_group_data(), 1) . "</pre></TD>"; } if ($selection == "*" or strstr($selection, "t")) { echo '<TD valign="top" ><strong>Tool</strong> : (_tid)' . var_export(claro_get_current_tool_id(), 1) . '<br /> reset = ' . var_export($tidReset, 1) . ' | req = ' . var_export($tidReq, 1) . '| req = ' . var_export($tlabelReq, 1) . ' <br /> _tool :' . var_export(get_init('_tool'), 1) . "</TD>"; } echo "</TR>"; if ($selection == "*" or strstr($selection, "u") && strstr($selection, "c")) { echo '<TR><TD valign="top" colspan="2"><strong>Course-User</strong>'; if (claro_is_user_authenticated()) { echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1); } if (claro_is_in_a_course()) { echo ' in ' . var_export(claro_get_current_course_id(), 1) . '<br />'; } if (claro_is_user_authenticated() && claro_get_current_course_id()) { echo '_courseUser : <pre>' . var_export(getInit('_courseUser'), 1) . '</pre>'; } echo '<br />is_courseMember : ' . var_export(claro_is_course_member(), 1); echo '<br />is_courseAdmin : ' . var_export(claro_is_course_manager(), 1); echo '<br />is_courseAllowed : ' . var_export(claro_is_course_allowed(), 1); echo '<br />is_courseTutor : ' . var_export(claro_is_course_tutor(), 1); echo '</TD></TR>'; } echo ""; if ($selection == "*" or strstr($selection, "u") && strstr($selection, "g")) { echo '<TR><TD valign="top" colspan="2">' . '<strong>Course-Group-User</strong>'; if (claro_is_user_authenticated()) { echo '<br /><strong>User</strong> :' . var_export(claro_is_in_a_course(), 1); } if (claro_is_in_a_group()) { echo ' in ' . var_export(claro_get_current_group_id(), 1); } if (claro_is_in_a_group()) { echo '<br />_groupUser:'******'_groupUser'), 1); } echo '<br />is_groupMember:' . var_export(claro_is_group_member(), 1) . '<br />is_groupTutor: ' . var_export(claro_is_group_tutor(), 1) . '<br />is_groupAllowed:' . var_export(claro_is_group_allowed(), 1) . '</TD>' . '</tr>'; } if ($selection == "*" or strstr($selection, "c") && strstr($selection, "t")) { echo '<tr> <TD valign="top" colspan="2" ><strong>Course-Tool</strong><br />'; if (claro_get_current_tool_id()) { echo 'Tool :' . claro_get_current_tool_id(); } if (claro_is_in_a_course()) { echo ' in ' . claro_get_current_course_id() . '<br />'; } if (claro_get_current_tool_id()) { echo "_courseTool : <pre>" . var_export($_courseTool, 1) . '</pre><br />'; } echo 'is_toolAllowed : ' . var_export(claro_is_tool_allowed(), 1); echo "</TD>"; } echo "</TR></TABLE>"; }
// 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 CAS is the only authentication system enabled if (get_conf('claro_CasEnabled', false) && !get_conf('claro_displayLocalAuthForm', true)) { claro_redirect($_SERVER['PHP_SELF'] . '?authModeReq=CAS&sourceUrl=' . urlencode($sourceUrl)); } if ($sourceUrl) { $sourceUrl = claro_htmlspecialchars($sourceUrl); } else { $sourceUrl = ''; } if (claro_is_in_a_course()) { $sourceCid = claro_htmlspecialchars(claro_get_current_course_id()); } else { $sourceCid = ''; } if (claro_is_in_a_group()) { $sourceGid = claro_htmlspecialchars(claro_get_current_group_id()); } else { $sourceGid = ''; } $cidRequired = isset($_REQUEST['cidRequired']) ? $_REQUEST['cidRequired'] : false; //TODO: possibility to continue in anonymous $uidRequired = true; // The script needs the user to be authentificated if (!claro_is_user_authenticated() && $uidRequired) { $defaultLoginValue = ''; $dialogBox = new DialogBox(); if (isset($_SESSION['lastUserName'])) { $defaultLoginValue = strip_tags($_SESSION['lastUserName']); unset($_SESSION['lastUserName']); } if (get_conf('claro_displayLocalAuthForm', true) == true) {
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();
} } //notify modification of the page $eventNotifier->notifyCourseEvent('wiki_page_modified', claro_get_current_course_id(), claro_get_current_tool_id(), $wikiId, claro_get_current_group_id(), '0'); } else { $wikiPage->create($creatorId, $title, $content, $time, true); if ($wikiPage->hasError()) { $message = get_lang("Database error : ") . $wikiPage->getError(); $dialogBox->error($message); } else { $message = get_lang("Page saved"); $dialogBox->success($message); } $action = 'show'; //notify creation of the page $eventNotifier->notifyCourseEvent('wiki_page_added', claro_get_current_course_id(), claro_get_current_tool_id(), $wikiId, claro_get_current_group_id(), '0'); } } break; } // change to use empty page content if (!isset($content)) { $content = ''; } // --------- End of wiki command processing ----------- // --------- Start of wiki display -------------------- // set xtra head $jspath = document_web_path() . '/lib/javascript'; // set image repository $htmlHeadXtra[] = "<script type=\"text/javascript\">" . "\nvar sImgPath = '" . get_path('imgRepositoryWeb') . "'" . "\n</script>\n"; // set style
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
$result = Claroline::getDatabase()->query($sql); $result->setFetchMode(Database_ResultSet::FETCH_ASSOC); // Create html options lists $userNotInGroupListHtml = ''; foreach ($result as $member) { $label = claro_htmlspecialchars(ucwords(strtolower($member['lastName'])) . ' ' . ucwords(strtolower($member['firstName'])) . ($member['role'] != '' ? ' (' . $member['role'] . ')' : '')) . ($nbMaxGroupPerUser > 1 ? ' (' . $member['nbg'] . ')' : ''); $userNotInGroupListHtml .= '<option value="' . $member['user_id'] . '">' . $label . '</option>' . "\n"; } $usersInGroupList = get_group_member_list(); $usersInGroupListHtml = ''; foreach ($usersInGroupList as $key => $val) { $usersInGroupListHtml .= '<option value="' . $key . '">' . $val . '</option>' . "\n"; } $thisGroupMaxMember = is_null($myStudentGroup['maxMember']) ? '-' : $myStudentGroup['maxMember']; $template = new CoreTemplate('group_form.tpl.php'); $template->assign('formAction', claro_htmlspecialchars($_SERVER['PHP_SELF'] . '?edit=yes&gidReq=' . claro_get_current_group_id())); $template->assign('relayContext', claro_form_relay_context()); $template->assign('groupName', claro_htmlspecialchars($myStudentGroup['name'])); $template->assign('groupId', claro_get_current_group_id()); $template->assign('groupDescription', claro_htmlspecialchars($myStudentGroup['description'])); $template->assign('groupTutorId', $myStudentGroup['tutorId']); $template->assign('groupUserLimit', claro_htmlspecialchars($thisGroupMaxMember)); $template->assign('tutorList', $tutor_list); $template->assign('usersInGroupListHtml', $usersInGroupListHtml); $template->assign('userNotInGroupListHtml', $userNotInGroupListHtml); $out = ''; $out .= claro_html_tool_title(array('supraTitle' => get_lang("Groups"), 'mainTitle' => $nameTools)); $out .= $dialogBox->render(); $out .= $template->render(); $claroline->display->body->appendContent($out); echo $claroline->display->render();
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'])) {
/** * @param int $gid * @param string $courseId * @param boolean $active if set to true, only actvated tool will be considered for display */ function get_group_tool_menu($gid = null, $courseId = null, $active = true) { $toolList = array(); if (is_null($gid)) { $gid = claro_get_current_group_id(); } if (is_null($courseId)) { $courseId = claro_get_current_course_id(); } require_once dirname(__FILE__) . '/../group.lib.inc.php'; $groupToolList = get_group_tool_list($courseId, $active); // group space links /* $toolList[] = claro_html_cmd_link( claro_htmlspecialchars(Url::Contextualize( get_module_url('CLGRP').'/group_space.php' )) , '<img src="' . get_icon_url('group') . '" alt="" /> ' . get_lang('Group area') ); */ $courseGroupData = claro_get_main_group_properties($courseId); foreach ($groupToolList as $groupTool) { if (is_tool_activated_in_groups($courseId, $groupTool['label']) && (isset($courseGroupData['tools'][$groupTool['label']]) && $courseGroupData['tools'][$groupTool['label']])) { $toolList[] = claro_html_cmd_link(claro_htmlspecialchars(Url::Contextualize(get_module_url($groupTool['label']) . '/' . $groupTool['url'])), '<img src="' . get_module_url($groupTool['label']) . '/' . $groupTool['icon'] . '" alt="" />' . ' ' . claro_get_tool_name($groupTool['label']), array('class' => $groupTool['visibility'] ? 'visible' : 'invisible')); } } if (count($toolList)) { return claro_html_menu_horizontal($toolList); } else { return ''; } }
ResourceLinker::updateLinkList($currentLocator, $resourceList); $dialogBox->success(get_lang('Introduction added')); // Notify that the introsection has been created $claroline->notifier->notifyCourseEvent('introsection_created', claro_get_current_course_id(), claro_get_current_tool_id(), $toolIntro->getId(), claro_get_current_group_id(), '0'); } } elseif ($cmd == 'exEd') { $toolIntro = new ToolIntro($id); $toolIntro->handleForm(); //TODO inputs validation if ($toolIntro->save()) { $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $toolIntro->getId())); $resourceList = isset($_REQUEST['resourceList']) ? $_REQUEST['resourceList'] : array(); ResourceLinker::updateLinkList($currentLocator, $resourceList); $dialogBox->success(get_lang('Introduction modified')); // Notify that the introsection has been modified $claroline->notifier->notifyCourseEvent('introsection_modified', claro_get_current_course_id(), claro_get_current_tool_id(), $toolIntro->getId(), claro_get_current_group_id(), '0'); } } elseif ($cmd == 'exDel') { $toolIntro = new ToolIntro($id); if ($toolIntro->delete()) { $dialogBox->success(get_lang('Introduction deleted')); //TODO linker_delete_resource('CLINTRO_'); } } elseif ($cmd == 'exMvUp') { $toolIntro = new ToolIntro($id); if ($toolIntro->load()) { if ($toolIntro->moveUp()) { $dialogBox->success(get_lang('Introduction moved up')); } else { $dialogBox->error(get_lang('This introduction can\'t be moved up')); }
/** * Returns the documents contained into args['curDirPath'] * @param array $args array of parameters, can contain : * - (boolean) recursive : if true, return the content of the requested directory and its subdirectories, if any. Default = true * - (String) curDirPath : returns the content of the directory specified by this path. Default = '' (root) * @throws InvalidArgumentException if $cid is missing * @webservice{/module/MOBILE/CLDOC/getResourceList/cidReq/[?recursive=BOOL&curDirPath='']} * @ws_arg{Method,getResourcesList} * @ws_arg{cidReq,SYSCODE of requested cours} * @ws_arg{recursive,[Optionnal: if true\, return the content of the requested directory and its subdirectories\, if any. Default = true]} * @ws_arg{curDirPath,[Optionnal: returns the content of the directory specified by this path. Default = '' (root)]} * @return array of document object */ function getResourcesList($args) { $recursive = isset($args['recursive']) ? $args['recursive'] : true; $curDirPath = isset($args['curDirPath']) ? $args['curDirPath'] : ''; $cid = claro_get_current_course_id(); if (is_null($cid)) { throw new InvalidArgumentException('Missing cid argument!'); } elseif (!claro_is_course_allowed()) { throw new RuntimeException('Not allowed', 403); } /* READ CURRENT DIRECTORY CONTENT = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ $claroline = Claroline::getInstance(); $exSearch = false; $groupContext = FALSE; $courseContext = TRUE; $dbTable = get_module_course_tbl(array('document'), $cid); $dbTable = $dbTable['document']; $docToolId = get_course_tool_id('CLDOC'); $groupId = claro_get_current_group_id(); $date = $claroline->notification->getLastActionBeforeLoginDate(claro_get_current_user_id()); if (!defined('A_DIRECTORY')) { define('A_DIRECTORY', 1); } if (!defined('A_FILE')) { define('A_FILE', 2); } $baseWorkDir = get_path('coursesRepositorySys') . claro_get_course_path($cid) . '/document'; /*---------------------------------------------------------------------------- LOAD FILES AND DIRECTORIES INTO ARRAYS ----------------------------------------------------------------------------*/ $searchPattern = ''; $searchRecursive = false; $searchBasePath = $baseWorkDir . $curDirPath; $searchExcludeList = array(); $searchBasePath = secure_file_path($searchBasePath); if (false === ($filePathList = claro_search_file(search_string_to_pcre($searchPattern), $searchBasePath, $searchRecursive, 'ALL', $searchExcludeList))) { switch (claro_failure::get_last_failure()) { case 'BASE_DIR_DONT_EXIST': pushClaroMessage($searchBasePath . ' : call to an unexisting directory in groups'); break; default: pushClaroMessage('Search failed'); break; } $filePathList = array(); } for ($i = 0; $i < count($filePathList); $i++) { $filePathList[$i] = str_replace($baseWorkDir, '', $filePathList[$i]); } if ($exSearch && $courseContext) { $sql = "SELECT path FROM `" . $dbTable . "`\n\t\t\t\t\tWHERE comment LIKE '%" . claro_sql_escape($searchPattern) . "%'"; $dbSearchResult = claro_sql_query_fetch_all_cols($sql); $filePathList = array_unique(array_merge($filePathList, $dbSearchResult['path'])); } $fileList = array(); if (count($filePathList) > 0) { /*-------------------------------------------------------------------------- SEARCHING FILES & DIRECTORIES INFOS ON THE DB ------------------------------------------------------------------------*/ /* * Search infos in the DB about the current directory the user is in */ if ($courseContext) { $sql = "SELECT `path`, `visibility`, `comment`\n\t\t\t\t\t\tFROM `" . $dbTable . "`\n\t\t\t\t\t\t\t\tWHERE path IN ('" . implode("', '", array_map('claro_sql_escape', $filePathList)) . "')"; $xtraAttributeList = claro_sql_query_fetch_all_cols($sql); } else { $xtraAttributeList = array('path' => array(), 'visibility' => array(), 'comment' => array()); } foreach ($filePathList as $thisFile) { $fileAttributeList['cours']['sysCode'] = $cid; $fileAttributeList['path'] = $thisFile; $fileAttributeList['resourceId'] = $thisFile; $tmp = explode('/', $thisFile); if (is_dir($baseWorkDir . $thisFile)) { $fileYear = date('n', time()) < 8 ? date('Y', time()) - 1 : date('Y', time()); $fileAttributeList['title'] = $tmp[count($tmp) - 1]; $fileAttributeList['isFolder'] = true; $fileAttributeList['type'] = A_DIRECTORY; $fileAttributeList['size'] = 0; $fileAttributeList['date'] = $fileYear . '-09-20'; $fileAttributeList['extension'] = ""; $fileAttributeList['url'] = null; } elseif (is_file($baseWorkDir . $thisFile)) { $fileAttributeList['title'] = implode('.', explode('.', $tmp[count($tmp) - 1], -1)); $fileAttributeList['type'] = A_FILE; $fileAttributeList['isFolder'] = false; $fileAttributeList['size'] = claro_get_file_size($baseWorkDir . $thisFile); $fileAttributeList['date'] = date('Y-m-d', filemtime($baseWorkDir . $thisFile)); $fileAttributeList['extension'] = get_file_extension($baseWorkDir . $thisFile); $fileAttributeList['url'] = $_SERVER['SERVER_NAME'] . claro_get_file_download_url($thisFile); } $xtraAttributeKey = array_search($thisFile, $xtraAttributeList['path']); if ($xtraAttributeKey !== false) { $fileAttributeList['description'] = $xtraAttributeList['comment'][$xtraAttributeKey]; $fileAttributeList['visibility'] = $xtraAttributeList['visibility'][$xtraAttributeKey] == 'v'; unset($xtraAttributeList['path'][$xtraAttributeKey]); } else { $fileAttributeList['description'] = null; $fileAttributeList['visibility'] = true; } $notified = $claroline->notification->isANotifiedDocument($cid, $date, claro_get_current_user_id(), $groupId, $docToolId, $fileAttributeList, false); $fileAttributeList['notifiedDate'] = $notified ? $date : $fileAttributeList['date']; $d = new DateTime($date); $d->sub(new DateInterval('P1D')); $fileAttributeList['seenDate'] = $d->format('Y-m-d'); if ($fileAttributeList['visibility'] || claro_is_allowed_to_edit()) { $fileList[] = $fileAttributeList; } } // end foreach $filePathList } if ($recursive) { foreach ($fileList as $thisFile) { if ($thisFile['type'] == A_DIRECTORY) { $args = array('curDirPath' => $thisFile['path'], 'recursive' => true); $new_list = $this->getResourcesList($args); $fileList = array_merge($fileList, $new_list); } } } return $fileList; }