Exemplo n.º 1
0
 /**
  * Grundlegende Systemeinstellungen
  *
  * @get /studip/settings
  */
 public function getSettings()
 {
     $sem_types = array_map(function ($item) {
         return array('name' => $item['name'], 'class' => $item['class']);
     }, \SemType::getTypes());
     $sem_classes = array_map(function ($item) {
         $item = (array) $item;
         return reset($item);
     }, \SemClass::getClasses());
     return array('ALLOW_CHANGE_USERNAME' => $GLOBALS['ALLOW_CHANGE_USERNAME'], 'ALLOW_CHANGE_EMAIL' => $GLOBALS['ALLOW_CHANGE_EMAIL'], 'ALLOW_CHANGE_NAME' => $GLOBALS['ALLOW_CHANGE_NAME'], 'ALLOW_CHANGE_TITLE' => $GLOBALS['ALLOW_CHANGE_TITLE'], 'INST_TYPE' => $GLOBALS['INST_TYPE'], 'SEM_TYPE' => $sem_types, 'SEM_CLASS' => $sem_classes, 'TERMIN_TYP' => $GLOBALS['TERMIN_TYP'], 'PERS_TERMIN_KAT' => $GLOBALS['PERS_TERMIN_KAT'], 'SUPPORT_EMAIL' => $GLOBALS['UNI_CONTACT'], 'TITLES' => $GLOBALS['DEFAULT_TITLE_FOR_STATUS'], 'UNI_NAME_CLEAN' => $GLOBALS['UNI_NAME_CLEAN']);
 }
Exemplo n.º 2
0
 /**
  * Returns all Seminar_ids to courses I am member of and in which blubber
  * is an active plugin.
  * @return array of string : array of Seminar_ids
  */
 protected function getMyCourses()
 {
     if ($GLOBALS['perm']->have_perm("admin", $this->user_id)) {
         return array();
     }
     $mandatory_classes = array();
     $standard_classes = array();
     $forbidden_classes = array();
     $mandatory_types = array();
     $standard_types = array();
     $forbidden_types = array();
     foreach (SemClass::getClasses() as $key => $class) {
         $blubber_setting = $class->getModuleMetadata("Blubber");
         if ($class->isModuleMandatory("Blubber")) {
             $mandatory_classes[] = $key;
         }
         if ($class->isSlotModule("Blubber") or $blubber_setting['activated'] && !$blubber_setting['sticky']) {
             $standard_classes[] = $key;
         }
         if (!$class->isModuleAllowed("Blubber")) {
             $forbidden_classes[] = $key;
         }
     }
     foreach (SemType::getTypes() as $key => $type) {
         if (in_array($type['class'], $mandatory_classes)) {
             $mandatory_types[] = $key;
         }
         if (in_array($type['class'], $standard_classes)) {
             $standard_types[] = $key;
         }
         if (in_array($type['class'], $forbidden_classes)) {
             $forbidden_types[] = $key;
         }
     }
     $is_deputy = get_config('DEPUTIES_ENABLE') && DBManager::get()->fetchColumn("SELECT 1 FROM deputies WHERE user_id=? LIMIT 1", array($this->user_id));
     $blubber_plugin_info = PluginManager::getInstance()->getPluginInfo('Blubber');
     $statement = DBManager::get()->prepare("\r\n            SELECT seminare.Seminar_id\r\n            FROM seminar_user\r\n                INNER JOIN seminare ON (seminare.Seminar_id = seminar_user.Seminar_id)\r\n            WHERE seminar_user.user_id = :me\r\n                AND seminare.status IN (:mandatory_types)\r\n                AND seminare.status NOT IN (:forbidden_types)\r\n\r\n            UNION DISTINCT SELECT seminare.Seminar_id\r\n            FROM seminar_user\r\n                INNER JOIN seminare ON (seminare.Seminar_id = seminar_user.Seminar_id)\r\n                INNER JOIN plugins_activated ON (pluginid = :blubber_plugin_id\r\n                    AND plugins_activated.poiid = CONCAT('sem', seminare.Seminar_id))\r\n            WHERE seminar_user.user_id = :me\r\n                AND plugins_activated.state = 'on'\r\n                AND seminare.status NOT IN (:forbidden_types)\r\n\r\n            UNION DISTINCT SELECT seminare.Seminar_id\r\n            FROM seminar_user\r\n                INNER JOIN seminare ON (seminare.Seminar_id = seminar_user.Seminar_id)\r\n                LEFT JOIN plugins_activated ON (pluginid = :blubber_plugin_id\r\n                    AND plugins_activated.poiid = CONCAT('sem', seminare.Seminar_id))\r\n            WHERE seminar_user.user_id = :me\r\n                AND plugins_activated.state IS NULL\r\n                AND seminare.status NOT IN (:forbidden_types)\r\n        ");
     $parameter = array('me' => $this->user_id);
     $parameter['mandatory_types'] = count($mandatory_types) ? $mandatory_types : null;
     $parameter['standard_types'] = count($standard_types) ? $standard_types : null;
     $parameter['forbidden_types'] = count($forbidden_types) ? $forbidden_types : array(-1);
     $parameter['blubber_plugin_id'] = $blubber_plugin_info['id'];
     $statement->execute($parameter);
     $my_courses = $statement->fetchFirst();
     if ($is_deputy) {
         $statement = DBManager::get()->prepare("SELECT deputies.range_id " . "FROM deputies " . "INNER JOIN seminare ON (seminare.Seminar_id = deputies.range_id) " . "LEFT JOIN plugins_activated ON (pluginid = :blubber_plugin_id AND plugins_activated.poiid = CONCAT('sem', seminare.Seminar_id)) " . "WHERE deputies.user_id = :me " . "AND (" . "seminare.status IN (:mandatory_types) " . "OR (plugins_activated.state = 'on') " . "OR (seminare.status IN (:standard_types) AND plugins_activated.state != 'off') " . ") " . "AND seminare.status NOT IN (:forbidden_types) " . "");
         $statement->execute($parameter);
         $my_courses = array_merge($my_courses, $statement->fetchFirst());
     }
     return $my_courses;
 }
Exemplo n.º 3
0
 /**
  * Returns the semType object that is defined for the course
  *
  * @return SemType The semTypeObject for the course
  */
 public function getSemType()
 {
     $semTypes = SemType::getTypes();
     if (isset($semTypes[$this->status])) {
         return $semTypes[$this->status];
     } else {
         Log::ERROR(sprintf('SemType not found id:%s status:%s', $this->id, $this->status));
         return new SemType(array('name' => 'Fehlerhafter Veranstaltungstyp'));
     }
 }
Exemplo n.º 4
0
 /**
  * Returns all courses matching set criteria.
  *
  * @param Array $params Additional parameters
  * @return Array of courses
  */
 private function getCourses($params = array())
 {
     // Init
     if ($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT === "all") {
         $inst = new SimpleCollection($this->insts);
         $inst->filter(function ($a) use(&$inst_ids) {
             $inst_ids[] = $a->Institut_id;
         });
     } else {
         $institut = new Institute($GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT);
         $inst_ids[] = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;
         if ($institut->isFaculty()) {
             foreach ($institut->sub_institutes->pluck("Institut_id") as $institut_id) {
                 $inst_ids[] = $institut_id;
             }
         }
     }
     $filter = AdminCourseFilter::get(true);
     $filter->where("sem_classes.studygroup_mode = '0'");
     if (is_object($this->semester)) {
         $filter->filterBySemester($this->semester->getId());
     }
     if ($params['typeFilter'] && $params['typeFilter'] !== "all") {
         list($class_filter, $type_filter) = explode('_', $params['typeFilter']);
         if (!$type_filter && !empty($GLOBALS['SEM_CLASS'][$class_filter])) {
             $type_filter = array_keys($GLOBALS['SEM_CLASS'][$class_filter]->getSemTypes());
         }
         $filter->filterByType($type_filter);
     }
     if ($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT) {
         $filter->filterBySearchString($GLOBALS['user']->cfg->ADMIN_COURSES_SEARCHTEXT);
     }
     if ($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER && $GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER !== "all") {
         $filter->filterByDozent($GLOBALS['user']->cfg->ADMIN_COURSES_TEACHERFILTER);
     }
     $filter->filterByInstitute($inst_ids);
     if ($params['sortby'] === "status") {
         $filter->orderBy(sprintf('sem_classes.name %s, sem_types.name %s, VeranstaltungsNummer', $params['sortFlag'], $params['sortFlag'], $params['sortFlag']), $params['sortFlag']);
     } elseif ($params['sortby'] === 'completion') {
         $filter->orderBy('is_complete', $params['sortFlag']);
     } elseif ($params['sortby']) {
         $filter->orderBy($params['sortby'], $params['sortFlag']);
     }
     $filter->storeSettings();
     $this->count_courses = $filter->countCourses();
     if ($this->count_courses && $this->count_courses <= $filter->max_show_courses) {
         $courses = $filter->getCourses();
     } else {
         return array();
     }
     if (in_array('contents', $params['view_filter'])) {
         $sem_types = SemType::getTypes();
         $modules = new Modules();
     }
     $seminars = array_map('reset', $courses);
     if (!empty($seminars)) {
         foreach ($seminars as $seminar_id => $seminar) {
             $dozenten = $this->getTeacher($seminar_id);
             $seminars[$seminar_id]['dozenten'] = $dozenten;
             if (in_array('teachers', $params['view_filter'])) {
                 if (SeminarCategories::getByTypeId($seminar['status'])->only_inst_user) {
                     $search_template = "user_inst_not_already_in_sem";
                 } else {
                     $search_template = "user_not_already_in_sem";
                 }
                 $sem_helper = new Seminar(Course::buildExisting($seminar));
                 $dozentUserSearch = new PermissionSearch($search_template, sprintf(_("%s suchen"), get_title_for_status('dozent', 1, $seminar['status'])), "user_id", array('permission' => 'dozent', 'seminar_id' => $this->course_id, 'sem_perm' => 'dozent', 'institute' => $sem_helper->getInstitutes()));
                 $seminars[$seminar_id]['teacher_search'] = MultiPersonSearch::get("add_member_dozent" . $seminar_id)->setTitle(_('Mehrere Lehrende hinzufügen'))->setSearchObject($dozentUserSearch)->setDefaultSelectedUser(array_keys($dozenten))->setDataDialogStatus(Request::isXhr())->setExecuteURL(URLHelper::getLink('dispatch.php/course/basicdata/add_member/' . $seminar_id, array('from' => 'admin/courses')));
             }
             if (in_array('contents', $params['view_filter'])) {
                 $seminars[$seminar_id]['sem_class'] = $sem_types[$seminar['status']]->getClass();
                 $seminars[$seminar_id]['modules'] = $modules->getLocalModules($seminar_id, 'sem', $seminar['modules'], $seminar['status']);
                 $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations($seminar_id, $seminars[$seminar_id], $seminars[$seminar_id]['sem_class'], $GLOBALS['user']->id);
             }
             if ($this->selected_action == 17) {
                 $seminars[$seminar_id]['admission_locked'] = false;
                 if ($seminar['course_set']) {
                     $set = new CourseSet($seminar['course_set']);
                     if (!is_null($set) && $set->hasAdmissionRule('LockedAdmission')) {
                         $seminars[$seminar_id]['admission_locked'] = 'locked';
                     } else {
                         $seminars[$seminar_id]['admission_locked'] = 'disable';
                     }
                     unset($set);
                 }
             }
         }
     }
     return $seminars;
 }
Exemplo n.º 5
0
 // set dummy navigation until db is ready
 Navigation::setRootNavigation(new Navigation(''));
 // set up default page layout
 PageLayout::initialize();
 //Besser hier globale Variablen definieren...
 $GLOBALS['_fullname_sql'] = array();
 $GLOBALS['_fullname_sql']['full'] = "TRIM(CONCAT(title_front,' ',Vorname,' ',Nachname,IF(title_rear!='',CONCAT(', ',title_rear),'')))";
 $GLOBALS['_fullname_sql']['full_rev'] = "TRIM(CONCAT(Nachname,', ',Vorname,IF(title_front!='',CONCAT(', ',title_front),''),IF(title_rear!='',CONCAT(', ',title_rear),'')))";
 $GLOBALS['_fullname_sql']['no_title'] = "CONCAT(Vorname ,' ', Nachname)";
 $GLOBALS['_fullname_sql']['no_title_rev'] = "CONCAT(Nachname ,', ', Vorname)";
 $GLOBALS['_fullname_sql']['no_title_short'] = "CONCAT(Nachname,', ',UCASE(LEFT(TRIM(Vorname),1)),'.')";
 $GLOBALS['_fullname_sql']['no_title_motto'] = "CONCAT(Vorname ,' ', Nachname,IF(motto!='',CONCAT(', ',motto),''))";
 $GLOBALS['_fullname_sql']['full_rev_username'] = "******";
 //Initialize $SEM_TYPE and $SEM_CLASS arrays
 $GLOBALS['SEM_CLASS'] = SemClass::getClasses();
 $GLOBALS['SEM_TYPE'] = SemType::getTypes();
 // set up global navigation
 Navigation::setRootNavigation(new StudipNavigation(''));
 /* set default umask to a sane value */
 umask(022);
 /*mail settings
   ----------------------------------------------------------------*/
 if ($GLOBALS['MAIL_TRANSPORT']) {
     $mail_transporter_name = strtolower($GLOBALS['MAIL_TRANSPORT']) . '_message';
 } else {
     $mail_transporter_name = 'smtp_message';
 }
 include 'vendor/email_message/email_message.php';
 include 'vendor/email_message/' . $mail_transporter_name . '.php';
 $mail_transporter_class = $mail_transporter_name . '_class';
 $mail_transporter = new $mail_transporter_class();
Exemplo n.º 6
0
 /**
  * Deletes the sem_class-object and all its sem_types. Will only delete,
  * if there are no seminars in this sem_class.
  * Remember to refresh the global $SEM_CLASS and $SEM_TYPE array.
  * @return boolean : success of deletion
  */
 public function delete()
 {
     if ($this->countSeminars() === 0) {
         foreach ($GLOBALS['SEM_TYPE'] as $sem_type) {
             if ($sem_type['class'] == $this->data['id']) {
                 $sem_type->delete();
             }
         }
         $GLOBALS['SEM_TYPE'] = SemType::getTypes();
         $db = DBManager::get();
         $statement = $db->prepare("DELETE FROM sem_classes " . "WHERE id = :id " . "");
         return $statement->execute(array('id' => $this->data['id']));
     } else {
         return false;
     }
 }