function down () { $db = DBManager::get(); $db->exec("ALTER TABLE log_actions CHANGE expires expires int(20) default NULL"); }
function get_booked_rooms_action($api_key, $start_timestamp, $end_timestamp) { $ret = array(); if (!$start_timestamp) { $start_timestamp = strtotime('today'); } if (!$end_timestamp) { $end_timestamp = strtotime("+2 weeks", $start_timestamp); } $db = DBManager::get(); $rs = $db->query(sprintf("\n SELECT begin, end, s.Name AS lecture_title, s.Beschreibung, i.Name AS lecture_home_institute, r.resource_id, r.name AS room, GROUP_CONCAT( CONCAT_WS( '|', auth_user_md5.Vorname, auth_user_md5.Nachname, user_info.title_front, user_info.title_rear )\n ORDER BY seminar_user.position\n SEPARATOR ';' ) AS lecturer_name\n FROM resources_assign ra\n INNER JOIN resources_objects r ON ra.resource_id = r.resource_id\n INNER JOIN termine t ON termin_id = assign_user_id\n INNER JOIN seminare s ON range_id = Seminar_id\n INNER JOIN Institute i ON i.Institut_id = s.Institut_id\n LEFT JOIN seminar_user ON s.seminar_id = seminar_user.seminar_id\n AND seminar_user.status = 'dozent'\n LEFT JOIN auth_user_md5 ON seminar_user.user_id = auth_user_md5.user_id\n LEFT JOIN user_info ON user_info.user_id = auth_user_md5.user_id\n WHERE begin\n BETWEEN %s\n AND %s\n GROUP BY assign_id", $db->quote($start_timestamp), $db->quote($end_timestamp))); while ($row = $rs->fetch(PDO::FETCH_ASSOC)) { $lecturers = explode(';', $row['lecturer_name']); list($vorname, $nachname, $titel1, $titel2) = explode('|', $lecturers[0]); $room = new Studip_Booked_Room(); $room->start_time = $row['begin']; $room->end_time = $row['end']; $room->room = $row['room']; $room->room_id = $row['resource_id']; $room->lecture_title = $row['lecture_title']; $room->lecture_home_institute = $row['lecture_home_institute']; $room->lecture_description = $row['Beschreibung']; $room->lecturer_title_front = $titel1; $room->lecturer_title_rear = $titel2; $room->lecturer_name = $vorname . ' ' . $nachname; $ret[] = $room; } return $ret; }
/** * constructor * * init class. * @access * @param string $cms system-type */ function Ilias4ConnectedUser($cms, $user_id = false) { // get auth_plugin $user_id = $user_id ? $user_id : $GLOBALS['user']->id; $this->auth_plugin = DBManager::get()->query("SELECT IFNULL(auth_plugin, 'standard') FROM auth_user_md5 WHERE user_id = '" . $user_id . "'")->fetchColumn(); parent::Ilias3ConnectedUser($cms, $user_id); }
function down() { $db = DBManager::get(); foreach ($this->options as $name => $descrition) { $db->exec("DELETE FROM config WHERE field = '{$name}'"); } }
/** * */ public static function increatePrioritiesByUserId($user_id) { $query = "UPDATE kategorien SET priority = priority + 1 WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($user_id)); return $statement->rowCount() > 0; }
function down() { $db = DBManager::get(); $db->exec("DROP TABLE `seminar_cycle_dates`"); $db->exec("ALTER TABLE `seminare` ADD `metadata_dates` TEXT NOT NULL DEFAULT ''"); $db->exec("DELETE FROM config WHERE field LIKE 'ALLOW_METADATE_SORTING'"); }
public function afterStoreCallback() { if ($this->isDirty()) { //add notification to writer of review if (!$this->review['host_id'] && $this->review['user_id'] !== $this['user_id']) { PersonalNotifications::add($this->review['user_id'], URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat einen Kommentar zu Ihrem Review geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable")); } //add notification to all users of this servers who discussed this review but are neither the new //commentor nor the writer of the review $statement = DBManager::get()->prepare("\n SELECT user_id\n FROM lernmarktplatz_comments\n WHERE review_id = :review_id\n AND host_id IS NULL\n GROUP BY user_id\n "); $statement->execute(array('review_id' => $this->review->getId())); foreach ($statement->fetchAll(PDO::FETCH_COLUMN, 0) as $user_id) { if (!in_array($user_id, array($this->review['user_id'], $this['user_id']))) { PersonalNotifications::add($user_id, URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat auch einen Kommentar geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable")); } } //only push if the comment is from this server and the material-server is different if (!$this['host_id']) { $myHost = LernmarktplatzHost::thisOne(); $data = array(); $data['host'] = array('name' => $myHost['name'], 'url' => $myHost['url'], 'public_key' => $myHost['public_key']); $data['data'] = $this->toArray(); $data['data']['foreign_comment_id'] = $data['data']['comment_id']; unset($data['data']['comment_id']); unset($data['data']['id']); unset($data['data']['user_id']); unset($data['data']['host_id']); $user_description_datafield = DataField::find(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")) ?: DataField::findOneBySQL("name = ?", array(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD"))); if ($user_description_datafield) { $datafield_entry = DatafieldEntryModel::findOneBySQL("range_id = ? AND datafield_id = ?", array($this['user_id'], $user_description_datafield->getId())); } $data['user'] = array('user_id' => $this['user_id'], 'name' => get_fullname($this['user_id']), 'avatar' => Avatar::getAvatar($this['user_id'])->getURL(Avatar::NORMAL), 'description' => $datafield_entry ? $datafield_entry['content'] : null); $statement = DBManager::get()->prepare("\n SELECT host_id\n FROM lernmarktplatz_comments\n WHERE review_id = :review_id\n AND host_id IS NOT NULL\n GROUP BY host_id\n "); $statement->execute(array('review_id' => $this->review->getId())); $hosts = $statement->fetchAll(PDO::FETCH_COLUMN, 0); if ($this->review['host_id'] && !in_array($this->review['host_id'], $hosts)) { $hosts[] = $this->review['host_id']; } if ($this->review->material['host_id'] && !in_array($this->review->material['host_id'], $hosts)) { $hosts[] = $this->review->material['host_id']; } foreach ($hosts as $host_id) { $remote = new LernmarktplatzHost($host_id); if (!$remote->isMe()) { $review_id = $this->review['foreign_review_id'] ?: $this->review->getId(); if ($this->review['foreign_review_id']) { if ($this->review->host_id === $remote->getId()) { $host_hash = null; } else { $host_hash = md5($this->review->host['public_key']); } } else { $host_hash = md5($myHost['public_key']); } $remote->pushDataToEndpoint("add_comment/" . $review_id . "/" . $host_hash, $data); } } } } }
private function getDatesFromDb() { $db = DBManager::get(); $dayend = $this->day + $this->daysec; $sql = "SELECT resources_objects.name AS 'Raum',\n resources_assign.assign_id,\n\t\tresources_assign.begin,\n resources_assign.end,\n resources_assign.repeat_interval,\n resources_assign.repeat_day_of_week,\n resources_assign.repeat_week_of_month,\n resources_assign.repeat_day_of_month,\n resources_assign.repeat_month_of_year,\n resources_assign.assign_user_id AS 'id',\n resources_assign.user_free_name AS 'titel',\n resources_assign.repeat_end,\n resources_assign.repeat_day_of_week\n FROM `resources_assign`\n INNER JOIN resources_objects ON resources_assign.resource_id = resources_objects.resource_id\n WHERE ((resources_assign.begin > ? AND resources_assign.begin < ?) OR (resources_assign.begin < ? AND resources_assign.repeat_end > ?))\n AND resources_assign.resource_id in (SELECT resource_id FROM `resources_objects` WHERE parent_id = ? ORDER BY Name)\n ORDER BY end ASC"; $sqldebug = "SELECT resources_objects.name AS 'Raum',\n resources_assign.begin,\n resources_assign.end,\n resources_assign.repeat_interval,\n resources_assign.repeat_day_of_week,\n resources_assign.repeat_week_of_month,\n resources_assign.repeat_day_of_month,\n resources_assign.repeat_month_of_year,\n resources_assign.assign_user_id AS 'id',\n resources_assign.user_free_name AS 'titel',\n resources_assign.repeat_end,\n resources_assign.repeat_day_of_week\n FROM `resources_assign`\n INNER JOIN resources_objects ON resources_assign.resource_id = resources_objects.resource_id\n WHERE ((resources_assign.begin > {$this->day} AND resources_assign.begin < {$dayend}) OR (resources_assign.begin < {$this->day} AND resources_assign.repeat_end < {$this->day}))\n AND resources_assign.resource_id in (SELECT resource_id FROM `resources_objects` WHERE parent_id = '" . $this->building . "' ORDER BY Name)\n ORDER BY end ASC"; //$this->debug($sqldebug); $db = DBManager::get()->prepare($sql); $db->execute(array($this->day, $dayend, $this->day, $this->day, $this->building)); //$dayend $result = $db->fetchAll(); if (empty($result)) { return false; } foreach ($result as $date) { if (!empty($date)) { if (date("w", $date['begin']) == date("w", $this->day) or $date['repeat_interval'] == "1" and $date['repeat_day_of_week'] == "0" or $date['repeat_interval'] == "0" and $date['repeat_day_of_week'] == "0" and $date['repeat_week_of_month'] == "0" and $date['repeat_day_of_month'] == "0" and $date['repeat_day_of_month'] == "0") { if (date("j", $date['begin']) != date("j", $this->day)) { $tempdate = mktime(date("H", $date['begin']), date("i", $date['begin']), date("s", $date['begin']), date("m", $this->day), date("j", $this->day), date("Y", $this->day)); $date['begin'] = $tempdate; } if (date("j", $date['end']) != date("j", $this->day)) { $tempdate = mktime(date("H", $date['end']), date("i", $date['end']), date("s", $date['end']), date("m", $this->day), date("j", $this->day), date("Y", $this->day)); $date['end'] = $tempdate; } //$this->debug($date); if ($date['repeat_day_of_week'] != date("N", $this->day)) { $this->dates[] = $date; } } } } //$this->debug($this->dates); }
function up() { $this->announce("add new value SEM_TREE_ALLOW_BRANCH_ASSIGN to table config"); $db = DBManager::get(); $db->exec("INSERT IGNORE INTO `config` " . "VALUES ('34f348c06bbd5d9fc7bb36a8d829e12e', '', " . "'SEM_TREE_ALLOW_BRANCH_ASSIGN', '1', 1, 'boolean', 'global', " . "'', 0, 1222947575, 1222947575, " . "'Diese Option beeinflusst die Möglichkeit, Veranstaltungen " . "entweder nur an die Blätter oder überall in der " . "Veranstaltungshierarchie einhängen zu dürfen.', '', '')"); $this->announce("done."); }
function up() { $db = DBManager::get(); $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber` (\n `topic_id` varchar(32) NOT NULL DEFAULT '',\n `parent_id` varchar(32) NOT NULL DEFAULT '',\n `root_id` varchar(32) NOT NULL DEFAULT '',\n `context_type` enum('public','private','course') NOT NULL DEFAULT 'public',\n `name` varchar(255) DEFAULT NULL,\n `description` text,\n `mkdate` int(20) NOT NULL DEFAULT '0',\n `chdate` int(20) NOT NULL DEFAULT '0',\n `author_host` varchar(255) DEFAULT NULL,\n `Seminar_id` varchar(32) NOT NULL DEFAULT '',\n `user_id` varchar(32) NOT NULL DEFAULT '',\n `external_contact` tinyint(4) NOT NULL DEFAULT '0',\n PRIMARY KEY (`topic_id`),\n KEY `root_id` (`root_id`),\n KEY `Seminar_id` (`Seminar_id`),\n KEY `parent_id` (`parent_id`),\n KEY `chdate` (`chdate`),\n KEY `mkdate` (`mkdate`),\n KEY `user_id` (`user_id`,`Seminar_id`)\n ) ENGINE=MyISAM;\n "); //Spezialevents, bisher nur für Löschen von Beiträgen verwendet $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_events_queue` (\n `event_type` varchar(32) NOT NULL,\n `item_id` varchar(32) NOT NULL,\n `mkdate` int(11) NOT NULL,\n PRIMARY KEY (`event_type`,`item_id`,`mkdate`),\n KEY `item_id` (`item_id`)\n ) ENGINE=MyISAM\n "); //Blubberautoren, die nicht in Stud.IP angemeldet sind wie anonyme $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_external_contact` (\n `external_contact_id` varchar(32) NOT NULL,\n `mail_identifier` varchar(256) DEFAULT NULL,\n `contact_type` varchar(16) NOT NULL DEFAULT 'anonymous',\n `name` varchar(256) NOT NULL,\n `data` text,\n `chdate` bigint(20) NOT NULL,\n `mkdate` bigint(20) NOT NULL,\n PRIMARY KEY (`external_contact_id`),\n KEY `mail_identifier` (`mail_identifier`),\n KEY `contact_type` (`contact_type`)\n ) ENGINE=MyISAM\n "); $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_follower` (\n `studip_user_id` varchar(32) NOT NULL,\n `external_contact_id` varchar(32) NOT NULL,\n `left_follows_right` tinyint(1) NOT NULL,\n KEY `studip_user_id` (`studip_user_id`),\n KEY `external_contact_id` (`external_contact_id`)\n ) ENGINE=MyISAM\n "); //Rechte für private Blubber $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_mentions` (\n `topic_id` varchar(32) NOT NULL,\n `user_id` varchar(32) NOT NULL,\n `external_contact` tinyint(4) NOT NULL DEFAULT '0',\n `mkdate` int(11) NOT NULL,\n UNIQUE KEY `unique_users_per_topic` (`topic_id`,`user_id`,`external_contact`),\n KEY `topic_id` (`topic_id`),\n KEY `user_id` (`user_id`)\n ) ENGINE=MyISAM\n "); $old_blubber = $db->query("SELECT * FROM plugins WHERE pluginclassname = 'Blubber' " . "")->fetch(PDO::FETCH_ASSOC); if ($old_blubber) { //Umschreiben des Ortes von Blubber $db->exec("\n UPDATE plugins SET pluginpath = 'core/Blubber' WHERE pluginclassname = 'Blubber'\n "); if ($old_blubber['pluginpath'] !== "core/Blubber") { @rmdirr($GLOBALS['PLUGINS_PATH'] . "/" . $old_blubber['pluginpath']); } $db->exec("\n INSERT IGNORE INTO blubber (`topic_id`,`parent_id`,`root_id`,`context_type`,`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,`external_contact`)\n SELECT `topic_id`,`parent_id`,`root_id`,'course',`name`,`description`,`mkdate`,`chdate`,`author_host`,`Seminar_id`,`user_id`,0\n FROM px_topics\n "); } else { //Installieren des Plugins $db->exec("\n INSERT INTO plugins\n SET pluginclassname = 'Blubber',\n pluginpath = 'core/Blubber',\n pluginname = 'Blubber',\n plugintype = 'StandardPlugin,SystemPlugin',\n enabled = 'yes',\n navigationpos = '1'\n "); $plugin_id = $db->lastInsertId(); $db->exec("\n INSERT IGNORE INTO roles_plugins (roleid, pluginid)\n SELECT roleid, " . $db->quote($plugin_id) . " FROM roles WHERE system = 'y'\n "); } }
function down() { $db = DBManager::get(); $db->exec("ALTER TABLE `lock_rules` DROP `permission`"); $db->exec("DELETE FROM config WHERE field = 'RANGE_TREE_ADMIN_PERM'"); $db->exec("DELETE FROM config WHERE field = 'SEM_TREE_ADMIN_PERM'"); }
public function up() { // Get all resources on a specific level. These will be used // as parent ids to find the children on the next level. $query = "SELECT `resource_id`\n FROM `resources_objects`\n WHERE `level` = :level"; $parent_statement = DBManager::get()->prepare($query); // Update the level for all children of a set of parent ids. $query = "UPDATE `resources_objects`\n SET `level` = :level\n WHERE `parent_id` IN (:ids)"; $child_statement = DBManager::get()->prepare($query); // Loop until the hierarchy has been built. $level = 0; do { // Read parent ids $parent_statement->bindValue(':level', $level); $parent_statement->execute(); $parent_ids = $parent_statement->fetchAll(PDO::FETCH_COLUMN); // No parents, no children -> we're done. if (count($parent_ids) === 0) { break; } // Increase level $level = $level + 1; // Update level on all children, exit if no children have been // found/updated. $child_statement->bindValue(':level', $level); $child_statement->bindValue(':ids', $parent_ids, StudipPDO::PARAM_ARRAY); $updated_rows = $child_statement->execute(); } while ($updated_rows > 0); }
public function execute($last_result, $parameters = array()) { $db = DBManager::get(); $dd_func = function ($d) { delete_document($d); }; //abgelaufenen News löschen $deleted_news = StudipNews::DoGarbageCollect(); //messages aufräumen $to_delete = $db->query("SELECT message_id, count( message_id ) AS gesamt, count(IF (deleted =0, NULL , 1) ) AS geloescht\n FROM message_user GROUP BY message_id HAVING gesamt = geloescht")->fetchAll(PDO::FETCH_COLUMN, 0); if (count($to_delete)) { $db->exec("DELETE FROM message_user WHERE message_id IN(" . $db->quote($to_delete) . ")"); $db->exec("DELETE FROM message WHERE message_id IN(" . $db->quote($to_delete) . ")"); $to_delete_attach = $db->query("SELECT dokument_id FROM dokumente WHERE range_id IN(" . $db->quote($to_delete) . ")")->fetchAll(PDO::FETCH_COLUMN, 0); array_walk($to_delete_attach, $dd_func); } //Attachments von nicht versendeten Messages aufräumen $to_delete_attach = $db->query("SELECT dokument_id FROM dokumente WHERE range_id = 'provisional' AND chdate < UNIX_TIMESTAMP(DATE_ADD(NOW(),INTERVAL -2 HOUR))")->fetchAll(PDO::FETCH_COLUMN, 0); array_walk($to_delete_attach, $dd_func); if ($parameters['verbose']) { printf(_("Gelöschte Ankündigungen: %u") . "\n", (int) $deleted_news); printf(_("Gelöschte Nachrichten: %u") . "\n", count($to_delete)); printf(_("Gelöschte Dateianhänge: %u") . "\n", count($to_delete_attach)); } PersonalNotifications::doGarbageCollect(); // Remove old plugin assets PluginAsset::deleteBySQL('chdate < ?', array(time() - PluginAsset::CACHE_DURATION)); }
function down () { $db = DBManager::get(); $db->exec("DELETE FROM config WHERE field = 'AUX_RULE_ADMIN_PERM'"); $db->exec("DELETE FROM config WHERE field = 'LOCK_RULE_ADMIN_PERM'"); }
function down() { $db = DBManager::get(); $db->exec("DROP TABLE IF EXISTS `personal_notifications` "); $db->exec("DROP TABLE IF EXISTS `personal_notifications_user` "); $db->exec("DELETE FROM `config` WHERE `field` = 'PERSONAL_NOTIFICATIONS_ACTIVATED'"); }
/** * Deletes all expired events. * * @return int Number of deleted events. */ public static function deleteExpired() { $db = DBManager::get(); $sql = 'DELETE log_events FROM log_events JOIN log_actions USING(action_id) WHERE expires > 0 AND mkdate + expires < UNIX_TIMESTAMP()'; return $db->exec($sql); }
function up() { $sql = "CREATE TABLE IF NOT EXISTS `user_visibility_settings` (\n `user_id` varchar(32) NOT NULL DEFAULT '',\n `visibilityid` int(11) NOT NULL AUTO_INCREMENT,\n `parent_id` int(11) NOT NULL,\n `category` int(2) NOT NULL,\n `name` varchar(128) NOT NULL,\n `state` int(2) NULL,\n `plugin` int(11),\n `identifier` varchar(64) NOT NULL,\n PRIMARY KEY (`visibilityid`),\n KEY `parent_id` (`parent_id`),\n KEY `identifier` (`identifier`),\n KEY `userid` (`user_id`)\n) ENGINE=MyISAM"; $db = DBManager::get(); $stmt = $db->prepare($sql); $stmt->execute(); $category = array('Studien-/Einrichtungsdaten' => 'studdata', 'Private Daten' => 'privatedata', 'Zusätzliche Datenfelder' => 'additionaldata', 'Eigene Kategorien' => 'owncategory', 'Allgemeine Daten' => 'commondata'); $result = $db->query("SELECT value FROM config WHERE field = 'HOMEPAGE_VISIBILITY_DEFAULT' ORDER BY is_default LIMIT 1"); $default_visibility = constant($result->fetchColumn()); $sql = "SELECT `username` FROM `auth_user_md5`"; $stmt = $db->prepare($sql); $stmt->execute(); while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) { $about = new about($result['username'], ''); Visibility::createDefaultCategories($about->auth_user['user_id']); //copy all homepage visibility $elements = $about->get_homepage_elements(); if (is_array($elements)) { foreach ($elements as $key => $state) { if ($state['visibility'] != $default_visibility) { Visibility::addPrivacySetting($state['name'], $key, $category[$state['category']], 1, $about->auth_user['user_id'], $state['visibility']); } } } } }
/** * returns the results of a search * Use the contextual_data variable to send more variables than just the input * to the SQL. QuickSearch for example sends all other variables of the same * <form>-tag here. * @param input string: the search-word(s) * @param contextual_data array: an associative array with more variables * @param limit int: maximum number of results (default: all) * @param offset int: return results starting from this row (default: 0) * @return array: array(array(), ...) */ public function getResults($input, $contextual_data = array(), $limit = PHP_INT_MAX, $offset = 0) { $db = DBManager::get(); $sql = $this->getSQL(); if ($offset || $limit != PHP_INT_MAX) { $sql .= sprintf(' LIMIT %d, %d', $offset, $limit); } if (is_callable($this->presets, true)) { $presets = call_user_func($this->presets, $this, $contextual_data); } else { $presets = $this->presets + $contextual_data; } foreach ($presets as $name => $value) { if ($name !== "input" && strpos($sql, ":" . $name) !== false) { if (is_array($value)) { if (count($value)) { $sql = str_replace(":" . $name, implode(',', array_map(array($db, 'quote'), $value)), $sql); } else { $sql = str_replace(":" . $name, "''", $sql); } } else { $sql = str_replace(":" . $name, $db->quote($value), $sql); } } } $statement = $db->prepare($sql, array(PDO::FETCH_NUM)); $data = array(); $data[":input"] = "%" . $input . "%"; $statement->execute($data); $results = $statement->fetchAll(); return $results; }
function get_local_tree($sem_tree_id) { $db = DBManager::get(); $stmt = $db->prepare('SELECT sem_tree_id FROM sem_tree WHERE parent_id = ? ORDER BY priority'); $stmt->execute(array($sem_tree_id)); return $stmt->fetchAll(PDO::FETCH_COLUMN); }
public function initItem() { parent::initItem(); if (is_object($GLOBALS['user']) && $GLOBALS['user']->id != 'nobody') { if (WidgetHelper::hasWidget($GLOBALS['user']->id, 'News')) { $news = StudipNews::CountUnread(); } if (Config::get()->VOTE_ENABLE && WidgetHelper::hasWidget($GLOBALS['user']->id, 'Evaluations')) { $threshold = Config::get()->NEW_INDICATOR_THRESHOLD ? strtotime("-{" . Config::get()->NEW_INDICATOR_THRESHOLD . "} days 0:00:00") : 0; $statement = DBManager::get()->prepare("\n SELECT COUNT(*)\n FROM questionnaire_assignments\n INNER JOIN questionnaires ON (questionnaires.questionnaire_id = questionnaire_assignments.questionnaire_id)\n WHERE questionnaire_assignments.range_id = 'start'\n AND questionnaires.visible = 1\n AND questionnaires.startdate IS NOT NULL\n AND questionnaires.startdate > UNIX_TIMESTAMP()\n AND questionnaires.startdate > :threshold\n AND (questionnaires.stopdate IS NULL OR questionnaires.stopdate <= UNIX_TIMESTAMP())\n "); $statement->execute(array('threshold' => $threshold)); $vote = (int) $statement->fetchColumn(); $query = "SELECT COUNT(IF(chdate > IFNULL(b.visitdate, :threshold) AND d.author_id != :user_id, a.eval_id, NULL))\n FROM eval_range a\n INNER JOIN eval d ON (a.eval_id = d.eval_id AND d.startdate < UNIX_TIMESTAMP() AND\n (d.stopdate > UNIX_TIMESTAMP() OR d.startdate + d.timespan > UNIX_TIMESTAMP() OR (d.stopdate IS NULL AND d.timespan IS NULL)))\n LEFT JOIN object_user_visits b ON (b.object_id = d.eval_id AND b.user_id = :user_id AND b.type = 'eval')\n WHERE a.range_id = 'studip'\n GROUP BY a.range_id"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':user_id', $GLOBALS['user']->id); $statement->bindValue(':threshold', ($threshold = Config::get()->NEW_INDICATOR_THRESHOLD) ? strtotime("-{$threshold} days 0:00:00") : 0); $statement->execute(); $vote += (int) $statement->fetchColumn(); } } $homeinfo = _('Zur Startseite'); if ($news) { $homeinfo .= ' - '; $homeinfo .= sprintf(ngettext('%u neue Ankündigung', '%u neue Ankündigungen', $news), $news); } if ($vote) { $homeinfo .= ' - '; $homeinfo .= sprintf(ngettext('%u neuer Fragebogen', '%u neue Fragebögen', $vote), $vote); } $this->setBadgeNumber($vote + $news); $this->setImage(Icon::create('home', 'navigation', ["title" => $homeinfo])); }
public function initItem() { global $user, $neux; parent::initItem(); $my_messaging_settings = UserConfig::get($user->id)->MESSAGING_SETTINGS; $lastVisitedTimestamp = isset($my_messaging_settings['last_box_visit']) ? (int) $my_messaging_settings['last_box_visit'] : 0; $query = "SELECT SUM(mkdate > :time AND readed = 0) AS num_new,\n SUM(readed = 0) AS num_unread,\n SUM(readed = 1) AS num_read\n FROM message_user\n WHERE snd_rec = 'rec' AND user_id = :user_id AND deleted = 0"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':time', $lastVisitedTimestamp); $statement->bindValue(':user_id', $GLOBALS['user']->id); $statement->execute(); list($neux, $neum, $altm) = $statement->fetch(PDO::FETCH_NUM); $this->setBadgeNumber($neum); if ($neux > 0) { $tip = sprintf(ngettext('Sie haben %d neue ungelesene Nachricht', 'Sie haben %d neue ungelesene Nachrichten', $neux), $neux); } else { if ($neum > 1) { $tip = sprintf(ngettext('Sie haben %d ungelesene Nachricht', 'Sie haben %d ungelesene Nachrichten', $neum), $neum); } else { if ($altm > 1) { $tip = sprintf(ngettext('Sie haben %d alte empfangene Nachricht', 'Sie haben %d alte empfangene Nachrichten', $altm), $altm); } else { $tip = _('Sie haben keine alten empfangenen Nachrichten'); } } } $this->setImage(Icon::create('mail', 'navigation', ["title" => $tip])); }
/** * Stores the privacy settings concerning the appearance of a user inside * the system. */ public function global_action() { $this->check_ticket(); $visibility = Request::option('global_visibility'); // Globally visible or unknown -> set local visibilities accordingly. if ($visibility != 'no') { $online = Request::int('online') ?: 0; $search = Request::int('search') ?: 0; $email = Request::int('email') ?: 0; $foaf_show_identity = Request::int('foaf_show_identity') ?: 0; // Globally invisible -> set all local fields to invisible. } else { $online = $search = $foaf_show_identity = 0; $email = get_config('DOZENT_ALLOW_HIDE_EMAIL') ? 0 : 1; $success = $this->about->change_all_homepage_visibility(VISIBILITY_ME); } $this->config->store('FOAF_SHOW_IDENTITY', $foaf_show_identity); $this->user->visible = $visibility; $this->user->store(); $query = "INSERT INTO user_visibility\n (user_id, online, search, email, mkdate)\n VALUES (?, ?, ?, ?, UNIX_TIMESTAMP())\n ON DUPLICATE KEY\n UPDATE online = VALUES(online),\n search = VALUES(search), email = VALUES(email)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($this->user->user_id, $online, $search, $email)); $this->reportSuccess(_('Ihre Sichtbarkeitseinstellungen wurden gespeichert.')); $this->redirect('settings/privacy'); }
public function checkLine($line) { $errors = ""; if (!FleximportTable::findOneByName("fleximport_semiro_course_import")) { return "Tabelle fleximport_semiro_course_import existiert nicht. "; } $dilp_kennung_feld = FleximportConfig::get("SEMIRO_DILP_KENNUNG_FIELD"); if (!$dilp_kennung_feld) { $dilp_kennung_feld = "dilp_teilnehmer"; } if (!$line[$dilp_kennung_feld]) { $errors .= "Teilnehmer hat keinen Wert für '{$dilp_kennung_feld}''. "; } else { $datafield = Datafield::findOneByName(FleximportConfig::get("SEMIRO_USER_DATAFIELD_NAME")); if (!$datafield) { $errors .= "System hat kein Datenfeld " . FleximportConfig::get("SEMIRO_USER_DATAFIELD_NAME") . ", womit die Nutzer identifiziert werden. "; } else { $entry = DatafieldEntryModel::findOneBySQL("datafield_id = ? AND content = ? ", array($datafield->getId(), $line[$dilp_kennung_feld])); if (!$entry || !User::find($entry['range_id'])) { $errors .= "Nutzer konnte nicht durch id_teilnehmer identifiziert werden. "; } } } if (!$line['teilnehmergruppe']) { $errors .= "Keine Teilnehmergruppe. "; } else { $statement = DBManager::get()->prepare("\n SELECT 1\n FROM fleximport_semiro_course_import\n WHERE teilnehmergruppe = ?\n "); $statement->execute(array($line['teilnehmergruppe'])); if (!$statement->fetch()) { $errors .= "Nicht verwendete Teilnehmergruppe. "; } } return $errors; }
function up() { $db = DBManager::get(); $db->exec("\n ALTER TABLE `px_topics` ADD `external_contact` TINYINT NOT NULL DEFAULT '0' AFTER `user_id` \n "); $db->exec("\n ALTER TABLE `blubber_mentions` ADD `external_contact` TINYINT NOT NULL DEFAULT '0' AFTER `user_id` \n "); $db->exec("\n CREATE TABLE IF NOT EXISTS `blubber_external_contact` (\n `external_contact_id` varchar(32) NOT NULL,\n `mail_identifier` varchar(256) DEFAULT NULL,\n `contact_type` varchar(16) NOT NULL DEFAULT 'anonymous',\n `name` varchar(256) NOT NULL,\n `data` TEXT NULL,\n `chdate` bigint(20) NOT NULL,\n `mkdate` bigint(20) NOT NULL,\n PRIMARY KEY (`external_contact_id`)\n ) ENGINE=MyISAM\n "); }
function up() { //Add table $query = "CREATE TABLE IF NOT EXISTS `blubber_reshares` (\n `topic_id` varchar(32) NOT NULL,\n `user_id` varchar(32) NOT NULL,\n `external_contact` tinyint(4) NOT NULL DEFAULT '0',\n `chdate` int(11) NOT NULL,\n UNIQUE KEY `unique_reshares` (`topic_id`,`user_id`,`external_contact`),\n KEY `topic_id` (`topic_id`),\n KEY `user_id` (`user_id`)\n ) ENGINE=MyISAM"; $statement = DBManager::get()->prepare($query); $statement->execute(); }
/** * Displays the global ranking list. * * @param int $page Page of the ranking list to be displayed. */ public function index_action($page = 1) { $vis_query = get_vis_query('b'); // Calculate offsets $max_per_page = get_config('ENTRIES_PER_PAGE'); if ($page < 1) { $page = 1; } $offset = max(0, ($page - 1) * $max_per_page); // Liste aller die mutig (oder eitel?) genug sind $query = "SELECT SQL_CALC_FOUND_ROWS a.user_id,username,score,geschlecht, {$GLOBALS['_fullname_sql']['full']} AS fullname\n FROM user_info AS a\n LEFT JOIN auth_user_md5 AS b USING (user_id)\n WHERE score > 0 AND locked = 0 AND {$vis_query}\n ORDER BY score DESC\n LIMIT " . (int) $offset . "," . (int) $max_per_page; $result = DBManager::get()->fetchAll($query); $count = DBManager::get()->fetchColumn("SELECT FOUND_ROWS()"); $persons = array(); foreach ($result as $row) { $row['is_king'] = StudipKing::is_king($row['user_id'], true); $persons[$row['user_id']] = $row; } $persons = Score::getScoreContent($persons); $this->persons = array_values($persons); $this->numberOfPersons = $count; $this->page = $page; $this->offset = $offset; $this->max_per_page = $max_per_page; $this->current_user = User::findCurrent(); $this->current_user_score = Score::getMyScore($this->current_user); // Set up sidebar and helpbar $sidebar = Sidebar::get(); $sidebar->setImage('sidebar/medal-sidebar.png'); $actions = new OptionsWidget(); $actions->addCheckbox(_('Ihren Wert veröffentlichen'), $this->current_user->score, $this->url_for('score/publish'), $this->url_for('score/unpublish')); $sidebar->addWidget($actions); $helpbar = Helpbar::get(); }
/** * Returns an array of CalendarColumn's, containing the seminar-entries * for the passed user (in the passed semester belonging to the passed institute) * The start- and end-hour are used to constrain the returned * entries to the passed time-period. The passed days constrain the entries * to these. * * @param string $user_id the ID of the user * @param array $semester an array containing the "beginn" of the semester * @param int $start_hour the start hour * @param int $end_hour the end hour * @param string $institute_id the ID of the institute * @param array $days the days to be displayed * @return array an array containing the entries */ static function getInstituteEntries($user_id, $semester, $start_hour, $end_hour, $institute_id, $days) { // fetch seminar-entries, show invisible seminars if the user has enough perms $visibility_perms = $GLOBALS['perm']->have_perm(get_config('SEM_VISIBILITY_PERM')); $stmt = DBManager::get()->prepare("SELECT * FROM seminare\n LEFT JOIN seminar_inst ON (seminare.Seminar_id = seminar_inst.seminar_id)\n WHERE seminar_inst.institut_id = :institute\n AND (start_time = :begin\n OR (start_time < :begin AND duration_time = -1)\n OR (start_time + duration_time >= :begin AND start_time <= :begin)) " . (!$visibility_perms ? " AND visible='1'" : "")); $stmt->bindParam(':begin', $semester['beginn']); $stmt->bindParam(':institute', $institute_id); $stmt->execute(); while ($entry = $stmt->fetch()) { $seminars[$entry['Seminar_id']] = $entry; } if (is_array($seminars)) { foreach ($seminars as $data) { $entries = self::getSeminarEntry($data['Seminar_id'], $user_id); foreach ($entries as $entry) { unset($entry['url']); $entry['onClick'] = 'function(id) { STUDIP.Instschedule.showInstituteDetails(id); }'; $entry['visible'] = 1; if ($entry['start'] >= $start_hour * 100 && $entry['start'] <= $end_hour * 100 || $entry['end'] >= $start_hour * 100 && $entry['end'] <= $end_hour * 100) { $entry['color'] = DEFAULT_COLOR_SEM; $day_number = ($entry['day'] + 6) % 7; if (!isset($ret[$day_number])) { $ret[$day_number] = CalendarColumn::create($day_number); } $ret[$day_number]->addEntry($entry); } } } } return CalendarScheduleModel::addDayChooser($ret, $days, 'instschedule'); }
function down() { $delete = "DELETE FROM log_actions WHERE action_id = MD5('%s')"; foreach ($this->logactions as $a) { DBManager::get()->query(sprintf($delete, $a['name'])); } }
function down() { $db = DBManager::get(); $query = $db->prepare("DELETE FROM `config` WHERE `field` = ?"); foreach (self::$config_entries as $entry) { $query->execute(array($entry['name'])); } // add "hidden" field to user categories... $db->exec("ALTER TABLE `kategorien` ADD `hidden` TINYINT(4) NOT NULL DEFAULT 0 AFTER `content`"); // ... and set it there according to privacy settings $result = $db->query("SELECT `user_id`, `homepage` FROM `user_visibility` WHERE `homepage` LIKE '%kat_%'"); while ($current = $result->fetch()) { $data = json_decode($current['homepage'], true); foreach ($data as $key => $visibility) { if (substr($key, 0, 4) == 'kat_' && $visibility == VISIBILITY_ME) { $category_id = substr($key, 4); DBManager::get()->exec("UPDATE `kategorien` SET `hidden`=1 WHERE `user_id`='" . $current['user_id'] . "'"); } } } // delete privacy settings from database $db->exec("DROP TABLE `user_visibility`"); // delete anonymous flag from forum posts $db->exec("ALTER TABLE `px_topics` DROP `anonymous`"); }
function down() { $db = DBManager::get(); $db->exec("DROP TABLE IF EXISTS `abschluss`"); $db->exec("ALTER TABLE `user_studiengang` DROP `semester`"); $db->exec("ALTER TABLE `user_studiengang` DROP `abschluss_id`"); }