Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 $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';
Ejemplo n.º 5
0
            <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']) ? '' : '&amp;gidReq =' . $this->forumSettings['idGroup'])));
        ?>
                <td>
                    <span class="<?php 
        echo $itemClass;
        ?>
">
                        <img src="<?php 
        echo get_icon_url('topic');
        ?>
" alt="" />&nbsp;
                        <a href="<?php 
        echo $itemLink;
        ?>
"><?php 
Ejemplo n.º 6
0
         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'));
         }
Ejemplo n.º 7
0
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>";
}
Ejemplo n.º 8
0
         $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $introId));
         $resourceList = isset($_REQUEST['resourceList']) ? $_REQUEST['resourceList'] : array();
         ResourceLinker::updateLinkList($currentLocator, $resourceList);
     }
 }
 if ($introCmd == 'exEd') {
     $intro_content = trim($_REQUEST['intro_content']);
     $introId = $_REQUEST['introId'];
     if (!empty($intro_content)) {
         $sql = "UPDATE `" . $TBL_INTRODUCTION . "`\n                    SET   `content` = '" . claro_sql_escape($intro_content) . "'\n                    WHERE `id` = " . (int) $introId;
         if (claro_sql_query($sql) != false) {
             $currentLocator = ResourceLinker::$Navigator->getCurrentLocator(array('id' => (int) $introId));
             $resourceList = isset($_REQUEST['resourceList']) ? $_REQUEST['resourceList'] : array();
             ResourceLinker::updateLinkList($currentLocator, $resourceList);
             // notify that a new introsection has been posted
             $claroline->notifier->notifyCourseEvent('introsection_modified', claro_get_current_course_id(), claro_get_current_tool_id(), $GLOBALS['moduleId'], claro_get_current_group_id(), '0');
         } else {
             // unsucceed
         }
     } else {
         $introCmd = 'exDel';
         // got to the delete command
     }
 }
 if ($introCmd == 'rqEd') {
     $sql = "SELECT `id`, `content`\n                FROM `" . $TBL_INTRODUCTION . "`\n                WHERE `id` = " . (int) $_REQUEST['introId'];
     $introSettingList = claro_sql_query_fetch_all($sql);
     if (isset($introSettingList[0])) {
         $introSettingList = $introSettingList[0];
     } else {
         $introSettingList = false;
Ejemplo n.º 9
0
$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)) {
Ejemplo n.º 10
0
                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="" />&nbsp;
                    <?php 
        if (!is_null($thisForum['group_id'])) {
            ?>
                        <?php 
Ejemplo n.º 11
0
            // 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
 =================================================================*/
Ejemplo n.º 12
0
                    }
                }
                //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
Ejemplo n.º 13
0
// check if user is anonymous
if ($lpUid) {
    $uidCheckString = "AND UMP.`user_id` = " . (int) $lpUid;
} else {
    $uidCheckString = "AND UMP.`user_id` IS NULL ";
}
// list available learning paths
$sql = "SELECT LP.* , MIN(UMP.`raw`) AS minRaw, LP.`lock`\n           FROM `" . $TABLELEARNPATH . "` AS LP\n     LEFT JOIN `" . $TABLELEARNPATHMODULE . "` AS LPM\n            ON LPM.`learnPath_id` = LP.`learnPath_id`\n     LEFT JOIN `" . $TABLEUSERMODULEPROGRESS . "` AS UMP\n            ON UMP.`learnPath_module_id` = LPM.`learnPath_module_id`\n            " . $uidCheckString . "\n         WHERE 1=1\n             " . $visibility . "\n      GROUP BY LP.`learnPath_id`\n      ORDER BY LP.`rank`";
$result = claro_sql_query($sql);
// used to know if the down array (for order) has to be displayed
$LPNumber = mysql_num_rows($result);
$iterator = 1;
$is_blocked = false;
while ($list = mysql_fetch_array($result)) {
    //modify style if the file is recently added since last login
    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(), $list['learnPath_id'])) {
        $classItem = ' hot';
    } else {
        $classItem = '';
    }
    if ($list['visibility'] == 'HIDE') {
        if ($is_allowedToEdit) {
            $style = " class=\"invisible\"";
        } else {
            continue;
            // skip the display of this file
        }
    } else {
        $style = "";
    }
    $out .= "<tr align=\"center\"" . $style . ">";
Ejemplo n.º 14
0
     Console::info("CLWORK: user #" . claro_get_current_user_id() . " posted a submission in assigment #{$assignmentId} in course " . claro_get_current_course_id() . " in place of user #{$authId}");
 }
 $submission->setAssignmentId($assignmentId);
 $submission->setUserId($posterId);
 $submission->setTitle($wrkForm['wrkTitle']);
 $submission->setAuthor($wrkForm['wrkAuthors']);
 $submission->setVisibility($assignment->getDefaultSubmissionVisibility());
 $submission->setSubmittedText($wrkForm['wrkTxt']);
 $submission->setSubmittedFilename($wrkForm['filename']);
 if ($assignment->getAssignmentType() == 'GROUP' && isset($wrkForm['wrkGroup'])) {
     $submission->setGroupId($wrkForm['wrkGroup']);
 }
 $submission->save();
 $dialogBox->success(get_lang('Work added'));
 // notify eventmanager that a new submission has been posted
 $eventNotifier->notifyCourseEvent("work_submission_posted", claro_get_current_course_id(), claro_get_current_tool_id(), $assignmentId, '0', '0');
 if (get_conf('mail_notification') && (claro_get_current_course_data('notify_submissions') || get_conf('automatic_mail_notification', false))) {
     // get teacher(s) mail
     $sql = "SELECT `U`.`user_id`\n                        FROM `" . $tbl_rel_cours_user . "` AS `CU`,`" . $tbl_user . "` AS `U`\n                        WHERE `CU`.`user_id` = `U`.`user_id`\n                        AND `CU`.`code_cours` = '" . claro_get_current_course_id() . "'\n                        AND `CU`.`isCourseManager` = 1";
     $userIdList = claro_sql_query_fetch_all_rows($sql);
     if (is_array($userIdList) && !empty($userIdList)) {
         require_once dirname(__FILE__) . '/../messaging/lib/message/platformmessagetosend.lib.php';
         require_once dirname(__FILE__) . '/../messaging/lib/recipient/userlistrecipient.lib.php';
         // subject
         $subject = $_user['firstName'] . ' ' . $_user['lastName'] . ' : ' . get_lang('New submission posted in assignment tool.');
         if ($assignment->getAssignmentType() == 'GROUP' && isset($_REQUEST['wrkGroup'])) {
             $authId = $wrkForm['wrkGroup'];
         } else {
             $authId = $_REQUEST['authId'];
         }
         $url = Url::Contextualize(get_path('rootWeb') . 'claroline/work/user_work.php?authId=' . $authId . '&assigId=' . $assignmentId);
Ejemplo n.º 15
0
 // 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 = '&nbsp;';
Ejemplo n.º 16
0
 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();
Ejemplo n.º 17
0
/**
 * function delete_groups($groupIdList = 'ALL')
 * deletes groups and their datas.
 *
 * @param  mixed   $groupIdList - group(s) to delete. It can be a single id
 *                                (int) or a list of id (array). If no id is
 *                                given all the course group are deleted
 *
 * @return integer : number of groups deleted.
 * @throws claro_failure
 */
function delete_groups($groupIdList = 'ALL')
{
    global $eventNotifier;
    $tbl_c_names = claro_sql_get_course_tbl();
    $tbl_groups = $tbl_c_names['group_team'];
    $tbl_groupsUsers = $tbl_c_names['group_rel_team_user'];
    $tbl_courseCalendar = $tbl_c_names['calendar_event'];
    require_once get_module_path('CLWIKI') . '/lib/lib.createwiki.php';
    require_once dirname(__FILE__) . '/forum.lib.php';
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLWIKI'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLWIKI')) {
        delete_group_wikis($groupIdList);
    }
    if (is_tool_activated_in_course(get_tool_id_from_module_label('CLFRM'), claro_get_current_course_id()) && is_tool_activated_in_groups(claro_get_current_course_id(), 'CLFRM')) {
        delete_group_forums($groupIdList);
    }
    /**
     * Check the data and notify eventmanager of the deletion
     */
    if (strtoupper($groupIdList) == 'ALL') {
        $sql_condition = '';
    } elseif (is_array($groupIdList)) {
        foreach ($groupIdList as $thisGroupId) {
            if (!is_int($thisGroupId)) {
                return false;
            }
        }
        $sql_condition = 'WHERE id IN (' . implode(' , ', $groupIdList) . ')';
    } else {
        if (settype($groupIdList, 'integer')) {
            $sql_condition = '  WHERE id = ' . (int) $groupIdList;
            $eventNotifier->notifyCourseEvent('group_deleted', claro_get_current_course_id(), claro_get_current_tool_id(), '0', $groupIdList, '0');
        } else {
            // TODO : perhaps a trigger erro is better
            return claro_failure::set_failure('CANT_SET_ID_GROUP_AS_INTEGER ' . __LINE__);
        }
    }
    /*
     * Search the groups data necessary to delete them
     */
    $sql_searchGroup = "SELECT `id` AS `id`,\n                               `secretDirectory` AS `directory`\n                        FROM `" . $tbl_groups . "`" . $sql_condition;
    $groupList = claro_sql_query_fetch_all_cols($sql_searchGroup);
    //notify event manager about the deletion for each group
    foreach ($groupList['id'] as $thisGroupId) {
        $eventNotifier->notifyCourseEvent('group_deleted', claro_get_current_course_id(), claro_get_current_tool_id(), '0', $thisGroupId, '0');
    }
    if (count($groupList['id']) > 0) {
        /*
         * Remove users, group(s) and group forum(s) from the course tables
         */
        $sql_deleteGroup = "DELETE FROM `" . $tbl_groups . "`\n                                   WHERE id IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        $sql_cleanOutGroupUsers = "DELETE FROM `" . $tbl_groupsUsers . "`\n                                   WHERE team IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        $sql_cleanOutGroupEvent = "DELETE FROM `" . $tbl_courseCalendar . "`\n                                    WHERE group_id IN (" . implode(' , ', $groupList['id']) . ")\n                                    # " . __FUNCTION__ . "\n                                    # " . __FILE__ . "\n                                    # " . __LINE__;
        // Deleting group record in table
        $deletedGroupNumber = claro_sql_query_affected_rows($sql_deleteGroup);
        // Delete all members of deleted group(s)
        claro_sql_query($sql_cleanOutGroupUsers);
        // Delete all calendar events for deleted group(s)
        claro_sql_query($sql_cleanOutGroupEvent);
        /**
         * Archive and delete the group files
         */
        // define repository for deleted element
        $groupGarbage = $GLOBALS['garbageRepositorySys'] . '/' . $GLOBALS['currentCourseRepository'] . '/group/';
        if (!file_exists($groupGarbage)) {
            claro_mkdir($groupGarbage, CLARO_FILE_PERMISSIONS, true);
        }
        foreach ($groupList['directory'] as $thisDirectory) {
            if (file_exists($GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/' . $thisDirectory)) {
                rename($GLOBALS['coursesRepositorySys'] . $GLOBALS['currentCourseRepository'] . '/group/' . $thisDirectory, $groupGarbage . $thisDirectory);
            }
        }
        return $deletedGroupNumber;
    } else {
        return FALSE;
    }
}
Ejemplo n.º 18
0
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'] . '&amp;topic=' . $topicId . '&amp;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'] . '&amp;topic=' . $topicId . '&amp;viewall=1');
                $cmdList[] = array('name' => get_lang('Full review'), 'url' => claro_htmlspecialchars(Url::Contextualize($viewallUrl)));
            }
        }
    }
    $out .= $postLister->disp_pager_tool_bar($pagerUrl);
Ejemplo n.º 19
0
     $out .= '<th>' . get_lang('Edit') . '</th>' . "\n" . '<th>' . get_lang('Delete') . '</th>' . "\n" . '<th>' . get_lang('Visibility') . '</th>' . "\n";
     $colspan += 3;
 }
 $out .= '</tr>' . "\n" . '<tbody>' . "\n\n";
 $atLeastOneAssignmentToShow = false;
 if (claro_is_user_authenticated()) {
     $date = $claro_notifier->get_notification_date(claro_get_current_user_id());
 }
 foreach ($assignmentList as $anAssignment) {
     //modify style if the file is recently added since last login and that assignment tool is used with visible default mode for submissions.
     $classItem = '';
     if (claro_is_user_authenticated()) {
         if ($claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $date, claro_get_current_user_id(), '', claro_get_current_tool_id(), $anAssignment['id'], FALSE) && ($anAssignment['def_submission_visibility'] == "VISIBLE" || $is_allowedToEdit)) {
             $classItem = ' hot';
         } else {
             $claro_notifier->is_a_notified_ressource(claro_get_current_course_id(), $date, claro_get_current_user_id(), '', claro_get_current_tool_id(), $anAssignment['id']);
         }
     }
     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'])) {
Ejemplo n.º 20
0
        $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';
    }
}
Ejemplo n.º 21
0
            <?php 
}
?>
        </tr>
    </thead>
    <tbody>
    <?php 
if (count($this->exerciseList) > 0) {
    ?>
    
        <?php 
    foreach ($this->exerciseList as $thisExercise) {
        ?>
        <?php 
        $invisibleClass = $this->is_allowedToEdit && 'INVISIBLE' == $thisExercise['visibility'] ? ' class="invisible"' : '';
        $appendToStyle = claro_is_user_authenticated() && $this->notifier->is_a_notified_ressource(claro_get_current_course_id(), $this->notifier->get_notification_date(claro_get_current_course_id()), claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisExercise['id']) ? ' hot' : '';
        ?>
        <tr <?php 
        echo $invisibleClass;
        ?>
>
            <td>
                <a href="<?php 
        echo claro_htmlspecialchars(Url::Contextualize('exercise_submit.php?exId=' . $thisExercise['id']));
        ?>
" class="item<?php 
        echo $appendToStyle;
        ?>
">
                    <img src="<?php 
        echo get_icon_url('quiz');