예제 #1
0
파일: User.php 프로젝트: tootutor/tto-api
 /**
  * @url POST register
  * @url POST
  */
 function postRegister($email, $password, $firstname, $lastname, $nickname, $phone, $birthdate, $school, $province, $level, $purpose, $avatarId)
 {
     //Hash password
     $hash = password_hash($password, PASSWORD_DEFAULT);
     $serial = sha1(uniqid());
     $statement = "\n  \t\tINSERT INTO user \n  \t\t\t(email, role, hash, serial, firstname, lastname, nickname, phone, birthdate, school, province, level, purpose, avatarId)\n  \t\tVALUE \n  \t\t\t(:email, :role, :hash, :serial, :firstname, :lastname, :nickname, :phone, :birthdate, :school, :province, :level, :purpose, :avatarId)\n  \t";
     $bind = array('email' => $email, 'role' => 'student', 'hash' => $hash, 'serial' => $serial, 'firstname' => $firstname, 'lastname' => $lastname, 'nickname' => $nickname, 'phone' => $phone, 'birthdate' => $birthdate, 'school' => $school, 'province' => $province, 'level' => $level, 'purpose' => $purpose, 'avatarId' => $avatarId);
     $count = \Db::execute($statement, $bind);
     $userId = \Db::getLastInsertId();
     \TTOMail::createAndSendAdmin('A new user registered', json_encode($bind));
     \TTOMail::createAndSend(ADMINEMAIL, \TTO::getEmail(), 'You have registered to Too Tutor Online', 'Your serial number : ' + $serial);
     $response = new \stdClass();
     $response->count = $count;
     $response->userId = $last_insert_id;
     return $response;
 }