コード例 #1
0
ファイル: apiDB.php プロジェクト: sasscaloadc/crowdweatherAPI
 static function updateUser($userid, $user)
 {
     if (get_class($user) != "User") {
         return "Error, received object other than User";
     }
     $dbUser = apiDB::getUser($userid);
     if (empty($dbUser->id)) {
         return "Error, Invalid User ID for Update";
     }
     $updatestring = "set ";
     $updatestring .= "email = " . (empty($user->email) ? "email" : "'" . $user->email . "'") . ", ";
     $updatestring .= "password = "******"password" : "'" . $user->password . "'") . ", ";
     $updatestring .= "firstname = " . (empty($user->firstname) ? "firstname" : "'" . $user->firstname . "'") . ", ";
     $updatestring .= "lastname = " . (empty($user->lastname) ? "lastname" : "'" . $user->lastname . "'") . ", ";
     $updatestring .= "postal = " . (empty($user->postal) ? "postal" : "'" . $user->postal . "'") . ", ";
     $updatestring .= "phone = " . (empty($user->phone) ? "phone" : "'" . $user->phone . "'") . ", ";
     $updatestring .= "verified = " . (empty($user->verified) ? "verified" : $user->verified) . ", ";
     $updatestring .= "sub_summary = " . (isset($user->sub_summary) ? $user->sub_summary : "sub_summary") . ", ";
     $updatestring .= "sub_gwadi = " . (isset($user->sub_gwadi) ? $user->sub_gwadi : "sub_gwadi") . ", ";
     $updatestring .= "sub_stats = " . (isset($user->sub_stats) ? $user->sub_stats : "sub_stats") . ", ";
     $updatestring .= "access = " . (empty($user->access) ? "access" : $user->access);
     $conxn = apiDB::getConnection();
     $sql = "UPDATE cw_user " . $updatestring . " WHERE id = " . $userid;
     $result = pg_query($conxn, $sql);
     if ($result) {
         $rows = pg_affected_rows($result);
         return $rows . " User(s) updated";
     } else {
         return "Error with User update query : " . pg_last_error($conxn);
     }
 }
コード例 #2
0
ファイル: apiDB.php プロジェクト: evoges/APIcrowdweather
 static function updateUser($userid, $user)
 {
     if (get_class($user) != "User") {
         return "Error, received object other than User";
     }
     $dbUser = apiDB::getUser($userid);
     if (empty($dbUser->id)) {
         return "Error, Invalid User ID for Update";
     }
     $updatestring = "set ";
     $updatestring .= "email = " . (empty($user->email) ? "email" : "'" . $user->email . "'");
     $updatestring .= ", ";
     $updatestring .= "password = "******"password" : "'" . $user->password . "'");
     $conxn = apiDB::getConnection();
     $sql = "UPDATE cw_user " . $updatestring . " WHERE id = " . $userid;
     $result = pg_query($conxn, $sql);
     if ($result) {
         $rows = pg_affected_rows($result);
         return $rows . " User(s) updated";
     } else {
         return "Error with User update query : " . pg_last_error($conxn);
     }
 }
コード例 #3
0
ファイル: User.class.php プロジェクト: evoges/APIcrowdweather
 public function getInstanceDetails($id)
 {
     $user = apiDB::getUser($id, 2);
     if (empty($user->id)) {
         return self::NO_SUCH_ID;
     }
     if ($_SERVER['PHP_AUTH_USER'] != $user->email && $this->access <= 1) {
         return self::ACCESS_DENIED;
     }
     $this->id = $user->id;
     $this->email = $user->email;
     $this->password = $user->password;
     $this->locations = $user->locations;
     // Does this array need cloning?
     // 	Preserving $this->access however, to retain admin rights.
     return self::SETUP_OK;
 }
コード例 #4
0
 public function getInstanceDetails($id)
 {
     $location = empty($this->userid) ? apiDB::getLocation($id) : apiDB::getUserLocation($id, $this->userid);
     if (empty($location->id)) {
         return self::NO_SUCH_ID;
     }
     $user = apiDB::getUser($location->userid);
     if ($_SERVER['PHP_AUTH_USER'] != $user->email && $this->access <= 1) {
         return self::ACCESS_DENIED;
     }
     $this->latitude = $location->latitude;
     $this->longitude = $location->longitude;
     $this->name = $location->name;
     $this->userid = $location->userid;
     $this->id = $location->id;
     $this->rain = $location->rain;
     $this->mintemp = $location->mintemp;
     // 	Preserving $this->access however, to retain admin rights.
     return self::SETUP_OK;
 }