예제 #1
0
 public static function get($response, $token, $string, $flag)
 {
     if (!TokensDB::check($token)) {
         return putError('invalid token', Users::ERROR_AUTH_INVALID, $response);
     }
     $search = SearchDB::get($token[Users::ID_KEY], $string, $flag);
     if ($search === FALSE) {
         return putError('database connection error', DATABASE::ERROR_DATABASE_CONN, $response);
     }
     return putJsonBody(array('error' => false, 'results' => $search), 200, $response);
 }
예제 #2
0
 public static function update($response, $token, $info)
 {
     if (!TokensDB::check($token)) {
         return putError('invalid token', Users::ERROR_AUTH_INVALID, $response);
     }
     if (count($info) < 4) {
         return putError('invalid request parameters', Users::ERROR_FORMAT, $response);
     }
     $info[Users::FNAME_KEY] = Validator::filterName($info, Users::FNAME_KEY);
     $info[Users::LNAME_KEY] = Validator::filterName($info, Users::LNAME_KEY);
     $info[Users::GENDER_KEY] = Validator::filterGender($info, Users::GENDER_KEY);
     $info[Users::BIRTHDATE_KEY] = Validator::filterDate($info, Users::BIRTHDATE_KEY);
     $info[Users::MOBILE_KEY] = Validator::filterMobile($info, Users::MOBILE_KEY);
     $info[Users::ABOUT_KEY] = Validator::filterAbout($info, Users::ABOUT_KEY);
     $info[Users::MARITAL_KEY] = Validator::filterMarital($info, Users::MARITAL_KEY);
     if (!$info[Users::FNAME_KEY]) {
         return putError('invalid firstname parameter', Users::ERROR_FNAME_FORMAT, $response);
     } else {
         if (!$info[Users::LNAME_KEY]) {
             return putError('invalid lastname parameter', Users::ERROR_LNAME_FORMAT, $response);
         } else {
             if (!$info[Users::GENDER_KEY]) {
                 return putError('invalid gender parameter', Users::ERROR_GENDER_FORMAT, $response);
             } else {
                 if (!$info[Users::BIRTHDATE_KEY]) {
                     return putError('invalid birthdate parameter', Users::ERROR_BIRTHDATE_FORMAT, $response);
                 }
             }
         }
     }
     $info[Users::GENDER_KEY] = $info[Users::GENDER_KEY] == "male";
     $info = UsersInfoDB::update($token[Users::ID_KEY], $info);
     if ($info === FALSE) {
         return putError('database connection error', DATABASE::ERROR_DATABASE_CONN, $response);
     }
     return putJsonBody(array('error' => false, 'info' => $info), 200, $response);
 }
예제 #3
0
 public static function delete($response, $token)
 {
     if (!TokensDB::check($token)) {
         return putError('invalid token', Users::ERROR_AUTH_INVALID, $response);
     }
     $delete = UsersDB::delete($token[Users::ID_KEY]);
     if ($delete === FALSE) {
         return putError('database connection error', DATABASE::ERROR_DATABASE_CONN, $response);
     }
     return putJsonBody(array('error' => false), 200, $response);
 }
예제 #4
0
 public static function accept($response, $token, $friend_id)
 {
     if (!TokensDB::check($token)) {
         return putError('invalid token', Users::ERROR_AUTH_INVALID, $response);
     }
     $accepted = FriendsDB::accept($token[Users::ID_KEY], $friend_id);
     if ($accepted === FALSE) {
         return putError('database connection error', DATABASE::ERROR_DATABASE_CONN, $response);
     }
     return putJsonBody(array('error' => false), 200, $response);
 }
예제 #5
0
 public static function likes($response, $token, $post_id)
 {
     if (!TokensDB::check($token)) {
         return putError('invalid token', Users::ERROR_AUTH_INVALID, $response);
     }
     $likes = PostsDB::likes($post_id);
     if ($likes === FALSE) {
         return putError('database connection error', DATABASE::ERROR_DATABASE_CONN, $response);
     }
     return putJsonBody(array('error' => false, 'likes' => $likes), 200, $response);
 }