function toString ($args = NULL) { $error_message = ""; // 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 = ?"; $parameters = array($seminar_id, $this->config->range_id); $statement = DBManager::get()->prepare($query); $statement->execute($parameters); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row === false && $row['Lesezugriff'] == 0) $error_message = $GLOBALS["EXTERN_ERROR_MESSAGE"]; } else { $seminar_id = $this->config->range_id; } $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) . " DESC"; } if (!$nameformat = $this->config->getValue("Main", "nameformat")) { $nameformat = "no_title_short"; } $folder_tree = TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $seminar_id)); $allowed_folders = $folder_tree->getReadableFolders('nobody'); $query = "SELECT dokument_id, description, filename, d.mkdate, d.chdate, filesize, "; $query .= $GLOBALS["_fullname_sql"][$nameformat]; $query .= "AS fullname, 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 ('"; $query .= implode("','", $allowed_folders) . "')$query_order"; $parameters = array($seminar_id); $statement = DBManager::get()->prepare($query); $statement->execute($parameters); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row === false) { $error_message = $this->config->getValue("Main", "nodatatext"); } $out = $this->elements["TableHeadrow"]->toString(); if ($error_message) { // use one column and set it visible to display error_message $this->config->setValue('Main', 'order', array('0')); $this->config->setValue('Main', 'visible', array('1')); $this->config->setValue('Main', 'width', array('100%')); $out = $this->elements['TableRow']->toString(array('content' => array('' => $error_message))); } else { $table_row_data["data_fields"] = $this->data_fields; do{ preg_match("/^.+\.([a-z1-9_-]+)$/i", $row['filename'], $file_suffix); $icon = ""; switch ($file_suffix[1]) { case "txt" : if (!$picture_file = $this->config->getValue("Main", "icontxt")) $icon = Icon::create("file-text", "clickable"); break; case "xls" : if (!$picture_file = $this->config->getValue("Main", "iconxls")) $icon = Icon::create("file-archive", "clickable"); break; case "ppt" : if (!$picture_file = $this->config->getValue("Main", "iconppt")) $icon = Icon::create("file-presentation", "clickable"); break; case "rtf" : if (!$picture_file = $this->config->getValue("Main", "iconrtf")) $icon = Icon::create("file-text", "clickable"); break; case "zip" : case "tgz" : case "gz" : if (!$picture_file = $this->config->getValue("Main", "iconzip")) $icon = Icon::create("file-archive", "clickable"); break; case "jpg" : case "png" : case "gif" : case "jpeg" : case "tif" : if (!$picture_file = $this->config->getValue("Main", "iconpic")) $icon = Icon::create("file-pic", "clickable"); break; case "pdf" : if (!$picture_file = $this->config->getValue("Main", "iconpdf")) $icon = Icon::create("file-pdf", "clickable"); break; default : if (!$picture_file = $this->config->getValue("Main", "icondefault")) $icon = Icon::create("file-generic", "clickable"); } if ($icon) { $picture_file = $icon; } $download_link = GetDownloadLink($row['dokument_id'], $row['filename']); // Aufbereiten der Daten $table_row_data["content"] = array( "icon" => sprintf("<a href=\"%s\">%s</a>", $download_link, is_string($picture_file) ? Assets::img($picture_file) : $picture_file->asImg()), "filename" => $this->elements["Link"]->toString(array("content" => htmlReady($row['filename']), "link" => $download_link)), "description" => htmlReady(mila_extern($row['description'], $this->config->getValue("Main", "lengthdesc"))), "mkdate" => strftime($this->config->getValue("Main", "dateformat"), $row['mkdate']), "filesize" => $row['filesize'] > 1048576 ? round($row['filesize'] / 1048576, 1) . " MB" : round($row['filesize'] / 1024, 1) . " kB", ); // if user is member of a group then link name to details page if (GetRoleNames(GetAllStatusgruppen($this->config->range_id, $row['user_id']))) { $table_row_data['content']['fullname'] = $this->elements['LinkIntern']->toString(array('content' => htmlReady($row['fullname']), 'module' => 'Persondetails', 'link_args' => 'username='******'username'])); } else { $table_row_data['content']['fullname'] = htmlReady($row['username'] ? $row['username'] : $row['author_name']); } $out .= $this->elements["TableRow"]->toString($table_row_data); }while($row = $statement->fetch(PDO::FETCH_ASSOC)); } return $this->elements["TableHeader"]->toString(array("content" => $out)); }
} } // freie Suche if (strlen($name) > 2) { $name = str_replace('%', '\\%', $name); $name = str_replace('_', '\\_', $name); $filter[] = "CONCAT(Vorname, ' ', Nachname) LIKE CONCAT('%', :needle, '%')"; $parameters[':needle'] = $name; } if (count($filter)) { $_fields = implode(', ', $fields); $_tables = implode(' ', $tables); $_filters = implode(' AND ', $filter); $query = "SELECT {$_fields}\n FROM {$_tables}\n WHERE {$_filters}\n ORDER BY {$sortby}"; $statement = DBManager::get()->prepare($query); $statement->execute($parameters); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { if ($row['visible']) { $userinfo = array('user_id' => $row['user_id'], 'username' => $row['username'], 'fullname' => $row['fullname'], 'status' => $row['status'] ?: $row['perms']); if (isset($row['inst_perms'])) { $gruppen = GetRoleNames(GetAllStatusgruppen($inst_id, $row['user_id'])); $userinfo['status'] = is_array($gruppen) ? join(', ', array_values($gruppen)) : _('keiner Funktion zugeordnet'); } $users[] = $userinfo; } } $template->set_attribute('users', $users); } /* --- View ----------------------------------------------------------------- */ echo $template->render(); page_close();
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; }
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; }
function GetRoleNames($roles, $level = 0, $pred = '', $all = false) { $out = array(); if (is_array($roles)) foreach ($roles as $role_id => $role) { if ($level == 0) $inst_id = $role_id; if (!$role['name']) $role['name'] = $role['role']->getName(); if ($pred != '') { $new_pred = $pred.' > '.$role['name']; } else { $new_pred = $role['name']; } if ($role['user_there'] || $all) { $out[$role_id] = $new_pred; } if ($role['child']) { $out = array_merge((array)$out, (array)GetRoleNames($role['child'], $level+1, $new_pred, $all)); } } return (sizeof($out) > 0 ? $out : null); }
function kontakt ($module, $row, $separate = FALSE) { $attr_table = $module->config->getAttributes("Contact", "table"); $attr_tr = $module->config->getAttributes("Contact", "table"); $attr_td = $module->config->getAttributes("Contact", "td"); $attr_fonttitle = $module->config->getAttributes("Contact", "fonttitle"); $attr_fontcontent = $module->config->getAttributes("Contact", "fontcontent"); $out = "<table$attr_table>\n"; if (!$separate) { $out .= "<tr$attr_tr>"; $out .= "<td colspan=\"2\"$attr_td>"; $out .= "<font$attr_fonttitle>"; if ($headline = $module->config->getValue("Contact", "headline")) $out .= "$headline</font>\n"; else $out .= "</font>\n"; $out .= "<font$attr_fontcontent>"; if (!$module->config->getValue("Contact", "hidepersname")) $out .= "<br><br>" . htmlReady($row['fullname'], TRUE) . "\n"; if ($module->config->getValue('Contact', 'showinstgroup')) { $allgroups = GetAllStatusgruppen($module->config->range_id, $row['user_id']); array_walk($allgroups, function(&$v, $k, $user_id) { $s = Statusgruppen::find($k); $v['role']->name = htmlReady($s->getGenderedName($user_id)); }, $row['user_id']); if ($gruppen = GetRoleNames($allgroups)) $out .= "<br>" . htmlReady(join(", ", array_values($gruppen))); } // display name of institution (as link) if ($row['Name']) { $br_out = ""; if ($module->config->getValue("Contact", "hideinstname") != '1') { if ($module->config->getValue("Contact", "hideinstname") == 'link' && $row['url']) { $url = htmlReady(trim($row['url'])); if (!stristr($url, "http://")) $url = "http://$url"; $out .= "<br><br><a href=\"$url\" target=\"_blank\">"; $out .= htmlReady($row['Name'], TRUE) . "</a><br>"; } else $out .= "<br><br>" . htmlReady($row['Name'], TRUE) . "<br>"; } if ($module->config->getValue("Contact", "adradd")) $out .= "<br>" . $module->config->getValue("Contact", "adradd"); } $out .= "<br>"; if ($row['Strasse']) { $out .= "<br>" . htmlReady($row['Strasse'], TRUE); if($row['Plz']) $out .= "<br>" . htmlReady($row['Plz'], TRUE); } $out .= "<br><br></font></td></tr>\n"; } $order = $module->config->getValue("Contact", "order"); $visible = $module->config->getValue("Contact", "visible"); $alias_contact = $module->config->getValue("Contact", "aliases"); foreach ($order as $position) { $data_field = $module->data_fields["contact"][$position]; if (!$visible[$position] || !$row[$data_field]) continue; switch ($data_field) { case 'Email' : if ($separate || !$module->config->getValue('Contact', 'separatelinks')) { $email_address = get_visible_email($row['user_id']); $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $mail = trim(htmlReady($email_address)); $out .= "<a href=\"mailto:$mail\">$mail</a>"; } break; case 'Home' : if (($separate || !$module->config->getValue('Contact', 'separatelinks')) && true�|| Visibility::verify('homepage', $row['user_id'])) { $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $out .= formatLinks($row['Home']); } break; default: if (!$separate) { $out .= "<tr$attr_tr>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fonttitle>"; $out .= $alias_contact[$position] . "</font></td>"; $out .= "<td$attr_td>"; $out .= "<font$attr_fontcontent>"; $out .= htmlReady($row[$data_field], TRUE); } } if ($row[$data_field]) $out .= "</font></td></tr>\n"; } $out .= "</table>\n"; return $out; }