Example #1
0
 /**
  * Helper to remove all users from a course
  * @param bool $keepClasses if true, all classes will be removed too
  * @param array $profilesToDelete array of profile labels
  * @param string $registeredBefore date yyyy-mm-dd hh:mm:ss
  * @param string $registeredAfter date yyyy-mm-dd hh:mm:ss
  * @return bool false if an error occured
  * @throws Exception
  */
 public function removeAllUsers($keepClasses = true, $profilesToDelete = array(), $registeredBefore = null, $registeredAfter = null)
 {
     if ($keepClasses && (!is_null($registeredBefore) || !is_null($registeredAfter))) {
         throw new Exception(get_lang('Cannot combine enrolment date filters and class deletion, please delete the classes independently'));
     }
     $courseUserList = new Claro_CourseUserList($this->course->courseId, $this->database);
     if (empty($profilesToDelete)) {
         $profilesToDelete = array(USER_PROFILE);
     }
     $courseUserIdList = $courseUserList->getFilteredUserIdList($profilesToDelete, $registeredBefore, $registeredAfter);
     $this->removeUserIdListFromCourse($courseUserIdList);
     if (!$keepClasses) {
         $courseClassList = new Claro_CourseClassList($this->course, $this->database);
         foreach ($courseClassList->getClassListIterator() as $class) {
             $classUserList = new Claro_ClassUserList($class, $this->database);
             $this->removeUserIdListFromCourse($classUserList->getClassUserIdList(), $class);
         }
     }
     return !$this->result->hasError();
 }
Example #2
0
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();
// Display
$template = new CoreTemplate('course_index.tpl.php');
$template->assign('dialogBox', $dialogBox);
$template->assign('activablePortlets', $activablePortlets);
$template->assign('portletIterator', $portletiterator);
$claroline->display->body->setContent($template->render());
echo $claroline->display->render();