Beispiel #1
0
 /**
  * returns array with information about enrolment to this course for given user_id
  * ['enrolment_allowed'] : true or false
  * ['cause']: keyword to describe the cause
  * ['description'] : readable description of the cause
  *
  * @param string $user_id
  * @return array
  */
 public function getEnrolmentInfo($user_id)
 {
     $info = array();
     $user = User::find($user_id);
     if ($this->read_level == 0 && get_config('ENABLE_FREE_ACCESS') && !$GLOBALS['perm']->get_studip_perm($this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'free_access';
         $info['description'] = _("Für die Veranstaltung ist keine Anmeldung erforderlich.");
         return $info;
     }
     if (!$user) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'nobody';
         $info['description'] = _("Sie sind nicht angemeldet.");
         return $info;
     }
     if ($GLOBALS['perm']->have_perm('root', $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'root';
         $info['description'] = _("Sie dürfen ALLES.");
         return $info;
     }
     if ($GLOBALS['perm']->have_studip_perm('admin', $this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'courseadmin';
         $info['description'] = _("Sie sind Administrator_in der Veranstaltung.");
         return $info;
     }
     if ($GLOBALS['perm']->have_perm('admin', $user_id)) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'admin';
         $info['description'] = _("Als Administrator_in können Sie sich nicht für eine Veranstaltung anmelden.");
         return $info;
     }
     //Ist bereits Teilnehmer
     if ($GLOBALS['perm']->have_studip_perm('user', $this->getId(), $user_id)) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'member';
         $info['description'] = _("Sie sind für die Veranstaltung angemeldet.");
         return $info;
     }
     $admission_status = $user->admission_applications->findBy('seminar_id', $this->getId())->val('status');
     if ($admission_status == 'accepted') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'accepted';
         $info['description'] = _("Sie wurden für diese Veranstaltung vorläufig akzeptiert.");
         return $info;
     }
     if ($admission_status == 'awaiting') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'awaiting';
         $info['description'] = _("Sie stehen auf der Warteliste für diese Veranstaltung.");
         return $info;
     }
     if ($GLOBALS['perm']->get_perm($user_id) == 'user') {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'user';
         $info['description'] = _("Sie haben nicht die erforderliche Berechtigung sich für eine Veranstaltung anzumelden.");
         return $info;
     }
     //falsche Nutzerdomäne
     $same_domain = true;
     $user_domains = UserDomain::getUserDomainsForUser($user_id);
     if (count($user_domains) > 0) {
         $seminar_domains = UserDomain::getUserDomainsForSeminar($this->getId());
         $same_domain = count(array_intersect($seminar_domains, $user_domains)) > 0;
     }
     if (!$same_domain && !$this->isStudygroup()) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'domain';
         $info['description'] = _("Sie sind nicht in einer zugelassenenen Nutzerdomäne, Sie können sich nicht eintragen!");
         return $info;
     }
     //Teilnehmerverwaltung mit Sperregel belegt
     if (LockRules::Check($this->getId(), 'participants')) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'locked';
         $lockdata = LockRules::getObjectRule($this->getId());
         $info['description'] = _("In diese Veranstaltung können Sie sich nicht eintragen!") . ($lockdata['description'] ? '<br>' . formatLinks($lockdata['description']) : '');
         return $info;
     }
     //Veranstaltung unsichtbar für aktuellen Nutzer
     if (!$this->visible && !$this->isStudygroup() && !$GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM'), $user_id)) {
         $info['enrolment_allowed'] = false;
         $info['cause'] = 'invisible';
         $info['description'] = _("Die Veranstaltung ist gesperrt, Sie können sich nicht eintragen!");
         return $info;
     }
     if ($courseset = $this->getCourseSet()) {
         $info['enrolment_allowed'] = true;
         $info['cause'] = 'courseset';
         $info['description'] = _("Die Anmeldung zu dieser Veranstaltung folgt speziellen Regeln. Lesen Sie den Hinweistext.");
         $user_prio = AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id);
         if (isset($user_prio[$this->getId()])) {
             $info['description'] .= ' ' . sprintf(_("(Sie stehen auf der Anmeldeliste für die automatische Platzverteilung mit der Priorität %s.)"), $user_prio[$this->getId()]);
         }
         return $info;
     }
     $info['enrolment_allowed'] = true;
     $info['cause'] = 'normal';
     $info['description'] = '';
     return $info;
 }
Beispiel #2
0
 public function index_action()
 {
     $this->prelim_discussion = vorbesprechung($this->course->id);
     $this->title = $this->course->getFullname();
     $this->course_domains = UserDomain::getUserDomainsForSeminar($this->course->id);
     $this->sem = new Seminar($this->course);
     if ($studienmodulmanagement = PluginEngine::getPlugin('StudienmodulManagement')) {
         foreach ($this->course->study_areas->filter(function ($m) {
             return $m->isModule();
         }) as $module) {
             $this->studymodules[] = array('nav' => $studienmodulmanagement->getModuleInfoNavigation($module->id, $this->course->start_semester->id), 'title' => $studienmodulmanagement->getModuleTitle($module->id, $this->course->start_semester->id));
         }
     }
     // Retrive display of sem_tree
     if (Config::get()->COURSE_SEM_TREE_DISPLAY) {
         $this->studyAreaTree = StudipStudyArea::backwards($this->course->study_areas);
     } else {
         $this->study_areas = $this->course->study_areas->filter(function ($m) {
             return !$m->isModule();
         });
     }
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->response->add_header('Content-Type', 'text/html;charset=Windows-1252');
         header('X-Title: ' . $this->title);
     } else {
         PageLayout::setHelpKeyword("Basis.InVeranstaltungDetails");
         PageLayout::setTitle($this->title . " - " . _("Details"));
         PageLayout::addSqueezePackage('admission');
         PageLayout::addSqueezePackage('enrolment');
         if ($GLOBALS['SessionSeminar'] == $this->course->id) {
             Navigation::activateItem('/course/main/details');
             SkipLinks::addIndex(Navigation::getItem('/course/main/details')->getTitle(), 'main_content', 100);
         } else {
             $sidebarlink = true;
             $enrolment_info = $this->sem->getEnrolmentInfo($GLOBALS['user']->id);
         }
         $sidebar = Sidebar::Get();
         if ($sidebarlink) {
             $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id));
         }
         $sidebar->setTitle(_('Details'));
         $links = new ActionsWidget();
         $links->addLink(_("Drucken"), URLHelper::getScriptLink("dispatch.php/course/details/index/" . $this->course->id), Icon::create('print', 'clickable'), array('class' => 'print_action', 'target' => '_blank'));
         if ($enrolment_info['enrolment_allowed'] && $sidebarlink) {
             if (in_array($enrolment_info['cause'], words('member root courseadmin'))) {
                 $abo_msg = _("direkt zur Veranstaltung");
             } else {
                 $abo_msg = _("Zugang zur Veranstaltung");
             }
             $links->addLink($abo_msg, URLHelper::getScriptLink("dispatch.php/course/enrolment/apply/" . $this->course->id), Icon::create('door-enter', 'clickable'), array('data-dialog' => ''));
         }
         if (Config::get()->SCHEDULE_ENABLE && !$GLOBALS['perm']->have_studip_perm("user", $this->course->id) && !$GLOBALS['perm']->have_perm('admin') && $this->sem->getMetaDateCount()) {
             $query = "SELECT COUNT(*) FROM schedule_seminare WHERE seminar_id = ? AND user_id = ?";
             if (!DBManager::Get()->fetchColumn($query, array($this->course->id, $GLOBALS['user']->id))) {
                 $links->addLink(_("Nur im Stundenplan vormerken"), URLHelper::getLink("dispatch.php/calendar/schedule/addvirtual/" . $this->course->id), Icon::create('info', 'clickable'));
             }
         }
         if ($this->send_from_search_page) {
             $links->addLink(_("Zurück zur letzten Auswahl"), URLHelper::getLink($this->send_from_search_page), Icon::create('link-intern', 'clickable'));
         }
         if ($links->hasElements()) {
             $sidebar->addWidget($links);
         }
         $sidebar->setImage('sidebar/seminar-sidebar.png');
         $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id));
         $sidebar = Sidebar::Get();
         $sidebar->setImage('sidebar/seminar-sidebar.png');
         $sidebar->setContextAvatar(CourseAvatar::getAvatar($this->course->id));
         if ($enrolment_info['description']) {
             PageLayout::postMessage(MessageBox::info($enrolment_info['description']));
         }
     }
 }
Beispiel #3
0
 function change_domains_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     if (Request::submitted('change_domains') && !LockRules::Check($this->course_id, 'user_domain')) {
         $old_domains = array_map(function ($d) {
             return $d->getId();
         }, UserDomain::getUserDomainsForSeminar($this->course_id));
         $new_domains = Request::getArray('user_domain');
         $changes = count(array_diff($old_domains, $new_domains)) + count(array_diff($new_domains, $old_domains));
         if ($changes) {
             UserDomain::removeUserDomainsForSeminar($this->course_id);
             foreach ($new_domains as $d) {
                 $domain = new UserDomain($d);
                 $domain->addSeminar($this->course_id);
             }
             PageLayout::postMessage(MessageBox::success(_("Die zugelassenen Nutzerdomänen wurden geändert.")));
         }
     }
     $this->redirect($this->url_for('/index'));
 }