Example #1
0
 /**
  * getUser - retrieves data of a user
  *
  * @get /user/:user_id
  * @get /user
  */
 public function getUser($user_id = '')
 {
     $user_id = $user_id ?: $GLOBALS['user']->id;
     $user = \User::find($user_id);
     if (!$user) {
         $this->halt(404, sprintf('User %s not found', $user_id));
     }
     $visibilities = get_local_visibility_by_id($user_id, 'homepage');
     if (is_array(json_decode($visibilities, true))) {
         $visibilities = json_decode($visibilities, true);
     } else {
         $visibilities = array();
     }
     $get_field = function ($field, $visibility) use($user_id, $user, $visibilities) {
         if (!$user[$field] || !is_element_visible_for_user($GLOBALS['user']->id, $user_id, $visibilities[$visibility])) {
             return '';
         }
         return $user[$field];
     };
     $avatar = \Avatar::getAvatar($user_id);
     $user = array('user_id' => $user_id, 'username' => $user['username'], 'name' => self::getNamesOfUser($user), 'perms' => $user['perms'], 'email' => get_visible_email($user_id), 'avatar_small' => $avatar->getURL(\Avatar::SMALL), 'avatar_medium' => $avatar->getURL(\Avatar::MEDIUM), 'avatar_normal' => $avatar->getURL(\Avatar::NORMAL), 'avatar_original' => $avatar->getURL(\Avatar::ORIGINAL), 'phone' => $get_field('privatnr', 'private_phone'), 'homepage' => $get_field('Home', 'homepage'), 'privadr' => strip_tags($get_field('privadr', 'privadr')));
     $query = "SELECT value\n                  FROM user_config\n                  WHERE field = ? AND user_id = ?";
     $statement = \DBManager::get()->prepare($query);
     $statement->execute(array('SKYPE_NAME', $user_id));
     $user['skype'] = $statement->fetchColumn() ?: '';
     $statement->closeCursor();
     if ($user['skype']) {
         $statement->execute(array('SKYPE_ONLINE_STATUS', $user_id));
         $user['skype_show'] = (bool) $statement->fetchColumn();
     } else {
         $user['skype_show'] = false;
     }
     // Data fields
     $datafields = array();
     foreach (\DataFieldEntry::getDataFieldEntries($user_id, 'user') as $entry) {
         if (!$entry->isVisible()) {
             continue;
         }
         if (!\Visibility::verify($entry->getID(), $user_id)) {
             continue;
         }
         $datafields[] = array('type' => $entry->getType(), 'id' => $entry->getId(), 'name' => $entry->getName(), 'value' => $entry->getValue());
     }
     $user['datafields'] = $datafields;
     $this->etag(md5(serialize($user)));
     return $user;
 }
Example #2
0
 /**
  * Set defaults for a single datafield of a statusgruppe.
  *
  * @param String $inst_id Id of the institute in question
  * @param String $role_id Id of the statusgruppe in question
  * @param String $datafield_id Id of the datafield in question
  * @param bool $state Indicates whether the defaults should be used or not
  */
 public function default_action($inst_id, $role_id, $datafield_id, $state)
 {
     $value = 'default_value';
     if (!$state) {
         $defaults = DataFieldEntry::getDataFieldEntries(array($this->user->user_id, $inst_id));
         $value = $defaults[$datafield_id]->getValue();
     }
     $entry = new DatafieldEntryModel($datafield_id);
     $entry->range_id = $this->user->user_id;
     $entry->sec_range_id = $role_id;
     $entry->content = $value;
     $entry->store();
     $this->redirect('settings/statusgruppen#' . $role_id);
 }
Example #3
0
 /**
  * Ändert alle Grunddaten der Veranstaltung (bis auf Personal) und leitet
  * danach weiter auf View.
  */
 public function set_action($course_id)
 {
     global $perm;
     $sem = Seminar::getInstance($course_id);
     $this->msg = array();
     $old_settings = $sem->getSettings();
     //Seminar-Daten:
     if ($perm->have_studip_perm("tutor", $sem->getId())) {
         $changemade = false;
         foreach (Request::getInstance() as $req_name => $req_value) {
             if (substr($req_name, 0, 7) === "course_") {
                 $varname = substr($req_name, 7);
                 if ($varname === "name" && !$req_value) {
                     $this->msg[] = array("error", _("Name der Veranstaltung darf nicht leer sein."));
                 } elseif ($sem->{$varname} != $req_value) {
                     $sem->{$varname} = $req_value;
                     $changemade = true;
                 }
             }
         }
         //seminar_inst:
         if (!LockRules::Check($course_id, 'seminar_inst') && $sem->setInstitutes(Request::optionArray('related_institutes'))) {
             $changemade = true;
         }
         //Datenfelder:
         $invalid_datafields = array();
         $all_fields_types = DataFieldEntry::getDataFieldEntries($sem->id, 'sem', $sem->status);
         foreach (Request::getArray('datafields') as $datafield_id => $datafield_value) {
             $datafield = $all_fields_types[$datafield_id];
             $valueBefore = $datafield->getValue();
             $datafield->setValueFromSubmit($datafield_value);
             if ($valueBefore != $datafield->getValue()) {
                 if ($datafield->isValid()) {
                     $datafield->store();
                     $changemade = true;
                 } else {
                     $invalid_datafields[] = $datafield->getName();
                 }
             }
         }
         if (count($invalid_datafields)) {
             $message = ngettext('%s der Veranstaltung wurde falsch angegeben', '%s der Veranstaltung wurden falsch angegeben', count($invalid_datafields));
             $message .= ', ' . _('bitte korrigieren Sie dies unter "Beschreibungen"') . '.';
             $message = sprintf($message, join(', ', array_map('htmlReady', $invalid_datafields)));
             $this->msg[] = array('error', $message);
         }
         $sem->store();
         // Logging
         $before = array_diff_assoc($old_settings, $sem->getSettings());
         $after = array_diff_assoc($sem->getSettings(), $old_settings);
         //update admission, if turnout was raised
         if ($after['admission_turnout'] > $before['admission_turnout'] && $sem->isAdmissionEnabled()) {
             update_admission($sem->getId());
         }
         if (sizeof($before) && sizeof($after)) {
             foreach ($before as $k => $v) {
                 $log_message .= "{$k}: {$v} => " . $after[$k] . " \n";
             }
             log_event('CHANGE_BASIC_DATA', $sem->getId(), " ", $log_message);
         }
         // end of logging
         if ($changemade) {
             $this->msg[] = array("msg", _("Die Grunddaten der Veranstaltung wurden verändert."));
         }
     } else {
         $this->msg[] = array("error", _("Sie haben keine Berechtigung diese Veranstaltung zu verändern."));
     }
     //Labels/Funktionen für Dozenten und Tutoren
     if ($perm->have_studip_perm("dozent", $sem->getId())) {
         foreach (Request::getArray("label") as $user_id => $label) {
             $sem->setLabel($user_id, $label);
         }
     }
     foreach ($sem->getStackedMessages() as $key => $messages) {
         foreach ($messages['details'] as $message) {
             $this->msg[] = array($key !== "success" ? $key : "msg", $message);
         }
     }
     $this->flash['msg'] = $this->msg;
     $this->flash['open'] = Request::get("open");
     $this->redirect($this->url_for('course/basicdata/view/' . $sem->getId()));
 }
    private function getContentListPersons () {
        if (!$nameformat = $this->config->getValue('Main', 'nameformat')) {
            $nameformat = 'full_rev';
        }
        
        $selected_item_ids = $this->config->getValue('SelectInstitutes', 'institutesselected');
        // at least one institute has to be selected in the configuration
        if (!is_array($selected_item_ids)) {
            return array();
        }
        
        $sort = $this->config->getValue('Main', 'sort');
        $query_order = '';
        foreach ($sort as $key => $position) {
            if ($position > 0) {
                $query_order[$position] = $this->data_fields[$key];
            }
        }
        if ($query_order) {
            ksort($query_order, SORT_NUMERIC);
            $query_order = ' ORDER BY ' . implode(',', $query_order);
        }
        
        $module_params = $this->getModuleParams($this->approved_params);
        
        $db = new DB_Seminar();
        
        $dbv = DbView::getView('sem_tree');

        if ($module_params['initiale']) {
            if ($this->config->getValue('Main', 'onlylecturers')) {
                $current_semester = get_sem_num(time());
                $query = sprintf("SELECT ui.Institut_id, su.user_id "
                . "FROM seminar_user su "
                . "LEFT JOIN seminare s USING (seminar_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "LEFT JOIN user_inst ui USING(user_id) "
                . "WHERE LOWER(LEFT(TRIM(aum.Nachname), 1)) = LOWER('%s') "
                . "AND su.status = 'dozent' "
                . "AND s.visible = 1 "
                . "AND ((%s) = %s OR ((%s) <= %s  AND ((%s) >= %s OR (%s) = -1))) "
                . "AND ui.Institut_id IN ('%s') "
                . "AND ui.inst_perms = 'dozent' "
                . "AND ui.externdefault = 1 "
                . "AND " . get_ext_vis_query(),
                substr($module_params['initiale'], 0, 1),
                $dbv->sem_number_sql,
                $current_semester,
                $dbv->sem_number_sql,
                $current_semester,
                $dbv->sem_number_end_sql,
                $current_semester,
                $dbv->sem_number_end_sql,
                implode("','", $selected_item_ids));
            } else {
                    // get only users with the given status
                $query = sprintf("SELECT ui.Institut_id, ui.user_id "
                    . "FROM user_inst ui "
                    . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                    . "WHERE LOWER(LEFT(TRIM(aum.Nachname), 1)) = LOWER('%s') "
                    . "AND ui.inst_perms IN('%s') "
                    . "AND ui.Institut_id IN ('%s') "
                    . "AND ui.externdefault = 1 "
                    . "AND " . get_ext_vis_query(),
                    substr($module_params['initiale'], 0, 1),
                    implode("','", $this->config->getValue('Main', 'instperms')),
                    implode("','", $selected_item_ids));
            }
        // item_id is given and it is in the list of item_ids selected in the configuration
        } else if ($module_params['item_id'] && in_array($module_params['item_id'], $selected_item_ids)) {
            if ($this->config->getValue('Main', 'onlylecturers')) {
                $current_semester = get_sem_num(time());
                // get only users with status dozent in an visible seminar in the current semester
                $query = sprintf("SELECT ui.Institut_id, ui.user_id "
                    . "FROM user_inst ui "
                    . "LEFT JOIN seminar_user su USING(user_id) "
                    . "LEFT JOIN seminare s USING (seminar_id) "
                    . "WHERE ui.Institut_id = '%s' "
                    . "AND ui.inst_perms = 'dozent' "
                    . "AND ui.externdefault = 1 "
                    . "AND " . get_ext_vis_query()
                    . "AND su.status = 'dozent' "
                    . "AND s.visible = 1 "
                    . "AND ((%s) = %s OR ((%s) <= %s  AND ((%s) >= %s OR (%s) = -1))) ",
                    $module_params['item_id'],
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql);
            } else {
                // get only users with the given status
                $query = sprintf("SELECT ui.Institut_id, ui.user_id "
                    . "FROM user_inst ui "
                    . "WHERE ui.Institut_id = '%s' "
                    . "AND ui.inst_perms IN('%s') "
                    . "AND ui.externdefault = 1 "
                    . "AND " . get_ext_vis_query(),
                    $module_params['item_id'],
                    implode("','", $this->config->getValue('Main', 'instperms')));
            }
        } else {
            return array();
        }
            
        $db->query($query);
        
        $user_list = array();
        while ($db->next_record()) {
            if (!isset($user_list[$db->f('user_id')])) {
                $user_list[$db->f('user_id')] = $db->f('user_id') . $db->f('Institut_id');
            }
        }
        
        if (sizeof($user_list) == 0) {
            return array();
        }

        $query = sprintf(
            "SELECT ui.Institut_id, ui.raum, ui.sprechzeiten, ui.Telefon, "
            . "inst_perms,  i.Name, aum.Email, aum.user_id, username, "
            . "%s AS fullname, aum.Nachname, aum.Vorname "
            . "FROM user_inst ui "
            . "LEFT JOIN Institute i USING(Institut_id) "
            . "LEFT JOIN auth_user_md5 aum USING(user_id)"
            . "LEFT JOIN user_info uin USING(user_id) "
            . "WHERE CONCAT(ui.user_id, ui.Institut_id) IN ('%s') "
            . "AND " . get_ext_vis_query()
            . "ORDER BY aum.Nachname ",
            $GLOBALS['_fullname_sql'][$nameformat],
            implode("','", $user_list));
        $db->query($query);
        
        $j = 0;
        while ($db->next_record()) {
            $content['PERSONS']['PERSON'][$j]['FULLNAME'] = ExternModule::ExtHtmlReady($db->f('fullname'));
            $content['PERSONS']['PERSON'][$j]['LASTNAME'] = ExternModule::ExtHtmlReady($db->f('Nachname'));
            $content['PERSONS']['PERSON'][$j]['FIRSTNAME'] = ExternModule::ExtHtmlReady($db->f('Vorname'));
            $content['PERSONS']['PERSON'][$j]['TITLEFRONT'] = ExternModule::ExtHtmlReady($db->f('title_front'));
            $content['PERSONS']['PERSON'][$j]['TITLEREAR'] = ExternModule::ExtHtmlReady($db->f('title_rear'));
            $content['PERSONS']['PERSON'][$j]['PERSONDETAIL-HREF'] = $this->elements['LinkInternPersondetails']->createUrl(array('link_args' => 'username='******'username')));
            $content['PERSONS']['PERSON'][$j]['USERNAME'] = $db->f('username');
            $content['PERSONS']['PERSON'][$j]['INSTNAME'] = ExternModule::ExtHtmlReady($db->f('Name'));
            $content['PERSONS']['PERSON'][$j]['PHONE'] = ExternModule::ExtHtmlReady($db->f('Telefon'));
            $content['PERSONS']['PERSON'][$j]['ROOM'] = ExternModule::ExtHtmlReady($db->f('raum'));
            $content['PERSONS']['PERSON'][$j]['EMAIL'] = ExternModule::ExtHtmlReady(get_visible_email($db->f('user_id')));
            $content['PERSONS']['PERSON'][$j]['EMAIL-LOCAL'] = array_shift(explode('@', $content['PERSONS']['PERSON'][$j]['EMAIL']));
            $content['PERSONS']['PERSON'][$j]['EMAIL-DOMAIN'] = array_pop(explode('@', $content['PERSONS']['PERSON'][$j]['EMAIL']));
            $content['PERSONS']['PERSON'][$j]['OFFICEHOURS'] = ExternModule::ExtHtmlReady($db->f('sprechzeiten'));
            $content['PERSONS']['PERSON'][$j]['PERSON-NO'] = $j + 1;
            
            // generic data fields
            if (is_array($generic_datafields)) {
                $localEntries = DataFieldEntry::getDataFieldEntries($db->f('user_id'), 'user');
                $k = 1;
                foreach ($generic_datafields as $datafield) {
                    if (isset($localEntries[$datafield]) && is_object($localEntries[$datafield])) {
                        if ($localEntries[$datafield]->getType() == 'link') {
                            $localEntry = ExternModule::extHtmlReady($localEntries[$datafield]->getValue());
                        } else {
                            $localEntry = $localEntries[$datafield]->getDisplayValue();
                        }
                        if ($localEntry) {
                            $content['PERSONS']['PERSON'][$j]['DATAFIELD_' . $k] = $localEntry;
                        }
                    }
                    $k++;
                }
            }
            $j++;
        }
        if (!$module_params['initiale']) {
            $this->global_markers['INSTNAME'] = $content['PERSONS']['PERSON'][0]['INSTNAME'];
        } else {
            $this->global_markers['CHARACTER'] = substr($module_params['initiale'], 0, 1);
        }
        
        return $content;
    }
Example #5
0
function dump_sem($sem_id, $print_view = false)
{
    global $TERMIN_TYP, $SEM_TYPE, $SEM_CLASS, $_fullname_sql, $AUTO_INSERT_SEM;

    $Modules = new Modules;
    $Modules = $Modules->getLocalModules($sem_id);

    $query = "SELECT status, Name, Untertitel, art, VeranstaltungsNummer,
                     ects, Beschreibung, teilnehmer, vorrausetzungen,
                     lernorga, leistungsnachweis, Sonstiges, Institut_id,
                     admission_turnout
              FROM seminare
              WHERE Seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $seminar = $statement->fetch(PDO::FETCH_ASSOC);

    $sem_type = $seminar['status'];

    $sem = Seminar::getInstance($sem_id);

    $dump  = '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
    $dump .= '<tr><td colspan="2" align="left" class="table_header_bold">';
    $dump .= '<h1 class="table_header_bold">&nbsp;' . htmlReady($seminar['Name'], 1, 1) . '</h1>';
    $dump .= '</td></tr>' . "\n";

    // Helper function that dumps into a single table row
    $dumpRow = function ($title, $content, $escape = false) use (&$dump) {
        $content = trim($content);
        if ($content) {
            if ($escape) {
                $content = htmlReady($content, 1, 1);
            }
            $dump .= sprintf('<tr><td width="15%%"><b>%s</b></td><td>%s</td></tr>' . "\n",
                             htmlReady($title), $content);
        }
    };

    //Grunddaten des Seminars, wie in den seminar_main
    $dumpRow(_('Untertitel:'), $seminar['Untertitel'], true);

    if ($data = $sem->getDatesExport()) {
        $dumpRow(_('Zeit:'), nl2br($data));
    }

    $dumpRow(_('Semester:'), get_semester($sem_id));
    $dumpRow(_('Erster Termin:'), veranstaltung_beginn($sem_id, 'export'));

    if ($temp = vorbesprechung($sem_id, 'export')) {
        $dumpRow(_('Vorbesprechung:'), htmlReady($temp));
    }

    if ($data = $sem->getDatesTemplate('dates/seminar_export_location')) {
        $dumpRow(_('Ort:'), nl2br($data));
    }

    //wer macht den Dozenten?
    $query = "SELECT {$_fullname_sql['full']} AS fullname
              FROM seminar_user
              LEFT JOIN auth_user_md5 USING (user_id)
              LEFT JOIN user_info USING (user_id)
              WHERE Seminar_id = ? AND status = 'dozent'
              ORDER BY position, Nachname";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $teachers = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($teachers) > 0) {
        $title = get_title_for_status('dozent', count($teachers), $sem_type);
        $dumpRow($title, implode('<br>', array_map('htmlReady', $teachers)));
    }

    //und wer ist Tutor?
    $query = "SELECT {$_fullname_sql['full']} AS fullname
              FROM seminar_user
              LEFT JOIN auth_user_md5 USING (user_id)
              LEFT JOIN user_info USING (user_id)
              WHERE Seminar_id = ? AND status = 'tutor'
              ORDER BY position, Nachname";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $tutors = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($tutors) > 0) {
        $title = get_title_for_status('tutor', count($tutors), $sem_type);
        $dumpRow($title, implode('<br>', array_map('htmlReady', $tutors)));
    }

    if ($seminar['status'] != '' && isset($SEM_TYPE[$seminar['status']])) {
        $content  = $SEM_TYPE[$seminar['status']]['name'];
        $content .= ' ' . _('in der Kategorie') . ' ';
        $content .= '<b>' . $SEM_CLASS[$SEM_TYPE[$seminar['status']]['class']]['name'] . '</b>';
        $dumpRow(_('Typ der Veranstaltung'), $content);
    }

    $dumpRow(_('Art der Veranstaltung:'), $seminar['art'], true);
    $dumpRow(_('VeranstaltungsNummer:'), htmlReady($seminar['VeranstaltungsNummer']));
    $dumpRow(_('ECTS-Punkte:'), htmlReady($seminar['ects']));
    $dumpRow(_('Beschreibung:'), $seminar['Beschreibung'], true);
    $dumpRow(_('Teilnehmende:'), $seminar['teilnehmende'], true);
    $dumpRow(_('Voraussetzungen:'), $seminar['vorrausetzungen'], true);
    $dumpRow(_('Lernorganisation:'), $seminar['lernorga'], true);
    $dumpRow(_('Leistungsnachweis:'), $seminar['leistungsnachweis'], true);

    //add the free adminstrable datafields
    $localEntries = DataFieldEntry::getDataFieldEntries($sem_id);
    foreach ($localEntries as $entry) {
        $dumpRow($entry->getName(), $entry->getDisplayValue());
    }

    $dumpRow(_('Sonstiges:'), $seminar['Sonstiges'], true);

    // Fakultaeten...
    $query = "SELECT DISTINCT c.Name
              FROM seminar_inst AS a
              LEFT JOIN Institute AS b USING (Institut_id)
              LEFT JOIN Institute AS c ON (c.Institut_id = b.fakultaets_id)
              WHERE a.seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $faculties = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($faculties) > 0) {
        $dumpRow(_('Fakultät(en):'), implode('<br>', array_map('htmlReady', $faculties)));
    }

    //Studienbereiche
    if (isset($SEM_TYPE[$seminar['status']]) && $SEM_CLASS[$SEM_TYPE[$seminar['status']]['class']]['bereiche']) {
        $sem_path = get_sem_tree_path($sem_id) ?: array();
        $dumpRow(_('Studienbereiche') . ':', implode('<br>', array_map('htmlReady', $sem_path)));
    }

    $iid = $seminar['Institut_id'];
    $query = "SELECT Name FROM Institute WHERE Institut_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($iid));
    $inst_name = $statement->fetchColumn();
    $dumpRow(_('Heimat-Einrichtung:'), $inst_name, true);

    $query = "SELECT Name
              FROM seminar_inst
              LEFT JOIN Institute USING (institut_id)
              WHERE seminar_id = ? AND Institute.institut_id != ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id, $iid));
    $other_institutes = $statement->fetchAll(PDO::FETCH_COLUMN);
    if (count($other_institutes) > 0) {
        $title = (count($other_institutes) == 1)
               ? _('Beteiligte Einrichtung:')
               : _('Beteiligte Einrichtungen:');
        $dumpRow($title, implode(', ', array_map('htmlReady', $other_institutes)));
    }

    //Teilnehmeranzahl
    $dumpRow(_('max. Personenanzahl:'), $seminar['admission_turnout']);

    //Statistikfunktionen
    $query = "SELECT COUNT(*) FROM seminar_user WHERE Seminar_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($sem_id));
    $count = $statement->fetchColumn();
    $dumpRow(_('Anzahl der angemeldeten Personen:'), $count);

    // number of postings for all forum-modules in this seminar
    $count = 0;
    $forum_modules = PluginEngine::getPlugins('ForumModule', $sem_id);
    foreach ($forum_modules as $plugin) {
        $count += $plugin->getNumberOfPostingsForSeminar($sem_id);
    }
    $dumpRow(_('Forenbeiträge:'), $count);

    if ($Modules['documents']) {
        //do not show hidden documents
        $unreadable_folders = array();
        if ($print_view) {
            $check_user = $print_view === true ? $GLOBALS['user']->id : $print_view;
            if ($Modules['documents_folder_permissions'] || StudipDocumentTree::ExistsGroupFolders($sem_id)) {
                if (!$GLOBALS['perm']->have_studip_perm('tutor', $sem_id, $check_user)) {
                    $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $sem_id,'entity_type' => 'sem'));
                    $unreadable_folders = $folder_tree->getUnReadableFolders($check_user);
                }
            }
        }
        $query = "SELECT COUNT(*) FROM dokumente WHERE seminar_id = ?";
        $parameters = array($sem_id);

        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN(?)";
            $parameters[] = $unreadable_folders;
        }
        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $docs = $statement->fetchColumn();
    }
    $dumpRow(_('Dokumente:'), $docs ?: 0);

    $dump.= '</table>' . "\n";

    // Ablaufplan
    if ($Modules['schedule']) {
        $dump.= dumpRegularDatesSchedule($sem_id);
        $dump.= dumpExtraDatesSchedule($sem_id);
    }

    //SCM
    if ($Modules['scm']) {
        foreach(StudipScmEntry::findByRange_id($sem_id, 'ORDER BY position ASC') as $scm) {
            if (!empty($scm->content)) {
                $dump .= '<br>';
                $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
                $dump .= ' <tr><td align="left" class="table_header_bold">';
                $dump .= '<h2 class="table_header_bold">&nbsp;' . htmlReady($scm->tab_name) . '</h2>';
                $dump .= '</td></tr>' . "\n";
                $dump .= '<tr><td align="left" width="100%"><br>'. formatReady($scm->content, 1, 1) .'<br></td></tr>' . "\n";
                $dump .= '</table>' . "\n";
            }
        }
    }

    if ($Modules['literature']) {
        $lit = StudipLitList::GetFormattedListsByRange($sem_id, false, false);
        if ($lit) {
            $dump .= '<br>';
            $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
            $dump .= '<tr><td align="left" class="table_header_bold">';
            $dump .= '<h2 class="table_header_bold">&nbsp;' . _('Literaturlisten') . '</h2>';
            $dump .= '</td></tr>' . "\n";
            $dump .= '<tr><td align="left" width="100%"><br>'. $lit .'<br></td></tr>' . "\n";
            $dump .= '</table>' . "\n";
        }
    }

    // Dateien anzeigen
    if ($Modules['documents']) {

        $link_text = _('Hinweis: Diese Datei wurde nicht archiviert, da sie lediglich verlinkt wurde.');
        $query = "SELECT name, filename, mkdate, filesize, Nachname AS nachname,
                         IF(url != '', CONCAT('{$link_text}', ' / ', description), description) AS description
                  FROM dokumente
                  LEFT JOIN auth_user_md5 USING (user_id)
                  WHERE seminar_id = ?";
        $parameters = array($sem_id);

        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN (?)";
            $parameters[] = $unreadable_folders;
        }

        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $dbresult = $statement->fetchAll(PDO::FETCH_ASSOC);

        if (count($dbresult) > 0) {
            $dump .= '<br>';
            $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
            $dump .= '<tr><td align="left" colspan="3" class="table_header_bold">';
            $dump .= '<h2 class="table_header_bold">&nbsp;' . _('Dateien:') . '</h2>';
            $dump .= '</td></tr>' . "\n";

            foreach ($dbresult as $row) {
                $name = ($row['name'] && $row['name'] != $row['filename'])
                      ? $row['name'] . ' (' . $row['filename'] . ')'
                      : $row['filename'];
                $dump .= sprintf('<tr><td width="100%%"><b>%s</b><br>%s (%u KB)</td><td>%s</td><td>%s</td></tr>' . "\n",
                                 htmlReady($name),
                                 htmlReady($row['description']),
                                 round($row['filesize'] / 1024),
                                 htmlReady($row['nachname']),
                                 date('d.m.Y', $row['mkdate']));
            }

            $dump .= '</table>' . "\n";
        }
    }

    // Teilnehmer
    if ($Modules['participants']
        && (Config::get()->AUTO_INSERT_SEM_PARTICIPANTS_VIEW_PERM || !in_array($sem_id, AutoInsert::getAllSeminars(true))))
    {
        $dump .= '<br>';

        // Prepare statement that obtains the number of document a specific
        // user has uploaded into a specific seminar
        $documents_params = array($sem_id, null);
        $query = "SELECT COUNT(*) FROM dokumente WHERE Seminar_id = ? AND user_id = ?";
        if (count($unreadable_folders) > 0) {
            $query .= " AND range_id NOT IN (?)";
            $documents_params[] = $unreadable_folders;

        }
        $documents_statement = DBManager::get()->prepare($query);
        // Prepare statement that obtains all participants of a specific
        // seminar with a specific status
        $ext_vis_query = get_ext_vis_query('seminar_user');
        $query = "SELECT user_id, {$_fullname_sql['full']} AS fullname,
                         {$ext_vis_query} AS user_is_visible
                    FROM seminar_user
                    LEFT JOIN auth_user_md5 USING (user_id)
                    LEFT JOIN user_info USING (user_id)
                    WHERE Seminar_id = ? AND status = ?
                    GROUP by user_id
                    ORDER BY Nachname, Vorname";
        $user_statement = DBManager::get()->prepare($query);

        foreach (words('dozent tutor autor user') as $key) {
            // die eigentliche Teil-Tabelle

            $user_statement->execute(array($sem_id, $key));
            $users = $user_statement->fetchAll(PDO::FETCH_ASSOC);
            $user_statement->closeCursor();

            //haben wir in der Personengattung ueberhaupt einen Eintrag?
            if (count($users) > 0) {
                $dump .= '<table width="100%" border="1" cellpadding="2" cellspacing="0">';
                $dump .= '<tr><td align="left" colspan="3" class="table_header_bold">';
                $dump .= '<h2 class="table_header_bold">&nbsp;' . get_title_for_status($key, count($users), $sem_type) . '</h2>';
                $dump .= '</td></tr>' . "\n";
                $dump .= '<th width="30%">' . _('Name') . '</th>';
                $dump .= '<th width="10%">' . _('Forenbeiträge') . '</th>';
                $dump .= '<th width="10%">' . _('Dokumente') . '</th></tr>' . "\n";

                foreach ($users as $user) {
                    $documents_params[1] = $user['user_id'];
                    $documents_statement->execute($documents_params);
                    $count = $documents_statement->fetchColumn() ?: 0;
                    $documents_statement->closeCursor();

                    // get number of postings for this user from all forum-modules
                    $postings = 0;
                    foreach ($forum_modules as $plugin) {
                        $postings += $plugin->getNumberOfPostingsForUser($user['user_id'], $sem_id);
                    }

                    $dump .= sprintf('<tr><td>%s</td><td align="center">%u</td><td align="center">%u</td></tr>' . "\n",
                                     $user['user_is_visible'] ? htmlReady($user['fullname']) : _('(unsichtbareR NutzerIn)'),
                                     $postings, $count);
                } // eine Zeile zuende

                $dump.= '</table>' . "\n";
            }
        } // eine Gruppe zuende
    }

    return $dump;
} // end function dump_sem($sem_id)
Example #6
0
<? 
    use Studip\Button, Studip\LinkButton;

    // Datenfelder für Rollen in Einrichtungen ausgeben
    // Default-Daten der Einrichtung
    $entries = (array)DataFieldEntry::getDataFieldEntries(array($user->user_id, $inst_id), 'userinstrole')
?>

<tr>
    <td class="<?php 
echo $followers ? 'in-between' : 'blank';
?>
">&nbsp;</td>
    <td colspan="2" class="centered">

        <br>
        <form action="<?php 
echo $controller->url_for('settings/statusgruppen/store/institute', $inst_id);
?>
" method="post">
            <?php 
echo CSRFProtection::tokenTag();
?>
            <input type="hidden" name="name" value="<?php 
echo htmlReady($institute['Name']);
?>
">

            <table class="default settings" style="width:90%">
                <colgroup>
                    <col width="50%">
Example #7
0
            $email = get_visible_email($row['user_id']);
            $data['content'] = array(
                'Nachname'     => $this->elements['LinkIntern']->toString(array(
                                      'content'   => htmlReady($row['fullname']),
                                      'module'    => 'Persondetails',
                                      'link_args' => 'username='******'username']
                                  )),
                'Telefon'      => htmlReady($row['Telefon']),
                'sprechzeiten' => htmlReady($row['sprechzeiten']),
                'raum'         => htmlReady($row['raum']),
                'Email'        => $this->elements['Link']->toString(array(
                                      'content' => htmlReady($email),
                                      'link'    => 'mailto:' . htmlReady($email)
                                  ))
            );

            // generic data fields
            if (is_array($generic_datafields)) {
                $localEntries = DataFieldEntry::getDataFieldEntries($row['user_id']);
                foreach ($generic_datafields as $id) {
                    $data['content'][$id] = is_object($localEntries[$id]) ? $localEntries[$id]->getDisplayValue() : '';
                }
            }
            $out .= $this->elements['TableRow']->toString($data);
        }
        $first_loop = FALSE;
    }
}

$this->elements['TableHeader']->printout(array('content' => $out));
Example #8
0
 /**
  * Collect user datafield informations
  *
  * @return array
  */
 function getDatafields()
 {
     // generische Datenfelder aufsammeln
     $short_datafields = array();
     $long_datafields = array();
     foreach (DataFieldEntry::getDataFieldEntries($this->current_user->user_id, 'user') as $entry) {
         if ($entry->isVisible() && $entry->getDisplayValue() && Visibility::verify($entry->getID(), $this->current_user->user_id)) {
             if ($entry instanceof DataFieldTextareaEntry) {
                 $long_datafields[] = $entry;
             } else {
                 $short_datafields[] = $entry;
             }
         }
     }
     return array('long' => $long_datafields, 'short' => $short_datafields);
 }
Example #9
0
<? use Studip\Button, Studip\LinkButton; ?>

<?
    $default_entries = DataFieldEntry::getDataFieldEntries(array($user->user_id, $inst_id));
?>

<tr>
    <td class="<?php 
echo $followers ? 'in-between' : 'blank';
?>
">&nbsp;</td>
    <td style="text-align: center;" colspan="2">

        <br>
        <form action="<?php 
echo $controller->url_for('settings/statusgruppen/store/role', $role_id);
?>
" method="post">
            <?php 
echo CSRFProtection::tokenTag();
?>
            <input type="hidden" name="studip_ticket" value="<?php 
echo get_ticket();
?>
">
            <input type="hidden" name="name[<?php 
echo $inst_id;
?>
]" value="<?php 
echo htmlReady($institute['Name']);
?>
    function toString ($args) {
        $out = "";
        $this->seminar_id = $args["seminar_id"];
        $query = "SELECT * FROM seminare WHERE Seminar_id = ?";
        $parameters = array($this->seminar_id);
        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $row = $statement->fetch(PDO::FETCH_ASSOC);
        
        $visible = $this->config->getValue("Main", "visible");
        $j = -1;
        if ($row !== false) {

            $data["name"] = htmlReady($row['Name']);

            if ($visible[++$j] && $row['Untertitel'])
                $data["subtitle"] = htmlReady($row['Untertitel']);

            if ($visible[++$j]) {
                if (!$name_sql = $this->config->getValue("Main", "nameformat"))
                    $name_sql = "full";
                $name_sql = $GLOBALS['_fullname_sql'][$name_sql];

                $query = "SELECT $name_sql AS name, username, position FROM seminar_user su LEFT JOIN
                        auth_user_md5 USING(user_id) LEFT JOIN user_info USING(user_id)
                        WHERE su.Seminar_id = ? AND su.status='dozent' ORDER BY position, username";
                $parameters = array($this->seminar_id);
                $statement = DBManager::get()->prepare($query);
                $statement->execute($parameters);
                while ($res = $statement->fetch(PDO::FETCH_ASSOC)) {
                    $data["lecturer"][] = $this->elements["LinkInternSimple"]->toString(
                            array("module" => "Persondetails",
                            "link_args" => "username="******"&seminar_id=" . $this->seminar_id,
                            "content" => $res['name'] ));
                }
                if (is_array($data["lecturer"]))
                    $data["lecturer"] = implode(", ", $data["lecturer"]);
            }

            if ($visible[++$j] && $row['art'])
                $data["art"] = htmlReady($row['art']);

            if ($visible[++$j]) {
                // reorganize the $SEM_TYPE-array
                foreach ($GLOBALS["SEM_CLASS"] as $key_class => $class) {
                    $i = 0;
                    foreach ($GLOBALS["SEM_TYPE"] as $key_type => $type) {
                        if ($type["class"] == $key_class) {
                            $i++;
                            $sem_types_position[$key_type] = $i;
                        }
                    }
                }

                $aliases_sem_type = $this->config->getValue("ReplaceTextSemType",
                        "class_" . $GLOBALS["SEM_TYPE"][$row['status']]['class']);
                if ($aliases_sem_type[$sem_types_position[$row['status']] - 1])
                    $data["status"] =  $aliases_sem_type[$sem_types_position[$row['status']] - 1];
                else
                    $data["status"] = htmlReady($GLOBALS["SEM_TYPE"][$row['status']]["name"]);
            }

            if ($visible[++$j] && $row['Beschreibung'])
                $data["description"] = formatLinks($row['Beschreibung']);

            if ($visible[++$j])
                $data["location"] = htmlReady(Seminar::getInstance($this->seminar_id)->getDatesTemplate('dates/seminar_export_location'));

            if ($visible[++$j])
                $data["semester"] = get_semester($this->seminar_id);

            if ($visible[++$j]) {
                $data["time"] = htmlReady(Seminar::getInstance($this->seminar_id)->getDatesExport());
                if ($first_app = vorbesprechung($this->seminar_id, 'export')) {
                    $data["time"] .= "<br>" . $this->config->getValue("Main", "aliaspredisc") . htmlReady($first_app);
                }
                if ($begin = Seminar::getInstance($this->seminar_id)->getFirstDate('export')) {
                    $data["time"] .= "<br>" . $this->config->getValue("Main", "aliasfirstmeeting") . htmlReady($begin);
                }
            }

            if ($visible[++$j] && $row['VeranstaltungsNummer'])
                $data["number"] = htmlReady($row['VeranstaltungsNummer']);

            if ($visible[++$j] && $row['teilnehmer'])
                $data["teilnehmer"] = htmlReady($row['teilnehmer']);

            if ($visible[++$j] && $row['vorrausetzungen'])
                $data["requirements"] = htmlReady($row['vorrausetzungen']);

            if ($visible[++$j] && $row['lernorga'])
                $data["lernorga"] = htmlReady($row['lernorga']);

            if ($visible[++$j] && $row['leistungsnachweis'])
                $data["leistung"] = htmlReady($row['leistungsnachweis']);

            if ($visible[++$j]) {
                $range_path_level = $this->config->getValue("Main", "rangepathlevel");
                $pathes = get_sem_tree_path($this->seminar_id, $range_path_level);
                if (is_array($pathes)) {
                    $data["range_path"] = htmlReady(implode("\n", array_values($pathes)),true,true);
                }
            }

            if ($visible[++$j] && $row['Sonstiges'])
                $data["misc"] = formatLinks($row['Sonstiges']);

            if ($visible[++$j] && $row['ects'])
                $data["ects"] = htmlReady($row['ects']);

            // generic data fields
            if ($generic_datafields = $this->config->getValue("Main", "genericdatafields")) {
                $localEntries = DataFieldEntry::getDataFieldEntries($this->seminar_id);
                foreach ($generic_datafields as $id) {
                    if ($visible[++$j] && isset($localEntries[$id]) && is_object($localEntries[$id])) {
                        $data[$id] = $localEntries[$id]->getDisplayValue();
                    }
                }
            }
            $out = $this->toStringMainTable($data, FALSE);
        }

        return $out;
    }
Example #11
0
 /**
  * Builds an array containing all available elements that are part of a
  * user's homepage together with their visibility. It isn't sufficient to
  * just load the visibility settings from database, because if the user
  * has added some data (e.g. CV) but not yet assigned a special visibility
  * to that field, it wouldn't show up.
  *
  * @return array An array containing all available homepage elements
  * together with their visibility settings in the form
  * $name => $visibility.
  */
 public function get_homepage_elements()
 {
     global $NOT_HIDEABLE_FIELDS;
     $query = "SELECT user_info.*, auth_user_md5.*\n                  FROM auth_user_md5\n                  LEFT JOIN user_info USING (user_id)\n                  WHERE user_id = ?";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array($this->auth_user['user_id']));
     $my_data = $statement->fetch(PDO::FETCH_ASSOC);
     $homepage_visibility = get_local_visibility_by_id($this->auth_user['user_id'], 'homepage');
     if (is_array(json_decode($homepage_visibility, true))) {
         $homepage_visibility = json_decode($homepage_visibility, true);
     } else {
         $homepage_visibility = array();
     }
     // News
     $news = StudipNews::GetNewsByRange($this->auth_user['user_id'], true);
     // Non-private dates.
     if (Config::get()->CALENDAR_ENABLE) {
         $dates = CalendarEvent::countBySql('range_id = ?', array($this->auth_user['user_id']));
     }
     // Votes
     if (Config::get()->VOTE_ENABLE) {
         //$voteDB = new VoteDB();
         $activeVotes = Questionnaire::countBySQL("user_id = ? AND visible = '1'", array($this->auth_user['user_id']));
         $stoppedVotes = Questionnaire::countBySQL("user_id = ? AND visible = '0'", array($this->auth_user['user_id']));
     }
     // Evaluations
     $evalDB = new EvaluationDB();
     $activeEvals = $evalDB->getEvaluationIDs($this->auth_user['user_id'], EVAL_STATE_ACTIVE);
     // Literature
     $lit_list = StudipLitList::GetListsByRange($this->auth_user['user_id']);
     // Free datafields
     $data_fields = DataFieldEntry::getDataFieldEntries($this->auth_user['user_id'], 'user');
     // Homepage plugins
     //$homepageplugins = PluginEngine::getPlugins('HomepagePlugin');
     // Deactivate plugin visibility settings because they aren't working now.
     $homepageplugins = array();
     $user_domains = count(UserDomain::getUserDomains());
     // Now join all available elements with visibility settings.
     $homepage_elements = array();
     if (Avatar::getAvatar($this->auth_user['user_id'])->is_customized() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['picture']) {
         $homepage_elements["picture"] = array("name" => _("Eigenes Bild"), "visibility" => $homepage_visibility["picture"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten');
     }
     if ($my_data["motto"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['motto']) {
         $homepage_elements["motto"] = array("name" => _("Motto"), "visibility" => $homepage_visibility["motto"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
     }
     if (Config::get()->ENABLE_SKYPE_INFO) {
         if ($GLOBALS['user']->cfg->getValue('SKYPE_NAME') && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['skype_name']) {
             $homepage_elements["skype_name"] = array("name" => _("Skype Name"), "visibility" => $homepage_visibility["skype_name"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
             if ($GLOBALS['user']->cfg->getValue('SKYPE_ONLINE_STATUS')) {
                 $homepage_elements["skype_online_status"] = array("name" => _("Skype Online Status"), "visibility" => $homepage_visibility["skype_online_status"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
             }
         }
     }
     if ($my_data["privatnr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['Private Daten_phone']) {
         $homepage_elements["private_phone"] = array("name" => _("Private Telefonnummer"), "visibility" => $homepage_visibility["private_phone"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
     }
     if ($my_data["privatcell"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['private_cell']) {
         $homepage_elements["private_cell"] = array("name" => _("Private Handynummer"), "visibility" => $homepage_visibility["private_cell"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
     }
     if ($my_data["privadr"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['privadr']) {
         $homepage_elements["privadr"] = array("name" => _("Private Adresse"), "visibility" => $homepage_visibility["privadr"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
     }
     if ($my_data["Home"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['homepage']) {
         $homepage_elements["homepage"] = array("name" => _("Homepage-Adresse"), "visibility" => $homepage_visibility["homepage"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten');
     }
     if ($news && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['news']) {
         $homepage_elements["news"] = array("name" => _("Ankündigungen"), "visibility" => $homepage_visibility["news"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten');
     }
     if (Config::get()->CALENDAR_ENABLE && $dates && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['dates']) {
         $homepage_elements["termine"] = array("name" => _("Termine"), "visibility" => $homepage_visibility["termine"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Allgemeine Daten');
     }
     if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['votes']) {
         $homepage_elements["votes"] = array("name" => _("Fragebögen"), "visibility" => $homepage_visibility["votes"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten');
     }
     $query = "SELECT 1\n                  FROM user_inst\n                  LEFT JOIN Institute USING (Institut_id)\n                  WHERE user_id = ? AND inst_perms = 'user'";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array($this->auth_user['user_id']));
     if ($statement->fetchColumn() && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['studying']) {
         $homepage_elements["studying"] = array("name" => _("Wo ich studiere"), "visibility" => $homepage_visibility["studying"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Studien-/Einrichtungsdaten');
     }
     if ($lit_list && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['literature']) {
         $homepage_elements["literature"] = array("name" => _("Literaturlisten"), "visibility" => $homepage_visibility["literature"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Allgemeine Daten');
     }
     if ($my_data["lebenslauf"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['lebenslauf']) {
         $homepage_elements["lebenslauf"] = array("name" => _("Lebenslauf"), "visibility" => $homepage_visibility["lebenslauf"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten');
     }
     if ($my_data["hobby"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['hobby']) {
         $homepage_elements["hobby"] = array("name" => _("Hobbies"), "visibility" => $homepage_visibility["hobby"] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Private Daten');
     }
     if ($my_data["publi"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['publi']) {
         $homepage_elements["publi"] = array("name" => _("Publikationen"), "visibility" => $homepage_visibility["publi"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten');
     }
     if ($my_data["schwerp"] && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']]['schwerp']) {
         $homepage_elements["schwerp"] = array("name" => _("Arbeitsschwerpunkte"), "visibility" => $homepage_visibility["schwerp"] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Private Daten');
     }
     if ($data_fields) {
         foreach ($data_fields as $key => $field) {
             if ($field->getValue() && $field->isEditable($this->auth_user['perms']) && !$NOT_HIDEABLE_FIELDS[$this->auth_user['perms']][$key]) {
                 $homepage_elements[$key] = array('name' => $field->getName(), 'visibility' => $homepage_visibility[$key] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'extern' => true, 'category' => 'Zusätzliche Datenfelder');
             }
         }
     }
     $query = "SELECT kategorie_id, name\n                  FROM kategorien\n                  WHERE range_id = ?\n                  ORDER BY priority";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array($this->auth_user['user_id']));
     while ($category = $statement->fetch(PDO::FETCH_ASSOC)) {
         $homepage_elements["kat_" . $category["kategorie_id"]] = array("name" => $category["name"], "visibility" => $homepage_visibility["kat_" . $category["kategorie_id"]] ?: get_default_homepage_visibility($this->auth_user['user_id']), "extern" => true, 'category' => 'Eigene Kategorien');
     }
     if ($homepageplugins) {
         foreach ($homepageplugins as $plugin) {
             $homepage_elements['plugin_' . $plugin->getPluginId()] = array("name" => $plugin->getPluginName(), "visibility" => $homepage_visibility["plugin_" . $plugin->getPluginId()] ?: get_default_homepage_visibility($this->auth_user['user_id']), 'category' => 'Plugins');
         }
     }
     return $homepage_elements;
 }
Example #12
0
 function getData()
 {
     global $invalidEntries;
     $role = array('id' => $this->statusgruppe_id, 'name' => $this->name, 'size' => $this->size, 'selfassign' => $this->selfassign, 'folder' => $this->hasFolder());
     // we fetch the generic datafields for roles if this is an institute
     if (!$this->isSeminar()) {
         $datafields = DataFieldEntry::getDataFieldEntries(array($this->range_id, $this->statusgruppe_id), 'roleinstdata');
         foreach ($datafields as $id => $field) {
             if (isset($invalidEntries[$id])) {
                 $invalid = true;
             } else {
                 $invalid = false;
             }
             $df[] = array('name' => $field->getName(), 'value' => $field->getValue(), 'html' => $field->getHTML('datafields'), 'datafield_id' => $field->getID(), 'datafield_type' => $field->getType(), 'invalid' => $invalid);
         }
         $role['datafields'] = $df;
     }
     return $role;
 }
Example #13
0
                }
                echo Icon::create('trash', 'clickable')->asImg(['class' => 'text-top']);
                echo "</a>&nbsp\n</td>\n";
            } else {
                echo '<td>&nbsp;</td>';
            }
        }

        echo "</tr>\n";

        // Statusgruppen kommen in neue Zeilen
        if ($structure["statusgruppe"]) {
            $statusgruppen = GetStatusgruppenForUser($member['user_id'], array_keys((array)$group_list));
            if (is_array($statusgruppen)) {
                foreach ($statusgruppen as $id) {
                    $entries = DataFieldEntry::getDataFieldEntries(array($member['user_id'], $id));

                    echo '<tr>';
                    for ($i = 0; $i <= $pre_cells; $i++) {
                        echo '<td>&nbsp;</td>';
                    }

                    echo '<td><font size="-1">';

                    if ($admin_view) {
                        echo '<a href="'.URLHelper::getLink('admin_statusgruppe.php?role_id='.$id.'&cmd=displayRole').'">'.htmlReady($group_list[$id]).'</a>';
                    } else {
                        echo htmlReady($group_list[$id]);
                    }

                    echo '</font></td>';
    function getContent () {
        global $SEM_TYPE, $SEM_CLASS, $sem_type_tmp;

        if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {

            // show only selected subject areas
            $selected_ranges = (array) $this->module->config->getValue('SelectSubjectAreas', 'subjectareasselected');
            $selected_ranges[] = $this->sem_browse_data['start_item_id'];
            if (!$this->module->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')
                    && count($selected_ranges)) {
                if ($this->module->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id NOT IN ('".implode("','", $selected_ranges)."')";
                } else {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id IN ('".implode("','", $selected_ranges)."')";
                }
            } else {
                $sem_range_query = '';
            }

            // show only selected SemTypes
            $selected_semtypes = $this->module->config->getValue('ReplaceTextSemType', 'visibility');
            $sem_types_array = array();
            if (count($selected_semtypes)) {
                for ($i = 0; $i < count($selected_semtypes); $i++) {
                    if ($selected_semtypes[$i] == '1') {
                        $sem_types_array[] = $i + 1;
                    }
                }
                $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
            } else {
                $sem_types_query = '';
            }

            // number of visible columns
            $group_colspan = array_count_values((array) $this->module->config->getValue("Main", "visible"));

            if ($this->sem_browse_data['group_by'] == 1){
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
            $the_tree->buildIndex();
            }

            if (!$this->module->config->getValue("Main", "allseminars")){
                $sem_inst_query = " AND seminare.Institut_id='{$this->module->config->range_id}' ";
            }
            if (!$nameformat = $this->module->config->getValue("Main", "nameformat"))
                $nameformat = "no_title_short";

            $dbv = DbView::getView('sem_tree');

            $query = "SELECT seminare.*
                , Institute.Name AS Institut,Institute.Institut_id,
                seminar_sem_tree.sem_tree_id AS bereich, " . $GLOBALS['_fullname_sql'][$nameformat] ." AS fullname, auth_user_md5.username, Vorname, Nachname, title_front, title_rear,
                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end,
                seminar_user.position AS position FROM seminare
                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent')
                LEFT JOIN auth_user_md5 USING (user_id)
                LEFT JOIN user_info USING (user_id)
                LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)
                LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id)
                LEFT JOIN Institute ON (seminar_inst.institut_id = Institute.Institut_id)
                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result']))
                 . "') $sem_inst_query $sem_range_query $sem_types_query";

            $db = new DB_Seminar($query);
            $snap = new DbSnapshot($db);
            $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
            $data_fields[0] = "Seminar_id";
            if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']){
                $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
            }
            $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
            $sem_data = $snap->getGroupedResult("Seminar_id");
            if ($this->sem_browse_data['group_by'] == 0){
                $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number","Seminar_id"));
                foreach ($group_by_duration as $sem_number_end => $detail){
                    if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end - 1] && count($detail['sem_number']) == 1)){
                        continue;
                    } else {
                        foreach ($detail['Seminar_id'] as $seminar_id => $foo){
                            $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                            if ($sem_number_end == -1){
                                if (is_array($this->sem_number)){
                                    $sem_number_end = $this->sem_number[0];
                                } else {
                                    $sem_number_end = count($this->sem_dates)-1;
                                }
                            }
                            for ($i = $start_sem; $i <= $sem_number_end; ++$i){
                                if ($this->sem_number === false || (is_array($this->sem_number) && in_array($i,$this->sem_number))){
                                    if ($group_by_data[$i] && !$tmp_group_by_data[$i]){
                                        foreach($group_by_data[$i]['Seminar_id'] as $id => $bar){
                                            $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                        }
                                    }
                                    $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                                }
                            }
                        }
                    }
                }
                if (is_array($tmp_group_by_data)){
                    if ($this->sem_number !== false){
                        unset($group_by_data);
                    }
                    foreach ($tmp_group_by_data as $start_sem => $detail){
                        $group_by_data[$start_sem] = $detail;
                    }
                }
            }

            foreach ($group_by_data as $group_field => $sem_ids){
                foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo){
                    $name = strtolower(key($sem_data[$seminar_id]["Name"]));
                    $name = str_replace("ä","ae",$name);
                    $name = str_replace("ö","oe",$name);
                    $name = str_replace("ü","ue",$name);
                    $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
                }
                uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
            }

            switch ($this->sem_browse_data["group_by"]){
                    case 0:
                    krsort($group_by_data, SORT_NUMERIC);
                    break;

                    case 1:
                    uksort($group_by_data, create_function('$a,$b',
                            '$the_tree = TreeAbstract::GetInstance("StudipSemTree", false);
                            return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
                            '));
                    break;

                    case 3:
                    if ($order = $this->module->config->getValue("ReplaceTextSemType", "order")) {
                        foreach ((array) $order as $position) {
                            if (isset($group_by_data[$position]))
                                $group_by_data_tmp[$position] = $group_by_data[$position];
                        }
                        $group_by_data = $group_by_data_tmp;
                        unset($group_by_data_tmp);
                    }
                    else {
                        uksort($group_by_data, create_function('$a,$b',
                                'global $SEM_CLASS,$SEM_TYPE;
                                return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
                                                $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
                    }
                    break;
                    default:
                    uksort($group_by_data, 'strnatcasecmp');
                    break;

            }

            // generic datafields
            $generic_datafields = $this->module->config->getValue("Main", "genericdatafields");

            $content['__GLOBAL__']['LECTURES-COUNT'] = count($sem_data);
            $group_by_name = $this->module->config->getValue("Main", "aliasesgrouping");
            $content['__GLOBAL__']['LECTURES-SUBSTITUTE-GROUPED-BY'] = $group_by_name[$this->sem_browse_data['group_by']];

            $i = 0;
            foreach ((array) $group_by_data as $group_field => $sem_ids) {
                $content['LECTURES']['GROUP'][$i]['GROUP'] = $this->getGroupContent($the_tree, $group_field);
                $content['LECTURES']['GROUP'][$i]['GROUP-NO'] = $i + 1;

                if (is_array($sem_ids['Seminar_id'])) {
                    $zebra = 0;
                    $j = 0;
                    while (list($seminar_id,) = each($sem_ids['Seminar_id'])) {

                //      $sem_name = key($sem_data[$seminar_id]["Name"]);

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['TITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Name']));

                        $sem_number_start = key($sem_data[$seminar_id]['sem_number']);
                        $sem_number_end = key($sem_data[$seminar_id]['sem_number_end']);
                        $sem_semester = $this->sem_dates[$sem_number_start]['name'];
                        if ($sem_number_start != $sem_number_end){
                            $sem_semester .= ' - ' . ($sem_number_end == -1 ? _("unbegrenzt") : $this->sem_dates[$sem_number_end]['name']);
                        }

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMESTER'] = $sem_semester;

                        // create turnus field
                        $sem_turnus = Seminar::getInstance($seminar_id)->getDatesExport(array('show_room' => true));

                        // shorten, if string too long
                        if (strlen($sem_turnus) > 70) {
                            $sem_turnus = substr($sem_turnus, 0,
                                    strpos(substr($sem_turnus, 70, strlen($sem_turnus)), ",") +71);
                            $sem_turnus .= "...";
                        }
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['CYCLE'] = ExternModule::ExtHtmlReady($sem_turnus);

                        $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                        $doz_lastname = array_keys($sem_data[$seminar_id]['Nachname']);
                        $doz_firstname = array_keys($sem_data[$seminar_id]['Vorname']);
                        $doz_titlefront = array_keys($sem_data[$seminar_id]['title_front']);
                        $doz_titlerear = array_keys($sem_data[$seminar_id]['title_rear']);
                        $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                        $doz_position = array_keys($sem_data[$seminar_id]['position']);
                        if (sizeof($doz_position) < $doz_name) $doz_position = array_fill(0, sizeof($doz_name), 0);
                        if (is_array($doz_name)){
                            array_multisort($doz_position, $doz_name, $doz_uname);
                            $k = 0;
                            foreach ($doz_name as $index => $value) {
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['PERSONDETAIL-HREF'] = $this->module->elements['LinkInternPersondetails']->createUrl(array('link_args' => 'username='******'LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['FULLNAME'] = ExternModule::ExtHtmlReady($doz_name[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['LASTNAME'] = ExternModule::ExtHtmlReady($doz_lastname[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['FIRSTNAME'] = ExternModule::ExtHtmlReady($doz_firstname[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['TITLEFRONT'] = ExternModule::ExtHtmlReady($doz_titlefront[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['TITLEREAR'] = ExternModule::ExtHtmlReady($doz_titlerear[$index]);
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['UNAME'] = $doz_uname[$index];
                                $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTURERS'][$k]['LECTURER-NO'] = $k + 1;
                                $k++;
                            }
                        }

                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['LECTUREDETAILS-HREF'] = $this->module->elements['LinkInternLecturedetails']->createUrl(array('link_args' => 'seminar_id=' . $seminar_id));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['NUMBER'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['VeranstaltungsNummer']));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SUBTITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Untertitel']));
                        $aliases_sem_type = $this->module->config->getValue('ReplaceTextSemType', 'class_' . $SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']);
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMTYPE-SUBSTITUTE'] = $aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]['status'])] - 1];
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['SEMTYPE'] = ExternModule::ExtHtmlReady($SEM_TYPE[key($sem_data[$seminar_id]['status'])]['name']
                                    .' ('. $SEM_CLASS[$SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']]['name'] . ')');
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['ROOM'] = ExternModule::ExtHtmlReady(Seminar::getInstance($seminar_id)->getDatesTemplate('dates/seminar_export_location'));
                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['FORM'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['art']));

                        // generic data fields
                        if (is_array($generic_datafields)) {
                            $localEntries = DataFieldEntry::getDataFieldEntries($seminar_id, 'sem');
                            #$datafields = $datafields_obj->getLocalFields($seminar_id);
                            $l = 1;
                            foreach ($generic_datafields as $datafield) {
                                if (isset($localEntries[$datafield]) && is_object($localEntries[$datafield])) {
                                    $localEntry = $localEntries[$datafield]->getDisplayValue();
                                    if ($localEntry) {
                                        $content['LECTURES']['GROUP'][$i]['LECTURE'][$j]['DATAFIELD_' . $l] = $localEntry;
                                    }
                                }
                                $l++;
                            }

                        }

                        $j++;
                    }
                }
                $i++;
            }
        } else {
            $content['__GLOBAL__']['LECTURES-COUNT'] = 0;
            $group_by_name = $this->module->config->getValue('Main', 'aliasesgrouping');
            $content['__GLOBAL__']['LECTURES-SUBSTITUTE-GROUPED-BY'] = $group_by_name[$this->sem_browse_data['group_by']];
            $content['LECTURES']['NO-LECTURES']['NO-LECTURES-TEXT'] = ExternModule::ExtHtmlReady($this->module->config->getValue('Main', 'nodatatext'));
        }
        return $content;

    }
    function print_result () {
        global $_fullname_sql,$SEM_TYPE,$SEM_CLASS,$sem_type_tmp;
        
        $sem_link = $this->module->getModuleLink("Lecturedetails",
            $this->module->config->getValue("SemLink", "config"),
            $this->module->config->getValue("SemLink", "srilink"));
        
        $lecturer_link = $this->module->getModuleLink("Persondetails",
            $this->module->config->getValue("LecturerLink", "config"),
            $this->module->config->getValue("LecturerLink", "srilink"));
        
        if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {
            
            // show only selected subject areas
            $selected_ranges = $this->module->config->getValue('SelectSubjectAreas', 'subjectareasselected');
            if ($stid = Request::option('sem_tree_id')) {
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
                $the_tree->buildIndex();
                $selected_ranges = array_merge(array($stid), $the_tree->getKidsKids($stid));
            }
            if (!$this->module->config->getValue('SelectSubjectAreas', 'selectallsubjectareas')
                    && count($selected_ranges)) {
                if ($this->module->config->getValue('SelectSubjectAreas', 'reverseselection')) {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id NOT IN ('".implode("','", $selected_ranges)."')";
                } else {
                    $sem_range_query =  "AND seminar_sem_tree.sem_tree_id IN ('".implode("','", $selected_ranges)."')";
                }
            } else {
                $sem_range_query = '';
            }
            
            // show only selected SemTypes
            $selected_semtypes = $this->module->config->getValue('ReplaceTextSemType', 'visibility');
            if (Request::get('semstatus')) {
                $selected_semtypes = array(Request::get('semstatus'));
            }
            $sem_types_array = array();
            if (count($selected_semtypes)) {
                for ($i = 0; $i < count($selected_semtypes); $i++) {
                    if ($selected_semtypes[$i] == '1') {
                        $sem_types_array[] = $i + 1;
                    }
                }
                $sem_types_query = "AND seminare.status IN ('" . implode("','", $sem_types_array) . "')";
            } else {
                $sem_types_query = '';
            }
            
            // number of visible columns
            $group_colspan = array_count_values($this->module->config->getValue("Main", "visible"));
            
            if ($this->sem_browse_data['group_by'] == 1){
                if (!is_object($this->sem_tree)){
                    $the_tree = TreeAbstract::GetInstance("StudipSemTree");
                } else {
                    $the_tree =& $this->sem_tree->tree;
                }
            $the_tree->buildIndex();
            }
            
            if (!$this->module->config->getValue("Main", "allseminars") && !Request::get('allseminars')){
                $sem_inst_query = " AND seminare.Institut_id='{$this->module->config->range_id}' ";
            }
            if (Request::option('aggregation')) {
                $i = Institute::find($this->config->range_id);
                $children = $i->sub_institutes->pluck('institut_id');
                $sem_inst_query = " AND seminare.Institut_id IN ('".(implode("', '", $children))."')";
            }
            if (!$nameformat = $this->module->config->getValue("Main", "nameformat"))
                $nameformat = "no_title_short";
            
            $dbv = DbView::getView('sem_tree');
                
            $query = "SELECT seminare.* 
                , Institute.Name AS Institut,Institute.Institut_id,
                seminar_sem_tree.sem_tree_id AS bereich, " . $_fullname_sql[$nameformat] ." AS fullname, auth_user_md5.username,
                " . $dbv->sem_number_sql . " AS sem_number, " . $dbv->sem_number_end_sql . " AS sem_number_end, " . 
            " seminar_user.position AS position " . 
            " FROM seminare 
                LEFT JOIN seminar_user ON (seminare.Seminar_id=seminar_user.Seminar_id AND seminar_user.status='dozent') 
                LEFT JOIN auth_user_md5 USING (user_id) 
                LEFT JOIN user_info USING (user_id) 
                LEFT JOIN seminar_sem_tree ON (seminare.Seminar_id = seminar_sem_tree.seminar_id)
                LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.Seminar_id) 
                LEFT JOIN Institute ON (seminar_inst.institut_id = Institute.Institut_id)
                WHERE seminare.Seminar_id IN('" . join("','", array_keys($this->sem_browse_data['search_result']))
                 . "') $sem_inst_query $sem_range_query $sem_types_query";
            
            $db = new DB_Seminar($query);
            $snap = new DbSnapshot($db);
            $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field'];
            $data_fields[0] = "Seminar_id";
            if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']){
                $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'];
            }
            $group_by_data = $snap->getGroupedResult($group_field, $data_fields);
            $sem_data = $snap->getGroupedResult("Seminar_id");
            if ($this->sem_browse_data['group_by'] == 0){
                $group_by_duration = $snap->getGroupedResult("sem_number_end", array("sem_number","Seminar_id"));
                foreach ($group_by_duration as $sem_number_end => $detail){
                    if ($sem_number_end != -1 && ($detail['sem_number'][$sem_number_end - 1] && count($detail['sem_number']) == 1)){
                        continue;
                    } else {
                        foreach ($detail['Seminar_id'] as $seminar_id => $foo){
                            $start_sem = key($sem_data[$seminar_id]["sem_number"]);
                            if ($sem_number_end == -1){
                                if (is_array($this->sem_number)){
                                    $sem_number_end = $this->sem_number[0];
                                } else {
                                    $sem_number_end = count($this->sem_dates)-1;
                                }
                            }
                            for ($i = $start_sem; $i <= $sem_number_end; ++$i){
                                if ($this->sem_number === false || (is_array($this->sem_number) && in_array($i,$this->sem_number))){
                                    if ($group_by_data[$i] && !$tmp_group_by_data[$i]){
                                        foreach($group_by_data[$i]['Seminar_id'] as $id => $bar){
                                            $tmp_group_by_data[$i]['Seminar_id'][$id] = true;
                                        }
                                    }
                                    $tmp_group_by_data[$i]['Seminar_id'][$seminar_id] = true;
                                }
                            }
                        }
                    }
                }
                if (is_array($tmp_group_by_data)){
                    if ($this->sem_number !== false){
                        unset($group_by_data);
                    }
                    foreach ($tmp_group_by_data as $start_sem => $detail){
                        $group_by_data[$start_sem] = $detail;
                    }
                }
            }
            //release memory
            unset($snap);
            unset($tmp_group_by_data);
            
            foreach ($group_by_data as $group_field => $sem_ids){
                foreach ($sem_ids['Seminar_id'] as $seminar_id => $foo){
                    $name = strtolower(key($sem_data[$seminar_id]["Name"]));
                    $name = str_replace("ä","ae",$name);
                    $name = str_replace("ö","oe",$name);
                    $name = str_replace("ü","ue",$name);
                    $group_by_data[$group_field]['Seminar_id'][$seminar_id] = $name;
                }
                uasort($group_by_data[$group_field]['Seminar_id'], 'strnatcmp');
            }
            
            switch ($this->sem_browse_data["group_by"]){
                    case 0:
                    krsort($group_by_data, SORT_NUMERIC);
                    break;
                    
                    case 1:
                    uksort($group_by_data, create_function('$a,$b',
                            '$the_tree = TreeAbstract::GetInstance("StudipSemTree");
                            return (int)($the_tree->tree_data[$a]["index"] - $the_tree->tree_data[$b]["index"]);
                            '));
                    break;
                    
                    case 3:
                    if ($order = $this->module->config->getValue("ReplaceTextSemType", "order")) {
                        foreach ($order as $position) {
                            if (isset($group_by_data[$position]))
                                $group_by_data_tmp[$position] = $group_by_data[$position];
                        }
                        $group_by_data = $group_by_data_tmp;
                        unset($group_by_data_tmp);
                    }
                    else {
                        uksort($group_by_data, create_function('$a,$b',
                                'global $SEM_CLASS,$SEM_TYPE;
                                return strnatcasecmp($SEM_TYPE[$a]["name"]." (". $SEM_CLASS[$SEM_TYPE[$a]["class"]]["name"].")",
                                                $SEM_TYPE[$b]["name"]." (". $SEM_CLASS[$SEM_TYPE[$b]["class"]]["name"].")");'));
                    }
                    break;
                    default:
                    uksort($group_by_data, 'strnatcasecmp');
                    break;
                    
            }
            
            // generic datafields
            $generic_datafields = $this->module->config->getValue("Main", "genericdatafields");
//              $datafields_obj = new DataFields();
            
            if ($this->module->config->getValue("Main", "addinfo")) {
                $info = "&nbsp;" . count($sem_data);
                $info .= $this->module->config->getValue("Main", "textlectures");
                $info .= ", " . $this->module->config->getValue("Main", "textgrouping");
                $group_by_name = $this->module->config->getValue("Main", "aliasesgrouping");
                $info .= $group_by_name[$this->sem_browse_data['group_by']];
                $out = $this->module->elements["InfoCountSem"]->toString(array("content" => $info));
            }
            else
                $out = "";
            
            $first_loop = TRUE;
            $repeat_headrow = $this->module->config->getValue("Main", "repeatheadrow");
            foreach ($group_by_data as $group_field => $sem_ids) {
                
                $group_content = $this->getGroupContent($the_tree, $group_field);
                
                if ($repeat_headrow == "beneath") {
                    $out .= $this->module->elements["Grouping"]->toString(array("content" => $group_content));
                    $out .= $this->module->elements["TableHeadrow"]->toString();
                }
    
                if($first_loop && $repeat_headrow != "beneath")
                    $out .= $this->module->elements["TableHeadrow"]->toString();
    
                if ($repeat_headrow != "beneath") {
                    if ($repeat_headrow && !$first_loop)
                        $out .= $this->module->elements["TableHeadrow"]->toString();
                    $out .= $this->module->elements["Grouping"]->toString(array("content" => $group_content));
                }
                $first_loop = FALSE;
                                
                if (is_array($sem_ids['Seminar_id'])) {
                    $zebra = 0;
                    while (list($seminar_id,) = each($sem_ids['Seminar_id'])) {
                                                
                        $sem_name = key($sem_data[$seminar_id]["Name"]);
                        $sem_number_start = key($sem_data[$seminar_id]["sem_number"]);
                        $sem_number_end = key($sem_data[$seminar_id]["sem_number_end"]);
                        if ($sem_number_start != $sem_number_end){
                            $sem_name .= " (" . $this->sem_dates[$sem_number_start]['name'] . " - ";
                            $sem_name .= (($sem_number_end == -1) ? _("unbegrenzt") : $this->sem_dates[$sem_number_end]['name']) . ")";
                        }
                        
                        //create Turnus field
                        $data["content"]["zeiten"] = Seminar::GetInstance($seminar_id)->getDatesExport(array('show_room' => true));
                        //Shorten, if string too long
                        if (strlen($data["content"]["zeiten"]) >70) {
                            $data["content"]["zeiten"] = substr($data["content"]["zeiten"], 0,
                                    strpos(substr($data["content"]["zeiten"], 70, strlen($data["content"]["zeiten"])), ",") +71);
                            $data["content"]["zeiten"] .= "...";
                        }
                        $data["content"]["zeiten"] = htmlReady($data["content"]["zeiten"]);
                        $doz_position = array_keys($sem_data[$seminar_id]['position']);
                        $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                        $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                        if (is_array($doz_name)){
                            if(count($doz_position) != count($doz_uname)) $doz_position = range(1, count($doz_uname));
                     array_multisort($doz_position, $doz_name, $doz_uname);
                            $data["content"]["dozent"] = "";
                            $i = 0;
                            foreach ($doz_name as $index => $value) {
                                if ($i == 4) {
                                    $data["content"]["dozent"] .= $this->module->elements["LecturerLink"]->toString(
                                        array("module" => "Lecturedetails", "link_args" => "seminar_id=$seminar_id",
                                        "content" => "..."));
                                    break;
                                }
                                $data["content"]["dozent"] .= $this->module->elements["LecturerLink"]->toString(
                                        array("module" => "Persondetails", "link_args" => "username="******"&seminar_id=$seminar_id",
                                        "content" =>  htmlReady($value)));
                                if ($i != count($doz_name) - 1) {
                                    $data["content"]["dozent"] .= ", ";
                                }
                                ++$i;
                            }
                        }
                        
                        $data["content"]["Name"] = $this->module->elements["SemLink"]->toString(
                                array("module" => "Lecturedetails", "link_args" => "seminar_id=$seminar_id",
                                "content" => htmlReady($sem_name)));
                        $data["content"]["VeranstaltungsNummer"] =
                                htmlReady(key($sem_data[$seminar_id]["VeranstaltungsNummer"]));
                        $data["content"]["Untertitel"] = htmlReady(key($sem_data[$seminar_id]["Untertitel"]));
                        
                        $aliases_sem_type = $this->module->config->getValue("ReplaceTextSemType",
                                "class_" . $SEM_TYPE[key($sem_data[$seminar_id]["status"])]['class']);
                        if ($aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]["status"])] - 1]) {
                            $data["content"]["status"] =
                                    $aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]["status"])] - 1];
                        }
                        else {
                            $data["content"]["status"] =
                                    htmlReady($SEM_TYPE[key($sem_data[$seminar_id]["status"])]["name"]
                                    ." (". $SEM_CLASS[$SEM_TYPE[key($sem_data[$seminar_id]["status"])]["class"]]["name"].")");
                        }
                        
                        $data["content"]["Ort"] = Seminar::getInstance($seminar_id)->getDatesTemplate('dates/seminar_export_location');
                        if ($sem_data[$seminar_id]["art"])
                            $data["content"]["art"] = htmlReady(key($sem_data[$seminar_id]["art"]));
                        else
                            $data["content"]["art"] = "";
                        
                        // generic data fields
                        if (is_array($generic_datafields)) {
                            $localEntries = DataFieldEntry::getDataFieldEntries($seminar_id);
                            foreach ($generic_datafields as $id) {
                                if (isset($localEntries[$id]) && is_object($localEntries[$id])) {
                                    $data["content"][$id] = $localEntries[$id]->getDisplayValue();
                                }
                            }
                        }
                        
                        $data["data_fields"] = $this->module->data_fields;
                        $out .= $this->module->elements["TableRow"]->toString($data);
                    }
                }
            }
            ob_end_clean();
            $this->module->elements["TableHeader"]->printout(array("content" => $out));
        }
    }
Example #16
0
 /**
  * Stores a user's details.
  */
 public function store_action()
 {
     $this->check_ticket();
     $changed = false;
     if (Config::get()->ENABLE_SKYPE_INFO) {
         $new_skype_name = Request::get('skype_name');
         if ($new_skype_name != $this->config->SKYPE_NAME) {
             $this->config->store('SKYPE_NAME', $new_skype_name);
             Visibility::updatePrivacySettingWithTest(Request::get('skype_name'), _("Skype Name"), "skype_name", 'privatedata', 1, $this->user->user_id);
             $changed = true;
         }
         if (Request::int('skype_online_status') != $this->config->SKYPE_ONLINE_STATUS) {
             $this->config->store('SKYPE_ONLINE_STATUS', Request::int('skype_online_status'));
             Visibility::updatePrivacySettingWithTest(Request::int('skype_online_status'), _("Skype Online Status"), "skype_online_status", 'skype_name', 1, $this->user->user_id);
             $changed = true;
         }
     }
     $mapping = array('telefon' => 'privatnr', 'cell' => 'privatcell', 'anschrift' => 'privadr', 'home' => 'Home', 'motto' => 'motto', 'hobby' => 'hobby', 'lebenslauf' => 'lebenslauf', 'schwerp' => 'schwerp', 'publi' => 'publi');
     // Visibilitymapping Remove in Stud.IP 3.0 with a migration
     $vis_mapping = array('telefon' => 'private_phone', 'cell' => 'private_cell', 'anschrift' => 'privadr', 'home' => 'homepage', 'motto' => 'motto', 'hobby' => 'hobby', 'lebenslauf' => 'lebenslauf', 'schwerp' => 'schwerp', 'publi' => 'publi');
     $settingsname = array('telefon' => _('Private Telefonnummer'), 'cell' => _('Private Handynummer'), 'anschrift' => _('Private Adresse'), 'home' => _('Homepage-Adresse'), 'motto' => _('Motto'), 'hobby' => _('Hobbies'), 'lebenslauf' => _('Lebenslauf'), 'schwerp' => _('Arbeitsschwerpunkte'), 'publi' => _('Publikationen'));
     foreach ($mapping as $key => $column) {
         $value = Request::get($key);
         if (in_array($key, array('hobby', 'lebenslauf', 'schwerp', 'publi'))) {
             // purify HTML input for these fields if wysiwyg is used
             $value = Studip\Markup::purifyHtml($value);
         }
         if ($this->user->{$column} != $value && $this->shallChange('user_info.' . $column, $column, $value)) {
             $this->user->{$column} = $value;
             Visibility::updatePrivacySettingWithTest($value, $settingsname[$key], $vis_mapping[$key], 'privatedata', 1, $this->user->user_id);
             $changed = true;
         }
     }
     $datafields_changed = false;
     $errors = array();
     $datafields = DataFieldEntry::getDataFieldEntries($this->user->user_id, 'user');
     $data = Request::getArray('datafields');
     foreach ($datafields as $id => $entry) {
         if (isset($data[$id]) && $data[$id] != $entry->getValue()) {
             // i really dont know if this is correct but it works
             Visibility::updatePrivacySettingWithTest($data[$id], $entry->getName(), $entry->getID(), 'additionaldata', 1, $this->user->user_id);
             $entry->setValueFromSubmit($data[$id]);
             if ($entry->isValid()) {
                 if ($entry->store()) {
                     $datafields_changed = true;
                 }
             } else {
                 $errors[] = sprintf(_('Fehlerhafter Eintrag im Feld <em>%s</em>: %s (Eintrag wurde nicht gespeichert)'), $entry->getName(), $entry->getDisplayValue());
             }
         }
     }
     if (count($errors) > 0) {
         $this->reportErrorWithDetails(_('Bitte überprüfen Sie Ihre Eingaben.'), $errors);
     } else {
         if ($this->user->store() || $changed || $datafields_changed) {
             $this->reportSuccess(_('Daten im Lebenslauf u.a. wurden geändert.'));
             setTempLanguage($this->user->user_id);
             $this->postPrivateMessage(_('Daten im Lebenslauf u.a. wurden geändert.'));
             restoreLanguage();
         }
     }
     $this->redirect('settings/details');
 }
    function getContent ($args = NULL, $raw = FALSE) {
        $error_message = "";
        if (!$args) {
            $args = array();
        }
        $content = array();

        // check for valid range_id
        if(!$this->checkRangeId($this->config->range_id)) {
            $error_message = $GLOBALS['EXTERN_ERROR_MESSAGE'];
        }
        // if $args['seminar_id'] is given, check for free access
        if ($args['seminar_id']) {
            $seminar_id = $args['seminar_id'];
            $query = "SELECT Lesezugriff FROM seminare s LEFT JOIN seminar_inst si ";
            $query .= "USING(seminar_id) WHERE s.seminar_id = ? ";
            $query .= "AND si.institut_id = ?";
            $params = array($seminar_id, $this->config->range_id);
            $statement = DBManager::get()->prepare($query);
            $statement->execute($params);
            $row = $statement->fetchColumn();
            if ($row !== false && $row == 0 ) {
                 $error_message = $GLOBALS['EXTERN_ERROR_MESSAGE'];
            }
        } else {
            $seminar_id = $this->config->range_id;
        }

        $sort = (array) $this->config->getValue('Main', 'sort');
        $query_order = '';
        foreach ($sort as $key => $position) {
            if ($position > 0) {
                $query_order[$position] = $this->data_fields[$key];
            }
        }
        if ($query_order) {
            ksort($query_order, SORT_NUMERIC);
            $query_order = ' ORDER BY ' . implode(',', $query_order) . ' DESC';
        }

        if (!$nameformat = $this->config->getValue('Main', 'nameformat')) {
            $nameformat = 'no_title_short';
        }

        // generic data fields
        $generic_datafields = $this->config->getValue('TemplateGeneric', 'genericdatafields');

        $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $seminar_id));

        $allowed_folders = $folder_tree->getReadableFolders('nobody');
        $mrks =  str_repeat('?,', count($allowed_folders) - 1) . '?';
        $query = "SELECT dokument_id, name, description, filename, d.mkdate, d.chdate, filesize, ";
        $query .= $GLOBALS['_fullname_sql'][$nameformat];
        $query .= "AS fullname, Vorname, Nachname, title_front, title_rear, username, aum.user_id, author_name FROM dokumente d LEFT JOIN user_info USING (user_id) ";
        $query .= "LEFT JOIN auth_user_md5 aum USING (user_id) WHERE ";
        $query .= "seminar_id = ? AND range_id IN ($mrks)$query_order";

        $parameters = $allowed_folders;
        $parameters[] = $seminar_id;          
        $statement = DBManager::get()->prepare($query);
        $statement->execute($parameters);
        $row = $statement->fetch(PDO::FETCH_ASSOC);
        if ( !$row ) {
            $content['NO-FILES']['NO-FILES-TEXT'] = $this->config->getValue('Main', 'nodatatext');
        } else {
            $i = 0;
            do {
                preg_match("/^.+\.([a-z1-9_-]+)$/i", $row['filename'], $file_suffix);

                $icon = '';
                switch ($file_suffix[1]) {
                    case 'txt' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'icontxt'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-text', 'clickable')->asImagePath(16);
                        break;
                    case 'xls' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconxls'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-xls', 'clickable')->asImagePath(16);
                        break;
                    case 'ppt' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconppt'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-presentation', 'clickable')->asImagePath(16);
                        break;
                    case 'rtf' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconrtf'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-text', 'clickable')->asImagePath(16);
                        break;
                    case 'zip' :
                    case 'tgz' :
                    case 'gz' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconzip'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-archive', 'clickable')->asImagePath(16);
                        break;
                    case 'jpg' :
                    case 'png' :
                    case 'gif' :
                    case 'jpeg' :
                    case 'tif' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconpic'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-pic', 'clickable')->asImagePath(16);
                        break;
                    case 'pdf' :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'iconpdf'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-pdf', 'clickable')->asImagePath(16);
                        break;
                    default :
                        if (!$content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = $this->config->getValue('Main', 'icondefault'))
                            $content['FILES']['FILE'][$i]['FILE_ICON-HREF'] = Icon::create('file-generic', 'clickable')->asImagePath(16);
                }
                $content['FILES']['FILE'][$i]['FILE_NO'] = $i + 1;

                $download_link = GetDownloadLink($row['dokument_id'], $row['filename']);

                $content['FILES']['FILE'][$i]['FILE_HREF'] = $download_link;
                $content['FILES']['FILE'][$i]['FILE_NAME'] = ExternModule::ExtHtmlReady($row['name']);
                $content['FILES']['FILE'][$i]['FILE_FILE-NAME'] = ExternModule::ExtHtmlReady($row['filename']);
                $content['FILES']['FILE'][$i]['FILE_DESCRIPTION'] = ExternModule::ExtHtmlReady(mila_extern($row["description"],
                                                     $this->config->getValue("Main", "lengthdesc")));
                $content['FILES']['FILE'][$i]['FILE_UPLOAD-DATE'] = strftime($this->config->getValue("Main", "dateformat"), $row["mkdate"]);
                $content['FILES']['FILE'][$i]['FILE_SIZE'] = $row['filesize'] > 1048576 ? round($row['filesize'] / 1048576, 1) . " MB" : round($row["filesize"] / 1024, 1) . " kB";

                $content['FILES']['FILE'][$i]['USERNAME'] = $row['username'];
                $content['FILES']['FILE'][$i]['FULLNAME'] = ExternModule::ExtHtmlReady($row['fullname'] ? $row['fullname'] : $row['author_name']);
                $content['FILES']['FILE'][$i]['FIRSTNAME'] = ExternModule::ExtHtmlReady($row['Vorname']);
                $content['FILES']['FILE'][$i]['LASTNAME'] = ExternModule::ExtHtmlReady($row['Nachname']);
                $content['FILES']['FILE'][$i]['TITLEFRONT'] = ExternModule::ExtHtmlReady($row['title_front']);
                $content['FILES']['FILE'][$i]['TITLEREAR'] = ExternModule::ExtHtmlReady($row['title_rear']);
                $content['FILES']['FILE'][$i]['PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl('Persondetails', array('link_args' => 'username='******'username']));

                // if user is member of a group then link name to details page
                $link_persondetail = '';
                if (GetRoleNames(GetAllStatusgruppen($this->config->range_id, $row['user_id']))) {
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl('Persondetails', array('link_args' => 'username='******'username']));
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_FULLNAME'] = ExternModule::ExtHtmlReady($row['fullname'] ? $row['fullname'] : $row['author_name']);
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_FIRSTNAME'] = ExternModule::ExtHtmlReady($row['Vorname']);
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_LASTNAME'] = ExternModule::ExtHtmlReady($row['Nachname']);
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_TITLEFRONT'] = ExternModule::ExtHtmlReady($row['title_front']);
                    $content['FILES']['FILE'][$i]['PERSONDETAIL-LINK']['LINK_TITLEREAR'] = ExternModule::ExtHtmlReady($row['title_rear']);
                }

                // generic data fields
                if (is_array($generic_datafields)) {
                    $localEntries = DataFieldEntry::getDataFieldEntries($row['user_id'], 'user');
                    $k = 1;
                    foreach ($generic_datafields as $datafield) {
                        if (isset($localEntries[$datafield]) && is_object($localEntries[$datafield])) {
                            $localEntry = $localEntries[$datafield]->getDisplayValue();
                            if ($localEntry) {
                                $content['FILES']['FILE'][$i]['DATAFIELD_' . $k] = $localEntry;
                            }
                        }
                        $k++;
                    }
                }

                $i++;
            }while($row = $statement->fetch(PDO::FETCH_ASSOC));
        }
        $content = array('DOWNLOAD' => $content);
        $content['__GLOBAL__']['FILES-COUNT'] = $i;

        return $content;
    }
/**
* helper function to export custom datafields
*
* only visible datafields are exported (depending on user perms)
* @access   public
* @param    string  $range_id   id for object to export
* @param    string  $childgroup_tag name of outer tag
* @param    string  $childobject_tag    name of inner tags
*/
function export_datafields($range_id, $childgroup_tag, $childobject_tag, $object_type = null, $object_class_hint = null)
{
    $ret = '';
    $d_fields = false;
    $localEntries = DataFieldEntry::getDataFieldEntries($range_id, $object_type, $object_class_hint);
    if (is_array($localEntries)) {
        foreach ($localEntries as $entry) {
            if ($entry->isVisible() && $entry->getDisplayValue()) {
                if (!$d_fields) {
                    $ret .= xml_open_tag($childgroup_tag);
                }
                $ret .= xml_open_tag($childobject_tag, $entry->getName());
                $ret .= xml_escape($entry->getDisplayValue(false));
                $ret .= xml_close_tag($childobject_tag);
                $d_fields = true;
            }
        }
    }
    if ($d_fields) {
        $ret .= xml_close_tag($childgroup_tag);
    }
    return $ret;
}
Example #19
0
 /**
  * Stores the changed or created institute data
  *
  * @param String $i_id Institute id or 'new' to create
  * @throws MethodNotAllowedException
  */
 public function store_action($i_id)
 {
     // We won't accept anything but a POST request
     if (!Request::isPost()) {
         throw new MethodNotAllowedException();
     }
     $create_institute = $i_id === 'new';
     $institute = new Institute($create_institute ? null : $i_id);
     $institute->name = trim(Request::get('Name', $institute->name));
     $institute->fakultaets_id = Request::option('Fakultaet', $institute->fakultaets_id);
     $institute->strasse = Request::get('strasse', $institute->strasse);
     // Beware: Despite the name, this contains both zip code AND city name
     $institute->plz = Request::get('plz', $institute->plz);
     $institute->url = Request::get('home', $institute->url);
     $institute->telefon = Request::get('telefon', $institute->telefon);
     $institute->email = Request::get('email', $institute->email);
     $institute->fax = Request::get('fax', $institute->fax);
     $institute->type = Request::int('type', $institute->type);
     $institute->lit_plugin_name = Request::get('lit_plugin_name', $institute->lit_plugin_name);
     $institute->lock_rule = Request::option('lock_rule', $institute->lock_rule);
     // Do we have all necessary data?
     if (!$institute->name) {
         PageLayout::postMessage(MessageBox::error(_('Bitte geben Sie eine Bezeichnung für die Einrichtung ein!')));
         return $this->redirect('institute/basicdata/index/' . $i_id);
     }
     if ($create_institute) {
         $institute->id = $institute->getNewId();
         // Is the user allowed to create new faculties
         if (!$institute->fakultaets_id && !$GLOBALS['perm']->have_perm('root')) {
             PageLayout::postMessage(MessageBox::error(_('Sie haben nicht die Berechtigung, neue Fakultäten zu erstellen')));
             return $this->redirect('institute/basicdata/index/new');
         }
         // Is the user allowed to create new institutes
         if (!$GLOBALS['perm']->have_perm('root') && !($GLOBALS['perm']->is_fak_admin() && get_config('INST_FAK_ADMIN_PERMS') !== 'none')) {
             PageLayout::postMessage(MessageBox::error(_('Sie haben nicht die Berechtigung, um neue Einrichtungen zu erstellen!')));
             return $this->redirect('institute/basicdata/index/new');
         }
         // Does an institute with the given name already exist in the given faculty?
         if ($institute->fakultaets_id && Institute::findOneBySQL('Name = ? AND fakultaets_id = ?', array($institute->name, $institute->fakultaets_id)) !== null) {
             $message = sprintf(_('Die Einrichtung "%s" existiert bereits innerhalb der angegebenen Fakultät!'), $institute->name);
             PageLayout::postMessage(MessageBox::error($message));
             return $this->redirect('institute/basicdata/index/new');
         }
         // Does a faculty with the given name already exist
         if (!$institute->fakultaets_id && Institute::findOneBySQL('Name = ? AND fakultaets_id = Institut_id', array($institute->name)) !== null) {
             $message = sprintf(_('Die Fakultät "%s" existiert bereits!'), $institute->name);
             PageLayout::postMessage(MessageBox::error($message));
             return $this->redirect('institute/basicdata/index/new');
         }
         // Initialize modules
         $modules = new Modules();
         $institute->modules = $modules->getDefaultBinValue('', 'inst', $institute->type);
         // Declare faculty status if neccessary
         if (!$institute->fakultaets_id) {
             $institute->fakultaets_id = $institute->getId();
         }
     } else {
         // Is the user allowed to change the institute/faculty?
         if (!$GLOBALS['perm']->have_studip_perm('admin', $institute->id)) {
             PageLayout::postMessage(MessageBox::error(_('Sie haben nicht die Berechtigung diese Einrichtung zu verändern!')));
             return $this->redirect('institute/basicdata/index/' . $institute->id);
         }
         // Save datafields
         $datafields = Request::getArray('datafields');
         $invalidEntries = array();
         $datafields_stored = 0;
         foreach (DataFieldEntry::getDataFieldEntries($institute->id, 'inst') as $entry) {
             if (isset($datafields[$entry->getId()])) {
                 $valueBefore = $entry->getValue();
                 $entry->setValueFromSubmit($datafields[$entry->getId()]);
                 if ($valueBefore != $entry->getValue()) {
                     if ($entry->isValid()) {
                         $datafields_stored += 1;
                         $entry->store();
                     } else {
                         $invalidEntries[] = $entry->getId();
                     }
                 }
             }
         }
         // If any errors occured while updating the datafields, report them
         if (count($invalidEntries) > 0) {
             $this->flash['invalid_entries'] = $invalidEntries;
             PageLayout::postMessage(MessageBox::error(_('ungültige Eingaben (s.u.) wurden nicht gespeichert')));
         }
     }
     // Try to store the institute, report any errors
     if ($institute->isDirty() && !$institute->store()) {
         if ($institute->isNew()) {
             PageLayout::postMessage(MessageBox::error(_('Die Einrichtung konnte nicht angelegt werden.')));
         } else {
             PageLayout::postMessage(MessageBox::error(_('Die Änderungen konnten nicht gespeichert werden.')));
         }
         return $this->redirect('institute/basicdata/index/' . $i_id);
     }
     if ($create_institute) {
         // Log creation of institute
         log_event('INST_CREATE', $institute->id, null, null, '');
         // logging
         // Further initialize modules (the modules class setup is in
         // no way expensive, so it can be constructed twice, don't worry)
         $modules = new Modules();
         $module_list = $modules->getLocalModules($institute->id, 'inst', $institute->modules, $institute->type);
         if (isset($module_list['documents'])) {
             create_folder(_('Allgemeiner Dateiordner'), _('Ablage für allgemeine Ordner und Dokumente der Einrichtung'), $institute->id, 7, $institute->id);
         }
         // Report success
         $message = sprintf(_('Die Einrichtung "%s" wurde erfolgreich angelegt.'), $institute->name);
         PageLayout::postMessage(MessageBox::success($message));
         openInst($institute->id);
     } else {
         // Report success
         $message = sprintf(_('Die Änderung der Einrichtung "%s" wurde erfolgreich gespeichert.'), htmlReady($institute->name));
         PageLayout::postMessage(MessageBox::success($message));
     }
     $this->redirect('institute/basicdata/index/' . $institute->id, array('cid' => $institute->id));
 }
 function getContentResult($level_id = null)
 {
     global $_fullname_sql, $SEM_TYPE, $SEM_CLASS;
     $content = null;
     if (is_array($this->sem_browse_data['search_result']) && count($this->sem_browse_data['search_result'])) {
         list($group_by_data, $sem_data) = $this->getResult($level_id);
         if (count($sem_data)) {
             $content['__GLOBAL__']['COURSES_COUNT'] = count($sem_data);
             $content['__GLOBAL__']['COURSES_GROUPING'] = $this->group_by_fields[$this->sem_browse_data['group_by']]['name'];
             $group_by_name = $this->config->getValue('Main', 'aliasesgrouping');
             $content['__GLOBAL__']['COURSES_SUBSTITUTE-GROUPED-BY'] = $group_by_name[$this->sem_browse_data['group_by']];
             $content['__GLOBAL__']['XLS_EXPORT-HREF'] = $this->getLinkToSelf(array('xls_export' => '1'), true);
             $content['__GLOBAL__']['GROUP_BY_TYPE-HREF'] = $this->getLinkToSelf(array('group_by' => '3'), true);
             $content['__GLOBAL__']['GROUP_BY_SEMESTER-HREF'] = $this->getLinkToSelf(array('group_by' => '0'), true);
             $content['__GLOBAL__']['GROUP_BY_RANGE-HREF'] = $this->getLinkToSelf(array('group_by' => '1'), true);
             $content['__GLOBAL__']['GROUP_BY_LECTURER-HREF'] = $this->getLinkToSelf(array('group_by' => '2'), true);
             $content['__GLOBAL__']['GROUP_BY_INSTITUTE-HREF'] = $this->getLinkToSelf(array('group_by' => '4'), true);
             $content['__GLOBAL__'] = array_merge($content['__GLOBAL__'], $this->global_markers);
             $j = 0;
             $semester = SemesterData::GetSemesterArray();
             foreach ($group_by_data as $group_field => $sem_ids) {
                 switch ($this->sem_browse_data['group_by']) {
                     case 0:
                         ExternModule::ExtHtmlReady($content['RESULT']['GROUP'][$j]['GROUP_NAME'] = $semester[$group_field]['name']);
                         break;
                     case 1:
                         if (!is_object($this->sem_tree)) {
                             $this->sem_tree = TreeAbstract::GetInstance("StudipSemTree");
                         }
                         if ($this->sem_tree->tree_data[$group_field]) {
                             $range_path_level = $this->config->getValue('Main', 'rangepathlevel');
                             $content['RESULT']['GROUP'][$j]['GROUP_NAME'] = ExternModule::ExtHtmlReady($this->sem_tree->getShortPath($group_field, NULL, '>', $range_path_level ? $range_path_level - 1 : 0));
                             /*
                             if ($this->sem_tree->isModuleItem($group_field) && $studienmodulmanagement = PluginEngine::getPlugin('StudienmodulManagement')) {
                                 $content['RESULT']['GROUP'][$j]['GROUP_INFO'] = $studienmodulmanagement->getModuleDescription($group_field, SemesterData::GetSemesterIdByIndex($this->sem_browse_data['sem']));
                             } else {
                             */
                             $content['RESULT']['GROUP'][$j]['NO_GROUP_INFO'] = true;
                             //  }
                         } else {
                             $content['RESULT']['GROUP'][$j]['NO_GROUP_NAME'] = true;
                         }
                         break;
                     case 3:
                         $aliases_sem_type = $this->config->getValue('ReplaceTextSemType', "class_{$SEM_TYPE[$group_field]['class']}");
                         if ($aliases_sem_type[$this->sem_types_position[$group_field] - 1]) {
                             $content['RESULT']['GROUP'][$j]['GROUP_NAME'] = $aliases_sem_type[$this->sem_types_position[$group_field] - 1];
                         } else {
                             $content['RESULT']['GROUP'][$j]['GROUP_NAME'] = ExternModule::ExtHtmlReady($SEM_TYPE[$group_field]['name'] . ' (' . $SEM_CLASS[$SEM_TYPE[$group_field]['class']]['name'] . ')');
                         }
                         break;
                     default:
                         $content['RESULT']['GROUP'][$j]['GROUP_NAME'] = ExternModule::ExtHtmlReady($group_field);
                 }
                 $content['RESULT']['GROUP'][$j]['GROUP-NO'] = $j + 1;
                 if (is_array($sem_ids['Seminar_id'])) {
                     $k = 0;
                     $semester = SemesterData::GetSemesterArray();
                     while (list($seminar_id, ) = each($sem_ids['Seminar_id'])) {
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['COURSE_ID'] = $seminar_id;
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['TITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Name']));
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['COURSE-NO'] = $k + 1;
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['COURSEDETAILS-HREF'] = $this->elements['LinkInternLecturedetails']->createUrl(array('link_args' => 'seminar_id=' . $seminar_id));
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['COURSE_NUMBER'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['VeranstaltungsNummer']));
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['DESCRIPTION'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Beschreibung']), true);
                         $sem_number_start = key($sem_data[$seminar_id]["sem_number"]);
                         $sem_number_end = key($sem_data[$seminar_id]["sem_number_end"]);
                         if ($sem_number_start != $sem_number_end) {
                             $sem_name = $semester[$sem_number_start]['name'] . " - ";
                             $sem_name .= $sem_number_end == -1 ? _("unbegrenzt") : $semester[$sem_number_end]['name'];
                         } else {
                             $sem_name = $semester[$sem_number_start]['name'];
                         }
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['SEMESTER'] = ExternModule::ExtHtmlReady($sem_name);
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['DATES'] = $this->getDates($seminar_id, $semester[$this->sem_browse_data['sem']]['beginn'], $semester[$this->sem_browse_data['sem']]['ende']);
                         if (!sizeof($content['RESULT']['GROUP'][$j]['COURSE'][$k]['DATES'])) {
                             $content['RESULT']['GROUP'][$j]['COURSE'][$k]['NO_DATES_TEXT'] = array();
                         }
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['SUBTITLE'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['Untertitel']));
                         $aliases_sem_type = $this->config->getValue('ReplaceTextSemType', 'class_' . $SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']);
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['SEMTYPE-SUBSTITUTE'] = $aliases_sem_type[$this->sem_types_position[key($sem_data[$seminar_id]['status'])] - 1];
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['SEMTYPE'] = ExternModule::ExtHtmlReady($SEM_TYPE[key($sem_data[$seminar_id]['status'])]['name'] . ' (' . $SEM_CLASS[$SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']]['name'] . ')');
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LOCATION'] = ExternModule::ExtHtmlReady(trim(key($sem_data[$seminar_id]['Ort'])));
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['FORM'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['art']));
                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['ECTS'] = ExternModule::ExtHtmlReady(key($sem_data[$seminar_id]['ects']));
                         // generic data fields
                         $generic_datafields = $this->config->getValue('TemplateResult', 'genericdatafields');
                         if (is_array($generic_datafields)) {
                             $localEntries = DataFieldEntry::getDataFieldEntries($seminar_id, 'sem', $SEM_TYPE[key($sem_data[$seminar_id]['status'])]['class']);
                             $m = 1;
                             foreach ($generic_datafields as $datafield) {
                                 if (isset($localEntries[$datafield]) && is_object($localEntries[$datafield])) {
                                     if ($localEntries[$datafield]->getType() == 'link') {
                                         $localEntry = ExternModule::extHtmlReady($localEntries[$datafield]->getValue());
                                     } else {
                                         $localEntry = $localEntries[$datafield]->getDisplayValue();
                                     }
                                     if ($localEntry) {
                                         $content['RESULT']['GROUP'][$j]['COURSE'][$k]['DATAFIELD_' . $m] = $localEntry;
                                     }
                                 }
                                 $m++;
                             }
                         }
                         $doz_name = array_keys($sem_data[$seminar_id]['fullname']);
                         $doz_uname = array_keys($sem_data[$seminar_id]['username']);
                         $doz_lastname = array_keys($sem_data[$seminar_id]['Nachname']);
                         $doz_firstname = array_keys($sem_data[$seminar_id]['Vorname']);
                         $doz_titlefront = array_keys($sem_data[$seminar_id]['title_front']);
                         $doz_titlerear = array_keys($sem_data[$seminar_id]['title_rear']);
                         $doz_position = array_keys($sem_data[$seminar_id]['position']);
                         if (is_array($doz_name)) {
                             if (count($doz_position) != count($doz_uname)) {
                                 $doz_position = range(1, count($doz_uname));
                             }
                             array_multisort($doz_position, $doz_name, $doz_uname);
                             $l = 0;
                             foreach ($doz_name as $index => $value) {
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['UNAME'] = $doz_uname[$index];
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['PERSONDETAILS-HREF'] = $this->elements['LinkInternPersondetails']->createUrl(array('link_args' => 'username='******'&seminar_id=' . $seminar_id));
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['FULLNAME'] = ExternModule::ExtHtmlReady($doz_name[$index]);
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['LASTNAME'] = ExternModule::ExtHtmlReady($doz_lastname[$index]);
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['FIRSTNAME'] = ExternModule::ExtHtmlReady($doz_firstname[$index]);
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['TITLEFRONT'] = ExternModule::ExtHtmlReady($doz_titlefront[$index]);
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['TITLEREAR'] = ExternModule::ExtHtmlReady($doz_titlerear[$index]);
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['LECTURER-NO'] = $l + 1;
                                 $content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l]['LECTURER_DELIMITER'] = true;
                                 $l++;
                             }
                             // remove last delimiter
                             unset($content['RESULT']['GROUP'][$j]['COURSE'][$k]['LECTURERS'][$l - 1]['LECTURER_DELIMITER']);
                         } else {
                             $content['RESULT']['GROUP'][$j]['COURSE'][$k]['NO_LECTURERS'] = true;
                         }
                         $k++;
                     }
                 }
                 $j++;
             }
             if ($this->config->getValue('Main', 'maxnumberofhits')) {
                 array_push($content['RESULT'], $this->getResultBrowser());
             }
         } else {
             $content['__GLOBAL__']['NO_COURSES'] = true;
         }
     } else {
         $content['__GLOBAL__']['NO_COURSES'] = true;
     }
     return $content;
 }
    private function getContent ($args = NULL, $raw = FALSE) {
        $instituts_id = $this->config->range_id;
        $username = $args['username'];
        $sem_id = $args['seminar_id'];

        if (!$nameformat = $this->config->getValue('Main', 'nameformat')) {
            $nameformat = 'full';
        }

        $row = false;
        $global_view = false;
        $dbv = new DbView();
        if (in_array(get_object_type($this->config->range_id), array('fak', 'global'))) {
            $global_view = true;
            $selected_item_ids = $this->config->getValue('SelectInstitutes', 'institutesselected');
            // at least one institute has to be selected in the configuration
            if (!is_array($selected_item_ids)) {
                return array();
            }
            // is user lecturer ?
            if ($this->config->getValue('Main', 'onlylecturers')) {
                $current_semester = get_sem_num(time());
                $stm = DBManager::get()->prepare(sprintf(
                    "SELECT aum.user_id "
                    . "FROM auth_user_md5 aum "
                    . "LEFT JOIN seminar_user su USING(user_id) "
                    . "LEFT JOIN seminare s USING (seminar_id) "
                    . "LEFT JOIN user_inst ui ON aum.user_id = ui.user_id "
                    . "WHERE aum.username = ? "
                    . "AND su.status = 'dozent' "
                    . "AND s.visible = 1 "
                    . "AND ((%s) = %s OR ((%s) <= %s  AND ((%s) >= %s OR (%s) = -1))) "
                    . "AND ui.Institut_id IN ('%s') "
                    . "AND ui.inst_perms = 'dozent' "
                    . "AND ui.externdefault = 1 "
                    . "AND %s",
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql,
                    $current_semester,
                    $dbv->sem_number_end_sql,
                    implode("','", $selected_item_ids),
                    get_ext_vis_query()));
                $stm->execute(array($username));
                // user is not a lecturer
                if (!$row = $stm->fetch()) {
                    return array();
                }
            } else {
                // have user the status dozent at an institute in the list of accepted institutes
                $stm = DBManager::get()->prepare(sprintf(
                    "SELECT aum.user_id "
                    . "FROM auth_user_md5 aum "
                    . "LEFT JOIN user_inst ui USING(user_id) "
                    . "WHERE aum.username = ? "
                    . "AND ui.Institut_id IN ('%s') "
                    . "AND ui.externdefault = 1 "
                    . "AND %s",
                    implode("','", $selected_item_ids), get_ext_vis_query()));
                $stm->execute(array($username));
                // user is not dozent at an institute that is in the list of accepted institutes
                if (!$row = $stm->fetch()) {
                    return array();
                }
            }
        }

        $row = false;

        // Mitarbeiter/in am Institut
        $stm_inst = DBManager::get()->prepare(
            "SELECT i.Institut_id "
            . "FROM Institute i "
            . "LEFT JOIN user_inst ui USING(Institut_id) "
            . "LEFT JOIN auth_user_md5 aum USING(user_id) "
            . "WHERE i.Institut_id = ? "
            . "AND aum.username = ? AND ui.inst_perms IN ('autor','tutor','dozent') AND " . get_ext_vis_query());
        $stm_inst->execute(array($instituts_id, $username));

        // Mitarbeiter/in am Heimatinstitut des Seminars
        if (!$row = $stm_inst->fetch(PDO::FETCH_ASSOC) && $sem_id) {
            $stm_inst = DBManager::get()->prepare(
                "SELECT s.Institut_id "
                . "FROM seminare s "
                . "LEFT JOIN user_inst ui USING(Institut_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "WHERE s.Seminar_id = ? "
                . "AND aum.username = ? AND ui.inst_perms = 'dozent' AND " . get_ext_vis_query());
            $stm_inst->execute(array($sem_id, $username));
            if ($row = $stm_inst->fetch(PDO::FETCH_ASSOC)) {
                $instituts_id = $row['Institut_id'];
            }
        }

        // an beteiligtem Institut Dozent(in)
        if (!$row && $sem_id) {
            $stm_inst = DBManager::get()->prepare(
                "SELECT si.institut_id "
                . "FROM seminare s "
                . "LEFT JOIN seminar_inst si ON(s.Seminar_id = si.seminar_id) "
                . "LEFT JOIN user_inst ui ON(si.institut_id = ui.Institut_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "WHERE s.Seminar_id = ? "
                . "AND si.institut_id != ? AND ui.inst_perms = 'dozent' AND aum.username = ? AND " . get_ext_vis_query());
            $stm_inst->execute(array($sem_id, $intituts_id, $username));
            if ($row = $stm_inst->fetch(PDO::FETCH_ASSOC)) {
                $instituts_id = $row['institut_id'];
            }
        }

        // ist zwar global Dozent, aber an keinem Institut eingetragen
        if (!$row && $sem_id) {
            $stm = DBManager::get()->prepare(sprintf(
                "SELECT aum.*, %s AS fullname "
                . "FROM auth_user_md5 aum "
                . "LEFT JOIN user_info USING(user_id) "
                . "LEFT JOIN seminar_user su "
                . "WHERE username = ? "
                . "AND perms = 'dozent' AND su.seminar_id = ? AND su.status = 'dozent' AND %s"
                , $GLOBALS['_fullname_sql'][$nameformat], get_ext_vis_query()));
            $stm->execute(array($username, $sem_id));
            $row = $stm->fetch(PDO::FETCH_ASSOC);
        } elseif ($global_view || $this->config->getValue('Main', 'defaultaddr')) {
            $stm = DBManager::get()->prepare(sprintf(
                "SELECT i.Institut_id, i.Name, i.Strasse, i.Plz, i.url, ui.*, aum.*, "
                . "%s AS fullname, uin.user_id, uin.lebenslauf, uin.publi, uin.schwerp, "
                . "uin.Home, uin.title_front, uin.title_rear "
                . "FROM Institute i "
                . "LEFT JOIN user_inst ui USING(Institut_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "LEFT JOIN user_info uin USING (user_id) "
                . "WHERE ui.inst_perms IN ('autor','tutor','dozent') "
                . "AND aum.username = ? AND ui.externdefault = 1 AND %s"
                , $GLOBALS['_fullname_sql'][$nameformat], get_ext_vis_query()));
            $stm->execute(array($username));
            $row = $stm->fetch(PDO::FETCH_ASSOC);
            if (!$row) {
                $stm = DBManager::get()->prepare(sprintf(
                    "SELECT i.Institut_id, i.Name, i.Strasse, i.Plz, i.url, ui.*, aum.*, "
                    . "%s AS fullname, uin.user_id, uin.lebenslauf, uin.publi, uin.schwerp, "
                    . "uin.Home, uin.title_front, uin.title_rear "
                    . "FROM Institute i "
                    . "LEFT JOIN user_inst ui USING(Institut_id) "
                    . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                    . "LEFT JOIN user_info uin USING (user_id) "
                    . "WHERE ui.inst_perms IN ('autor','tutor','dozent') "
                    . "AND aum.username = ? AND i.Institut_id = ? AND %s"
                    , $GLOBALS['_fullname_sql'][$nameformat], get_ext_vis_query()));
                $stm->execute(array($username, $instituts_id));
                $row = $stm->fetch(PDO::FETCH_ASSOC);
            }
        } else {
            $stm = DBManager::get()->prepare(sprintf(
                "SELECT i.Institut_id, i.Name, i.Strasse, i.Plz, i.url, ui.*, aum.*, "
                . "%s AS fullname, uin.user_id, uin.lebenslauf, uin.publi, uin.schwerp, "
                . "uin.Home, uin.title_front, uin.title_rear "
                . "FROM Institute i "
                . "LEFT JOIN user_inst ui USING(Institut_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "LEFT JOIN user_info uin USING (user_id) "
                . "WHERE ui.inst_perms IN ('autor','tutor','dozent') "
                . "AND aum.username = ? AND i.Institut_id = ? AND %s"
                , $GLOBALS['_fullname_sql'][$nameformat], get_ext_vis_query()));
            $stm->execute(array($username, $instituts_id));
            $row = $stm->fetch(PDO::FETCH_ASSOC);
        }

        // the user with the given username does not fulfill the conditions above
        if (!$row) {
            return array();
        }

        // Alle Einrichtungen hohlen
        $stm = DBManager::get()->prepare(sprintf(
                "SELECT i.Institut_id, i.Name, i.Strasse, i.Plz, i.url, ui.*, aum.*, "
                . "%s AS fullname, uin.user_id, uin.lebenslauf, uin.publi, uin.schwerp, "
                . "uin.Home, uin.title_front, uin.title_rear "
                . "FROM Institute i "
                . "LEFT JOIN user_inst ui USING(Institut_id) "
                . "LEFT JOIN auth_user_md5 aum USING(user_id) "
                . "LEFT JOIN user_info uin USING (user_id) "
                . "WHERE ui.inst_perms IN ('autor','tutor','dozent') "
                . "AND aum.username = ?"
                , $GLOBALS['_fullname_sql'][$nameformat]));
        $stm->execute(array($username));
        $allRows = $stm->fetchAll();
        
        $this->user_id = $row['user_id'];

        $this->user_perm = $visibilities['perms'];

        $content['__GLOBAL__']['STUDIP-EDIT-HREF'] = "{$GLOBALS['ABSOLUTE_URI_STUDIP']}dispatch.php/settings/account?username=$username&login=yes";

        $content['PERSONDETAILS']['FULLNAME'] = ExternModule::ExtHtmlReady($row['fullname']);
        $content['PERSONDETAILS']['LASTNAME'] = ExternModule::ExtHtmlReady($row['Nachname']);
        $content['PERSONDETAILS']['FIRSTNAME'] = ExternModule::ExtHtmlReady($row['Vorname']);
        $content['PERSONDETAILS']['TITLEFRONT'] = ExternModule::ExtHtmlReady($row['title_front']);
        $content['PERSONDETAILS']['TITLEREAR'] = ExternModule::ExtHtmlReady($row['title_rear']);
        if ($statusgroups = Statusgruppen::getUserRoles($instituts_id, $this->user_id)) {
            $content['PERSONDETAILS']['STATUSGROUPS'] = ExternModule::ExtHtmlReady(join(', ', array_values($statusgroups)));
        }
        $content['PERSONDETAILS']['USERNAME'] = $row['username'];
        
        $content['PERSONDETAILS']['IMAGE-HREF'] = Avatar::getAvatar($this->user_id)->getURL(Avatar::NORMAL);

        $gruppen = GetRoleNames(GetAllStatusgruppen($this->config->range_id, $row['user_id']));
        for ($i = 0; $i < sizeof($gruppen); $i++) {
            $content['PERSONDETAILS']['GROUPS'][$i]['GROUP'] = ExternModule::ExtHtmlReady($gruppen[$i]);
        }

        $content['PERSONDETAILS']['INST-NAME'] = ExternModule::ExtHtmlReady($row['Name']);
        $content['PERSONDETAILS']['INST-HREF'] = ExternModule::ExtHtmlReady(trim($row['url']));
        $content['PERSONDETAILS']['STREET'] = ExternModule::ExtHtmlReady($row['Strasse']);
        $content['PERSONDETAILS']['ZIPCODE'] = ExternModule::ExtHtmlReady($row['Plz']);
        $email = get_visible_email($this->user_id);
        $content['PERSONDETAILS']['EMAIL'] = ExternModule::ExtHtmlReady($email);
        $content['PERSONDETAILS']['EMAIL-LOCAL'] = array_shift(explode('@', $content['PERSONDETAILS']['EMAIL']));
        $content['PERSONDETAILS']['EMAIL-DOMAIN'] = array_pop(explode('@', $content['PERSONDETAILS']['EMAIL']));
        $content['PERSONDETAILS']['ROOM'] = ExternModule::ExtHtmlReady($row['raum']);
        $content['PERSONDETAILS']['PHONE'] = ExternModule::ExtHtmlReady($row['Telefon']);
        $content['PERSONDETAILS']['FAX'] = ExternModule::ExtHtmlReady($row['Fax']);
        if (Visibility::verify('homepage', $this->user_id)) {
            $content['PERSONDETAILS']['HOMEPAGE-HREF'] = ExternModule::ExtHtmlReady(trim($row['Home']));
        }
        $content['PERSONDETAILS']['OFFICE-HOURS'] = ExternModule::ExtHtmlReady($row['sprechzeiten']);

        $j = 0;
        foreach($allRows as $curRow)
        {
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-NAME'] = ExternModule::ExtHtmlReady($curRow['Name']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-HREF'] = ExternModule::ExtHtmlReady(trim($curRow['url']));
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-STREET'] = ExternModule::ExtHtmlReady($curRow['Strasse']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-ZIPCODE'] = ExternModule::ExtHtmlReady($curRow['Plz']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-EMAIL'] = ExternModule::ExtHtmlReady($curRow['Email']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-EMAIL-LOCAL'] = array_shift(explode('@', $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-EMAIL']));
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-EMAIL-DOMAIN'] = array_pop(explode('@', $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-EMAIL']));
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-ROOM'] = ExternModule::ExtHtmlReady($curRow['raum']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-PHONE'] = ExternModule::ExtHtmlReady($curRow['Telefon']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-FAX'] = ExternModule::ExtHtmlReady($curRow['Fax']);
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-HOMEPAGE-HREF'] = ExternModule::ExtHtmlReady(trim($curRow['Home']));
            $content['PERSONDETAILS']['ALL-INST']['SINGLE-INST'][$j]['SINGLE-INST-OFFICE-HOURS'] = ExternModule::ExtHtmlReady($curRow['sprechzeiten']);
            $j++;
        }
        
        // generic data fields
        if ($generic_datafields = $this->config->getValue('Main', 'genericdatafields')) {
            $localEntries = DataFieldEntry::getDataFieldEntries($this->user_id, 'user');
            $k = 1;
            foreach ($generic_datafields as $datafield) {
                if (isset($localEntries[$datafield]) &&
                        is_object($localEntries[$datafield]) &&
                        Visibility::verify($localEntries[$datafield]->getId(), $this->user_id)) {
                    if ($localEntries[$datafield]->getType() == 'link') {
                        $localEntry = ExternModule::extHtmlReady($localEntries[$datafield]->getValue());
                    } else {
                        $localEntry = $localEntries[$datafield]->getDisplayValue();
                    }
                    if ($localEntry) {
                        $content['PERSONDETAILS']["DATAFIELD_$k"] = $localEntry;
                    }
                }
                $k++;
            }
        }

        // homepage plugins
        $plugins = PluginEngine::getPlugins('HomepagePlugin');

        foreach ($plugins as $plugin) {
            $template = $plugin->getHomepageTemplate($this->user_id);

            if ($template) {
                $keyname = 'PLUGIN_' . strtoupper($plugin->getPluginName());
                $content['PERSONDETAILS'][$keyname] = $template->render();
            }
        }

        if (Visibility::verify('lebenslauf', $this->user_id)) {
            $content['PERSONDETAILS']['CV'] = ExternModule::ExtFormatReady($row['lebenslauf']);
        }
        if (Visibility::verify('schwerp', $this->user_id)) {
            $content['PERSONDETAILS']['RESEARCH-INTERESTS'] = ExternModule::ExtFormatReady($row['schwerp']);
        }
        if (Visibility::verify('publi', $this->user_id)) {
            $content['PERSONDETAILS']['PUBLICATIONS'] = ExternModule::ExtFormatReady($row['publi']);
        }

        $content['PERSONDETAILS']['LECTURES'] = $this->elements['TemplateLectures']->toString(array('content' => $this->getContentLectures(), 'subpart' => 'LECTURES'));
        if (Visibility::verify('news', $this->user_id)) {
            $content['PERSONDETAILS']['NEWS'] = $this->elements['TemplateNews']->toString(array('content' => $this->getContentNews(), 'subpart' => 'NEWS'));
        }
        if (Visibility::verify('dates', $this->user_id)) {
            $content['PERSONDETAILS']['APPOINTMENTS'] = $this->elements['TemplateAppointments']->toString(array('content' => $this->getContentAppointments(), 'subpart' => 'APPOINTMENTS'));
        }
        if (Visibility::verify('literature', $this->user_id)) {
            $content['PERSONDETAILS']['LITERATURE'] = $this->elements['TemplateLitList']->toString(array('content' => $this->elements['LitList']->getContent(array('user_id' => $this->user_id)), 'subpart' => 'LITLISTS'));
        }
        $content['PERSONDETAILS']['OWNCATEGORIES'] = $this->elements['TemplateOwnCategories']->toString(array('content' => $this->getContentOwnCategories(), 'subpart' => 'OWNCATEGORIES'));

        return $content;
    }
Example #22
0
 public function getDatafields()
 {
     return DataFieldEntry::getDataFieldEntries(array($this->range_id, $this->statusgruppe_id), 'roleinstdata');
 }
    function getContent ($args = NULL, $raw = FALSE) {
        if ($raw) {
            $this->setRawOutput();
        }

        if (!$all_groups = get_all_statusgruppen($this->config->range_id)) {
            die($GLOBALS["EXTERN_ERROR_MESSAGE"]);
        } else {
            $all_groups = array_keys($all_groups);
        }

        if (!$group_ids = $this->config->getValue('Main', 'groupsvisible')) {
            die($GLOBALS["EXTERN_ERROR_MESSAGE"]);
        } else {
            $group_ids = array_intersect($all_groups, $group_ids);
        }

        if (!is_array($group_ids)) {
            die($GLOBALS["EXTERN_ERROR_MESSAGE"]);
        }

        if (!$visible_groups = get_statusgruppen_by_id($this->config->range_id, $group_ids)) {
            die($GLOBALS["EXTERN_ERROR_MESSAGE"]);
        }

        $sort = $this->config->getValue('Main', 'sort');
        $query_order = '';
        foreach ($sort as $key => $position) {
            if ($position > 0) {
                $query_order[$position] = $this->data_fields[$key];
            }
        }
        if ($query_order) {
            ksort($query_order, SORT_NUMERIC);
            $query_order = ' ORDER BY ' . implode(',', $query_order);
        }

        $grouping = $this->config->getValue("Main", "grouping");
        if (!$nameformat = $this->config->getValue('Main', 'nameformat')) {
            $nameformat = 'full_rev';
        }

        if(!$grouping) {
            $query = "SELECT DISTINCT ui.raum, ui.sprechzeiten, ui.Telefon, inst_perms, Email, aum.user_id, ";
            $query .= 'username, aum.Vorname, title_front, title_rear, ';
            $query .= $GLOBALS['_fullname_sql'][$nameformat] . " AS fullname, aum.Nachname ";
            if ($query_order != '') {
                $query .= "FROM statusgruppe_user LEFT JOIN auth_user_md5 aum USING(user_id) ";
                $query .= "LEFT JOIN user_info USING(user_id) LEFT JOIN user_inst ui USING(user_id) ";
                $query .= "WHERE statusgruppe_id IN (?) AND Institut_id = ? AND ".get_ext_vis_query()."$query_order";
            } else {
                $query .= "FROM statusgruppen s LEFT JOIN statusgruppe_user su USING(statusgruppe_id) ";
                $query .= "LEFT JOIN auth_user_md5 aum USING(user_id) ";
                $query .= "LEFT JOIN user_info USING(user_id) LEFT JOIN user_inst ui USING(user_id) ";
                $query .= "WHERE su.statusgruppe_id IN (?) AND Institut_id = ? ";
                $query .= "' AND ".get_ext_vis_query()." ORDER BY ";
                $query .= "s.position ASC, su.position ASC";
            }
            $parameters = array($this->config->getValue('Main', 'groupsvisible'), $this->config->range_id);
            $statement = DBManager::get()->prepare($query);
            $statement->execute($parameters);
            $row = $statement->fetch(PDO::FETCH_ASSOC);
            $visible_groups = array('');
        }

        // generic data fields
        $generic_datafields = $this->config->getValue('TemplateGeneric', 'genericdatafields');

        $data['data_fields'] = $this->data_fields;
        $defaultaddress = $this->config->getValue('Main', 'defaultadr');
        if (! $defaultaddress) {
           $db_out =& $row;
        }

        $content = null;
        $i = 0;
        $aliases_groups = $this->config->getValue('Main', 'groupsalias');
        foreach ($visible_groups as $group_id => $group) {
            if ($grouping) {
                if ($query_order == '') {
                    $query_order = ' ORDER BY su.position';
                }
                $query = 'SELECT ui.raum, ui.sprechzeiten, ui.Telefon, inst_perms, Email, aum.user_id, ';
                $query .= 'username, aum.Vorname, title_front, title_rear, ';
                $query .= $GLOBALS['_fullname_sql'][$nameformat] . " AS fullname, aum.Nachname ";
                $query .= 'FROM statusgruppe_user su LEFT JOIN auth_user_md5 aum USING(user_id) ';
                $query .= 'LEFT JOIN user_info USING(user_id) LEFT JOIN user_inst ui USING(user_id) ';
                $query .= "WHERE su.statusgruppe_id = ? AND ".get_ext_vis_query()." AND Institut_id = ? $query_order";

                $parameters = array($group_id, $this->config->range_id );
                $statement = DBManager::get()->prepare($query);
                $statement->execute($parameters);
                $row = $statement->fetch(PDO::FETCH_ASSOC);

                if($aliases_groups[$group_id]) {
                    $group = $aliases_groups[$group_id];
                }
            }


            if ($row !== false) {
                if($aliases_groups[$group_id]) {
                    $content['PERSONS']['GROUP'][$i]['GROUPTITLE-SUBSTITUTE'] = ExternModule::ExtHtmlReady($aliases_groups[$group_id]);
                }
                $content['PERSONS']['GROUP'][$i]['GROUPTITLE'] = ExternModule::ExtHtmlReady($group);
                $content['PERSONS']['GROUP'][$i]['GROUP-NO'] = $i + 1;

                $j = 0;
                do{
                    $visibilities = get_local_visibility_by_id($row['user_id'], 'homepage', true);
                    $user_perm = $visibilities['perms'];
                    $visibilities = json_decode($visibilities['homepage'], true);

                    if ($defaultaddress) {
                        $query = 'SELECT ui.raum, ui.sprechzeiten, ui.Telefon, inst_perms,  Email, ';
                        $query .= 'title_front, title_rear, ';
                        $query .= 'aum.user_id, username, ' . $GLOBALS['_fullname_sql'][$nameformat];
                        $query .= ' AS fullname, aum.Nachname, aum.Vorname FROM auth_user_md5 aum LEFT JOIN ';
                        $query .= 'user_info USING(user_id) LEFT JOIN ';
                        $query .= "user_inst ui USING(user_id) WHERE aum.user_id = '" . $row['user_id'];
                        $query .= "' AND ".get_ext_vis_query().' AND externdefault = 1';

                        $statement2 = DBManager::get()->prepare($query);
                        $statement2->execute();
                        $db_out = $statement2->fetch(PDO::FETCH_ASSOC);
                        //no default
                        if ($db_out === false) {
                            $query = 'SELECT ui.raum, ui.sprechzeiten, ui.Telefon, inst_perms,  Email, ';
                            $query .= 'title_front, title_rear, ';
                            $query .= 'aum.user_id, username, ' . $GLOBALS['_fullname_sql'][$nameformat];
                            $query .= ' AS fullname, aum.Nachname, aum.Vorname FROM auth_user_md5 aum LEFT JOIN ';
                            $query .= 'user_info USING(user_id) LEFT JOIN ';
                            $query .= "user_inst ui USING(user_id) WHERE aum.user_id = '" . $row['user_id'];
                            $query .= "' AND ".get_ext_vis_query()." AND Institut_id = ? " ;
                            $statement2 = DBManager::get()->prepare($query);
                            $params = array($this->config->range_id);
                            $statement2->execute($params);
                            $db_out = $statement2->fetch(PDO::FETCH_ASSOC);
                        }
                    }
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['FULLNAME'] = ExternModule::ExtHtmlReady($db_out['fullname']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['LASTNAME'] = ExternModule::ExtHtmlReady($db_out['Nachname']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['FIRSTNAME'] = ExternModule::ExtHtmlReady($db_out['Vorname']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['TITLEFRONT'] = ExternModule::ExtHtmlReady($db_out['title_front']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['TITLEREAR'] = ExternModule::ExtHtmlReady($db_out['title_rear']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['PERSONDETAIL-HREF'] = $this->elements['LinkInternTemplate']->createUrl(array('link_args' => 'username='******'username']));
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['USERNAME'] = $db_out['username'];

                    if (is_element_visible_externally( $row['user_id'], $user_perm, 'picture', $visibilities['picture'])) {
                        $avatar = Avatar::getAvatar($db_out['user_id']);
                    } else {
                        $avatar = Avatar::getNobody();
                    }
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['IMAGE-URL-SMALL'] = $avatar->getURL(Avatar::SMALL);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['IMAGE-URL-MEDIUM'] = $avatar->getURL(Avatar::MEDIUM);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['IMAGE-URL-NORMAL'] = $avatar->getURL(Avatar::NORMAL);

                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['PHONE'] = ExternModule::ExtHtmlReady($db_out['Telefon']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['ROOM'] = ExternModule::ExtHtmlReady($db_out['raum']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['EMAIL'] = get_visible_email($row['user_id']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['EMAIL-LOCAL'] = array_shift(explode('@', $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['EMAIL']));
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['EMAIL-DOMAIN'] = array_pop(explode('@', $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['EMAIL']));
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['OFFICEHOURS'] = ExternModule::ExtHtmlReady($db_out['sprechzeiten']);
                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['PERSON-NO'] = $j + 1;

                    // generic data fields
                    if (is_array($generic_datafields)) {
                        $localEntries = DataFieldEntry::getDataFieldEntries($db_out['user_id'], 'user');
                        #$datafields = $datafields_obj->getLocalFields($db_out->f('user_id'));
                        $k = 1;
                        foreach ($generic_datafields as $datafield) {
                            if (isset($localEntries[$datafield]) &&
                                    is_object($localEntries[$datafield] &&
                                    is_element_visible_externally($db_out['user_id'],
                                        $user_perm, $localEntries[$datafield]->getId(),
                                        $visibilities[$localEntries[$datafield]->getId()]))) {
                                if ($localEntries[$datafield]->getType() == 'link') {
                                    $localEntry = ExternModule::extHtmlReady($localEntries[$datafield]->getValue());
                                } else {
                                    $localEntry = $localEntries[$datafield]->getDisplayValue();
                                }
                                if ($localEntry) {
                                    $content['PERSONS']['GROUP'][$i]['PERSON'][$j]['DATAFIELD_' . $k] = $localEntry;
                                }
                            }
                            $k++;
                        }
                    }
                    $j++;
                }while ($row = $statement->fetch(PDO::FETCH_ASSOC));
            }
            $i++;
        }

        return $content;
    }