Пример #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);
 }
Пример #2
0
// Fetch the session courses (if any)
if (ClaroCourse::isSourceCourse($thisCourse->id)) {
    $sessionCourses = $thisCourse->getSessionCourses();
} else {
    $sessionCourses = array();
}
// Notices for course managers
if (claro_is_allowed_to_edit()) {
    if ($thisCourse->status == 'pending') {
        $dialogBox->warning(get_lang('This course is deactivated: you can reactive it from your course list'));
    } elseif ($thisCourse->status == 'date') {
        if (!empty($thisCourse->publicationDate) && $thisCourse->publicationDate > claro_mktime()) {
            $dialogBox->warning(get_lang('This course will be enabled on the %date', array('%date' => claro_date('d/m/Y', $thisCourse->publicationDate))));
        }
        if (!empty($thisCourse->expirationDate) && $thisCourse->expirationDate > claro_mktime()) {
            $dialogBox->warning(get_lang('This course will be disable on the %date', array('%date' => claro_date('d/m/Y', $thisCourse->expirationDate))));
        }
    }
    if ($thisCourse->userLimit > 0) {
        $dialogBox->warning(get_lang('This course is limited to %userLimit users', array('%userLimit' => $thisCourse->userLimit)));
    }
    if ($thisCourse->registration == 'validation') {
        $courseUserList = new Claro_CourseUserList(claro_get_current_course_id());
        if ($courseUserList->has_registrationPending()) {
            $usersPanelUrl = claro_htmlspecialchars(Url::Contextualize($toolRepository . 'user/user.php'));
            $dialogBox->warning(get_lang('You have to validate users to give them access to this course through the <a href="%url">course user list</a>', array('%url' => $usersPanelUrl)));
        }
    }
}
// Get the portlets buttons
$activablePortlets = claro_is_course_manager() ? CourseHomePagePortlet::getActivablePortlets() : array();
Пример #3
0
            foreach ($stats as $key => $elmt) {
                $csvSubTab = array();
                $csvSubTab['courseCode'] = $key;
                $csvSubTab['courseTitle'] = $elmt['courseTitle'];
                $csvSubTab['courseTitulars'] = $elmt['courseTitulars'];
                foreach ($elmt['courseStats'] as $key => $elmt2) {
                    $csvSubTab[$key . '_count'] = $elmt2['count'];
                    $csvSubTab[$key . '_size'] = round($elmt2['size'] / 1024);
                }
                foreach ($elmt['courseCategory'] as $key => $cat) {
                    $csvSubTab[$key . '_courseCategory'] = $cat;
                }
                $csvTab[] = $csvSubTab;
            }
            $csvExporter = new CsvExporter(';', '"');
            $fileName = get_lang('files_stats') . '_' . claro_date('d-m-Y') . '.csv';
            $stream = $csvExporter->export($csvTab);
            claro_send_stream($stream, $fileName, 'text/csv');
        }
    } else {
        $dialogBox->warning(get_lang('Statistics in progress, please don\'t refresh until further instructions ! ') . '<br />' . get_lang('Course actually treated : ') . $course['title'] . '<br />' . get_lang(' Number of course treated : ') . count($stats));
        $claroline->display->body->appendContent($dialogBox->render());
        echo $claroline->display->render();
    }
} else {
    $dialogBox = new DialogBox();
    $dialogBox->warning(get_lang('Caution: building files\' statistics is a pretty heavy work.  It might take a while and a lot of resources, depending of the size of your campus.'));
    if (!empty($extensions)) {
        $dialogBox->info(get_lang('You\'ve chosen to isolate the following extensions: %types.  If you wish to modify these extensions, check the advanced platform settings', array('%types' => implode(', ', $extensions))));
    } else {
        $dialogBox->info(get_lang('You don\'t have chosen any extension to isolate.  If you wish to isolate extensions in your statistics, check the advanced platform settings'));
Пример #4
0
 /**
  * tell to user list that user $userId is still active
  *
  * @param integer $userId
  * @return boolean result of operation
  */
 public function ping($userId)
 {
     $sql = "DELETE FROM `" . $this->tblChatUsers . "`\n                      WHERE `user_id` = " . (int) $userId;
     if (!is_null($this->groupId)) {
         $sql .= " AND `group_id` = " . (int) $this->groupId . " ";
     } else {
         $sql .= " AND `group_id` IS NULL ";
     }
     claro_sql_query($sql);
     $sql = "INSERT INTO `" . $this->tblChatUsers . "`\n                SET `user_id` = " . (int) $userId . ",";
     if (!is_null($this->groupId)) {
         $sql .= " `group_id` = " . (int) $this->groupId . ", ";
     }
     $sql .= " `last_action` = '" . claro_date('Y-m-d H:i:s') . "'";
     claro_sql_query($sql);
     return true;
 }
Пример #5
0
 public function modificationDefault($event)
 {
     $event_args = $event->getArgs();
     $cid = array_key_exists('cid', $event_args) ? $event_args['cid'] : '';
     $tid = array_key_exists('tid', $event_args) ? $event_args['tid'] : 0;
     $rid = array_key_exists('rid', $event_args) ? $event_args['rid'] : '';
     $gid = array_key_exists('gid', $event_args) ? $event_args['gid'] : 0;
     $uid = array_key_exists('uid', $event_args) ? $event_args['uid'] : 0;
     $eventType = $event->getEventType();
     // call function to update db info
     if ($eventType != 'delete') {
         $tbl_mdb_names = claro_sql_get_main_tbl();
         $tbl_notify = $tbl_mdb_names['notify'];
         // 1- check if row already exists
         $sql = "SELECT count(`id`) FROM `" . $tbl_notify . "`\n                         WHERE `course_code`= '" . claro_sql_escape($cid) . "'\n                           AND `tool_id`= " . (int) $tid . "\n                           AND `ressource_id`= '" . claro_sql_escape($rid) . "'\n                           AND `group_id` = " . (int) $gid . "\n                           AND `user_id` = " . (int) $uid;
         $do_update = (bool) claro_sql_query_get_single_value($sql);
         // 2- update or create for concerned row
         $now = claro_date("Y-m-d H:i:s");
         if ($do_update) {
             $sqlDoUpdate = "UPDATE `" . $tbl_notify . "`\n                     SET `date` = '" . claro_sql_escape($now) . "'\n                     WHERE `course_code` = '" . claro_sql_escape($cid) . "'\n                       AND `tool_id`     =  " . (int) $tid . "\n                       AND `ressource_id`= '" . claro_sql_escape($rid) . "'\n                       AND `group_id`    =  " . (int) $gid . "\n                       AND `user_id`     =  " . (int) $uid;
         } else {
             $sqlDoUpdate = "INSERT INTO `" . $tbl_notify . "`\n                            SET   `course_code`  = '" . claro_sql_escape($cid) . "',\n                                  `tool_id`      =  " . (int) $tid . ",\n                                  `date`         = '" . claro_sql_escape($now) . "',\n                                  `ressource_id` = '" . claro_sql_escape($rid) . "',\n                                  `group_id`     =  " . (int) $gid . ",\n                                  `user_id`      =  " . (int) $uid;
         }
         claro_sql_query($sqlDoUpdate);
         // 3- save in session of this user that this ressource is already seen.
         // --> as he did the modification himself, he shouldn't be notified
         $_SESSION['ConsultedRessourceList'][$cid . ':' . $tid . ':' . $gid . ':' . $rid . ':' . $now] = TRUE;
     }
 }
Пример #6
0
 protected function isCourseUnregistrationAllowed()
 {
     // Check if course available or option set to allow unregistration from unavailable course
     if (get_conf('crslist_UserCanUnregFromInactiveCourses', false)) {
         $isUserAllowedToUnenrol = true;
     } else {
         $curdate = claro_time();
         if (!in_array($this->course->status, array('enable', 'date'))) {
             $isUserAllowedToUnenrol = false;
             $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE;
             $this->errorMessage = get_lang('This course currently does not allow to unenrol (status: %status)', array('%status' => $this->course->status));
         } elseif ($this->course->status == 'date' && !empty($this->course->publicationDate) && $this->course->publicationDate >= $curdate) {
             $isUserAllowedToUnenrol = false;
             $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE;
             $this->errorMessage = get_lang('This course will be enabled on the %date', array('%date' => claro_date('d/m/Y', $this->course->publicationDate)));
         } elseif ($this->course->status == 'date' && !empty($this->course->expirationDate) && $this->course->expirationDate <= $curdate) {
             $isUserAllowedToUnenrol = false;
             $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE;
             $this->errorMessage = get_lang('This course has been deactivated on the %date', array('%date' => claro_date('d/m/Y', $this->course->expirationDate)));
         } elseif ($this->course->status == 'date' && (empty($this->course->expirationDate) && empty($this->course->publicationDate))) {
             $isUserAllowedToUnenrol = false;
             $this->status = self::STATUS_SYSTEM_ERROR;
             $this->errorMessage = get_lang('This course is not available');
             Console::error("Invalid publication and expiration date for course " . $this->course->courseId);
         } else {
             $isUserAllowedToUnenrol = true;
         }
     }
     return $isUserAllowedToUnenrol;
 }