function consultarid($id_expediente) { $con = new DBManager(); if ($con->conectar() == true) { $query = "SELECT * FROM t_expediente WHERE id_expediente={$id_expediente}"; $result = @mysql_query($query); if (!$result) { return false; } else { return $result; } } }
protected function executeInner() { // update user in database $userid = $this->getUser()->getUserid(); // instantiate db $dbManager = new DBManager(); // escape strings for insert $email = $dbManager->escapeString($this->email); $result = null; if (!Str::nullOrEmpty($this->password)) { // they put something in for password, update it $password = md5($this->password); $result = mysql_query("UPDATE users SET email='{$email}', password='******' WHERE userid = {$userid}"); } else { // just update email $result = mysql_query("UPDATE users SET email='{$email}' WHERE userid = {$userid}"); } // check if successful if (!$result) { $this->addError("An error occured attempting update user info. " . $dbManager->getLastError()); return GlobalConstants::USER_INPUT; } $this->addNotice("Successfully updated user info for \"" . $this->email . "\"."); // get new user object $result = mysql_query("SELECT * FROM users WHERE userid = {$userid}"); $user = mysql_fetch_object($result, 'User'); // update user object in session $_SESSION[ValidateCredentials::USER_KEY] = $user; // return success regardless since returned to the same place and error displayed return GlobalConstants::SUCCESS; }
public function executeInner() { // instantiate db $dbManager = new DBManager(); // make comments safe and nicely formatted // TODO: strip tags with exceptions (see examples at http://us2.php.net/manual/en/function.strip-tags.php) // allowable tags <b><strong><u><i><a><em> possibly allowable <ul><ol><li> // TODO: convert "safe" tags to safe implementations, ex <strong style="foo"></strong> becomes <strong></strong> // TODO: sanitize anchor tags, ex <a href="javascript://"> is killed and <a href="foo"> becomes <a href="foo" target="_blank"> // escape strings for insert $name = $dbManager->escapeString($this->name); $contents = $dbManager->escapeString($this->contents); // do query $result = mysql_query("INSERT INTO blogcomments SET blogid=" . $this->blogId . ",name='{$name}', message='{$contents}'"); // check if successful if ($result) { $this->addNotice("Successfully posted a blog entry from \"" . $this->name . "\"."); // TODO: determine why trend micro firewall causing this to hang and why email not sending even when not hanging //$this->notifyAdmins(); } else { $this->addError("An error occured attempting to add a blog post. " . $dbManager->getLastError()); } // return success regardless since returned to the same place and error displayed return GlobalConstants::SUCCESS; }
public static function setConfig($mod, $name, $value) { $db = new DBManager(); $table = 'core_conf'; if (!Comman::isConfig($mod, $name)) { return Comman::createConfig($mod, $name, $value); } return $db->updateSingleColumn($table, 'value', $value, "module='{$mod}' AND name='{$name}'"); }
function execSQL($sql_file_path) { $mysql_host = MYSQL_HOST; $mysql_db = MYSQL_DB; $mysql_login = MYSQL_LOGIN; $mysql_password = MYSQL_PASSWORD; App::import('Vendor', 'sqlclient', array('file' => 'DbManager.class.php')); $dbcon = new DBManager($mysql_host, $mysql_login, $mysql_password, $mysql_db); $sql_result = $dbcon->run_all($sql_file_path); return $sql_result; }
protected function executeInner() { // instantiate db $dbManager = new DBManager(); // do query $result = mysql_query("DELETE FROM blogcomments WHERE commentid = " . $this->commentId); // check if successful if ($result) { $this->addNotice("blog.notice.commentDeleted", array("id" => $this->commentId)); } else { $this->addError("blog.error.failedCommentDeletion", array("id" => $this->commentId, "error" => $dbManager->getLastError())); } // return success regardless since returned to the same place and error displayed return GlobalConstants::SUCCESS; }
function __construct($ro = true) { $dbManager = new DBManager(); $this->link = $dbManager->getDataBaseLink($ro); // readonly if (!$this->link) { error_log('Error connecting to database: ' . mysql_error()); die('Error connecting to database'); } if (!$dbManager->selectOzoneDB($this->link)) { error_log('Error selecting ozone database: ' . mysql_error()); die('Error selecting ozone database'); } $this->dbManager = $dbManager; }
/** * 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 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; }
/** * */ 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; }
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; }
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])); }
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 renderTableGestion() { $this->man = DBManager::getInstance(); //crea instancia $this->man->connect(); //conectate a la bbdd }
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']); } } } } }
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'"); }
/** * 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 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); } } } } }
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 down() { $db = DBManager::get(); foreach ($this->options as $name => $descrition) { $db->exec("DELETE FROM config WHERE field = '{$name}'"); } }
/** * 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(); }
/** * Fetch the next job in the queue and mark it running * @param string $clientID ID of the client requesting the job * @return SugarJob */ public function nextJob($clientID) { $now = $this->db->now(); $queued = SchedulersJob::JOB_STATUS_QUEUED; $try = $this->jobTries; while ($try--) { // TODO: tranaction start? $id = $this->db->getOne("SELECT id FROM {$this->job_queue_table} WHERE execute_time <= {$now} AND status = '{$queued}' ORDER BY date_entered ASC"); if (empty($id)) { return null; } $job = new SchedulersJob(); $job->retrieve($id); if (empty($job->id)) { return null; } $job->status = SchedulersJob::JOB_STATUS_RUNNING; $job->client = $clientID; $client = $this->db->quote($clientID); // using direct query here to be able to fetch affected count // if count is 0 this means somebody changed the job status and we have to try again $res = $this->db->query("UPDATE {$this->job_queue_table} SET status='{$job->status}', date_modified={$now}, client='{$client}' WHERE id='{$job->id}' AND status='{$queued}'"); if ($this->db->getAffectedRowCount($res) == 0) { // somebody stole our job, try again continue; } else { // to update dates & possible hooks $job->save(); break; } // TODO: commit/check? } return $job; }
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 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(); }
/** * @param string $table_name * @param array $join_key_values * * @return bool */ function relationship_exists($table_name, $join_key_values) { // find the key values for the table. $dup_keys = $this->_get_alternate_key_fields($table_name); if (empty($dup_keys)) { Log::debug("No alternate key define, skipping duplicate check.."); return false; } $delimiter = ''; $this->_duplicate_where = ' WHERE '; foreach ($dup_keys as $field) { //look for key in $join_key_values, if found add to filter criteria else abort duplicate checking. if (isset($join_key_values[$field])) { $this->_duplicate_where .= $delimiter . ' ' . $field . "='" . $join_key_values[$field] . "'"; $delimiter = 'AND'; } else { Log::error('Duplicate checking aborted, Please supply a value for this column ' . $field); return false; } } //add deleted check. $this->_duplicate_where .= $delimiter . ' deleted=0'; $query = 'SELECT id FROM ' . $table_name . $this->_duplicate_where; Log::debug("relationship_exists query(" . $query . ')'); $result = $this->_db->query($query, true); $row = $this->_db->fetchByAssoc($result); if ($row == null) { return false; } else { $this->_duplicate_key = $row['id']; return true; } }
/** * 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'); }
/** * Get query for retrieving beans from this link * @param array $params * optional parameters. Possible Values; * 'return_as_array': returns the query broken into * @return String/Array query to grab just ids for this relationship */ public function getQuery($params = array()) { $query_array['select'] = "SELECT DISTINCT emails.* "; $query_array['from'] = "FROM emails "; $query_array['join'] = $this->getEmailsJoin(); $deleted = !empty($params['deleted']) ? 1 : 0; $query_array['where'] = " WHERE emails.deleted={$deleted} "; // Add any optional where clause if (!empty($params['where'])) { $query_array['where'] .= " AND ({$params['where']}) "; } if (!empty($params['enforce_teams'])) { $seed = BeanFactory::getBean($this->getRelatedModuleName()); $seed->addVisibilityFrom($query_array['join']); $seed->addVisibilityWhere($query_array['where']); } if (!empty($params['return_as_array'])) { return $query_array; } $query = $query_array['select'] . $query_array['from'] . $query_array['join'] . $query_array['where']; if (!empty($params['orderby'])) { $query .= "ORDER BY {$params['orderby']}"; } if (!empty($params['limit']) && $params['limit'] > 0) { $offset = isset($params['offset']) ? $params['offset'] : 0; $query = $this->db->limitQuery($query, $offset, $params['limit'], false, "", false); } return $query; }
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 `personal_notifications` "); $db->exec("DROP TABLE IF EXISTS `personal_notifications_user` "); $db->exec("DELETE FROM `config` WHERE `field` = 'PERSONAL_NOTIFICATIONS_ACTIVATED'"); }