Example #1
0
 public function getUserTo()
 {
     $userTo = CI_User::getById($this->userTo)[0];
     $myUserTo = new stdClass();
     $myUserTo->id = $userTo->getId();
     $myUserTo->name = $userTo->getName();
     $myUserTo->email = $userTo->getEmail();
     $myUserTo->profileImage = 'http://www.gravatar.com/avatar/' . md5($userTo->getGravatarEmail());
     return $myUserTo;
 }
 public static function signin($options)
 {
     $CI =& get_instance();
     $CI->load->library("JWT");
     $CI->load->model('user_model');
     $results = $CI->user_model->getByUsernameAndPassword($options);
     $return = array();
     if (!empty($results)) {
         $user = CI_User::getInstance($results[0]);
         $token = $CI->jwt->encode(array('userId' => $user->getId(), 'issuedAt' => time(), 'ttl' => time() + TOKEN_TTL), SECRET);
         $return = array('user' => $user, 'token' => $token);
     }
     return $return;
 }
Example #3
0
 public function payment_post()
 {
     //checkIsLoggedIn($this);
     $arrOptions['userId'] = $this->post('userId');
     $arrOptions['code'] = $this->post('code');
     $isSaved = CI_User::addPaymentCode($arrOptions);
     $status = 500;
     $return["result"] = "NOOK";
     if ($isSaved) {
         $status = 200;
         $return["result"] = "OK";
     }
     $this->response($return, $status);
 }
Example #4
0
 public function notify_post()
 {
     $status = 404;
     $return['result'] = 'NOOK';
     $return['data'] = '';
     $id = $this->input->post('id');
     $donations = CI_Donation::getById($id);
     if (empty($donations)) {
         $this->response($return, $status);
     }
     $donation = $donations[0];
     $publication = CI_Request::getById($donation->getPublicationId())[0];
     $publicationId = $donation->getPublicationId();
     $userIdTo = $donation->getUserId();
     $userIdFrom = $publication->userId;
     $ownerPublication = CI_User::getById($userIdFrom)[0];
     $ownerDonation = CI_User::getById($userIdTo)[0];
     $options['donatedObjects'] = $donation->getDonatedObjects();
     $options['nameOwnerPublication'] = $ownerPublication->getName();
     $options['nameOwnerDonation'] = $ownerDonation->getName();
     $options['publicationTitle'] = $publication->title;
     $options['personalDataOwnerDonation'] = $ownerDonation->getPersonalData();
     $notifyMessage = new CI_Message();
     $notifyMessage->setUserIdTo($userIdTo);
     $notifyMessage->setUserIdFrom($userIdFrom);
     $notifyMessage->setPublicationId($publicationId);
     $notifyMessage->setCommonState('N');
     $notifyMessage->setNotifyText($options);
     if ($notifyMessage->save()) {
         $status = 200;
         $return['result'] = 'OK';
         $return['data'] = $donation;
     }
     $this->response($return, $status);
 }
Example #5
0
 public function index_put()
 {
     $arrOptions['id'] = 0;
     $arrOptions['name'] = trim($this->put('name'));
     $arrOptions['email'] = trim($this->put('email'));
     $arrOptions['password'] = trim($this->put('password'));
     $status = 404;
     $return["data"] = "";
     $return["result"] = "EMPTY_VALUES";
     if (!empty($arrOptions['email']) && !empty($arrOptions['name']) && !empty($arrOptions['password'])) {
         $users = CI_User::getByUsername($arrOptions['email']);
         $return["result"] = "REPEAT_ENTRY";
         if (!$users) {
             $user = new CI_User();
             $user->setEmail($arrOptions['email']);
             $user->setPassword($arrOptions['password']);
             $user->setName($arrOptions['name']);
             $user->setGravatarEmail($arrOptions['email']);
             $return["result"] = "NOOK";
             if ($user->save()) {
                 $myUser = new stdClass();
                 $myUser->id = $user->getId();
                 $myUser->email = $user->getEmail();
                 $myUser->name = $user->getName();
                 $myUser->lastName = $user->getLastName();
                 $myUser->profileImage = !empty($user->getGravatarEmail()) ? 'http://www.gravatar.com/avatar/' . md5($user->getGravatarEmail()) : "http://www.gravatar.com/avatar/?s=100&d=mm";
                 CI_Account::create($myUser);
                 $status = 200;
                 $return["result"] = "OK";
                 $return["data"] = $myUser;
             }
         }
     }
     $this->response($return, $status);
 }