public function __construct(WebRequest $request)
 {
     $this->mType = $request->getText('type');
     $this->mOid = preg_replace('/\\?.*$/', '', $request->getText('oid'));
     parse_str(urldecode($request->getText('params')), $this->mParams);
     $this->mCb = $request->getInt('cb');
     if (!empty($this->mParams['noexternals'])) {
         $this->mNoExternals = true;
     }
     if (!empty($this->mParams['forceprofile'])) {
         $this->mForceProfile = true;
     }
 }
 /**
  * @param WebRequest $request
  *
  * @return string
  */
 function loadDataFromRequest($request)
 {
     $size = $request->getInt($this->mName);
     if (!$size) {
         return $this->getDefault();
     }
     $size = abs($size);
     // negative numbers represent "max", positive numbers represent "min"
     if ($request->getVal($this->mName . '-mode') === 'max') {
         return -$size;
     } else {
         return $size;
     }
 }
 protected function runPage()
 {
     try {
         $id = WebRequest::getInt("id");
         $hash = WebRequest::get("hash");
         // data validation
         $customer = Customer::getById($id);
         if ($customer == null) {
             throw new NonexistantObjectException();
         }
         $customer->confirmEmail($hash);
         // save
         $customer->save();
         Session::setLoggedInCustomer($id);
         $this->mSmarty->assign("content", Message::getMessage("mail-confirmed"));
     } catch (NonexistantObjectException $ex) {
         global $cScriptPath;
         $this->mHeaders[] = "Location: {$cScriptPath}";
     }
 }
 /**
  * Guess the rev ID the text of this form is based off
  * Note: baseRevId trusted for Reviewers - check text for others.
  * @return int
  */
 protected static function getBaseRevId(EditPage $editPage, WebRequest $request)
 {
     if (!isset($editPage->fr_baseRevId)) {
         $article = $editPage->getArticle();
         // convenience
         $latestId = $article->getLatest();
         // current rev
         $undo = $request->getIntOrNull('undo');
         # Undoing consecutive top edits...
         if ($undo && $undo === $latestId) {
             # Treat this like a revert to a base revision.
             # We are undoing all edits *after* some rev ID (undoafter).
             # If undoafter is not given, then it is the previous rev ID.
             $revId = $request->getInt('undoafter', $article->getTitle()->getPreviousRevisionID($latestId, Title::GAID_FOR_UPDATE));
             # Undoing other edits...
         } elseif ($undo) {
             $revId = $latestId;
             // current rev is the base rev
             # Other edits...
         } else {
             # If we are editing via oldid=X, then use that rev ID.
             # Otherwise, check if the client specified the ID (bug 23098).
             $revId = $article->getOldID() ? $article->getOldID() : $request->getInt('baseRevId');
             // e.g. "show changes"/"preview"
         }
         # Zero oldid => draft revision
         if (!$revId) {
             $revId = $latestId;
         }
         $editPage->fr_baseRevId = $revId;
     }
     return $editPage->fr_baseRevId;
 }
Example #5
0
 public function fetchValuesFromRequest(WebRequest $r, $values = false)
 {
     if (!$values) {
         $values = array_keys($this->options);
     }
     foreach ($values as $name) {
         $default = $this->options[$name]['default'];
         $type = $this->options[$name]['type'];
         switch ($type) {
             case self::BOOL:
                 $value = $r->getBool($name, $default);
                 break;
             case self::INT:
                 $value = $r->getInt($name, $default);
                 break;
             case self::STRING:
                 $value = $r->getText($name, $default);
                 break;
             case self::INTNULL:
                 $value = $r->getIntOrNull($name);
                 break;
             default:
                 throw new MWException('Unsupported datatype');
         }
         if ($value !== null) {
             $this->options[$name]['value'] = $value === $default ? null : $value;
         }
     }
 }
Example #6
0
 /**
  * Tries to create an existing title object for current request. Used for setting the title
  * global during ajax requests. It uses title URL param to keep backward compatibility.
  *
  * @static
  * @param WebRequest $request
  * @return Title
  */
 public static function createTitleFromRequest($request)
 {
     if ($request->getVal('title', '') === '') {
         $title = Title::newMainPage();
     } else {
         $title = Title::newFromText($request->getVal('title', 'AJAX'), $request->getInt('namespace', NS_MAIN));
         if (!$title instanceof Title) {
             $title = Title::makeTitle(NS_MAIN, 'AJAX');
         }
     }
     return $title;
 }
 /**
  * Guess the alternative rev ID the text of this form is based off.
  * When undoing the top X edits, the base can be though of as either
  * the current or the edit X edits prior to the latest.
  * Note: baseRevId trusted for Reviewers - check text for others.
  * @param EditPage $editPage
  * @param WebRequest $request
  * @return int
  */
 protected static function getAltBaseRevId(EditPage $editPage, WebRequest $request)
 {
     if ($editPage->isConflict) {
         return 0;
         // throw away these values (bug 33481)
     }
     if (!isset($editPage->fr_altBaseRevId)) {
         $article = $editPage->getArticle();
         // convenience
         $latestId = $article->getLatest();
         // current rev
         $undo = $request->getIntOrNull('undo');
         # Undoing consecutive top edits...
         if ($undo && $undo === $latestId) {
             # Treat this like a revert to a base revision.
             # We are undoing all edits *after* some rev ID (undoafter).
             # If undoafter is not given, then it is the previous rev ID.
             $revId = $request->getInt('undoafter', $article->getTitle()->getPreviousRevisionID($latestId, Title::GAID_FOR_UPDATE));
         } else {
             $revId = $request->getInt('altBaseRevId');
         }
         $editPage->fr_altBaseRevId = $revId;
     }
     return $editPage->fr_altBaseRevId;
 }
 private function doDeleteUserAction()
 {
     $userid = WebRequest::getInt("id");
     if ($userid < 1) {
         throw new Exception("UserID too small");
     }
     if (InternalUser::getById($userid) == null) {
         throw new Exception("User does not exist");
     }
     InternalUser::getById($userid)->delete();
     global $cScriptPath;
     $this->mHeaders[] = "Location: {$cScriptPath}/SystemUsers";
 }
 private function doPayBillAction()
 {
     $id = WebRequest::getInt("id");
     $items = Bill_item::getIdListByBooking($id);
     $total = 0;
     foreach ($items as $i) {
         $bi = Bill_item::getById($i);
         $total += $bi->getPrice();
     }
     $inv = new Bill_item();
     $inv->setBooking(Booking::getById($id));
     $inv->setName("Payment");
     $inv->setPrice(-$total);
     $inv->save();
     global $cScriptPath;
     $this->mHeaders[] = "Location: {$cScriptPath}/Billing?action=view&id=" . $id;
 }
 private function doResendCustomerAction()
 {
     $cid = WebRequest::getInt("id");
     if ($cid < 1) {
         throw new Exception("CustomerId too small");
     }
     $customer = Customer::getById($cid);
     if ($customer == null) {
         throw new Exception("CustomerId does not exist");
     }
     $customer->setEmail($customer->getEmail());
     $customer->save();
     $customer->sendMailConfirm();
     global $cScriptPath;
     $this->mHeaders[] = "Location: {$cScriptPath}/Customers";
 }
 private function doDeleteBookingAction()
 {
     $bid = WebRequest::getInt("id");
     if ($bid < 1) {
         throw new Exception("BookingId too small");
     }
     if (Booking::getById($bid) == null) {
         throw new Exception("Booking does not exist");
     }
     Booking::getById($bid)->delete();
     global $cScriptPath;
     $this->mHeaders[] = "Location: {$cScriptPath}/Bookings";
 }
 private function doDeleteRoomAction()
 {
     $rid = WebRequest::getInt("id");
     if ($rid < 1) {
         throw new Exception("RoomId too small");
     }
     if (Room::getById($rid) == null) {
         throw new Exception("Room does not exist");
     }
     Room::getById($rid)->delete();
     global $cScriptPath;
     $this->mHeaders[] = "Location: {$cScriptPath}/Rooms";
 }