function getLinkToModule ($linked_element_name = null, $params = null, $with_module_params = false, $self = false) { if ($with_module_params) { $module_params = $this->getModuleParams(); $params = array_merge($module_params, $params); } $query_parts = array(); if (is_array($params)) { $param_key = 'ext_' . strtolower($this->name); foreach ($params as $name => $value) { $query_parts[] = "{$param_key}[{$name}]=" . $value; } } if (is_null($linked_element_name)) { $sriurl = trim($this->config->getValue('Main', 'sriurl')); $includeurl = trim($this->config->getValue('Main', 'includeurl')); } else { $sriurl = trim($this->config->getValue($linked_element_name, 'srilink')); $includeurl = trim($this->config->getValue($linked_element_name, 'includlink')); } if ($sriurl) { $url = $sriurl; } else if ($includeurl) { $url = $includeurl; } else { $url = $GLOBALS['EXTERN_SERVER_NAME'] . 'extern.php'; } if (parse_url($url, PHP_URL_QUERY)) { $url .= '&'; } else { $url .= '?'; } if ($self) { $module = $this->name; } else { // get module name by config id $linked_element_id = $this->config->getValue($linked_element_name, 'config'); // linked with module declared as standard? if ($linked_element_id) { $config_meta_data = ExternConfig::GetConfigurationMetaData($this->config->range_id, $linked_element_id); } else { $config_meta_data = array('module_name' => $this->config->module_name); } if (is_array($config_meta_data)) { $module = $config_meta_data['module_name']; // var_dump($this->config); } else { return ''; } } $url .= "module={$module}&config_id=" . (is_null($linked_element_name) ? $this->config->getId() : $this->config->getValue($linked_element_name, 'config')) . "&range_id={$this->config->range_id}"; if (sizeof($query_parts)) { $url .= '&' . implode('&', $query_parts); } return $url; }
function GetInfo ($range_id, $config_id) { $query = "SELECT * FROM extern_config WHERE config_id = ? "; $query .= " AND range_id = ? "; $params = array($config_id, $range_id); $state = DBManager::get()->prepare($query); $state->execute($params); $res = $state->fetch(PDO::FETCH_ASSOC); if ($res) { $global_config = ExternConfig::GetGlobalConfiguration($range_id); $module_type = $res['config_type']; $module = $GLOBALS["EXTERN_MODULE_TYPES"][$res['config_type']]["module"]; $level = $GLOBALS["EXTERN_MODULE_TYPES"][$res['config_type']]["level"]; $make = strftime("%x", $res['mkdate']); $change = strftime("%x", $res['chdate']); $sri = "<studip_remote_include>\n\t<module name=\"$module\" />"; $sri .= "\n\t<config id=\"$config_id\" />\n\t"; if ($global_config) { $sri .= "<global id=\"$global_config\" />\n\t"; } $sri .= "<range id=\"$range_id\" />"; $sri .= "\n</studip_remote_include>"; $link_sri = $GLOBALS["EXTERN_SERVER_NAME"] . 'extern.php?page_url=' . _("URL_DER_INCLUDE_SEITE"); if ($level) { $link = $GLOBALS["EXTERN_SERVER_NAME"] . "extern.php?module=$module"; if ($global_config) { $link .= "&config_id=$config_id&global_id=$global_config&range_id=$range_id"; } else { $link .= "&config_id=$config_id&range_id=$range_id"; } $link_structure = $link . "&view=tree"; $sri_structure = "<studip_remote_include>\n\tmodule = $module\n\t"; $sri_structure = "config_id = $config_id\n\t"; if ($global_config) { $sri_structure .= "global_id = $global_config\n\t"; } $sri_structure .= "range_id=$range_id"; $sri_structure .= "\n\tview = tree\n</studip_remote_include>"; $link_br = $GLOBALS["EXTERN_SERVER_NAME"] . "extern.php?module=$module<br>"; if ($global_config) { $link_br .= "&config_id=$config_id<br>&global_id=$global_config<br>&range_id=$range_id"; } else { $link_br .= "&config_id=$config_id<br>&range_id=$range_id"; } $info = array("module_type" => $module_type, "module_name" => $module, "name" => $res['name'], "make_date" => $make, "change_date" => $change, "link" => $link, "link_stucture" => $link_structure, "sri" => $sri, "sri_structure" => $sri_structure, "link_sri" => $link_sri, "level" => $level, "link_br" => $link_br); } else { $info = array("module_type" => $module_type, "module_name" => $module_name, "name" =>$res['name'], "make_date" => $make, "change_date" => $change, "sri" => $sri, "link_sri" => $link_sri, "level" => $level); } return $info; } return FALSE; }
function insertConfiguration () { if (!parent::insertConfiguration()) { return false; } $serialized_config = serialize($config_obj->config); $time = time(); $query = "INSERT INTO extern_config VALUES (?,?,?,?,0,?,?,?)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->id, $this->range_id, $this->module_type, $this->config_name, $serialized_config, $time, $time )); if (!$statement->rowCount()) { return FALSE; } return TRUE; }
echo CSRFProtection::tokenTag(); echo "<blockquote><font size=\"2\">"; $choose_institute_copy = "<select name=\"copychooseinst\">\n"; foreach ($conf_institutes as $conf_institute) { $choose_institute_copy .= sprintf("<option value=\"%s\" style=\"%s\">%s</option>\n", $conf_institute['institut_id'], ($conf_institute['fakultaets_id'] == $conf_institute['institut_id'] ? '"font-weight:bold;' : ''), htmlReady(strlen($conf_institute['name']) > 60 ? substr_replace($conf_institute['name'], '[...]', 30, -30) : $conf_institute['name'])); } $choose_institute_copy .= "</select>\n"; printf(_("Konfiguration aus Einrichtung %s kopieren."), $choose_institute_copy); echo Button::create(_("Weiter") . " >>"); echo "</font></blockquote>\n"; echo "</form>\n"; } } else { if (Request::option('com') == 'copychoose') { $choose_module_select = "<select name=\"copyconfigid\">\n"; $configurations_copy = ExternConfig::GetAllConfigurations(Request::quoted('copychooseinst')); foreach ($module_types_ordered as $module_type) { $print_module_name = TRUE; if (is_array($configurations_copy[$GLOBALS['EXTERN_MODULE_TYPES'][$module_type]['module']])) { foreach ($configurations_copy[$GLOBALS['EXTERN_MODULE_TYPES'][$module_type]['module']] as $config_id_copy => $config_data_copy) { if ($print_module_name) { $choose_module_select .= '<option value="" style="font-weight: bold;">' . htmlReady($GLOBALS['EXTERN_MODULE_TYPES'][$module_type]['name']) . '</option>'; } $choose_module_select .= '<option value="' . $config_id_copy . '"> ' . htmlReady($config_data_copy['name']) . '</option>'; $print_module_name = FALSE; } } } echo '<form method="post" action="' . URLHelper::getLink('?com=copyconfig') . '">';
exit; } } } // if there is no global_id or global_name, take the DEFAULT global configuration if ($global_name) { // check for valid configuration name and convert it into a config_id if (!$global_id = ExternConfig::GetConfigurationByName($range_id, $type, $config_name)) { echo $EXTERN_ERROR_MESSAGE; exit; } } elseif (!$global_id) { // check for standard configuration if ($id = ExternConfig::GetGlobalConfiguration($range_id)) $global_id = $id; else { // use no global configuration $global_id = NULL; } } // sem == -1: show data from last semester // sem == +1: show data from next semester // other values: show data from current semester $now = time(); foreach ($all_semester as $key => $sem_record) { if ($now >= $sem_record["beginn"] && $now <= $sem_record["ende"]) { $current = $key; break;
// +---------------------------------------------------------------------------+ // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or any later version. // +---------------------------------------------------------------------------+ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // +---------------------------------------------------------------------------+ $info = ExternConfig::GetInfo($range_id, $config_id); $css_switcher = new CssClassSwitcher("", ""); echo "<tr><td class=\"blank\" width=\"100%\">"; echo " </td></tr>\n"; echo "<tr><td class=\"" . $css_switcher->getHeaderClass() . "\" height=\"20\" valign=\"bottom\">\n"; echo "<font size=\"2\"><b> " . _("Allgemeine Daten") . "</b></font></td></tr>\n"; $css_switcher->switchClass(); echo "<tr><td" . $css_switcher->getFullClass() . ">\n"; echo "<blockquote><font size=\"2\"><br><b>"; echo _("Modulname") . ':'; echo "</b>  " . $info["module_name"]; echo "<br><br>\n<font size=\"2\"><b>"; echo _("Name der Konfiguration") . ':'; echo "</b>  " . $info["name"]; echo "<br><br>\n<b>";
function toString ($args) { if (!$args["main_module"]) { $args["main_module"] = "Main"; } $config_meta_data = ExternConfig::GetConfigurationMetaData($this->config->range_id, $this->config->getValue($this->name, 'config')); $sri_link = $this->config->getValue($this->name, "srilink"); $extern_link = $this->config->getValue($this->name, "externlink"); if ($this->config->config[$args["main_module"]]["incdata"]) { $link = $sri_link; if ($args["link_args"]) { if (preg_match("#.*\?.*#", $link)) { $link .= "&" . $args["link_args"]; } else { $link .= "?" . $args["link_args"]; } } } else { if ($sri_link) { $link = $GLOBALS['EXTERN_SERVER_NAME'] . 'extern.php'; if ($args["link_args"]) { $link .= "?" . $args["link_args"] . "&"; } else { $link .= "?"; } $link .= "page_url=" . $sri_link; } elseif ($extern_link) { if (strrpos($extern_link, '?')) { $link = "$extern_link&module={$config_meta_data['module_name']}"; } else { $link = "$extern_link?module={$config_meta_data['module_name']}"; } if ($config = $this->config->getValue($this->name, 'config')) { $link .= "&config_id=" . $config; } $link .= "&range_id={$this->config->range_id}"; if ($args["link_args"]) { $link .= "&" . $args["link_args"]; } } else { $link = $GLOBALS['EXTERN_SERVER_NAME'] . "extern.php?module={$config_meta_data['module_name']}"; if ($config = $this->config->getValue($this->name, 'config')) { $link .= "&config_id=" . $config; } $link .= "&range_id={$this->config->range_id}"; if ($args["link_args"]) { $link .= "&" . $args["link_args"]; } } } if ($this->config->global_id) { $link .= "&global_id=" . $this->config->global_id; } // to set the color of the font in the style-attribute of the a-tag if ($color = $this->config->getValue($this->name, "font_color")) { $this->config->setValue($this->name, "a_style", "color:$color;" . $this->config->getValue($this->name, "a_style")); } if ($font_attr = $this->config->getAttributes($this->name, "font")) { $out = "<font$font_attr>" . $args["content"] . "</font>"; } else { $out = $args["content"]; } $out = "<a href=\"$link\"" . $this->config->getAttributes($this->name, "a") . ">" . $out . "</a>"; return $out; }
/** * Deletes an institute * @param String $i_id Institute id */ public function delete_action($i_id) { CSRFProtection::verifyUnsafeRequest(); // Missing parameter if (!Request::get('i_kill')) { return $this->redirect('institute/basicdata/index/' . $i_id); } // Invalid ticket if (!check_ticket(Request::option('studipticket'))) { PageLayout::postMessage(MessageBox::error(_('Ihr Ticket ist abgelaufen. Versuchen Sie die letzte Aktion erneut.'))); return $this->redirect('institute/basicdata/index/' . $i_id); } // User may not delete this institue if (!$GLOBALS['perm']->have_perm('root') && !($GLOBALS['perm']->is_fak_admin() && get_config('INST_FAK_ADMIN_PERMS') === 'all')) { PageLayout::postMessage(MessageBox::error(_('Sie haben nicht die Berechtigung Fakultäten zu löschen!'))); return $this->redirect('institute/basicdata/index/' . $i_id); } $institute = Institute::find($i_id); if ($institute === null) { throw new Exception('Invalid institute id'); } // Institut in use? if (count($institute->home_courses)) { PageLayout::postMessage(MessageBox::error(_('Diese Einrichtung kann nicht gelöscht werden, da noch Veranstaltungen an dieser Einrichtung existieren!'))); return $this->redirect('institute/basicdata/index/' . $i_id); } // Institute has sub institutes? if (count($institute->sub_institutes)) { PageLayout::postMessage(MessageBox::error(_('Diese Einrichtung kann nicht gelöscht werden, da sie den Status Fakultät hat und noch andere Einrichtungen zugeordnet sind!'))); return $this->redirect('institute/basicdata/index/' . $i_id); } // Is the user allowed to delete faculties? if ($institute->is_fak && !$GLOBALS['perm']->have_perm('root')) { PageLayout::postMessage(MessageBox::error(_('Sie haben nicht die Berechtigung Fakultäten zu löschen!'))); return $this->redirect('institute/basicdata/index/' . $i_id); } // Save users, name and number of courses $user_ids = $institute->members->pluck('user_id'); $i_name = $institute->name; $i_courses = count($institute->courses); // Delete that institute if (!$institute->delete()) { PageLayout::postMessage(MessageBox::error(_('Die Einrichtung konnte nicht gelöscht werden.'))); } else { $details = array(); // logging - put institute's name in info - it's no longer derivable from id afterwards log_event('INST_DEL', $i_id, NULL, $i_name); // set a suitable default institute for each user foreach ($user_ids as $user_id) { log_event('INST_USER_DEL', $i_id, $user_id); checkExternDefaultForUser($user_id); } if (count($user_ids)) { $details[] = sprintf(_('%u Mitarbeiter gelöscht.'), count($user_ids)); } // Report number of formerly associated courses if ($i_courses) { $details[] = sprintf(_('%u Beteiligungen an Veranstaltungen gelöscht'), $i_courses); } // delete literatur $del_lit = StudipLitList::DeleteListsByRange($i_id); if ($del_lit) { $details[] = sprintf(_('%u Literaturlisten gelöscht.'), $del_lit['list']); } // delete news-links StudipNews::DeleteNewsRanges($i_id); //delete entry in news_rss_range StudipNews::UnsetRssId($i_id); //updating range_tree $query = "UPDATE range_tree SET name = ?, studip_object = '', studip_object_id = '' WHERE studip_object_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array(_('(in Stud.IP gelöscht)'), $i_id)); if (($db_ar = $statement->rowCount()) > 0) { $details[] = sprintf(_('%u Bereiche im Einrichtungsbaum angepasst.'), $db_ar); } // Statusgruppen entfernen if ($db_ar = DeleteAllStatusgruppen($i_id) > 0) { $details[] = sprintf(_('%s Funktionen/Gruppen gelöscht.'), $db_ar); } //kill the datafields DataFieldEntry::removeAll($i_id); //kill all wiki-pages $removed_wiki_pages = 0; foreach (array('', '_links', '_locks') as $area) { $query = "DELETE FROM wiki{$area} WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($i_id)); $removed_wiki_pages += $statement->rowCount(); } if ($removed_wiki_pages > 0) { $details[] = sprintf(_('%u Wikiseiten gelöscht.')); } // kill all the ressources that are assigned to the Veranstaltung (and all the linked or subordinated stuff!) if (get_config('RESOURCES_ENABLE')) { $killAssign = new DeleteResourcesUser($i_id); $killAssign->delete(); } // delete all configuration files for the "extern modules" if (get_config('EXTERN_ENABLE')) { $counts = ExternConfig::DeleteAllConfigurations($i_id); if ($counts) { $details[] = sprintf(_('%u Konfigurationsdateien für externe Seiten gelöscht.'), $counts); } } // delete all contents in forum-modules foreach (PluginEngine::getPlugins('ForumModule') as $plugin) { $plugin->deleteContents($i_id); // delete content irrespective of plugin-activation in the seminar if ($plugin->isActivated($i_id)) { // only show a message, if the plugin is activated, to not confuse the user $details[] = sprintf(_('Einträge in %s gelöscht.'), $plugin->getPluginName()); } } // Delete assigned documents $db_ar = delete_all_documents($i_id); if ($db_ar > 0) { $details[] = sprintf(_('%u Dokumente gelöscht.'), $db_ar); } //kill the object_user_vists for this institut object_kill_visits(null, $i_id); // Report success with details $message = sprintf(_('Die Einrichtung "%s" wurde gelöscht!'), $i_name); PageLayout::postMessage(MessageBox::success($message, $details)); } $this->redirect('institute/basicdata/index?cid='); }
function deleteConfiguration () { if (parent::deleteConfiguration()) { if (!@unlink($GLOBALS['EXTERN_CONFIG_FILE_PATH'] . $this->file_name)) { return FALSE; } } else { return FALSE; } return TRUE; }
function createUrl ($args) { if (!$args["main_module"]) { $args["main_module"] = "Main"; } $config_meta_data = ExternConfig::GetConfigurationMetaData($this->config->range_id, $this->config->getValue($this->name, 'config')); if (is_array($config_meta_data)) { $module_name = $config_meta_data['module_name']; } else { foreach ((array) $this->link_module_type as $type) { if (is_array($GLOBALS['EXTERN_MODULE_TYPES'][$type])) { $module_name = $GLOBALS['EXTERN_MODULE_TYPES'][$type]['module']; break; } } } $sri_link = $this->config->getValue($this->name, "srilink"); $extern_link = $this->config->getValue($this->name, "externlink"); if ($this->config->config[$args["main_module"]]["incdata"]) { $link = $sri_link; if ($args["link_args"]) { if (strrpos($link, '?')) { $link .= "&" . $args["link_args"]; } else { $link .= "?" . $args["link_args"]; } } if ($this->config->global_id) { $link .= "&global_id=" . $this->config->global_id; } } else { if ($sri_link) { $link = $GLOBALS['EXTERN_SERVER_NAME'] . 'extern.php'; if ($args["link_args"]) { $link .= "?" . $args["link_args"] . "&"; } else { $link .= "?"; } if ($this->config->global_id) { $link .= "global_id=" . $this->config->global_id . '&'; } $link .= "page_url=" . $sri_link; } elseif ($extern_link) { if (strrpos($extern_link, '?')) { $link = "$extern_link&module=$module_name"; } else { $link = "$extern_link?module=$module_name"; } if ($config = $this->config->getValue($this->name, "config")) { $link .= "&config_id=" . $config; } $link .= "&range_id={$this->config->range_id}"; if ($args["link_args"]) { $link .= "&" . $args["link_args"]; } if ($this->config->global_id) { $link .= "&global_id=" . $this->config->global_id; } } else { $link = $GLOBALS['EXTERN_SERVER_NAME'] . "extern.php?module=$module_name"; if ($config = $this->config->getValue($this->name, "config")) { $link .= "&config_id=" . $config; } $link .= "&range_id={$this->config->range_id}"; if ($args["link_args"]) { $link .= "&" . $args["link_args"]; } if ($this->config->global_id) { $link .= "&global_id=" . $this->config->global_id; } } } return $link; }
} else { echo $GLOBALS['EXTERN_ERROR_MESSAGE']; exit; } } } // the module itself validates the rest } else { // without a range_id and a module-name there's no chance to printout data // except an error message echo $GLOBALS['EXTERN_ERROR_MESSAGE']; exit; } // check for standard global configuration if (empty($global_id) && ($global_configuration = ExternConfig::GetGlobalConfiguration($range_id))) { $global_id = $global_configuration; } // all parameters ok, instantiate module and print data foreach ($GLOBALS['EXTERN_MODULE_TYPES'] as $type) { if ($type["module"] == $module) { $module_obj = ExternModule::GetInstance($range_id, $module, $config_id, $default, $global_id); } } // Workaround to include data in scripts if ($incdata) { $module_obj->config->config["Main"]["incdata"] = 1; }