示例#1
0
 private function types()
 {
     return array('inst' => array('name' => _('Institut'), 'after_user_add' => function ($user_id) {
         $newInstUser = new InstituteMember(array($user_id, $_SESSION['SessionSeminar']));
         if ($newInstUser->isNew()) {
             $user = new User($user_id);
             $newInstUser->inst_perms = $user->perms;
             if ($newInstUser->store()) {
                 StudipLog::INST_USER_ADD($_SESSION['SessionSeminar'], $user->id, $user->perms);
             }
         }
     }, 'after_user_delete' => function ($user_id) {
         null;
     }, 'after_user_move' => function ($user_id) {
         null;
     }, 'view' => function ($user_id) {
         return true;
     }, 'needs_size' => false, 'needs_self_assign' => false, 'edit' => function ($user_id) {
         return $GLOBALS['perm']->have_studip_perm('admin', $_SESSION['SessionSeminar']) && !LockRules::Check($_SESSION['SessionSeminar'], 'groups');
     }, 'redirect' => function () {
         require_once 'lib/admin_search.inc.php';
         die;
         //must not return
     }, 'groups' => array('members' => array('name' => _('Mitglieder')))));
 }
示例#2
0
 /**
  * Imports a line of the table into the Stud.IP database if the check returns no errors.
  * @param array $line : array of fields
  * @return array : array('found' => true|false, 'errors' => "Error message", 'pk' => "primary key")
  */
 public function importLine($line)
 {
     $plugin = $this->getPlugin();
     $classname = $this['import_type'];
     if (!$classname) {
         return array();
     }
     $data = $this->getMappedData($line);
     $pk = $this->getPrimaryKey($data);
     //Last chance to quit:
     $error = $this->checkLine($line, $data, $pk);
     $output = array();
     $object = new $classname($pk);
     if (!$object->isNew()) {
         $output['found'] = true;
         $output['pk'] = $pk;
         foreach ((array) $this['tabledata']['ignoreonupdate'] as $fieldname) {
             unset($data[$fieldname]);
         }
     } else {
         $output['found'] = false;
     }
     foreach ($data as $fieldname => $value) {
         if ($value !== false && in_array($fieldname, $this->getTargetFields())) {
             $object[$fieldname] = $value;
             if ($classname === "User" && $fieldname === "password") {
                 $object[$fieldname] = UserManagement::getPwdHasher()->HashPassword($value);
             }
         }
     }
     if (method_exists($object, "getFullName")) {
         $error['name'] = $output['name'] = $object->getFullName();
     } elseif ($object->isField("name")) {
         $error['name'] = $output['name'] = $object['name'];
     } elseif ($object->isField("title")) {
         $error['name'] = $output['name'] = $object['title'];
     }
     if ($error && $error['errors']) {
         //exit here to have the name of the object in the log
         return $error;
     }
     if ($plugin) {
         $plugin->beforeUpdate($object, $line, $data);
     }
     $object->store();
     $output['pk'] = (array) $object->getId();
     //Dynamic special fields:
     switch ($classname) {
         case "Course":
             //fleximport_dozenten
             foreach ($data['fleximport_dozenten'] as $dozent_id) {
                 $seminar = new Seminar($object->getId());
                 $seminar->addMember($dozent_id, 'dozent');
             }
             //fleximport_related_institutes
             if (!$data['fleximport_related_institutes']) {
                 $data['fleximport_related_institutes'] = array($object['institut_id']);
             } else {
                 if (!in_array($object['institut_id'], $data['fleximport_related_institutes'])) {
                     $data['fleximport_related_institutes'][] = $object['institut_id'];
                 }
             }
             foreach ($data['fleximport_related_institutes'] as $institut_id) {
                 $insert = DBManager::get()->prepare("\n                        INSERT IGNORE INTO seminar_inst\n                        SET seminar_id = :seminar_id,\n                            institut_id = :institut_id\n                    ");
                 $insert->execute(array('seminar_id' => $object->getId(), 'institut_id' => $institut_id));
             }
             if ($this['tabledata']['simplematching']["fleximport_course_userdomains"]['column'] || in_array("fleximport_course_userdomains", $this->fieldsToBeDynamicallyMapped())) {
                 $statement = DBManager::get()->prepare("\n                        SELECT userdomain_id\n                        FROM seminar_userdomains\n                        WHERE seminar_id = ?\n                    ");
                 $statement->execute(array($object->getId()));
                 $olddomains = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
                 foreach (array_diff($data['fleximport_user_inst'], $olddomains) as $to_add) {
                     $domain = new UserDomain($to_add);
                     $domain->addSeminar($object->getId());
                 }
                 foreach (array_diff($olddomains, $data['fleximport_user_inst']) as $to_remove) {
                     $domain = new UserDomain($to_remove);
                     $domain->removeSeminar($object->getId());
                 }
             }
             break;
         case "User":
             if ($this['tabledata']['simplematching']["fleximport_user_inst"]['column'] || in_array("fleximport_user_inst", $this->fieldsToBeDynamicallyMapped())) {
                 if ($object['perms'] !== "root") {
                     foreach ($data['fleximport_user_inst'] as $institut_id) {
                         $member = new InstituteMember(array($object->getId(), $institut_id));
                         $member['inst_perms'] = $object['perms'];
                         $member->store();
                     }
                 }
             }
             if ($this['tabledata']['simplematching']["fleximport_userdomains"]['column'] || in_array("fleximport_userdomains", $this->fieldsToBeDynamicallyMapped())) {
                 $olddomains = UserDomain::getUserDomainsForUser($object->getId());
                 foreach ($olddomains as $olddomain) {
                     if (!in_array($olddomain->getID(), (array) $data['fleximport_userdomains'])) {
                         $olddomain->removeUser($object->getId());
                     }
                 }
                 foreach ($data['fleximport_userdomains'] as $userdomain) {
                     $domain = new UserDomain($userdomain);
                     $domain->addUser($object->getId());
                 }
                 AutoInsert::instance()->saveUser($object->getId());
                 foreach ($data['fleximport_userdomains'] as $domain_id) {
                     if (!in_array($domain_id, $olddomains)) {
                         $welcome = FleximportConfig::get("USERDOMAIN_WELCOME_" . $domain_id);
                         if ($welcome) {
                             foreach ($object->toArray() as $field => $value) {
                                 $welcome = str_replace("{{" . $field . "}}", $value, $welcome);
                             }
                             foreach ($line as $field => $value) {
                                 $welcome = str_replace("{{" . $field . "}}", $value, $welcome);
                             }
                             if (strpos($welcome, "\n") === false) {
                                 $subject = _("Willkommen!");
                             } else {
                                 $subject = strstr($welcome, "\n", true);
                                 $welcome = substr($welcome, strpos($welcome, "\n") + 1);
                             }
                             $messaging = new messaging();
                             $count = $messaging->insert_message($welcome, $object->username, '____%system%____', null, null, null, null, $subject, true, 'normal');
                         }
                     }
                 }
             }
             if ($this['tabledata']['simplematching']["fleximport_expiration_date"]['column'] || in_array("fleximport_expiration_date", $this->fieldsToBeDynamicallyMapped())) {
                 if ($data['fleximport_expiration_date']) {
                     UserConfig::get($object->getId())->store("EXPIRATION_DATE", $data['fleximport_expiration_date']);
                 } else {
                     UserConfig::get($object->getId())->delete("EXPIRATION_DATE");
                 }
             }
             if ($output['found'] === false && $data['fleximport_welcome_message'] !== "none") {
                 $user_language = getUserLanguagePath($object->getId());
                 setTempLanguage(false, $user_language);
                 if ($data['fleximport_welcome_message'] && FleximportConfig::get($data['fleximport_welcome_message'])) {
                     $message = FleximportConfig::get($data['fleximport_welcome_message']);
                     foreach ($data as $field => $value) {
                         $message = str_replace("{{" . $field . "}}", $value, $message);
                     }
                     foreach ($line as $field => $value) {
                         if (!in_array($field, $data)) {
                             $message = str_replace("{{" . $field . "}}", $value, $message);
                         }
                     }
                     if (strpos($message, "\n") === false) {
                         $subject = dgettext($user_language, "Anmeldung Stud.IP-System");
                     } else {
                         $subject = strstr($message, "\n", true);
                         $message = substr($message, strpos($message, "\n") + 1);
                     }
                 } else {
                     $Zeit = date("H:i:s, d.m.Y", time());
                     $this->user_data = array('auth_user_md5.username' => $object['username'], 'auth_user_md5.perms' => $object['perms'], 'auth_user_md5.Vorname' => $object['vorname'], 'auth_user_md5.Nachname' => $object['nachname'], 'auth_user_md5.Email' => $object['email']);
                     $password = $data['password'];
                     //this is the not hashed password in cleartext
                     include "locale/{$user_language}/LC_MAILS/create_mail.inc.php";
                     $message = $mailbody;
                 }
                 if ($message) {
                     $mail = new StudipMail();
                     $mail->addRecipient($object['email'], $object->getFullName());
                     $mail->setSubject($subject);
                     $mail->setBodyText($message);
                     $mail->setBodyHtml(formatReady($message));
                     if (Config::get()->MAILQUEUE_ENABLE) {
                         MailQueueEntry::add($mail);
                     } else {
                         $mail->send();
                     }
                 }
                 restoreLanguage();
             }
             break;
     }
     //Datafields:
     $datafields = array();
     switch ($classname) {
         case "Course":
             $datafields = Datafield::findBySQL("object_type = 'sem'");
             break;
         case "User":
             $datafields = Datafield::findBySQL("object_type = 'user'");
             break;
         case "CourseMember":
             $datafields = Datafield::findBySQL("object_type = 'usersemdata'");
             break;
     }
     foreach ($datafields as $datafield) {
         $fieldname = $datafield['name'];
         if (isset($data[$fieldname])) {
             $entry = new DatafieldEntryModel(array($datafield->getId(), $object->getId(), ""));
             $entry['content'] = $data[$fieldname];
             $entry->store();
         }
     }
     if ($classname === "Course") {
         if ($this['tabledata']['simplematching']["fleximport_studyarea"]['column'] || in_array("fleximport_studyarea", $this->fieldsToBeDynamicallyMapped())) {
             //Studienbereiche:
             $remove = DBManager::get()->prepare("\n                    DELETE FROM seminar_sem_tree\n                    WHERE seminar_id = :seminar_id\n                ");
             $remove->execute(array('seminar_id' => $object->getId()));
             if ($GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$data['status']]['class']]['bereiche']) {
                 foreach ($data['fleximport_studyarea'] as $sem_tree_id) {
                     $insert = DBManager::get()->prepare("\n                            INSERT IGNORE INTO seminar_sem_tree\n                            SET sem_tree_id = :sem_tree_id,\n                                seminar_id = :seminar_id\n                        ");
                     $insert->execute(array('sem_tree_id' => $sem_tree_id, 'seminar_id' => $object->getId()));
                 }
             }
         }
         if ($this['tabledata']['simplematching']["fleximport_locked"]['column'] || in_array("fleximport_locked", $this->fieldsToBeDynamicallyMapped())) {
             //Lock or unlock course
             if ($data['fleximport_locked']) {
                 CourseSet::addCourseToSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId());
             } elseif (in_array($data['fleximport_locked'], array("0", 0)) && $data['fleximport_locked'] !== "") {
                 CourseSet::removeCourseFromSet(CourseSet::getGlobalLockedAdmissionSetId(), $object->getId());
             }
         }
         $folder_exist = DBManager::get()->prepare("\n                SELECT 1 FROM folder WHERE range_id = ?\n            ");
         $folder_exist->execute(array($object->getId()));
         if (!$folder_exist->fetch()) {
             $insert_folder = DBManager::get()->prepare("\n                    INSERT IGNORE INTO folder\n                    SET folder_id = MD5(CONCAT(:seminar_id, 'allgemeine_dateien')),\n                    range_id = :seminar_id,\n                    user_id = :user_id,\n                    name = :name,\n                    description = :description,\n                    mkdate = UNIX_TIMESTAMP(),\n                    chdate = UNIX_TIMESTAMP()\n                ");
             $insert_folder->execute(array('seminar_id' => $object->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => _("Allgemeiner Dateiordner"), 'description' => _("Ablage für allgemeine Ordner und Dokumente der Veranstaltung")));
         }
     }
     if ($plugin && !$object->isNew()) {
         $plugin->afterUpdate($object, $line);
     }
     return $output;
 }
示例#3
0
 /**
  * Zeigt die Grunddaten an. Man beachte, dass eventuell zuvor eine andere
  * Action wie Set ausgeführt wurde, von der hierher weitergeleitet worden ist.
  * Wichtige Daten dazu wurden dann über $this->flash übertragen.
  *
  * @param md5 $course_id
  */
 public function view_action($course_id = null)
 {
     global $user, $perm, $_fullname_sql;
     $deputies_enabled = get_config('DEPUTIES_ENABLE');
     //damit QuickSearch funktioniert:
     Request::set('new_doz_parameter', $this->flash['new_doz_parameter']);
     if ($deputies_enabled) {
         Request::set('new_dep_parameter', $this->flash['new_dep_parameter']);
     }
     Request::set('new_tut_parameter', $this->flash['new_tut_parameter']);
     $this->course_id = Request::option('cid', $course_id);
     Navigation::activateItem('/course/admin/details');
     //Berechtigungscheck:
     if (!$perm->have_studip_perm("tutor", $this->course_id)) {
         throw new AccessDeniedException(_("Sie haben keine Berechtigung diese " . "Veranstaltung zu verändern."));
     }
     //Kopf initialisieren:
     PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenGrunddaten");
     PageLayout::setTitle(_("Verwaltung der Grunddaten"));
     if ($this->course_id) {
         PageLayout::setTitle(Course::find($this->course_id)->getFullname() . " - " . PageLayout::getTitle());
     }
     //Daten sammeln:
     $sem = Seminar::getInstance($this->course_id);
     $data = $sem->getData();
     //Erster Reiter des Akkordions: Grundeinstellungen
     $this->attributes = array();
     $this->attributes[] = array('title' => _("Name der Veranstaltung"), 'name' => "course_name", 'must' => true, 'type' => 'text', 'value' => $data['name'], 'locked' => LockRules::Check($this->course_id, 'Name'));
     $this->attributes[] = array('title' => _("Untertitel der Veranstaltung"), 'name' => "course_subtitle", 'type' => 'text', 'value' => $data['subtitle'], 'locked' => LockRules::Check($this->course_id, 'Untertitel'));
     $sem_types = array();
     if ($perm->have_perm("admin")) {
         foreach (SemClass::getClasses() as $sc) {
             foreach ($sc->getSemTypes() as $st) {
                 if (!$sc['course_creation_forbidden']) {
                     $sem_types[$st['id']] = $st['name'] . ' (' . $sc['name'] . ')';
                 }
             }
         }
     } else {
         $sc = $sem->getSemClass();
         foreach ($sc->getSemTypes() as $st) {
             $sem_types[$st['id']] = $st['name'] . ' (' . $sc['name'] . ')';
         }
     }
     if (!isset($sem_types[$data['status']])) {
         $sem_types[$data['status']] = $sem->getSemType()->offsetGet('name');
     }
     $this->attributes[] = array('title' => _("Typ der Veranstaltung"), 'name' => "course_status", 'must' => true, 'type' => 'select', 'value' => $data['status'], 'locked' => LockRules::Check($this->course_id, 'status'), 'choices' => array_map('htmlReady', $sem_types));
     $this->attributes[] = array('title' => _("Art der Veranstaltung"), 'name' => "course_form", 'type' => 'text', 'value' => $data['form'], 'locked' => LockRules::Check($this->course_id, 'art'));
     $this->attributes[] = array('title' => _("Veranstaltungs-Nummer"), 'name' => "course_seminar_number", 'type' => 'text', 'value' => $data['seminar_number'], 'locked' => LockRules::Check($this->course_id, 'VeranstaltungsNummer'));
     $this->attributes[] = array('title' => _("ECTS-Punkte"), 'name' => "course_ects", 'type' => 'text', 'value' => $data['ects'], 'locked' => LockRules::Check($this->course_id, 'ects'));
     $this->attributes[] = array('title' => _("max. Teilnehmerzahl"), 'name' => "course_admission_turnout", 'must' => false, 'type' => 'number', 'value' => $data['admission_turnout'], 'locked' => LockRules::Check($this->course_id, 'admission_turnout'), 'min' => '0');
     $this->attributes[] = array('title' => _("Beschreibung"), 'name' => "course_description", 'type' => 'textarea', 'value' => $data['description'], 'locked' => LockRules::Check($this->course_id, 'Beschreibung'));
     //Zweiter Reiter: Institute
     $this->institutional = array();
     $institute = Institute::getMyInstitutes();
     $choices = array();
     foreach ($institute as $inst) {
         //$choices[$inst['Institut_id']] = $inst['Name'];
         $choices[$inst['Institut_id']] = ($inst['is_fak'] ? "<span style=\"font-weight: bold\">" : "&nbsp;&nbsp;&nbsp;&nbsp;") . htmlReady($inst['Name']) . ($inst['is_fak'] ? "</span>" : "");
     }
     $this->institutional[] = array('title' => _("Heimat-Einrichtung"), 'name' => "course_institut_id", 'must' => true, 'type' => 'select', 'value' => $data['institut_id'], 'choices' => $choices, 'locked' => LockRules::Check($this->course_id, 'Institut_id'));
     $institute = Institute::getInstitutes();
     $choices = array();
     foreach ($institute as $inst) {
         $choices[$inst['Institut_id']] = ($inst['is_fak'] ? "<span style=\"font-weight: bold\">" : "&nbsp;&nbsp;&nbsp;&nbsp;") . htmlReady($inst['Name']) . ($inst['is_fak'] ? "</span>" : "");
     }
     $sem_institutes = $sem->getInstitutes();
     $inst = array_flip($sem_institutes);
     unset($inst[$sem->institut_id]);
     $inst = array_flip($inst);
     $this->institutional[] = array('title' => _("beteiligte Einrichtungen"), 'name' => "related_institutes[]", 'type' => 'multiselect', 'value' => $inst, 'choices' => $choices, 'locked' => LockRules::Check($this->course_id, 'seminar_inst'));
     $this->dozent_is_locked = LockRules::Check($this->course_id, 'dozent');
     $this->tutor_is_locked = LockRules::Check($this->course_id, 'tutor');
     //Dritter Reiter: Personal
     $this->dozenten = $sem->getMembers('dozent');
     $instUsers = new SimpleCollection(InstituteMember::findByInstituteAndStatus($sem->getInstitutId(), 'dozent'));
     $this->lecturersOfInstitute = $instUsers->pluck('user_id');
     if (SeminarCategories::getByTypeId($sem->status)->only_inst_user) {
         $search_template = "user_inst_not_already_in_sem";
     } else {
         $search_template = "user_not_already_in_sem";
     }
     $this->dozentUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $sem->status)), "user_id", array('permission' => 'dozent', 'seminar_id' => $this->course_id, 'sem_perm' => 'dozent', 'institute' => $sem_institutes));
     $this->dozenten_title = get_title_for_status('dozent', 1, $sem->status);
     $this->deputies_enabled = $deputies_enabled;
     if ($this->deputies_enabled) {
         $this->deputies = getDeputies($this->course_id);
         $this->deputySearch = new PermissionSearch("user_not_already_in_sem_or_deputy", sprintf(_("%s suchen"), get_title_for_status('deputy', 1, $sem->status)), "user_id", array('permission' => getValidDeputyPerms(), 'seminar_id' => $this->course_id));
         $this->deputy_title = get_title_for_status('deputy', 1, $sem->status);
     }
     $this->tutoren = $sem->getMembers('tutor');
     $this->tutorUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('tutor', 1, $sem->status)), "user_id", array('permission' => array('dozent', 'tutor'), 'seminar_id' => $this->course_id, 'sem_perm' => array('dozent', 'tutor'), 'institute' => $sem_institutes));
     $this->tutor_title = get_title_for_status('tutor', 1, $sem->status);
     $instUsers = new SimpleCollection(InstituteMember::findByInstituteAndStatus($sem->getInstitutId(), 'tutor'));
     $this->tutorsOfInstitute = $instUsers->pluck('user_id');
     unset($instUsers);
     //Vierter Reiter: Beschreibungen (darunter Datenfelder)
     $this->descriptions[] = array('title' => _("Teilnehmde"), 'name' => "course_participants", 'type' => 'textarea', 'value' => $data['participants'], 'locked' => LockRules::Check($this->course_id, 'teilnehmer'));
     $this->descriptions[] = array('title' => _("Voraussetzungen"), 'name' => "course_requirements", 'type' => 'textarea', 'value' => $data['requirements'], 'locked' => LockRules::Check($this->course_id, 'voraussetzungen'));
     $this->descriptions[] = array('title' => _("Lernorganisation"), 'name' => "course_orga", 'type' => 'textarea', 'value' => $data['orga'], 'locked' => LockRules::Check($this->course_id, 'lernorga'));
     $this->descriptions[] = array('title' => _("Leistungsnachweis"), 'name' => "course_leistungsnachweis", 'type' => 'textarea', 'value' => $data['leistungsnachweis'], 'locked' => LockRules::Check($this->course_id, 'leistungsnachweis'));
     $this->descriptions[] = array('title' => _("Ort") . "<br><span style=\"font-size: 0.8em\"><b>" . _("Achtung:") . "&nbsp;</b>" . _("Diese Ortsangabe wird nur angezeigt, wenn keine " . "Angaben aus Zeiten oder Sitzungsterminen gemacht werden können.") . "</span>", 'name' => "course_location", 'type' => 'textarea', 'value' => $data['location'], 'locked' => LockRules::Check($this->course_id, 'Ort'));
     $datenfelder = DataFieldEntry::getDataFieldEntries($this->course_id, 'sem', $data["status"]);
     if ($datenfelder) {
         foreach ($datenfelder as $datenfeld) {
             if ($datenfeld->isVisible()) {
                 $locked = !$datenfeld->isEditable() || LockRules::Check($this->course_id, $datenfeld->getID());
                 $this->descriptions[] = array('title' => $datenfeld->getName(), 'must' => $datenfeld->isRequired(), 'name' => "datafield_" . $datenfeld->getID(), 'type' => "datafield", 'html_value' => $datenfeld->getHTML("datafields"), 'display_value' => $datenfeld->getDisplayValue(), 'locked' => $locked, 'description' => !$datenfeld->isEditable() ? "Diese Felder werden zentral durch die zuständigen Administratoren erfasst." : $datenfeld->getDescription());
             }
         }
     }
     $this->descriptions[] = array('title' => _("Sonstiges"), 'name' => "course_misc", 'type' => 'textarea', 'value' => $data['misc'], 'locked' => LockRules::Check($this->course_id, 'Sonstiges'));
     $this->perm_dozent = $perm->have_studip_perm("dozent", $this->course_id);
     $this->mkstring = $data['mkdate'] ? date("d.m.Y, G:i", $data['mkdate']) : _("unbekannt");
     $this->chstring = $data['chdate'] ? date("d.m.Y, G:i", $data['chdate']) : _("unbekannt");
     $lockdata = LockRules::getObjectRule($this->course_id);
     if ($lockdata['description'] && LockRules::CheckLockRulePermission($this->course_id, $lockdata['permission'])) {
         $this->flash['msg'] = array_merge((array) $this->flash['msg'], array(array("info", formatLinks($lockdata['description']))));
     }
     $this->flash->discard();
     //schmeißt ab jetzt unnötige Variablen aus der Session.
     $sidebar = Sidebar::get();
     $sidebar->setImage("sidebar/admin-sidebar.png");
     $widget = new ActionsWidget();
     $widget->addLink(_('Bild ändern'), $this->url_for('course/avatar/update', $course_id), Icon::create('edit', 'clickable'));
     if ($this->deputies_enabled) {
         if (isDeputy($user->id, $this->course_id)) {
             $newstatus = 'dozent';
             $text = _('Lehrende werden');
         } else {
             if (in_array($user->id, array_keys($this->dozenten)) && sizeof($this->dozenten) > 1) {
                 $newstatus = 'deputy';
                 $text = _('Vertretung werden');
             }
         }
         $widget->addLink($text, $this->url_for('course/basicdata/switchdeputy', $this->course_id, $newstatus), Icon::create('persons', 'clickable'));
     }
     $sidebar->addWidget($widget);
     // Entry list for admin upwards.
     if ($perm->have_studip_perm("admin", $this->course_id)) {
         $list = new SelectorWidget();
         $list->setUrl("?#admin_top_links");
         $list->setSelectParameterName("cid");
         foreach (AdminCourseFilter::get()->getCoursesForAdminWidget() as $seminar) {
             $list->addElement(new SelectElement($seminar['Seminar_id'], $seminar['Name']), 'select-' . $seminar['Seminar_id']);
         }
         $list->setSelection($this->course_id);
         $sidebar->addWidget($list);
     }
 }
示例#4
0
文件: my_realm.php 项目: ratbird/hope
 /**
  * Get all user assigned institutes based on simple or map
  * @return array
  */
 public static function getMyInstitutes()
 {
     $memberShips = InstituteMember::findByUser($GLOBALS['user']->id);
     if (empty($memberShips)) {
         return null;
     }
     $insts = new SimpleCollection($memberShips);
     $institutes = array();
     $insts->filter(function ($a) use(&$institutes) {
         $array = $a->institute->toArray();
         $array['perms'] = $a->inst_perms;
         $array['visitdate'] = object_get_visit($a->institut_id, 'inst', '');
         $array['last_visitdate'] = object_get_visit($a->institut_id, 'inst', 'last');
         $institutes[] = $array;
         return true;
     });
     if (!empty($institutes)) {
         $Modules = new Modules();
         foreach ($institutes as $index => $inst) {
             $institutes[$index]['modules'] = $Modules->getLocalModules($inst['institut_id'], 'inst', $inst['modules'], $inst['type'] ?: 1);
             $institutes[$index]['obj_type'] = 'inst';
             $institutes[$index]['navigation'] = MyRealmModel::getAdditionalNavigations($inst['institut_id'], $institutes[$index], null, $GLOBALS['user']->id);
         }
         unset($Modules);
     }
     return $institutes;
 }