Exemple #1
6
 public function search($for_text)
 {
     global $search_params;
     $search_params = words($for_text);
     $wrds = array();
     foreach ($search_params as $param) {
         array_push($wrds, "stem = '{$param}'");
     }
     $word_sql = "SELECT * from words where 'join(" or ", {$wrds})'";
     global $search_words;
     $search_words = mysql_query($word_sql);
     $tables = array();
     $joins = array();
     $ids = array();
     foreach ($search_words as $w => $index) {
         array_push($tables, "locations loc{$index}");
         array_push($joins, "loc{$index}.page_id = loc({$index}+1).page_id");
         array_push($ids, "loc{$index}.word_id = {$w}.id");
     }
     array_pop($joins);
     global $common_select;
     $common_select = "from join(', ', {$tables}) where join(', ', ({$joins} + {$ids})) group by loc0.page_id";
     array_slice(rank(), 0, $searchLimit);
 }
 /**
  *
  * @param string $query: SQL with at least ":input" as parameter
  * @param array $presets: variables from the same form that should be used
  * in this search. array("input_name" => "placeholder_in_sql_query")
  * @return void
  */
 public function __construct($search, $title = "", $avatarLike = "user_id", $presets = array())
 {
     $this->search = $search;
     $this->presets = $presets;
     $this->title = $title;
     $this->avatarLike = in_array($avatarLike, words('user_id, username')) ? $avatarLike : 'user_id';
 }
Exemple #3
0
 /**
  * Before filter, set up the page by initializing the session and checking
  * all conditions.
  *
  * @param String $action Name of the action to be invoked
  * @param Array  $args   Arguments to be passed to the action method
  */
 public function before_filter(&$action, &$args)
 {
     $this->priviledged = $GLOBALS['perm']->have_studip_perm('tutor', $GLOBALS['SessSemName'][1]);
     if (Request::isXhr()) {
         $this->set_content_type('text/html;charset=Windows-1252');
     } else {
         $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     }
     if (!in_array($action, words('index create edit move delete'))) {
         array_unshift($args, $action);
         $action = 'index';
     }
     if (in_array($action, words('create edit move delete')) && !$this->priviledged) {
         throw new AccessDeniedException(_('Sie sind nicht berechtigt, auf diesen Bereich zuzugreifen'));
     }
     if ($GLOBALS['perm']->have_studip_perm('tutor', $GLOBALS['SessSemName'][1])) {
         $widget = new ActionsWidget();
         $widget->addLink(_('Neuen Eintrag anlegen'), $this->url_for('show/create'), 'icons/16/blue/add.png')->asDialog();
         Sidebar::get()->addWidget($widget);
     }
     PageLayout::setHelpKeyword('Basis.Informationsseite');
     /**
             checkObject(); // do we have an open object?
             checkObjectModule('scm');
             object_set_visit_module('scm');
     	 **/
 }
 function initialize()
 {
     $styles = $this->combineAssets('plugingenerator', words('form buttons tooltip generator styles'), '.css');
     PageLayout::addStylesheet($styles);
     $scripts = $this->combineAssets('plugingenerator', words('form-protect generator application'), '.js');
     PageLayout::addScript($scripts);
 }
Exemple #5
0
 /**
  * common tasks for all actions
  */
 function before_filter(&$action, &$args)
 {
     global $perm;
     parent::before_filter($action, $args);
     $course_id = $args[0];
     $this->course_id = Request::option('cid', $course_id);
     Navigation::activateItem('/course/admin/admission');
     if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) {
         throw new Trails_Exception(403);
     }
     $this->course = Course::find($this->course_id);
     $this->user_id = $GLOBALS['user']->id;
     PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenZugangsberechtigungen");
     PageLayout::setTitle($this->course->getFullname() . " - " . _("Verwaltung von Zugangsberechtigungen"));
     $lockrules = words('admission_turnout admission_type admission_endtime admission_binding passwort read_level write_level admission_prelim admission_prelim_txt admission_starttime admission_endtime_sem admission_disable_waitlist user_domain admission_binding admission_studiengang');
     foreach ($lockrules as $rule) {
         $this->is_locked[$rule] = LockRules::Check($this->course_id, $rule) ? 'disabled readonly' : '';
     }
     if (!SeminarCategories::GetByTypeId($this->course->status)->write_access_nobody) {
         $this->is_locked['write_level'] = 'disabled readonly';
     }
     update_admission($this->course->id);
     PageLayout::addSqueezePackage('admission');
     URLHelper::addLinkParam('return_to_dialog', Request::get('return_to_dialog'));
 }
Exemple #6
0
 private static function entryToJson($entry)
 {
     $json = array();
     foreach (words("start end content title color type") as $key) {
         $json[$key] = $entry[$key];
     }
     return $json;
 }
Exemple #7
0
 /**
  * @param StudipCache $cache       The actual cache object
  * @param mixed       $proxy_these List of operations to proxy (should be
  *                                 an array but a space seperated string
  *                                 is also valid)
  */
 public function __construct(StudipCache $cache, $proxy_these = array('expire'))
 {
     if (!is_array($proxy_these)) {
         $proxy_these = words($proxy_these);
     }
     $this->actual_cache = $cache;
     $this->proxy_these = is_array($proxy_these) ? $proxy_these : words($proxy_these);
 }
Exemple #8
0
 /**
  * Set the seminar denoted by the passed id as visited by the currently 
  * logged in user
  * 
  * @param string $seminar_id
  */
 static function setVisit($seminar_id)
 {
     $type = get_object_type($seminar_id, words('fak inst sem'));
     if ($type === 'fak') {
         $type = 'inst';
     }
     if (self::getVisit($seminar_id) < object_get_visit($seminar_id, $type, false, false)) {
         self::setVisitdates($seminar_id);
     }
 }
 private function addWidgetDefaulConfiguration($classnames)
 {
     foreach ($classnames as $key => $classname) {
         $plugin_id = DBManager::get()->query("SELECT pluginid FROM plugins\n                WHERE pluginclassname = '{$classname}'")->fetchColumn();
         $stmt = DBManager::get()->prepare("INSERT INTO widget_default\n                (`pluginid`, `col`, `position`, `perm`) VALUES (?, ?, ?, ?)");
         foreach (words("user autor tutor dozent admin root") as $perm) {
             $stmt->execute(array($plugin_id, 0, $key, $perm));
         }
     }
 }
Exemple #10
0
 /**
  * this action is the main action of the schedule-controller, setting the environment for the timetable,
  * accepting a comma-separated list of days.
  *
  * @param  string  a list of an arbitrary mix of the numbers 0-6, separated with a comma (e.g. 1,2,3,4,5 (for Monday to Friday, the default))
  */
 function index_action($days = false)
 {
     if ($GLOBALS['perm']->have_perm('admin')) {
         $inst_mode = true;
     }
     $my_schedule_settings = $GLOBALS['user']->cfg->SCHEDULE_SETTINGS;
     // set the days to be displayed
     if ($days === false) {
         if (Request::getArray('days')) {
             $this->days = array_keys(Request::getArray('days'));
         } else {
             $this->days = array(0, 1, 2, 3, 4, 5, 6);
         }
     } else {
         $this->days = explode(',', $days);
     }
     // try to find the correct institute-id
     $institute_id = Request::option('institute_id', $SessSemName[1] ? $SessSemName[1] : Request::option('cid', false));
     if (!$institute_id) {
         $institute_id = $GLOBALS['user']->cfg->MY_INSTITUTES_DEFAULT;
     }
     if (!$institute_id || in_array(get_object_type($institute_id), words('inst fak')) === false) {
         throw new Exception(sprintf(_('Kann Einrichtungskalendar nicht anzeigen!' . 'Es wurde eine ungültige Instituts-Id übergeben (%s)!', $institute_id)));
     }
     // load semester-data and current semester
     $semdata = new SemesterData();
     $this->semesters = $semdata->getAllSemesterData();
     if (Request::option('semester_id')) {
         $this->current_semester = $semdata->getSemesterData(Request::option('semester_id'));
     } else {
         $this->current_semester = $semdata->getCurrentSemesterData();
     }
     $this->entries = (array) CalendarInstscheduleModel::getInstituteEntries($GLOBALS['user']->id, $this->current_semester, 8, 20, $institute_id, $this->days);
     Navigation::activateItem('/course/main/schedule');
     PageLayout::setHelpKeyword('Basis.TerminkalenderStundenplan');
     PageLayout::setTitle($GLOBALS['SessSemName']['header_line'] . ' - ' . _('Veranstaltungs-Stundenplan'));
     $zoom = Request::int('zoom', 0);
     $this->controller = $this;
     $this->calendar_view = new CalendarWeekView($this->entries, 'instschedule');
     $this->calendar_view->setHeight(40 + 20 * $zoom);
     $this->calendar_view->setRange($my_schedule_settings['glb_start_time'], $my_schedule_settings['glb_end_time']);
     $this->calendar_view->groupEntries();
     // if enabled, group entries with same start- and end-date
     URLHelper::addLinkParam('zoom', $zoom);
     URLHelper::addLinkParam('semester_id', $this->current_semester['semester_id']);
     $style_parameters = array('whole_height' => $this->calendar_view->getOverallHeight(), 'entry_height' => $this->calendar_view->getHeight());
     $factory = new Flexi_TemplateFactory($this->dispatcher->trails_root . '/views');
     PageLayout::addStyle($factory->render('calendar/stylesheet', $style_parameters));
     if (Request::option('printview')) {
         PageLayout::addStylesheet('print.css');
     } else {
         PageLayout::addStylesheet('print.css', array('media' => 'print'));
     }
 }
Exemple #11
0
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     PageLayout::setTitle(_("Nachrichten"));
     PageLayout::setHelpKeyword("Basis.InteraktionNachrichten");
     if (Request::isXhr() && Request::isGet()) {
         $request = Request::getInstance();
         foreach (words('default_body default_subject') as $key) {
             $request[$key] = Request::removeMagicQuotes($_GET[$key]);
         }
     }
 }
Exemple #12
0
 /**
  * Set up this controller.
  *
  * @param String $action Name of the action to be invoked
  * @param Array  $args   Arguments to be passed to the action method
  */
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     if (!in_array($this->user->perms, words('autor tutor dozent'))) {
         throw new AccessDeniedException();
     }
     PageLayout::setHelpKeyword('Basis.HomepageUniversitäreDaten');
     PageLayout::setTitle(_('Studiengang bearbeiten'));
     Navigation::activateItem('/profile/edit/studies');
     SkipLinks::addIndex(_('Fächer und Abschlüsse auswählen'), 'select_fach_abschluss');
     SkipLinks::addIndex(_('Zu Einrichtungen zuordnen'), 'select_institute');
     $this->allow_change = array('sg' => !StudipAuthAbstract::CheckField('studiengang_id', $this->user->auth_plugin) && (Config::get()->ALLOW_SELFASSIGN_STUDYCOURSE || $GLOBALS['perm']->have_perm('admin')), 'in' => Config::get()->ALLOW_SELFASSIGN_INSTITUTE || $GLOBALS['perm']->have_perm('admin'));
 }
Exemple #13
0
 public static function remove($haystack, $needle, $delim = ',')
 {
     $words = words($haystack, $delim);
     $out = "";
     $last = count($words);
     foreach ($words as $word) {
         if (matches($needle, $word)) {
             continue;
         } else {
             $out .= $word . $delim;
         }
     }
     return rtrim($out, $delim);
 }
Exemple #14
0
 private static function get_kings_uncached()
 {
     $types = words('files forum news voter votes wiki');
     $kings = array();
     foreach ($types as $type) {
         $method = "{$type}_kings";
         foreach (self::$method() as $user_id => $amount) {
             if (!isset($kings[$user_id])) {
                 $kings[$user_id] = array();
             }
             $kings[$user_id][$type] = $amount;
         }
     }
     return $kings;
 }
Exemple #15
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $this->institute_id = current($args);
     if ($this->institute_id === '' || !in_array(get_object_type($this->institute_id), words('inst fak')) || !$GLOBALS['perm']->have_studip_perm("admin", $this->institute_id)) {
         $this->set_status(403);
         return FALSE;
     }
     $this->body_id = 'custom_avatar';
     PageLayout::setTitle(getHeaderLine($this->institute_id) . ' - ' . _('Bild ändern'));
     Navigation::activateItem('/admin/institute/details');
     # choose base layout w/o infobox and set tabs
     $layout = $GLOBALS['template_factory']->open('layouts/base_without_infobox');
     $this->set_layout($layout);
 }
Exemple #16
0
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $this->cid = self::requireContext();
     self::requireAuthorisation($this->cid);
     // TODO: anders sicherstellen, dass sich #state und #start/stopdate nicht widersprechen
     Question::consolidateState($this->cid);
     # find and set question
     # URL: /cliqr/questions/(show|update|destroy|start|stop)/:question_id
     if (in_array($action, words("show update destroy start stop"))) {
         $question_id = self::ensureMD5($args[0]);
         $this->question = Question::find($question_id);
     }
     # else: index create
 }
Exemple #17
0
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $course_id = Request::option('cid');
     if (isset($_SESSION['seminar_change_view_' . $course_id])) {
         unset($_SESSION['seminar_change_view_' . $course_id]);
         // Reset simulated view, redirect to administration page.
         $this->redirect(URLHelper::getURL('dispatch.php/course/management'));
     } elseif (get_object_type($course_id, array('sem')) && !SeminarCategories::GetBySeminarId($course_id)->studygroup_mode && in_array($GLOBALS['perm']->get_studip_perm($course_id), words('tutor dozent'))) {
         // Set simulated view, redirect to overview page.
         $_SESSION['seminar_change_view_' . $course_id] = 'autor';
         $this->redirect(URLHelper::getURL('seminar_main.php'));
     } else {
         throw new Trails_Exception(400);
     }
 }
Exemple #18
0
 /**
  * returns the lock rule object for the given id, else null
  * 
  * @param string $object_id id of course, institute or user
  * @param bool $renew if true, reloads the rule from database
  * @return LockRule 
  */
 public static function getObjectRule($object_id, $renew = false)
 {
     if (!array_key_exists($object_id, self::$lockmap) || $renew) {
         $object_type = get_object_type($object_id, words('sem inst user'));
         if ($object_type) {
             $methodmap = array('sem' => 'Seminar', 'inst' => 'Institute', 'fak' => 'Institute', 'user' => 'User');
             $lr = call_user_func(array('LockRule', 'FindBy' . $methodmap[$object_type]), $object_id);
             if ($lr) {
                 self::$lockmap[$object_id] = $lr->getId();
                 self::$lockrules[$lr->getId()] = $lr;
             } else {
                 self::$lockmap[$object_id] = null;
             }
         }
     }
     return self::$lockmap[$object_id] ? self::$lockrules[self::$lockmap[$object_id]] : null;
 }
Exemple #19
0
 /**
  * common tasks for all actions
  */
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     $this->course_id = $args[0];
     if (!in_array($action, words('apply claim delete order_down order_up'))) {
         $this->redirect($this->url_for('/apply/' . $action));
         return false;
     }
     if (!get_object_type($this->course_id, array('sem'))) {
         throw new Trails_Exception(400);
     }
     $course = Seminar::GetInstance($this->course_id);
     $enrolment_info = $course->getEnrolmentInfo($GLOBALS['user']->id);
     //Ist bereits Teilnehmer/Admin/freier Zugriff -> gleich weiter
     if ($enrolment_info['enrolment_allowed'] && (in_array($enrolment_info['cause'], words('root courseadmin member')) || $enrolment_info['cause'] == 'free_access' && $GLOBALS['user']->id == 'nobody')) {
         $redirect_url = UrlHelper::getUrl('seminar_main.php', array('auswahl' => $this->course_id));
         if (Request::isXhr()) {
             $this->response->add_header('X-Location', $redirect_url);
             $this->render_nothing();
         } else {
             $this->redirect($redirect_url);
         }
         return false;
     }
     //Grundsätzlich verboten
     if (!$enrolment_info['enrolment_allowed']) {
         throw new AccessDeniedException($enrolment_info['description']);
     }
     PageLayout::setTitle($course->getFullname() . " - " . _("Veranstaltungsanmeldung"));
     PageLayout::addSqueezePackage('enrolment');
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->response->add_header('X-No-Buttons', 1);
         $this->response->add_header('X-Title', PageLayout::getTitle());
         $request = Request::getInstance();
         foreach ($request as $key => $value) {
             $request[$key] = studip_utf8decode($value);
         }
     } else {
         $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     }
     $this->set_content_type('text/html;charset=windows-1252');
     if (Request::submitted('cancel')) {
         $this->redirect(URLHelper::getURL('dispatch.php/course/details/', array('sem_id' => $this->course_id)));
     }
 }
Exemple #20
0
 /**
  * Set up this controller.
  *
  * @param String $action Name of the action to be invoked
  * @param Array  $args   Arguments to be passed to the action method
  */
 public function before_filter(&$action, &$args)
 {
     // Interpret every action other than 'index', 'publish' or 'unpublish'
     // as page number
     if (!in_array($action, words('index publish unpublish'))) {
         array_unshift($args, (int) $action);
         $action = 'index';
     }
     parent::before_filter($action, $args);
     if (!Config::Get()->SCORE_ENABLE) {
         throw new AccessDeniedException(_('Die Rangliste und die Score-Funktion sind nicht aktiviert.'));
     }
     PageLayout::setHelpKeyword('Basis.VerschiedenesScore');
     // external help keyword
     PageLayout::setTitle(_('Rangliste'));
     Navigation::activateItem('/community/score');
 }
Exemple #21
0
 function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     if (Config::Get()->STUDYGROUPS_ENABLE || in_array($action, words('globalmodules savemodules deactivate'))) {
         // args at position zero is always the studygroup-id
         if ($args[0]) {
             if (SeminarCategories::GetBySeminarId($args[0])->studygroup_mode == false) {
                 throw new Exception(_('Dieses Seminar ist keine Studiengruppe!'));
             }
         }
         PageLayout::setTitle(_("Studiengruppe bearbeiten"));
         PageLayout::setHelpKeyword('Basis.Studiengruppen');
         PageLayout::addSqueezePackage('tablesorter');
     } else {
         throw new Exception(_("Die von Ihnen gewählte Option ist im System nicht aktiviert."));
     }
     Sidebar::get()->setImage('sidebar/studygroup-sidebar.png');
 }
Exemple #22
0
 /**
  * Editview: Edit the configuration parameters: value, comment, section
  */
 public function edit_configuration_action()
 {
     PageLayout::setTitle(_('Konfigurationsparameter editieren'));
     $field = Request::get('id');
     $value = Request::get('value');
     if (Request::isPost()) {
         CSRFProtection::verifyUnsafeRequest();
         if ($this->validateInput($field, $value)) {
             $section = Request::get('section_new') ?: Request::get('section');
             $comment = Request::get('comment');
             Config::get()->store($field, compact(words('value section comment')));
             $message = sprintf(_('Der Konfigurationseintrag "%s" wurde erfolgreich übernommen!'), $field);
             PageLayout::postMessage(MessageBox::success($message));
             $this->relocate('admin/configuration/configuration/' . $section);
         }
     }
     // set variables for view
     $this->config = ConfigurationModel::getConfigInfo($field);
     $this->allconfigs = ConfigurationModel::getConfig();
 }
Exemple #23
0
 public function up()
 {
     // Create directory
     if (empty($GLOBALS['USER_DOC_PATH'])) {
         throw new Exception('Config variable "USER_DOC_PATH" has not been set in file "config/config_local.inc.php". ' . 'If you are upgrading to a newer release, please refer to the file "config/config_local.inc.php.dist" ' . 'or just set it to default value of "$USER_DOC_PATH = $STUDIP_BASE_PATH . \'/data/user_doc\';".');
     }
     if (!file_exists($GLOBALS['USER_DOC_PATH'])) {
         $result = mkdir($GLOBALS['USER_DOC_PATH'], 0755, true);
         if ($result === false) {
             throw new Exception('Could not create user file path. Please check the config variable "USER_DOC_PATH" ' . 'in file "config/config_local.inc.php".');
         }
     }
     /*
      * Migration for API in lib/files
      */
     DBManager::get()->exec("CREATE TABLE IF NOT EXISTS files\n            (file_id CHAR(32) NOT NULL,\n            user_id CHAR(32) NOT NULL,\n            filename VARCHAR(255) NOT NULL,\n            mime_type VARCHAR(64) NOT NULL,\n            size BIGINT UNSIGNED NOT NULL,\n            restricted TINYINT(1) NOT NULL DEFAULT 0,\n            storage VARCHAR(32) NOT NULL DEFAULT 'DiskFileStorage',\n            storage_id VARCHAR(32) NOT NULL,\n            mkdate INT(11) UNSIGNED NOT NULL DEFAULT 0,\n            chdate INT(11) UNSIGNED NOT NULL DEFAULT 0,\n            PRIMARY KEY (file_id)) ENGINE=MyISAM");
     DBManager::get()->exec("CREATE TABLE IF NOT EXISTS file_refs\n            (id CHAR(32) NOT NULL,\n            file_id CHAR(32) NOT NULL,\n            parent_id CHAR(32) NOT NULL,\n            name VARCHAR(255) NOT NULL,\n            description TEXT NOT NULL,\n            downloads INT NOT NULL DEFAULT 0,\n            PRIMARY KEY (id)) ENGINE=MyISAM");
     DBManager::get()->exec("CREATE TABLE IF NOT EXISTS files_backend_studip\n            (id INT UNSIGNED NOT NULL,\n            files_id VARCHAR(64) NOT NULL,\n            path VARCHAR(256) NOT NULL,\n            PRIMARY KEY (id)) ENGINE=MyISAM");
     DBManager::get()->exec("CREATE TABLE IF NOT EXISTS files_backend_url\n            (id INT UNSIGNED NOT NULL,\n            files_id VARCHAR(64) NOT NULL,\n            url VARCHAR(256) NOT NULL,\n            PRIMARY KEY (id)) ENGINE=MyISAM");
     DBManager::get()->exec("CREATE TABLE IF NOT EXISTS files_share\n            (files_id VARCHAR(64) NOT NULL,\n            entity_id VARCHAR(32) NOT NULL,\n            description MEDIUMTEXT NULL,\n            read_perm BOOLEAN DEFAULT FALSE,\n            write_perm BOOLEAN DEFAULT FALSE,\n            start_date INT UNSIGNED NOT NULL,\n            end_date INT UNSIGNED NOT NULL,\n            PRIMARY KEY (files_id, entity_id)) ENGINE=MyISAM");
     /*
      * Migration for the Admin-Area
      */
     DBManager::get()->query("CREATE  TABLE IF NOT EXISTS `doc_filetype`\n            (`id` INT NOT NULL AUTO_INCREMENT ,\n            `type` VARCHAR(45) NOT NULL ,\n            `description` TEXT NULL ,\n            PRIMARY KEY (`id`)) ENGINE=MyISAM");
     DBManager::get()->query("CREATE  TABLE IF NOT EXISTS `doc_usergroup_config`\n            (`id` INT NOT NULL AUTO_INCREMENT ,\n            `usergroup` VARCHAR(45) NOT NULL ,\n            `upload_quota` TEXT NOT NULL ,\n            `upload_unit` VARCHAR(45) NULL ,\n            `quota` TEXT NULL ,\n            `quota_unit` VARCHAR(45) NULL ,\n            `upload_forbidden` INT NOT NULL DEFAULT 0 ,\n            `area_close` INT NOT NULL DEFAULT 0 ,\n            `area_close_text` TEXT NULL ,\n            `is_group_config` INT NOT NULL DEFAULT 0 ,\n            PRIMARY KEY (`id`, `usergroup`)) ENGINE=MyISAM");
     DBManager::get()->query("CREATE  TABLE IF NOT EXISTS `doc_filetype_forbidden`\n            (`id` INT NOT NULL AUTO_INCREMENT ,\n            `usergroup` VARCHAR(45) NOT NULL ,\n            `dateityp_id` INT NOT NULL ,\n            PRIMARY KEY (`id`) ,\n            INDEX `fk_dateityp_verbot_nutzerbereich_2_idx` (`dateityp_id` ASC) ,\n            INDEX `fk_dateityp_verbot_nutzerbereich_1_idx` (`usergroup` ASC)) ENGINE=MyISAM");
     /*
      * Set the entry into the table "config" to enable or disable the Personal Document Area
      */
     $query = "INSERT IGNORE INTO `config`\n                  (`config_id`, `field`, `value`, `is_default`, `type`, `range`, `section`,\n                   `mkdate`, `chdate`, `description`)\n                  VALUES (:id, :field, :value, 1, :type, 'global', 'files', UNIX_TIMESTAMP(),\n                          UNIX_TIMESTAMP(), :description)";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array(':id' => md5(uniqid('PERSONALDOCUMENT_ENABLE')), ':field' => 'PERSONALDOCUMENT_ENABLE', ':value' => (int) false, ':type' => 'boolean', ':description' => 'Aktiviert den persoenlichen Dateibereich'));
     $query = "INSERT IGNORE INTO `doc_usergroup_config`\n                     (`id`, `usergroup`, `upload_quota`, `upload_unit`,\n                      `quota`, `quota_unit`, `is_group_config`)\n                   VALUES (:id, :group, :uploadQuota, :uploadUnit, :quota,\n                           :quotaUnit, :isGroupConfig)";
     $statement = DBManager::get()->prepare($query);
     $statement->execute(array(':id' => '1', ':group' => 'default', ':uploadQuota' => '5242880', ':uploadUnit' => 'MB', ':quota' => '52428800', ':quotaUnit' => 'MB', ':isGroupConfig' => '1'));
     $query = "INSERT IGNORE INTO `doc_filetype` (`type`) VALUES (:type)";
     $statement = DBManager::get()->prepare($query);
     foreach (words('exe com pif bat scr') as $value) {
         $statement->execute(array(':type' => $value));
     }
 }
Exemple #24
0
 /**
  * Before filter, set up the page by initializing the session and checking
  * all conditions.
  *
  * @param String $action Name of the action to be invoked
  * @param Array  $args   Arguments to be passed to the action method
  */
 public function before_filter(&$action, &$args)
 {
     parent::before_filter($action, $args);
     // open session
     page_open(array('sess' => 'Seminar_Session', 'auth' => 'Seminar_Default_Auth', 'perm' => 'Seminar_Perm', 'user' => 'Seminar_User'));
     // set up user session
     include 'lib/seminar_open.php';
     if (!Config::Get()->SCM_ENABLE) {
         throw new AccessDeniedException(_('Die freien Informationsseiten sind nicht aktiviert.'));
     }
     $GLOBALS['auth']->login_if(Request::get('again') && $GLOBALS['auth']->auth['uid'] == 'nobody');
     $this->priviledged = $GLOBALS['perm']->have_studip_perm('tutor', $GLOBALS['SessSemName'][1]);
     if (Request::isXhr()) {
         $this->set_content_type('text/html;charset=Windows-1252');
     } else {
         $this->set_layout($GLOBALS['template_factory']->open('layouts/base'));
     }
     if (!in_array($action, words('index create edit move delete'))) {
         array_unshift($args, $action);
         $action = 'index';
     }
     if (in_array($action, words('create edit move delete')) && !$this->priviledged) {
         throw new AccessDeniedException();
     }
     if ($GLOBALS['perm']->have_studip_perm('tutor', $GLOBALS['SessSemName'][1])) {
         $widget = new ActionsWidget();
         $widget->addLink(_('Neuen Eintrag anlegen'), URLHelper::getLink('dispatch.php/course/scm/create'), Icon::create('add', 'clickable'))->asDialog();
         Sidebar::get()->addWidget($widget);
     }
     PageLayout::setHelpKeyword('Basis.Informationsseite');
     Navigation::activateItem('/course/scm');
     checkObject();
     // do we have an open object?
     checkObjectModule('scm');
     object_set_visit_module('scm');
     // Set sidebar image
     $sidebar = Sidebar::get();
     $sidebar->setImage('sidebar/info-sidebar.png');
 }
Exemple #25
0
 private function courseToJSON($course)
 {
     $json = array();
     $json['course_id'] = $course->id;
     $json['number'] = $course->VeranstaltungsNummer;
     $json['title'] = $course->Name;
     $json['subtitle'] = $course->Untertitel;
     $json['type'] = $course->status;
     $json['description'] = $course->Beschreibung;
     $json['location'] = $course->Ort;
     // lecturers
     foreach ($course->getMembersWithStatus('dozent') as $lecturer) {
         $url = $this->urlf('/user/%s', array(htmlReady($lecturer->user_id)));
         $json['lecturers'][$url] = User::getMiniUser($this, $lecturer->user);
     }
     // other members
     foreach (words("user autor tutor dozent") as $status) {
         $json['members'][$status] = $this->urlf('/course/%s/members?status=%s', array($course->id, $status));
         $json['members'][$status . '_count'] = $course->countMembersWithStatus($status);
     }
     foreach (words("start_semester end_semester") as $key) {
         $json[$key] = $course->{$key} ? $this->urlf('/semester/%s', array(htmlReady($course->{$key}->id))) : null;
     }
     $modules = new \Modules();
     $activated = $modules->getLocalModules($course->id, 'sem');
     $json['modules'] = array();
     foreach (array('forum' => 'forum_categories', 'documents' => 'files', 'wiki' => 'wiki') as $module => $uri) {
         if ($activated[$module]) {
             $json['modules'][$module] = $this->urlf('/course/%s/%s', array(htmlReady($course->id), $uri));
         }
     }
     return $json;
 }
 public static function findByInstituteAndStatus($institute_id, $status)
 {
     $db = DbManager::get();
     return $db->fetchAll("SELECT user_inst.*, aum.vorname,aum.nachname,aum.email,\n                             aum.username,ui.title_front,ui.title_rear\n                             FROM user_inst\n                             LEFT JOIN auth_user_md5 aum USING (user_id)\n                             LEFT JOIN user_info ui USING (user_id)\n                             WHERE institut_id = ? AND user_inst.inst_perms IN (?) ORDER BY inst_perms,nachname", array($institute_id, is_array($status) ? $status : words($status)), __CLASS__ . '::buildExisting');
 }
Exemple #27
0
}
//download from archive, allowed if former participant
if ($type == 1) {
    $query = "SELECT seminar_id FROM archiv WHERE archiv_file_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($file_id));
    $archiv_seminar_id = $statement->fetchColumn();
    if ($archiv_seminar_id) {
        $no_access = !archiv_check_perm($archiv_seminar_id);
    } else {
        $query = "SELECT seminar_id FROM archiv WHERE archiv_protected_file_id = ?";
        $statement = DBManager::get()->prepare($query);
        $statement->execute(array($file_id));
        $archiv_seminar_id = $statement->fetchColumn();
        if ($archiv_seminar_id) {
            $no_access = !in_array(archiv_check_perm($archiv_seminar_id), words('tutor dozent admin'));
        }
    }
}
//download bibliography
if ($type == 5) {
    $range_id = Request::option('range_id');
    $list_id = Request::option('list_id');
    if ($range_id == $user->id || $perm->have_studip_perm('tutor', $range_id)) {
        $no_access = false;
        $the_data = StudipLitList::GetTabbedList($range_id, $list_id);
    }
}
//download ad hoc created files, always allowed
if (in_array($type, array(2, 3, 4))) {
    $no_access = false;
Exemple #28
0
function closeStructure ($resource_id)
{
    unset($_SESSION['resources_data']['structure_opens'][$resource_id]);

    $query = "SELECT resource_id FROM resources_objects WHERE parent_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($resource_id));
    while ($resource_id = $statement->fetchColumn()) {
        closeStructure ($resource_id);
    }
}
/*****************************************************************************
Initialization
/*****************************************************************************/
$GLOBALS['messageForUsers'] = '';
foreach (words('view view_mode quick_view quick_view_mode') as $parameter_name) {
    $$parameter_name = Request::option($parameter_name);
}
$change_schedule_repeat_quantity = Request::option('change_schedule_repeat_quantity');
//a small helper function to update some data of the tree-structure (after move something)
function updateStructure ($resource_id, $root_id, $level)
{
    $query = "UPDATE resources_objects
              SET root_id = ?, level = ?
              WHERE resource_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array(
        $root_id,
        $level,
        $resource_id
    ));
Exemple #29
0
 /**
  * Add a needle to search (optionally as quick search)
  *
  * @param String $label        Label for the input element
  * @param String $name         Name of the input (which will be the
  *                             transmitted name attribute)
  * @param bool   $placeholder  Use label as placeholder (this will hide
  *                             the associated label)
  * @param mixed  $quick_search An optional SearchType object if quick
  *                             search should be used
  * @param mixed  $js_func      Optional name of a js function or a js
  *                             function itself that's executed when an
  *                             entry of the found elements is selected
  */
 public function addNeedle($label, $name, $placeholder = false, SearchType $quick_search = null, $js_func = null, $value = null)
 {
     $value = $value ?: Request::get($name);
     $this->needles[] = compact(words('label name placeholder value quick_search js_func'));
 }
 /**
  * returns the collection as grouped array
  * first param is the column to group by, it becomes the key in
  * the resulting array, default is pk. Limit returned fields with second param
  * The grouped entries can optoionally go through the given
  * callback. If no callback is provided, only the first grouped
  * entry is returned, suitable for grouping by unique column
  *
  * @param string $group_by the column to group by, pk if ommitted
  * @param mixed $only_these_fields limit returned fields
  * @param Closure $group_func closure to aggregate grouped entries
  * @return array assoc array
  */
 function toGroupedArray($group_by = 'id', $only_these_fields = null, Closure $group_func = null)
 {
     $result = array();
     if (is_string($only_these_fields)) {
         $only_these_fields = words($only_these_fields);
     }
     foreach ($this->toArray() as $record) {
         $key = $record[$group_by];
         $ret = array();
         if (is_array($only_these_fields)) {
             $result[$key][] = array_intersect_key($record, array_flip($only_these_fields));
         } else {
             $result[$key][] = $record;
         }
     }
     if ($group_func === null) {
         $group_func = 'current';
     }
     return array_map($group_func, $result);
 }