public function get_array_all()
 {
     if (empty($this->userid)) {
         //if ($this->access > 1) {
         //	return apiDB::getLocations();
         //} else {
         $user = apiDB::getUserByEmail($_SERVER['PHP_AUTH_USER']);
         return apiDB::getUserLocations($user->id);
         //}
     } else {
         return apiDB::getUserLocations($this->userid);
     }
 }
 public function get_array_all()
 {
     if (empty($this->userid)) {
         $user = apiDB::getUserByEmail($_SERVER['PHP_AUTH_USER']);
         $locations = apiDB::getUserLocations($user->id, $this->columnName());
         if (count($locations) == 1) {
             return apiDB::getLocationMeasurements($locations[0]->locationid, $user->userid, get_class($this));
         } else {
             $error = array();
             $error["ERROR"] = "cannot display all measurements - please specify a location ID";
             return $error;
             //This is a hack
         }
     }
     return apiDB::getLocationMeasurements($this->locationid, $this->userid, get_class($this));
 }
示例#3
0
 static function getUser($userid, $level = 1)
 {
     $conxn = apiDB::getConnection();
     $user = new User();
     $sql = "SELECT * FROM cw_user WHERE id = " . $userid;
     $result = pg_query($conxn, $sql);
     if (pg_num_rows($result) > 0) {
         $row = pg_fetch_array($result);
         if ($level > 0) {
             $user->email = $row["email"];
             $user->password = $row["password"];
             $user->id = $row["id"];
             $user->access = $row["access"];
             $user->verified = $row["verified"];
             $user->firstname = $row["firstname"];
             $user->lastname = $row["lastname"];
             $user->postal = $row["postal"];
             $user->phone = $row["phone"];
             $user->sub_summary = $row["sub_summary"];
             $user->sub_gwadi = $row["sub_gwadi"];
             $user->sub_stats = $row["sub_stats"];
             $user->locations = apiDB::getUserLocations($userid, $level - 1);
         } else {
             $user = $row["id"];
         }
     }
     pg_close($conxn);
     return $user;
 }
示例#4
0
 static function getUser($userid, $level = 1)
 {
     $conxn = apiDB::getConnection();
     $user = new User();
     $sql = "SELECT * FROM cw_user WHERE id = " . $userid;
     $result = pg_query($conxn, $sql);
     if (pg_num_rows($result) > 0) {
         $row = pg_fetch_array($result);
         if ($level > 0) {
             $user->email = $row["email"];
             $user->password = $row["password"];
             $user->id = $row["id"];
             $user->locations = apiDB::getUserLocations($userid, $level - 1);
         } else {
             $user = $row["id"];
         }
     }
     pg_close($conxn);
     return $user;
 }