Ejemplo n.º 1
0
 /**
  * Is the user allowed to enrol to the course
  * @return boolean
  */
 protected function isUnregistrationAllowed()
 {
     $coursePrivileges = new CourseUserPrivileges($this->course->courseId, $this->userAuthProfile->getUserId());
     if (!$this->forceUnregOfManager && $coursePrivileges->isCourseManager() && $this->userAuthProfile->getUserId() == claro_get_current_user_id() && !claro_is_platform_admin()) {
         $this->status = self::STATUS_MANAGER_CANNOT_UNREGISTER_ITSELF;
         $this->errorMessage = get_lang('Course manager cannot unsubscribe himself');
         // unless he is platform admin too
         return false;
     }
     // check if is thelast course manager
     if ($coursePrivileges->isCourseManager() && $this->onlyOneCourseManagerLeft()) {
         $this->status = self::STATUS_CANNOT_UNREGISTER_LASTMANAGER;
         $this->errorMessage = get_lang('You cannot unsubscribe the last course manager of the course');
         // even if platform admin...
         return false;
     }
     if ($this->isSuperUser) {
         return true;
     }
     if ($this->userAuthProfile->isProfileAllowedToRegisterInCourse()) {
         return $this->isCourseUnregistrationAllowed();
     } else {
         $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE;
         $this->errorMessage = get_lang('Your profile does not allow you to unregister from this course.');
         return false;
     }
 }
Ejemplo n.º 2
0
                    $dialogBox->success(get_lang('This user account is now active in the course'));
                } else {
                    $dialogBox->warning(get_lang('No change'));
                }
            } elseif ('revoke' == $validationChange && !$validation->isPending()) {
                if ($validation->revoke()) {
                    $dialogBox->success(get_lang('This user account is not active anymore in this course'));
                } else {
                    $dialogBox->warning(get_lang('No change'));
                }
            } else {
                $dialogBox->warning(get_lang('No change'));
            }
        } else {
            $dialogBox->error(get_lang('The user activation cannot be changed'));
            if ($courseUserPrivileges->isCourseManager()) {
                $dialogBox->error(get_lang('You have to remove the course manager status first'));
            }
        }
    }
}
// end if allowed to edit
$courseUserList = new Claro_CourseUserList(claro_get_current_course_id());
if ($courseUserList->has_registrationPending()) {
    $usersPanelUrl = claro_htmlspecialchars(Url::Contextualize(get_module_entry_url('CLUSR')));
    $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 Course informations
  ----------------------------------------------------------------------*/
$sql = "SELECT `course`.`registration`\n        FROM `" . $tbl_courses . "` AS course\n        WHERE `course`.`code`='" . claro_sql_escape(claro_get_current_course_id()) . "'";