/**
  * Check the signup data of a user and checks if data exist in DB already
  * @param type post  set of variables passed to view pages
  * @return type json        
  */
 public static function checkSignupData()
 {
     $post = Core\Input::post();
     $username = $post["username"];
     $email = $post["email"];
     //invalid username
     if (!(isset($username) && preg_match("/^[a-zA-Z0-9]*\$/", $username))) {
         return json_encode(array('status' => 0, 'errorCode' => 1));
     }
     $res = Model\User::getUserByUsername($username);
     $row = isset($res[0]) ? $res[0] : $res;
     $user = User::constructByRow($row);
     //username exists in db
     if (isset($user)) {
         return json_encode(array('status' => 0, 'errorCode' => 2));
     }
     //invalid email - preg match pattern doesn't work properly; don't know why
     //&& preg_match("/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,3}$/", $email)
     if (!isset($email)) {
         return json_encode(array('status' => 0, 'errorCode' => 3));
     }
     $res = Model\User::getUserByEmail($email);
     $row = isset($res[0]) ? $res[0] : $res;
     $user = User::constructByRow($row);
     //email exist in db
     if (isset($user)) {
         return json_encode(array('status' => 0, 'errorCode' => 4));
     }
     return json_encode(array('status' => 1));
 }