public function authenticate()
 {
     global $SESSION;
     $username = $this->input->post("login_username");
     $user_pass = $this->input->post("login_password");
     if (!$username || !$user_pass) {
         if (!$username) {
             return $this->showForm(0, "Informe seu usuário!");
         }
         if (!$user_pass) {
             return $this->showForm(0, "Informe sua senha!");
         }
     }
     include "User.php";
     $user = new User(0);
     $trying = $user->tryLogin($username, md5($user_pass));
     if ($trying["is_authenticated"]) {
         FUTURI_Session::set("futuri_logged", true);
         $user->setID($trying["user_data"]["id"]);
         FUTURI_Session::set("user_info", $user->fields);
         SystemHelper::executeJavascript("localStorage.setItem('FUTURI_user_id','" . $user->fields['id'] . "');");
         if ($user->fields['tour_visto']) {
             SystemHelper::executeJavascript("window.location = '" . base_url() . "inicio" . "'");
         } else {
             SystemHelper::executeJavascript("window.location = '" . base_url() . "tour" . "'");
         }
     } else {
         $this->showForm(0, "Usuário e/ou senha incorretos!");
     }
 }
Example #2
0
 public static function find($id)
 {
     $db = Database::getInstance();
     $pstmt = $db->prepare("SELECT * FROM user WHERE email = :x");
     $pstmt->execute(array(':x' => $id));
     $result = $pstmt->fetch(PDO::FETCH_OBJ);
     $p = new User();
     if ($result) {
         $p->setID($result->id);
         $p->setEmail($result->email);
         $p->setPassword($result->password);
         $p->setIsActive($result->isActive);
         $p->setUsername($result->username);
         $p->setImage($result->image);
         $p->setDescription($result->description);
         $p->setFerraille($result->ferraille);
         $p->setPrestige($result->prestige);
         $pstmt->closeCursor();
         $db = Database::close();
         return $p;
     }
     $pstmt->closeCursor();
     $db = Database::close();
     return null;
 }
Example #3
0
 private static function getUserFromJSON($json)
 {
     $user = new User();
     $user->setID($json['id']);
     $user->setName($json['name']);
     $user->setPhoneNumber($json['phoneNumber']);
     return $user;
 }
 static function put($id)
 {
     $json_user = json_decode($_POST['data'], true);
     $user = new User();
     $user->setID($id);
     $user->setName($json_user['name']);
     $user->setPhoneNumber($json_user['phoneNumber']);
     UserStorage::updateUser($user);
 }
Example #5
0
 public function addUser(User $user)
 {
     $STH = $this->DBH->prepare("INSERT INTO Users (login, email, password, code) \n            VALUES (:login, :email, :password, :code)");
     $STH->bindValue(":login", $user->getLogin());
     $STH->bindValue(":email", $user->getEmail());
     $STH->bindValue(":password", $user->getPassword());
     $STH->bindValue(":code", $user->getCode());
     $STH->execute();
     $user->setID($this->DBH->lastInsertId());
 }
Example #6
0
 private static function setData($userFetch)
 {
     $user = new User($userFetch["pseudo"], $userFetch["birth"], $userFetch["sexe"], $userFetch["mail"], $userFetch["password"]);
     $user->setID($userFetch["id_user"]);
     $user->setAvatar($userFetch["avatar"]);
     $user->setCountry($userFetch["country"]);
     $user->setCity($userFetch["city"]);
     $user->setInscription($userFetch["inscription"]);
     $user->setLastMessage($userFetch["lastMessage"]);
     return $user;
 }
 /**
  * @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');
             }
         }
     }
 }
 public function getAbonentByID($user_id)
 {
     try {
         $sql = "select * from users t1, phonenumbers t2 where t1.user_id=t2.user_id and t1.user_id=?";
         $query = $this->db->query($sql, array($user_id));
         $UserObj = new User();
         if ($query->num_rows() > 0) {
             $row = $query->row_array();
             $UserObj->setID($row['user_id']);
             $UserObj->setFirstName($row['first_name']);
             $UserObj->setLastName($row['last_name']);
             $UserObj->setAddress($row['address']);
             $UserObj->setPhoneNumber($row['phonenumber']);
         }
         return $UserObj;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Example #9
0
 public function getUserList()
 {
     // query database
     $sql = "select * from user_info";
     $res = $this->retrieve($sql);
     $res->setFormat("ASSOC");
     $users = new ArrayObject();
     // retrieve row and create user object
     if ($res->getNumRows() >= 1) {
         foreach ($res as $row) {
             $user = new User();
             $user->setID($row->offsetGet("id"));
             $user->setName($row->offsetGet("name"));
             $user->setEmail($row->offsetGet("email"));
             $users->append($user);
         }
         return $users;
     } else {
         return false;
     }
 }
 function notifyOnPageChangeOrNewpage(&$title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     # we use $wgEmergencyContact as sender's address
     global $wgUser, $wgLang, $wgEmergencyContact;
     global $wgEnotifWatchlist, $wgEnotifMinorEdits;
     global $wgEnotifUserTalk;
     global $wgEnotifNewPages;
     global $wgEnotifForAnyChange;
     global $wgEnotifRevealEditorAddress;
     global $wgEnotifFromEditor;
     global $wgShowUpdatedMarker;
     $initialised = false;
     $fname = 'UserMailer::notifyOnPageChangeOrNewpage';
     wfProfileIn($fname);
     # The following code is only run, if several conditions are met:
     # 1. EmailNotification for pages (other than user_talk pages) must be enabled
     # 2. minor edits (changes) are only regarded if the global flag indicates so
     $isUserTalkPage = $title->getNamespace() == NS_USER_TALK;
     $enotifusertalkpage = $isUserTalkPage && $wgEnotifUserTalk;
     $enotifwatchlistpage = !$isUserTalkPage && $wgEnotifWatchlist;
     if (($enotifusertalkpage || $enotifwatchlistpage) && (!$minorEdit || $wgEnotifMinorEdits)) {
         $dbr =& wfGetDB(DB_MASTER);
         if ($wgEnotifForAnyChange) {
             $res = $dbr->select('watchlist', array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user <> ' . $wgUser->getID()), $fname);
         } else {
             $res = $dbr->select('watchlist', array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user <> ' . $wgUser->getID(), $dbr->wl_notificationtimestampIsNULL()), $fname);
         }
         # if anyone is watching ... set up the email message text which is
         # common for all receipients ...
         if ($dbr->numRows($res) > 0) {
             $this->user &= $wgUser;
             $this->title =& $title;
             $this->timestamp = $timestamp;
             $this->summary = $summary;
             $this->minorEdit = $minorEdit;
             $this->oldid = $oldid;
             $mail = $this->composeCommonMailtext();
             $watchingUser = new User();
             $initialised = true;
             # ... now do for all watching users ... if the options fit
             for ($i = 1; $i <= $dbr->numRows($res); $i++) {
                 $wuser = $dbr->fetchObject($res);
                 $watchingUser->setID($wuser->wl_user);
                 if (($enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') || $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages')) && (!$minorEdit || $wgEnotifMinorEdits && $watchingUser->getOption('enotifminoredits')) && $watchingUser->canReceiveEmail()) {
                     # ... adjust remaining text and page edit time placeholders
                     # which needs to be personalized for each user
                     $this->composeAndSendPersonalisedMail($watchingUser);
                 }
                 # if the watching user has an email address in the preferences
                 # see remark below regard the Tim-Starling improvement
                 # 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
                 # save also the last seen revision of that page for (lvr) links
                 $dbw =& wfGetDB(DB_MASTER);
                 $succes = $dbw->update('watchlist', array('wl_notificationtimestamp' => wfTimestamp(TS_MW, $timestamp), 'wl_lastvisitedrevision' => $oldid), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user' => $wuser->wl_user), $fname);
             }
             # for every watching user
         }
         # if anyone is watching
     }
     # if $wgEnotifWatchlist = true
     if ($wgEnotifNewPages && isset($oldid) && $oldid == 0) {
         $dbr =& wfGetDB(DB_MASTER);
         $res = $dbr->select('user', 'user_id', 'user_enotif_newpages=1 AND user_id<>' . $wgUser->getID(), $fname);
         for ($i = 1; $i <= $dbr->numRows($res); $i++) {
             if (!$initialised) {
                 # initialise if not yet done
                 $this->user &= $wgUser;
                 $this->title =& $title;
                 $this->timestamp = $timestamp;
                 $this->summary = $summary;
                 $this->minorEdit = $minorEdit;
                 $this->oldid = $oldid;
                 $mail = $this->composeCommonMailtext();
                 $watchingUser = new User();
             }
             $wuser = $dbr->fetchObject($res);
             $watchingUser->setID($wuser->user_id);
             # We must not send new page notification to users, who already received an enotif
             # during the first loop when notifs for watched pages were sent
             $enotiftimestamp = $dbr->selectField('watchlist', 'wl_notificationtimestamp', array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user' => $wuser->user_id), $fname);
             # two possibilities exist, where an enotif is sent now
             # a) page is not watched (query failed)
             # b) page is watched and not yet notified (should not happen here)
             if (!$enotiftimestamp || $enotiftimestamp == wfTimestampOrNull()) {
                 $this->composeAndSendPersonalisedMail($watchingUser);
             }
         }
     }
     # notifications for a new page
     # This is the Tim Starling improvement:
     # he updates all pages in one go, what is correct as suchn and should be the preferred solution.
     #
     # However, it needs that the timestamp is no longer determining where the updated marker is shown
     # on revisions in recent changes lists (which is currently still time-based, based on a comparison with the
     # exact notification time.
     #
     # This is very efficient and should be reactivated at the soonest.
     # <FIXME> Tom 26.06.2005
     #
     #		if ( $wgShowUpdatedMarker || $wgEnotifWatchlist ) {
     #			# 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, ...
     #			$dbw =& wfGetDB( DB_MASTER );
     #			$success = $dbw->update( 'watchlist',
     #				array( /* SET */
     #					'wl_notificationtimestamp' => $timestamp
     #				), array( /* WHERE */
     #					'wl_title' => $title->getDBkey(),
     #					'wl_namespace' => $title->getNamespace(),
     #				), 'UserMailer::NotifyOnChange'
     #			);
     #		}
 }
Example #11
0
 /**
  * Special page main function
  */
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgTitle;
     wfReviewExtensionInitMessages();
     $out = "";
     $skin =& $wgUser->getSkin();
     $mode = $wgRequest->getText('mode', 'view_page_statistics');
     $page_id = $wgRequest->getInt('page_id', 0);
     $rev_id = $wgRequest->getInt('rev_id', 0);
     $user_id = $wgRequest->getInt('user_id', 0);
     $user_ip = $wgRequest->getText('user_ip', "");
     $error = false;
     if ($user_id != 0 or $user_ip != "") {
         $theuser = new User();
         if ($user_id == 0) {
             $theuser->setName($user_ip);
         } else {
             $theuser->setID($user_id);
             $theuser->loadFromDatabase();
         }
     }
     if ($page_id == 0) {
         if ($par != '') {
             $title = Title::newFromURL($par);
             $page_id = $title->getArticleID();
         } else {
             $title = null;
         }
     } else {
         $title = Title::newFromID($page_id);
     }
     # Info ahead
     $o = array();
     if ($page_id != 0) {
         $link = $skin->makeLinkObj($title);
         $o[] = wfMsgForContent('review_concerns_page', $link);
     }
     if (isset($theuser)) {
         $link = $skin->makeLinkObj($theuser->getUserPage(), $theuser->getName());
         $o[] = wfMsgForContent('review_concerns_user', $link);
     }
     if ($page_id > 0 and $rev_id > 0) {
         $link = $skin->makeLinkObj($wgTitle, wfMsgForContent('revision_review_this_page_version_link'), "&mode=review&page_id={$page_id}&rev_id={$rev_id}");
         $o[] = $link;
     }
     if (count($o) > 0) {
         $out .= "<ul><li>" . implode("</li>\n<li>", $o) . "</li></ul>";
     }
     // FIXME: use private methods!
     # Modes
     if ($mode == 'view_page_statistics' && $title != null) {
         # View statistics for one page
         $revisions = $this->get_reviewed_revisions($title);
         arsort($revisions);
         # Newest first
         if (count($revisions) == 0) {
             $out .= wfMsgForContent('review_no_reviews_for_page', $skin->makeLinkObj($title));
         } else {
             # Load review data for each version separately to avoid memory apocalypse
             $statistics = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -1, $statistics);
             $out2 = "";
             foreach ($revisions as $revision) {
                 $reviews = $this->get_reviews_for_revision($title, $revision);
                 $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                 $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
             }
             $out .= $this->get_revision_statistics_row($title, 0, $statistics);
             $out .= $out2;
             $out .= "</table>\n";
         }
         $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
     } else {
         if ($mode == 'view_version_statistics' && $title != null) {
             # View statistics for a specific version of a page
             $data = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -2, $data);
             $reviews = $this->get_reviews_for_revision($title, $rev_id);
             $this->analyze_review_data($title, $rev_id, $reviews, $data);
             $out .= $this->get_revision_statistics_row($title, 0, $data);
             # Statistics for the revision
             $data = $this->group_data_by_user($reviews);
             foreach ($data as $entry) {
                 $out .= $this->get_revision_statistics_row($title, 1, $entry, true);
             }
             $out .= "</table>\n";
             $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
         } else {
             if ($mode == 'view_user_reviews' and isset($theuser)) {
                 if ($page_id != 0) {
                     # View the reviews of a user for a specific page
                     global $wgReviewFeatureSingleUserMode;
                     $wgReviewFeatureSingleUserMode = true;
                     $revisions = wfReviewExtensionGetUserRatingsForPage($title, $theuser);
                     $statistics = array();
                     $out .= "<table id='review_statistics_table'>\n";
                     $out .= $this->get_revision_statistics_row($title, -1, $statistics);
                     $out2 = "";
                     foreach ($revisions as $revision => $reviews) {
                         $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                         $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
                     }
                     $out .= $this->get_revision_statistics_row($title, 0, $statistics);
                     $out .= $out2;
                     $out .= "</table>\n";
                     $wgReviewFeatureSingleUserMode = false;
                 } else {
                     # View the pages reviewed by a user
                     $data = $this->get_list_of_pages_reviewed_by_user($theuser);
                     $out .= "<h2>" . wfMsgExt('review_user_page_list', array('content', 'parsemag'), $theuser->getName()) . "</h2>\n";
                     $data2 = array();
                     if ($user_id == 0) {
                         $user_link = "user_ip=" . $user_ip;
                     } else {
                         $user_link = "user_id=" . $user_id;
                     }
                     foreach ($data as $pid) {
                         $t = Title::newFromID($pid);
                         $link1 = $skin->makeLinkObj($t);
                         $link2 = $skin->makeLinkObj($wgTitle, wfMsgForContent('review_user_details_link'), "mode=view_user_reviews&" . $user_link . "&page_id={$pid}");
                         $data2[] = $link1 . " " . $link2;
                     }
                     asort($data2);
                     if (count($data2) > 0) {
                         $out .= "<ol><li>" . implode("</li>\n<li>", $data2) . "</li></ul>";
                     }
                 }
                 $page_title = wfMsgForContent('review_for_user', $theuser->getName());
             } else {
                 if ($mode == 'review') {
                     $out = $this->review_page($page_id, $rev_id);
                     $page_title = wfMsgForContent('review_page_review', $title->getPrefixedText());
                 } else {
                     $error = true;
                 }
             }
         }
     }
     $this->setHeaders();
     if ($error) {
         $wgOut->addHTML(wfMsgForContent('review_error'));
     } else {
         $wgOut->setPageTitle($page_title);
         $wgOut->addHTML($out);
     }
 }
Example #12
0
 function execute($par)
 {
     global $wgOut, $wgUser, $wgShowRatings, $wgRequest, $wgLang;
     $err = "";
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $restore = $wgRequest->getVal('restore', null);
     $sk = $wgUser->getSkin();
     $wgOut->setHTMLTitle('Clear Ratings - Accuracy Patrol');
     $t = Title::newFromText($target);
     if ($t == '') {
         $wgOut->addHTML(wfMsg('clearratings_notitle'));
         $this->addClearForm($target);
         return;
     }
     $me = SpecialPage::getTitleFor('Clearratings', $t->getText());
     if ($wgUser->getID() == 0) {
         return;
     }
     if ($wgRequest->wasPosted()) {
         // clearing ratings
         $clear = $wgRequest->getVal('clear', null);
         $confirm = $wgRequest->getVal('confirm', null);
         if ($clear != null && $confirm == null && false) {
             $id = $t->getArticleID();
             $wgOut->addHTML(wfMsg('clearratings_clear_confirm_prompt', $sk->makeLinkObj($t, $t->getFullText())) . "\n\t\t\t\t\t\t<br/><br/>\n\t\t\t\t\t\t<form  id='clear_ratings' method='POST'>\n\t\t\t\t\t\t\t<input type=hidden value='{$id}' name='clear'>\n\t\t\t\t\t\t\t<input type=hidden value='true' name='confirm'>\n\t\t\t\t\t\t\t<input type=hidden value='" . htmlspecialchars($target) . "' name='target'>\n\t\t\t\t\t\t\t<input type=submit value='" . wfMsg('clearratings_clear_confirm') . "'>\n\t\t\t\t\t\t</form>");
             return;
         } else {
             if ($clear != null) {
                 RateArticle::clearRatingForPage($clear, $t, $wgUser);
                 $wgOut->addHTML(wfMsg('clearratings_clear_finished') . "<br/><br/>");
             }
         }
     }
     if ($restore != null && $wgRequest->getVal('reason', null) == null) {
         $wgOut->addHTML(wfMsg('clearreating_reason_restore') . "<br/><br/>");
         $wgOut->addHTML("<form  id='clear_ratings' method='POST' action='{$me->getFullURL()}'>");
         $wgOut->addHTML(wfMsg('clearratings_reason') . " <input type='text' name='reason' size='40'><br/><br/>");
         foreach ($_GET as $k => $v) {
             $wgOut->addHTML("<input type='hidden' value='{$v}' name='{$k}'/>");
         }
         $wgOut->addHTML("<input type='submit' value='" . wfMsg('clearratings_submit') . "'/>");
         $wgOut->addHTML("</form>");
         return;
     } else {
         if ($restore != null) {
             $dbw =& wfGetDB(DB_MASTER);
             $user = $wgRequest->getVal('user');
             $page = $wgRequest->getVal('page');
             $u = new User();
             $u->setID($user);
             $up = $u->getUserPage();
             $hi = $wgRequest->getVal('hi');
             $low = $wgRequest->getVal('low');
             $count = $dbw->selectField('rating', 'count(*)', array("rat_page={$page}", "rat_isdeleted=1"));
             $sql = "update rating set rat_isdeleted= 0 where rat_user_deleted = {$user} and rat_page={$page} and rat_id <= {$hi} and rat_id >= {$low};";
             $dbw->query($sql);
             $wgOut->addHTML("<br/><br/>" . wfMsg('clearratings_clear_restored', $sk->makeLinkObj($up, $u->getName()), $when) . "<br/><br/>");
             // add the log entry
             $t = Title::newFromId($page);
             $params = array($page, $min, $max);
             $log = new LogPage('accuracy', true);
             $reason = $wgRequest->getVal('reason');
             $log->addEntry('accuracy', $t, wfMsg('clearratings_logrestore', $reason, $t->getFullText(), $count), $params);
         }
     }
     if ($target != null) {
         $t = Title::newFromText($target);
         $id = $t->getArticleID();
         if ($id == 0) {
             $err = wfMsg('clearratings_no_such_title', $wgRequest->getVal('target'));
         } else {
             if ($t->getNamespace() != NS_MAIN) {
                 $err = wfMsg('clearratings_only_main', $wgRequest->getVal('target'));
             } else {
                 // clearing info
                 $dbr =& wfGetDB(DB_MASTER);
                 //  get log
                 $res = $dbr->select(array('logging'), array('log_timestamp', 'log_user', 'log_comment', 'log_params'), array('log_type' => 'accuracy', "log_title" => $t->getDBKey()), "wfSpecialClearratings");
                 $count = 0;
                 $wgOut->addHTML(wfMsg('clearratings_previous_clearings') . "<ul>");
                 while ($row = $dbr->fetchObject($res)) {
                     $d = $wgLang->date($row->log_timestamp);
                     $u = new User();
                     $u->setID($row->log_user);
                     $up = $u->getUserPage();
                     $params = split("\n", $row->log_params);
                     $wgOut->addHTML("<li>" . $sk->makeLinkObj($up, $u->getName()) . " ({$d}): ");
                     $wgOut->addHTML(preg_replace('/<?p>/', '', $wgOut->parse($row->log_comment)));
                     $wgOut->addHTML("</i>");
                     if (strpos($row->log_comment, wfMsg('clearratings_restore')) === false) {
                         $wgOut->addHTML("(" . $sk->makeLinkObj($me, wfMsg('clearratings_previous_clearings_restore'), "page={$id}&hi={$params[2]}&low={$params[1]}&target={$target}&user={$row->log_user}&restore=1") . ")");
                     }
                     $wgOut->addHTML("</li>");
                     $count++;
                 }
                 $wgOut->addHTML("</ul>");
                 if ($count == 0) {
                     $wgOut->addHTML(wfMsg('clearratings_previous_clearings_none') . "<br/><br/>");
                 }
                 $dbr->freeResult($res);
                 $res = $dbr->select(array("rating"), array("COUNT(*) AS C", "AVG(rat_rating) AS R"), array("rat_page" => $id, "rat_isdeleted" => "0"), __METHOD__);
                 if ($row = $dbr->fetchObject($res)) {
                     $percent = $row->R * 100;
                     $wgOut->addHTML($sk->makeLinkObj($t, $t->getFullText()) . "<br/><br/>" . wfMsg('clearratings_number_votes') . " {$row->C}<br/>" . wfMsg('clearratings_avg_rating') . " {$percent} %<br/><br/>\n\t\t\t\t\t\t<form  id='clear_ratings' method='POST' action='{$me->getFullURL()}'>\n\t\t\t\t\t\t\t<input type=hidden value='{$id}' name='clear'>\n\t\t\t\t\t\t\t<input type=hidden value='" . htmlspecialchars($target) . "' name='target'>\n\t\t\t\t\t\t\t" . wfMsg('clearratings_reason') . " <input type='text' name='reason' size='40'><br/><br/>\n\t\t\t\t\t\t\t<input type=submit value='" . wfMsg('clearratings_clear_submit') . "'>\n\t\t\t\t\t\t</form><br/><br/>\n\t\t\t\t\t\t");
                 }
                 $dbr->freeResult($res);
                 $ap = Title::makeTitle(NS_SPECIAL, "AccuracyPatrol");
                 $wgOut->addHTML($sk->makeLinkObj($ap, "Return to accuracy patrol"));
             }
         }
     }
     $this->addClearForm($target);
 }
Example #13
0
 /**
  * @todo document
  * @param $title Title object
  * @param $timestamp
  * @param $summary
  * @param $minorEdit
  * @param $oldid (default: false)
  */
 function notifyOnPageChange(&$title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     # we use $wgEmergencyContact as sender's address
     global $wgUser, $wgEnotifWatchlist;
     global $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgShowUpdatedMarker;
     $fname = 'UserMailer::notifyOnPageChange';
     wfProfileIn($fname);
     # The following code is only run, if several conditions are met:
     # 1. EmailNotification for pages (other than user_talk pages) must be enabled
     # 2. minor edits (changes) are only regarded if the global flag indicates so
     $isUserTalkPage = $title->getNamespace() == NS_USER_TALK;
     $enotifusertalkpage = $isUserTalkPage && $wgEnotifUserTalk;
     $enotifwatchlistpage = $wgEnotifWatchlist;
     if (!$minorEdit || $wgEnotifMinorEdits) {
         if ($wgEnotifWatchlist) {
             // Send updates to watchers other than the current editor
             $userCondition = 'wl_user <> ' . intval($wgUser->getId());
         } elseif ($wgEnotifUserTalk && $title->getNamespace() == NS_USER_TALK) {
             $targetUser = User::newFromName($title->getText());
             if (is_null($targetUser)) {
                 wfDebug("{$fname}: user-talk-only mode; no such user\n");
                 $userCondition = false;
             } elseif ($targetUser->getId() == $wgUser->getId()) {
                 wfDebug("{$fname}: user-talk-only mode; editor is target user\n");
                 $userCondition = false;
             } else {
                 // Don't notify anyone other than the owner of the talk page
                 $userCondition = 'wl_user = '******'watchlist', array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), $userCondition, 'wl_notificationtimestamp IS NULL'), $fname);
             # if anyone is watching ... set up the email message text which is
             # common for all receipients ...
             if ($dbr->numRows($res) > 0) {
                 $this->title =& $title;
                 $this->timestamp = $timestamp;
                 $this->summary = $summary;
                 $this->minorEdit = $minorEdit;
                 $this->oldid = $oldid;
                 $this->composeCommonMailtext();
                 $watchingUser = new User();
                 # ... now do for all watching users ... if the options fit
                 for ($i = 1; $i <= $dbr->numRows($res); $i++) {
                     $wuser = $dbr->fetchObject($res);
                     $watchingUser->setID($wuser->wl_user);
                     if ($enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') || $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages') && $title->equals($watchingUser->getTalkPage()) && (!$minorEdit || $wgEnotifMinorEdits && $watchingUser->getOption('enotifminoredits')) && $watchingUser->isEmailConfirmed()) {
                         # ... adjust remaining text and page edit time placeholders
                         # which needs to be personalized for each user
                         $this->composeAndSendPersonalisedMail($watchingUser);
                     }
                     # if the watching user has an email address in the preferences
                 }
             }
         }
         # if anyone is watching
     }
     # if $wgEnotifWatchlist = true
     if ($wgShowUpdatedMarker || $wgEnotifWatchlist) {
         # 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, ...
         $dbw =& wfGetDB(DB_MASTER);
         $success = $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp($timestamp)), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace()), 'UserMailer::NotifyOnChange');
         # FIXME what do we do on failure ?
     }
     wfProfileOut($fname);
 }
 /**
  * @todo document
  * @param $currentPage
  * @param $currentNs
  * @param $timestamp
  * @param $currentSummary
  * @param $currentMinorEdit
  * @param $oldid (default: false)
  */
 function notifyOnPageChange(&$title, $timestamp, $summary, $minorEdit, $oldid = false)
 {
     # we use $wgEmergencyContact as sender's address
     global $wgUser, $wgLang, $wgEmergencyContact;
     global $wgEnotifWatchlist, $wgEnotifMinorEdits;
     global $wgEnotifUserTalk;
     global $wgEnotifRevealEditorAddress;
     global $wgEnotifFromEditor;
     global $wgEmailAuthentication;
     global $wgShowUpdatedMarker;
     $fname = 'UserMailer::notifyOnPageChange';
     wfProfileIn($fname);
     # The following code is only run, if several conditions are met:
     # 1. EmailNotification for pages (other than user_talk pages) must be enabled
     # 2. minor edits (changes) are only regarded if the global flag indicates so
     $isUserTalkPage = $title->getNamespace() == NS_USER_TALK;
     $enotifusertalkpage = $isUserTalkPage && $wgEnotifUserTalk;
     $enotifwatchlistpage = !$isUserTalkPage && $wgEnotifWatchlist;
     if (($enotifusertalkpage || $enotifwatchlistpage) && (!$minorEdit || $wgEnotifMinorEdits)) {
         $dbr =& wfGetDB(DB_MASTER);
         extract($dbr->tableNames('watchlist'));
         $res = $dbr->select('watchlist', array('wl_user'), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace(), 'wl_user <> ' . $wgUser->getID(), 'wl_notificationtimestamp <= 1'), $fname);
         # if anyone is watching ... set up the email message text which is
         # common for all receipients ...
         if ($dbr->numRows($res) > 0) {
             $this->user &= $wgUser;
             $this->title =& $title;
             $this->timestamp = $timestamp;
             $this->summary = $summary;
             $this->minorEdit = $minorEdit;
             $this->oldid = $oldid;
             $this->composeCommonMailtext();
             $watchingUser = new User();
             # ... now do for all watching users ... if the options fit
             for ($i = 1; $i <= $dbr->numRows($res); $i++) {
                 $wuser = $dbr->fetchObject($res);
                 $watchingUser->setID($wuser->wl_user);
                 if ($enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') || $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages') && (!$minorEdit || $wgEnotifMinorEdits && $watchingUser->getOption('enotifminoredits')) && $watchingUser->isEmailConfirmed()) {
                     # ... adjust remaining text and page edit time placeholders
                     # which needs to be personalized for each user
                     $this->composeAndSendPersonalisedMail($watchingUser);
                 }
                 # if the watching user has an email address in the preferences
             }
         }
         # if anyone is watching
     }
     # if $wgEnotifWatchlist = true
     if ($wgShowUpdatedMarker || $wgEnotifWatchlist) {
         # 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, ...
         $dbw =& wfGetDB(DB_MASTER);
         $success = $dbw->update('watchlist', array('wl_notificationtimestamp' => $timestamp), array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace()), 'UserMailer::NotifyOnChange');
     }
 }
Example #15
0
 public function isAllowed($isLoggedIn, $userId = 0)
 {
     if (!$isLoggedIn) {
         return false;
     } else {
         if ($isLoggedIn && $userId == 0) {
             return false;
         } else {
             $user = new User();
             $user->setID($userId);
             return in_array('newarticlepatrol', $user->getRights());
         }
     }
 }
Example #16
0
 protected function saveAnonUser(User $user)
 {
     $user->setID(null);
     $this->session->set('checkoutUser', $user);
     SessionUser::setUser($user);
 }
Example #17
0
 private static function createFromDBManager($db)
 {
     $row = $db->fetch_result();
     define_tables();
     defineUserColumns();
     $data = array(NICKNAME => $row[USER_NICKNAME], EMAIL => $row[USER_E_MAIL], PASSWORD => $row[USER_PASSWORD], NAME => $row[USER_NAME], SURNAME => $row[USER_SURNAME], GENDER => $row[USER_GENDER], BIRTHDAY => date_timestamp_get(date_create($row[USER_BIRTHDAY])), BIRTHPLACE => $row[USER_BIRTHPLACE], LIVING_PLACE => $row[USER_LIVINGPLACE], AVATAR => $row[USER_AVATAR], HOBBIES => $row[USER_HOBBIES], JOB => $row[USER_JOB], ROLE => $row[USER_ROLE], VISIBLE => $row[USER_VISIBLE]);
     $user = new User($data);
     $user->setID(intval($row[USER_ID]))->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[USER_CREATION_DATE])))->setVerified($row[USER_VERIFIED]);
     require_once "common.php";
     $user->setAccessCount(LogManager::getAccessCount("User", $user->getID()));
     return $user;
 }
 /**
  * Display the HTML for this special page with all the widgets in it
  */
 private function displayContainer()
 {
     global $wgWidgetList, $wgUser, $wgWidgetShortCodes;
     $containerJS = array('community-dashboard.js', 'dashboard-widget.js', 'jquery.ui.sortable.min.js', 'jquery.json-2.2.min.js');
     $containerCSS = array('community-dashboard.css');
     $jsTags = $this->makeUrlTags('js', $containerJS);
     $cssTags = $this->makeUrlTags('css', $containerCSS);
     // get all commonly updating stats, to see the initial widget
     // displays with
     $this->refreshData = $this->dashboardData->getStatsData();
     // get all data such as wikihow-defined structure goals, dynamic
     // global data, and user-specific data
     $staticData = $this->dashboardData->loadStaticGlobalOpts();
     $priorities = json_decode($staticData['cdo_priorities_json'], true);
     if (!is_array($priorities)) {
         $priorities = array();
     }
     $thresholds = json_decode($staticData['cdo_thresholds_json'], true);
     DashboardWidget::setThresholds($thresholds);
     $baselines = (array) json_decode($staticData['cdo_baselines_json']);
     DashboardWidget::setBaselines($baselines);
     DashboardWidget::setMaxUsernameLength(CommunityDashboard::USERNAME_MAX_LENGTH);
     // display the user-defined ordering of widgets inside an outside
     // container
     $userData = $this->dashboardData->loadUserData();
     $prefs = !empty($userData['prefs']) ? $userData['prefs'] : array();
     $userOrdering = isset($prefs['ordering']) ? $prefs['ordering'] : array();
     $completion = !empty($userData['completion']) ? $userData['completion'] : array();
     DashboardWidget::setCompletion($completion);
     // add any new widgets that have been added since the user last
     // customized
     foreach ($wgWidgetList as $name) {
         $found = false;
         foreach ($userOrdering as $arr) {
             if ($arr['wid'] == $name) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $userOrdering[] = array('wid' => $name, 'show' => 1);
         }
     }
     // create the user-defined ordering list, removing any community
     // priority widgets from the list so their not displayed twice
     $userWidgets = array();
     foreach ($userOrdering as $arr) {
         $found = false;
         foreach ($priorities as $name) {
             if ($arr['wid'] == $name) {
                 $found = true;
                 break;
             }
         }
         if (!$found && $arr['show']) {
             $userWidgets[] = $arr['wid'];
         }
     }
     $func = array($this, 'displayWidgets');
     $out = call_user_func($func, array('test'));
     $langKeys = array('howto', 'cd-pause-updates', 'cd-resume-updates', 'cd-current-priority', 'cd-network-error');
     $langScript = Wikihow_i18n::genJSMsgs($langKeys);
     //TODO: Likely should move this somewhere else
     //but not sure where yet
     //load user specific info that only needs to be loaded
     //once
     if ($wgUser->getID() > 0) {
         $u = new User();
         $u->setID($wgUser->getID());
         $img = Avatar::getPicture($u->getName(), true);
         if ($img == '') {
             $img = Avatar::getDefaultPicture();
         }
         $sk = $wgUser->getSkin();
         $userName = $sk->makeLinkObj($u->getUserPage(), $u->getName());
         $tipsLink = "/Special:TipsPatrol";
     } else {
         $tipsLink = "/Special:Userlogin?returnto=Special:TipsPatrol";
     }
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $tmpl->set_vars(array('jsTags' => $jsTags, 'cssTags' => $cssTags, 'thresholds' => $staticData['cdo_thresholds_json'], 'GLOBAL_DATA_REFRESH_TIME_SECS' => self::GLOBAL_DATA_REFRESH_TIME_SECS, 'USER_DATA_REFRESH_TIME_SECS' => self::USER_DATA_REFRESH_TIME_SECS, 'USERNAME_MAX_LENGTH' => self::USERNAME_MAX_LENGTH, 'widgetTitles' => DashboardData::getTitles(), 'priorityWidgets' => $priorities, 'userWidgets' => $userWidgets, 'prefsOrdering' => $userOrdering, 'userCounts' => $userData['counts'], 'userImage' => $img, 'userName' => $userName, 'displayWidgetsFunc' => array($this, 'displayWidgets'), 'appShortCodes' => $wgWidgetShortCodes, 'tipsLink' => $tipsLink));
     $html = $tmpl->execute('dashboard-container.tmpl.php');
     return $langScript . $html;
 }
Example #19
0
<?php

require_once 'commandLine.inc';
$start = 1236367281;
$wgUser = new User();
$wgUser->setID(1236204);
$debug = 0;
# 60 days
$offset = 60 * 60 * 24 * 60;
$cutoff = wfTimestamp(TS_MW, time() - $offset);
$minedits = 5;
$dbw = wfGetDB(DB_MASTER);
$dbr = wfGetDB(DB_MASTER);
$from = new MailAddress("*****@*****.**");
# get all of the docents
$users = array();
$res = $dbr->query("select distinct(dc_user) as dc_user from docentcategories;");
while ($row = $dbr->fetchObject($res)) {
    $users[] = $row->dc_user;
}
$project_page = Title::makeTitle(NS_PROJECT, "Docents");
function dropDocent($user)
{
    global $dbw, $debug, $project_page;
    if (!$debug) {
        $dbw->query("delete from docentcategories where dc_user={$user->getId()}");
    }
    $params = array($user->getID());
    $log = new LogPage('doc', false);
    $log->addEntry('doc', $project_page, wfMsg('doc_logsummary', $user->getName()), $params);
}
	/**
	 * For a list of tasks, get a single table row
	 * This function is heavy on output!
	 */
	function get_task_table_row( &$task, &$title, $show_page = false, $returnto = '' ) { # Checked for HTML and MySQL insertion attacks
		global $wgContLang, $wgUser, $wgTasksNamespace, $wgExtraNamespaces;
		$out = '';
		$sk = $wgUser->getSkin();
		$ct = $wgContLang->timeanddate( $task->task_timestamp ); # Time object from string of digits
		$cu = Title::makeTitleSafe( NS_USER, $task->task_user_text ); # Safe user name
		$comment = htmlspecialchars( $task->task_comment ); # Safe user comment, no HTML allowed
		$comment = nl2br( $comment ); # display newlines as they were in the edit box
		$status = $task->task_status; # Integer
		$tid = $task->task_id; # Integer
		$encType = $this->get_type_html( $this->get_task_type( $task->task_type ) ); # Will catch illegal types and wfDebug them
		if( $returnto != '' ) {
			$returnto = '&returnto=' . urlencode( $returnto );
		}

		$out .= '<tr>';
		if( $show_page ) {
			$out .= '<td align="left" valign="top">';
			$out .= $sk->makeLinkObj( $title );
			$out .= '<br />';
			$out .= $sk->makeLinkObj( $title, wfMsgHTML('tasks_see_page_tasks'), 'action=tasks' );
			$out .= '</td>';
		}
		$out .= '<td valign="top" align="left" nowrap class="tasks_status_bgcol_' . $this->status_types[$status] . '">';
		$out .= '<b>' . $encType . '</b><br /><i>';
		$out .= wfMsgForContent( 'tasks_status_' . $this->status_types[$status] );
		$out .= '</i><br />' ;

		# Additional info
		$help_title = Title::makeTitleSafe( NS_HELP, wfMsgForContent('tasks_help_page') );
		$help_title->mFragment = $encType ;
		$ext1 = $sk->makeLinkObj( $help_title , htmlspecialchars( wfMsgForContent('tasks_help_page_link') ) );
		$more_title = SpecialPage::getTitleFor( 'Tasks' ); # This special page
		$ext2 = $sk->makeLinkObj( $more_title , htmlspecialchars( wfMsgForContent('tasks_more_like_it') ), 'task_type='.$task->task_type );
		$out .= wfMsgForContent ( 'tasks_help_separator' , $ext1 , $ext2 ) ;


		$out .= '</td>';
		$out .= '<td align="left" valign="top" nowrap>';
		$out .= wfMsgHTML( 'tasks_created_by', $sk->makeLinkObj( $cu, htmlspecialchars( $task->task_user_text ) ) );
		$out .= '<br />' . $ct ;

		# Closing information
		if( $task->task_user_close != 0 && $this->is_closed( $status ) ) {
			$user_close = new User;
			$user_close->setID( $task->task_user_close );
			$uct = Title::makeTitleSafe( NS_USER, $user_close->getName() ); # Assigned user title
			$out .= '<br />' . wfMsgHTML( 'tasks_closedby', $sk->makeLinkObj( $uct, htmlspecialchars( $user_close->getName() ) ) );
			if( $task->task_timestamp_closed != "" ) {
				$out .= '<br />' . $wgContLang->timeanddate( $task->task_timestamp_closed ); # Time object from string of digits
			}
		}
		$out .= '</td>';

		$out .= '<td align="left" valign="top">' . $comment . '</td>' ; # Comment is HTML-stripped
		$out .= '<td align="left" valign="top">';
		if( $task->task_user_assigned == 0 ) {
			# Noone is assigned this task
			$out .= '<form method="get">' // Added a form in place of old "assign to me" link
				. wfMsgHTML( 'tasks_assign_to' ) . ' <input type="text" name="username" />'
				. '<input type="hidden" name="action" value="tasks" />'
				. '<input type="hidden" name="mode" value="assignto" />'
				. '<input type="hidden" name="title" value="'.htmlspecialchars($title->getPrefixedText()).'" />'
				. '<input type="hidden" name="taskid" value="'.$tid.'" />'
				. '<input type="submit" name="submit" value="' . wfMsgHTML( 'ok' ) . '" />'
				. '</form>';
		} else {
			# Someone is assigned this task
			$au = new User(); # Assigned user
			$au->setID( $task->task_user_assigned );
			$aut = Title::makeTitleSafe( NS_USER, $au->getName() ); # Assigned user title
			$out .= wfMsgHTML( 'tasks_assignedto', $sk->makeLinkObj( $aut, htmlspecialchars( $au->getName() ) ) );
		}
		if( $wgUser->isLoggedIn() ) {
			$txt = array();
			if( $this->is_open( $status ) ) {
				# Assignment
				if( $wgUser->getID() != $task->task_user_assigned ) {
					# Assign myself
					$txt[] = $sk->makeLinkObj( $title,
						wfMsgHTML( 'tasks_assign_me' ),
						"action=tasks&mode=assignme&taskid={$tid}{$returnto}" ); # tid is integer, returnto is safe
				} else {
					# Unassign myself
					$txt[] = $sk->makeLinkObj( $title,
						wfMsgHTML( 'tasks_unassign_me' ),
						"action=tasks&mode=unassignme&taskid={$tid}{$returnto}" ); # tid is integer, returnto is safe
				}
			}
			if( $this->is_open( $status ) ) {
				# Open or assigned
				$txt[] = $sk->makeLinkObj( $title, wfMsgHTML( 'tasks_close' ), "action=tasks&mode=close&taskid={$tid}{$returnto}" );
				$txt[] = $sk->makeLinkObj( $title, wfMsgHTML( 'tasks_wontfix' ), "action=tasks&mode=wontfix&taskid={$tid}{$returnto}" );
			} elseif( $this->get_task_type( $task->task_type ) != 'create' ) {
				# Closed or wontfix, can reopen (maybe)
				$txt[] = $sk->makeLinkObj( $title, wfMsgHTML( 'tasks_reopen' ), "action=tasks&mode=reopen&taskid={$tid}{$returnto}" );
			}

			if( $wgUser->isAllowed( 'delete' ) ) {
				$txt[] = $sk->makeLinkObj( $title, wfMsgHTML( 'tasks_delete' ), "action=tasks&mode=delete&taskid={$tid}{$returnto}" );
			}

			if( count( $txt ) > 0 ) {
				$out .= '<br />' . implode( ' - ', $txt );
			}

		}
		$tdp = $this->get_task_discussion_page( $task );
		$out .= '<br />' . $sk->makeLinkObj( $tdp, wfMsgHTML('tasks_discussion_page_link') );
		$out .= '</td></tr>' ;

		# Transclude comments page, if wanted
		if( $wgUser->getOption( 'show_task_comments' ) ) {
			if( $this->pagemode == 'search' || $this->pagemode == 'tasks_of_page' ) {
				$out .= $this->transclude_comments( $tdp, $show_page ? 5 : 4 ) ;
			}
		}
		return $out;
	}
 /**
  *
  * For a given user id, returns the html
  * for an avatar to be displayed on the right
  * rail or in the info box
  *
  */
 static function getUserInfo($user_id)
 {
     if ($user_id) {
         $u = new User();
         $u->setID($user_id);
         $img = Avatar::getAvatarURL($u->getName());
         if ($img == '') {
             $img = Avatar::getDefaultPicture();
         } else {
             $img = "<img src='{$img}' />";
         }
         $avatar = "<span><a href='{$u->getUserPage()->getFullURL()}' target='_blank' class='tooltip'>{$img}</a>";
         $avatar .= "<span class='tooltip_span'>Hi, I'm {$u->getName()}</span></span>";
         $avatar .= "<a target='new' href='{$u->getUserPage()->getFullURL()}'>{$u->getName()}</a>";
     }
     return $avatar;
 }
Example #22
0
<?php

if (!empty($attributes['id'])) {
    if (is_numeric($attributes['id'])) {
        if (!($tmpUser = $oUserManager->getUserByID($attributes['id']))) {
            _error("ENoSuchUser", "There is no user with ID = " . $attributes['id']);
        }
    } else {
        _error("EInvalidUserID", "Invalid user ID");
    }
} else {
    $attributes['id'] = 0;
    $tmpUser = new User();
}
if (isset($attributes['id']) && isset($attributes['fLogin']) && isset($attributes['fPwd']) && isset($attributes['fPwd2']) && isset($attributes['fEmail'])) {
    $tmpUser->setID($attributes['id']);
    if (!$tmpUser->setLogin($attributes['fLogin'])) {
        _warning("WInvalidLogin", "Login is invalid or empty");
    }
    if (!$tmpUser->setEmail($attributes['fEmail'])) {
        _warning("WInvalidEmail", "Email address is invalid or empty");
    }
    $tmpUser->setFirstName($attributes['fFirstName']);
    $tmpUser->setMiddleName($attributes['fMiddleName']);
    $tmpUser->setLastName($attributes['fLastName']);
    $tmpUser->setBirthDate($attributes['fBirthDate']);
}
_assign("arrCountries", $oPropertyManager->getDictionary("fCountry"));
_assign("tmpUser", $tmpUser);
_display("admin/dspUserForm.tpl");