public function editUser(User $user) { $STH = $this->DBH->prepare("UPDATE Users SET login=:login, email=:email, password=:password WHERE id=:id"); $STH->bindValue(":login", $user->getLogin()); $STH->bindValue(":email", $user->getEmail()); $STH->bindValue(":password", $user->getPassword()); $STH->bindValue(":id", $user->getID()); $STH->execute(); }
protected function autoreview_current(User $user) { $this->output("Auto-reviewing all current page versions...\n"); if (!$user->getID()) { $this->output("Invalid user specified.\n"); return; } elseif (!$user->isAllowed('review')) { $this->output("User specified (id: {$user->getID()}) does not have \"review\" rights.\n"); return; } $db = wfGetDB(DB_MASTER); $this->output("Reviewer username: "******"\n"); $start = $db->selectField('page', 'MIN(page_id)', false, __METHOD__); $end = $db->selectField('page', 'MAX(page_id)', false, __METHOD__); if (is_null($start) || is_null($end)) { $this->output("...page table seems to be empty.\n"); return; } # Do remaining chunk $end += $this->mBatchSize - 1; $blockStart = $start; $blockEnd = $start + $this->mBatchSize - 1; $count = 0; $changed = 0; $flags = FlaggedRevs::quickTags(FR_CHECKED); // Assume basic level while ($blockEnd <= $end) { $this->output("...doing page_id from {$blockStart} to {$blockEnd}\n"); $res = $db->select(array('page', 'revision'), '*', array("page_id BETWEEN {$blockStart} AND {$blockEnd}", 'page_namespace' => FlaggedRevs::getReviewNamespaces(), 'rev_id = page_latest'), __METHOD__); # Go through and autoreview the current version of every page... foreach ($res as $row) { $title = Title::newFromRow($row); $rev = Revision::newFromRow($row); # Is it already reviewed? $frev = FlaggedRevision::newFromTitle($title, $row->page_latest, FR_MASTER); # Rev should exist, but to be safe... if (!$frev && $rev) { $article = new Article($title); $db->begin(); FlaggedRevs::autoReviewEdit($article, $user, $rev, $flags, true); FlaggedRevs::HTMLCacheUpdates($article->getTitle()); $db->commit(); $changed++; } $count++; } $db->freeResult($res); $blockStart += $this->mBatchSize - 1; $blockEnd += $this->mBatchSize - 1; // XXX: Don't let deferred jobs array get absurdly large (bug 24375) DeferredUpdates::doUpdates('commit'); wfWaitForSlaves(5); } $this->output("Auto-reviewing of all pages complete ..." . "{$count} rows [{$changed} changed]\n"); }
/** * Returns true if this relationship is applicable to the supplied user * @param User $user * @return boolean */ public function isRelated(User $user) { if ($this->organisation && $user->getOrganisationId() != $this->organisation || $this->group && $user->getGroup() != $this->group || $this->role && $user->getRole() != $this->role || $this->user && $user->getID() != $this->user) { return false; } return true; }
function login() { //登录 if (isset($_POST['name'])) { $model = new User(); if ($model->check()) { //检查用户输入的用户名和密码是否有效 setcookie('user', $_POST['name']); //有效则将用户信息存入cookie和session中 $_SESSION['name'] = $model->getName(); $_SESSION['id'] = $model->getID(); $_SESSION['role'] = $model->getRole(); header('location:http://' . $_SERVER['HTTP_HOST'] . '/WeiXianPin/index.php'); //重定向到主页 exit; } else { $error = '用户名或密码错误,请重新登录'; } } else { $error = ''; } //没有提交登录表单,自然没错 include 'login.html.php'; //进入登录页面并显示错误信息(如果没有则不显示) }
public static function addEvent($message, User $user, $type) { global $mysqli; $date = date("Y-m-d H:i:s"); $mess = $mysqli->real_escape_string($message); $mysqli->query("INSERT INTO events VALUES (NULL, '{$mess}', {$user->getID()} , {$type}, '{$date}')"); }
/** * @see NotificationTarget::getSpecificTargets() **/ function getSpecificTargets($data, $options) { $user = new User(); if ($user->getFromDB($this->obj->fields['users_id'])) { $this->addToAddressesList(array('language' => $user->getField('language'), 'users_id' => $user->getID())); } }
public function processSaveComplete($article, $user, $revision, $status) { wfProfileIn(__METHOD__); $this->mUser = $user; if (self::canEarnBadges($this->mUser)) { $this->mArticle = $article; $this->mRevision = $revision; if ($this->mArticle) { // logic should be processed only one time during one request if (!self::$mDone) { $this->mStatus = $status; $this->mTitle = $this->mArticle->getTitle(); $this->mUserCountersService = new AchUserCountersService($this->mUser->getID()); $this->mCounters = $this->mUserCountersService->getCounters(); $this->loadUserBadges(); $this->processAllNotInTrack(); $this->processAllInTrack(); $this->mUserCountersService->setCounters($this->mCounters); $this->mUserCountersService->save(); $this->processCountersForInTrack(); $this->saveBadges(); if (count($this->mNewBadges) > 0) { $this->calculateAndSaveScore(); } self::$mDone = true; } } } wfProfileOut(__METHOD__); }
public function setUser(User $user) { $id = $user->getID(); if ($id != $this->userID) { $this->userID = $id; $this->forceUpdate = true; } }
public static function add($code, User $user, $purpose) { global $mysqli; $insert = $mysqli->query("INSERT INTO codegen VALUES(NULL, '{$code}', {$user->getID()}, '{$purpose}', NOW())"); if (!$insert) { throw new DBException('Could not add new approval code.', $mysqli->error); } }
private function addNewOrEdit($action, $feed, User $user) { if (!$feed instanceof WallNotificationEntity) { return false; } $data = $feed->data; $this->internalAdd((int) $data->parent_page_id, (int) $user->getID(), $user->getName(), $feed->isReply(), $data->title_id, $data->article_title_ns, $data->parent_id, $feed->threadTitleFull, $action, $data->reason, $data->rev_id); return true; }
function getBiographicalFeature(User $user, $feature) { switch ($feature) { case "name": $feat_str = $user->getName("%f %l"); break; case "group": $feat_str = $user->getGroup(); break; case "role": $feat_str = $user->getRole(); break; case "photo": $official_photo = UserPhoto::get($user->getID(), UserPhoto::OFFICIAL); $feat_str = $official_photo->getFilename(); break; case "organisation": $organisation = $user->getOrganisation(); $feat_str = $organisation->getTitle(); break; case "email": $feat_str = $user->getEmail(); break; case "email_alt": $feat_str = $user->getEmailAlternate(); break; case "address": $address = $user->getAddress(); $postcode = $user->getPostalCode(); $city = $user->getCity(); $province = $user->getProvince(); $prov_name = $province->getName(); $country = $user->getCountry(); $country_name = $country->getName(); $feat_str = html_encode($address) . "<br />" . html_encode($city); if ($prov_name) { $feat_str .= ", " . html_encode($prov_name); } $feat_str .= "<br />"; $feat_str .= html_encode($country_name); if ($postcode) { $feat_str .= ", " . html_encode($postcode); } break; case "phone": $feat_str = $user->getTelephone(); break; case "fax": $feat_str = $user->getFax(); break; default: Zend_Debug::dump($feature); return; } return $feat_str; }
public static function getUserAddress($className, $addressID, User $user) { $f = new ARSelectFilter(); $f->setCondition(new EqualsCond(new ARFieldHandle($className, 'ID'), $addressID)); $f->mergeCondition(new EqualsCond(new ARFieldHandle($className, 'userID'), $user->getID())); $s = ActiveRecordModel::getRecordSet($className, $f, array('UserAddress')); if (!$s->size()) { throw new ARNotFoundException($className, $addressID); } return $s->get(0); }
function set(User $user) { //update de todos los campos menos el ID, devuelve el num de filas modificadas //$parametrosSet=$city->getGenerico(); /*foreach ($city as $key => $value) { $parametrosSet[$key] = $value; }*/ $parametrosWhere = array(); $parametrosWhere["ID"] = $user->getID(); return $this->bd->update($this->tabla, $user->getGenerico(), $parametrosWhere); }
private function getWatchersToNotify($notificationTimeoutSql) { $watchers = []; $dbw = wfGetDB(DB_MASTER); $res = $dbw->select(['watchlist'], ['wl_user'], ['wl_title' => $this->title->getDBkey(), 'wl_namespace' => $this->title->getNamespace(), 'wl_user != ' . intval($this->editor->getID()), $notificationTimeoutSql], __METHOD__); foreach ($res as $row) { /** @var stdClass $row */ $watchers[] = $row->wl_user; } return $watchers; }
function __construct(User $userObj, $score, $currentRanking = null, $previousRanking = null) { wfProfileIn(__METHOD__); $this->mUserId = $userObj->getID(); $this->mUsername = $userObj->getName(); $this->mScore = $score; $this->mUserPageUrl = $userObj->getUserPage()->getLocalURL(); $this->mCurrentRanking = $currentRanking; $this->mPreviousRanking = $previousRanking; wfProfileOut(__METHOD__); }
/** * @param User $user * @param $talks * @return bool */ function wfGetWikiaNewtalk(&$user, &$talks) { global $wgMemc, $wgWikiaNewtalkExpiry, $wgExternalSharedDB; # hack: don't check it for our varnish ip addresses global $wgSquidServers, $wgSquidServersNoPurge; if (!$user->mId && (in_array($user->getName(), $wgSquidServers) || in_array($user->getName(), $wgSquidServersNoPurge))) { return true; } wfProfileIn(__METHOD__); $key = 'wikia:shared_newtalk:' . $user->getID() . ':' . str_replace(' ', '_', $user->getName()); $wikia_talks = $wgMemc->get($key); if (!is_array($wikia_talks)) { $wikia_talks = array(); // Get the data from master. Otherwise we may get the data // from a lagged slave. The effect for the user would be // that he can't clear his user talk notice (the data are // removed on master but not replicated to the slave yet). $dbr = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); $sth = $dbr->select(array("shared_newtalks"), array("sn_wiki"), array("sn_user_id" => $user->getID(), "sn_user_ip" => $user->getName()), __METHOD__, array("LIMIT" => 255)); $wikis = array(); while ($row = $dbr->fetchObject($sth)) { $wikis[] = $row->sn_wiki; } $dbr->freeResult($sth); if (count($wikis)) { $sth = $dbr->select('city_list', array("city_id", "city_title", "city_url", "city_dbname"), array($dbr->makeList(array("city_dbname" => $wikis), LIST_OR), "city_public" => 1), __METHOD__); while ($row = $dbr->fetchObject($sth)) { $link = $row->city_url . 'index.php?title=User_talk:' . urlencode($user->getTitleKey()); $wiki = empty($row->city_title) ? $row->city_dbname : $row->city_title; $wikia_talks[$row->city_id] = array('wiki' => $wiki, 'link' => $link); } $dbr->freeResult($sth); } $wgMemc->set($key, $wikia_talks, $wgWikiaNewtalkExpiry); } if (is_array($wikia_talks) && count($wikia_talks) > 0) { $talks += $wikia_talks; } wfProfileOut(__METHOD__); return true; }
/** * Fetch notifications for User * @param User $paramUser User object * @return array Array with Notification & ID */ public static function fetchNotificationsByUser($paramUser) { if ($paramUser instanceof User == false) { throw new IllegalArgumentException("Invalid argument, User object expected."); } $notifications = array(); $rows = getDatabase()->query("SELECT `id`, `title`, `text`, `image`, `time` FROM `notifications` WHERE `userID` = %i", $paramUser->getID()); foreach ($rows as $row) { $notifications[count($notifications)] = array("notification" => new OrongoNotification($row['title'], $row['text'], $row['image'], $row['time']), "id" => $row['id']); } return $notifications; }
public static function setUser(User $user) { self::$currentUser = $user; $app = ActiveRecordModel::getApplication(); $app->processRuntimePlugins('session/before-login'); $session = new Session(); $session->set('User', $user->getID()); $session->set('UserGroup', $user->userGroup->get() ? $user->userGroup->get()->getID() : 0); if ($app->getSessionHandler()) { $app->getSessionHandler()->setUser($user); } $app->processRuntimePlugins('session/login'); }
/** * emailNotification -- sent Notification for all related article * * @static * @access public * * * @param Title $childTitle * @param $list * @param $namespace * @param User $user * @param $action * @param $message * * @throws MWException */ public static function emailNotification($childTitle, $list, $namespace, $user, $action, $message) { wfProfileIn(__METHOD__); if (count($list) < 1) { wfProfileOut(__METHOD__); return; } $dbw = wfGetDB(DB_SLAVE); $queryIn = array(); foreach ($list as $value) { $queryIn[] = $dbw->addQuotes($value); } /* Wikia change begin - @author: wladek */ /* RT#55604: Add a timeout to the watchlist email block */ global $wgEnableWatchlistNotificationTimeout, $wgWatchlistNotificationTimeout; $now = wfTimestampNow(); if (!empty($wgEnableWatchlistNotificationTimeout) && isset($wgWatchlistNotificationTimeout)) { // not using !empty() to allow setting integer value 0 $blockTimeout = wfTimestamp(TS_MW, wfTimestamp(TS_UNIX, $now) - intval($wgWatchlistNotificationTimeout)); $notificationTimeoutSql = "(wl_notificationtimestamp IS NULL OR wl_notificationtimestamp < '{$blockTimeout}')"; } else { $notificationTimeoutSql = "wl_notificationtimestamp IS NULL"; } if ($action == self::LOG_ACTION_BLOG_POST) { $notificationTimeoutSql = "1"; } $res = $dbw->select(array('watchlist'), array('wl_user, wl_title'), array('wl_user != ' . intval($user->getID()), 'wl_namespace' => $namespace, 'wl_title in(' . implode(",", $queryIn) . ') ', $notificationTimeoutSql), __METHOD__); $watchers = array(); while ($row = $dbw->fetchObject($res)) { if (empty($watchers[$row->wl_title])) { $watchers[$row->wl_title] = array($row->wl_user); } else { if (in_array($row->wl_user, $watchers[$row->wl_title])) { $watchers[$row->wl_title][] = $row->wl_user; } } } /** * Selecting all watching users took to long * and was causing timeouts. It's been moved to a task. * @see CE-1239 by adamk@wikia-inc.com */ if (!empty($watchers)) { $oTask = new FollowEmailTask(); $oTask->title($childTitle); $oTask->wikiId(F::app()->wg->CityId); $oTask->call('emailFollowNotifications', F::app()->wg->User->getId(), $watchers, $user->getId(), $namespace, $message, $action); $oTask->queue(); } wfProfileOut(__METHOD__); }
/** * @todo document * @param string $action * @param integer $ns * @param $title * @param $summary * @param $minoredit * @param $timestamp */ function UserTalkUpdate($action, $ns, $title, $summary, $minoredit, $timestamp) { global $wgUser, $wgLang, $wgMemc, $wgDBname; $fname = 'UserTalkUpdate::UserTalkUpdate'; $this->mAction = $action; $this->mNamespace = $ns; $this->mTitle = $title; $this->mSummary = $summary; $this->mMinorEdit = $minoredit; $this->mTimestamp = $timestamp; # If namespace isn't User_talk:, do nothing. if ($this->mNamespace != NS_USER_TALK) { return; } # If the user talk page is our own, clear the flag # when we are reading it or writing it. if (0 == strcmp(str_replace('_', ' ', $this->mTitle), $wgUser->getName())) { $wgUser->setNewtalk(0); $wgUser->saveSettings(); } else { # Not ours. If writing, then mark it as modified. $sql = false; if (1 == $this->mAction) { $user = new User(); $user->setID(User::idFromName($this->mTitle)); if ($id = $user->getID()) { $sql = true; $wgMemc->delete("{$wgDBname}:user:id:{$id}"); } else { if ($wgUser->isIP($this->mTitle)) { # anonymous $dbw =& wfGetDB(DB_MASTER); $dbw->replace('watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')), array('wl_user' => 0, 'wl_namespace' => NS_USER_TALK, 'wl_title' => $this->mTitle, 'wl_notificationtimestamp' => 1), 'UserTalkUpdate'); $sql = true; $wgMemc->delete("{$wgDBname}:newtalk:ip:{$this->mTitle}"); } } if ($sql && !$user->getNewtalk()) { # create an artificial watchlist table entry for the owner X of the user_talk page X # only insert if X is a real user and the page is not yet watched # mark the changed watch-listed page with a timestamp, so that the page is listed with # an "updated since your last visit" icon in the watch list, ... # ... no matter, if the watching user has or has not indicated an email address in his/her preferences. # We memorise the event of sending out a notification and use this as a flag to suppress # further mails for changes on the same page for that watching user $dbw =& wfGetDB(DB_MASTER); $dbw->replace('watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')), array('wl_user' => $id, 'wl_namespace' => NS_USER_TALK, 'wl_title' => $this->mTitle, 'wl_notificationtimestamp' => 1), 'UserTalkUpdate'); } } } }
/** * Get an array suitable for passing to $dbw->insert() or $dbw->update() * @param DatabaseBase $db * @return array */ protected function getDatabaseArray($db = null) { if (!$db) { $db = wfGetDB(DB_SLAVE); } $expiry = $db->encodeExpiry($this->mExpiry); if ($this->forcedTargetID) { $uid = $this->forcedTargetID; } else { $uid = $this->target instanceof User ? $this->target->getID() : 0; } $a = array('ipb_address' => (string) $this->target, 'ipb_user' => $uid, 'ipb_by' => $this->getBy(), 'ipb_by_text' => $this->getByName(), 'ipb_reason' => $this->mReason, 'ipb_timestamp' => $db->timestamp($this->mTimestamp), 'ipb_auto' => $this->mAuto, 'ipb_anon_only' => !$this->isHardblock(), 'ipb_create_account' => $this->prevents('createaccount'), 'ipb_enable_autoblock' => $this->isAutoblocking(), 'ipb_expiry' => $expiry, 'ipb_range_start' => $this->getRangeStart(), 'ipb_range_end' => $this->getRangeEnd(), 'ipb_deleted' => intval($this->mHideName), 'ipb_block_email' => $this->prevents('sendemail'), 'ipb_allow_usertalk' => !$this->prevents('editownusertalk'), 'ipb_parent_block_id' => $this->mParentBlockId); return $a; }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_leaves_of_absence` WHERE `user_id` = " . $db->qstr($user_id); $results = $db->getAll($query); $frs = array(); if ($results) { foreach ($results as $result) { $fr = LeaveOfAbsence::fromArray($result); $frs[] = $fr; } return new self($frs); } }
public static function get(User $user) { global $db; $frs = array(); $user_id = $user->getID(); $query = "SELECT * FROM `student_formal_remediations` WHERE `user_id` = " . $db->qstr($user_id); $results = $db->getAll($query); if ($results) { foreach ($results as $result) { $fr = FormalRemediation::fromArray($result); $frs[] = $fr; } } return new self($frs); }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_disciplinary_actions` WHERE `user_id` = " . $db->qstr($user_id); $results = $db->getAll($query); $das = array(); if ($results) { foreach ($results as $result) { $da = new DisciplinaryAction($user, $result['id'], $result['action_details']); $das[] = $da; } return new self($das); } }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_student_run_electives` WHERE `user_id` = " . $db->qstr($user_id) . " ORDER BY `start_year` ASC, `start_month` ASC"; $results = $db->getAll($query); $sres = array(); if ($results) { foreach ($results as $result) { $sre = new StudentRunElective($result['id'], $result['user_id'], $result['group_name'], $result['university'], $result['location'], $result['start_month'], $result['start_year'], $result['end_month'], $result['end_year']); $sres[] = $sre; } } return new self($sres); }
public static function get(User $user) { global $db; $studentships = array(); $user_id = $user->getID(); $query = "SELECT * FROM `student_studentships` WHERE `user_id` = " . $db->qstr($user_id) . " ORDER BY `year` ASC"; $results = $db->getAll($query); if ($results) { foreach ($results as $result) { $studentship = new Studentship($result['id'], $result['user_id'], $result['title'], $result['year']); $studentships[] = $studentship; } } return new self($studentships); }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT *, UNIX_TIMESTAMP(`end`) as `end`, UNIX_TIMESTAMP(`start`) as `start` FROM `student_international_activities` WHERE `student_id` = " . $db->qstr($user_id) . " ORDER BY `start` ASC"; $results = $db->getAll($query); $int_acts = array(); if ($results) { foreach ($results as $result) { $int_act = new InternationalActivity($result['id'], $result['student_id'], $result['title'], $result['site'], $result['location'], $result['start'], $result['end']); $int_acts[] = $int_act; } } return new self($int_acts); }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_research` WHERE `user_id` = " . $db->qstr($user_id) . " ORDER BY `priority` ASC"; $results = $db->getAll($query); $citations = array(); if ($results) { foreach ($results as $result) { $citation = ResearchCitation::fromArray($result); $citations[] = $citation; } } return new self($citations); }
public static function get(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT * FROM `student_contributions` WHERE `user_id` = " . $db->qstr($user_id) . " ORDER BY `start_year` DESC, `start_month` DESC"; $results = $db->getAll($query); $contributions = array(); if ($results) { foreach ($results as $result) { $contribution = Contribution::fromArray($result); $contributions[] = $contribution; } } return new self($contributions); }
/** * Returns all events for which the provided user is a listed contact * @param User $user * @return Events */ public static function getByContact(User $user) { global $db; $user_id = $user->getID(); $query = "SELECT distinct a.* from `events` a join `event_contacts` b on a.`event_id`=b.`event_id` where `proxy_id`=?"; $results = $db->getAll($query, array($user_id)); $events = array(); if ($results) { foreach ($results as $result) { $event = new Event($result['event_id'], $result['recurring_id'], $result['region_id'], $result['course_id'], $result['event_phase'], $result['event_title'], $result['event_description'], $result['event_goals'], $result['event_objectives'], $result['event_message'], $result['event_location'], $result['event_start'], $result['event_finish'], $result['event_duration'], $result['release_date'], $result['release_until'], $result['updated_date'], $result['updated_by']); $events[] = $event; } } return new self($events); }