Beispiel #1
0
 /**
  * Summary of execute
  * @param \DOMElement $apiDocument
  * @return \DOMElement
  * @throws ApiException
  * @throws \Exception
  */
 public function execute(\DOMElement $apiDocument)
 {
     $username = isset($_GET['user']) ? trim($_GET['user']) : '';
     $wikiusername = isset($_GET['wikiuser']) ? trim($_GET['wikiuser']) : '';
     if ($username === '' && $wikiusername === '') {
         throw new ApiException("Please specify a username using either user or wikiuser parameters.");
     }
     $userElement = $this->document->createElement("user");
     $apiDocument->appendChild($userElement);
     $this->database = gGetDb();
     if ($username !== '') {
         $this->user = \User::getByUsername($username, $this->database);
     } else {
         $this->user = \User::getByOnWikiUsername($wikiusername, $this->database);
     }
     if ($this->user === false) {
         $userElement->setAttribute("missing", "true");
         return $apiDocument;
     }
     $userElement->setAttribute("username", $this->user->getUsername());
     $userElement->setAttribute("status", $this->user->getStatus());
     $userElement->setAttribute("lastactive", $this->user->getLastActive());
     $userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate());
     $userElement->setAttribute("onwikiname", $this->user->getOnWikiName());
     $userElement->setAttribute("oauth", $this->user->isOAuthLinked() ? "true" : "false");
     return $apiDocument;
 }
Beispiel #2
0
 public function UpdateUser(User $user = null)
 {
     if ($user == null || $user->getUID() == null) {
         return false;
     }
     $props = array("UName" => $user->getUserName(), "UPass" => $user->getPassword(), "UEmail" => $user->getEmail(), "Session" => $user->getSession(), "FirstName" => $user->getFirstName(), "LastName" => $user->getLastName(), "Phone" => $user->getPhoneNumber(), "LastCheckInLocation" => $user->getLocation(), "Department" => $user->getDeparment(), "PayRate" => $user->getPayRate(), "Online" => $user->getActive(), "AccType" => $user->getAccountType(), "StatusID" => $user->getCurrentStatus(), "LastCheckIn" => $user->getLastActive(), "ManagerID" => $user->getManagerID(), "AccountVerified" => $user->getVerifStatus(), "IsManager" => $user->getIsManager());
     foreach ($props as $k => $v) {
         if ($v != null) {
             if ($k == "IsManager") {
                 $_props[$k] = "{$v}";
             } else {
                 if (gettype($v) == "string") {
                     $_props[$k] = "'" . $v . "', ";
                 } else {
                     $_props[$k] = "{$v}, ";
                 }
             }
         }
     }
     $cond = array("UID = " => $user->getUID());
     $this->_dbAdapt->UStatement(DB_TBL_USER, $_props, $cond);
     $tmp = $this->_dbAdapt->getLnk();
     $tmp->query($this->_dbAdapt->getQry());
     unset($tmp);
     return true;
 }