public function end_post() { //checkIsLoggedIn($this); $status = 200; $return["result"] = "OK"; $datestring = "%Y/%m/%d %H:%i:%s"; $currentDate = mdate($datestring, now()); $arrOptions['userFromId'] = $this->post('userFromId'); $arrOptions['userToId'] = $this->post('userToId'); $arrOptions['publicationId'] = $this->post('publicationId'); $arrOptions['publicationType'] = $this->post('publicationType'); $arrOptions['objectId'] = $this->post('objectId'); $arrOptions['comments'] = $this->post('comments'); $arrOptions['quantity'] = $this->post('quantity'); $processState = $arrOptions['publicationType'] == "money" ? "F" : "W"; try { $donation = new CI_Donation(); $donation->setUserId($arrOptions['userFromId']); $donation->setPublicationId($arrOptions['publicationId']); $donation->setDonationDate($currentDate); $donation->setProcessState($processState); $donationId = $donation->save(); if ($donationId) { $donatedObject = new CI_DonatedObject(); $donatedObject->setDonationId($donationId); $donatedObject->setObjectId($arrOptions['objectId']); $donatedObject->setQuantity($arrOptions['quantity']); $donatedObjectId = $donatedObject->save(); $message = new CI_Message(); $message->setUserFrom($arrOptions['userFromId']); $message->setUserTo($arrOptions['userToId']); $message->setPublication($arrOptions['publicationId']); $message->setText($arrOptions['comments']); $message->save(); } } catch (Exception $ex) { $status = 500; $return["result"] = "NOOK"; } if ($status == 200) { if ($arrOptions['publicationType'] == "money") { $request = CI_Request::getById($arrOptions['publicationId'])[0]; $amountCollected = $request->amountCollected[0]->quan; $quantityGoal = $request->quantity; if ($amountCollected >= $quantityGoal) { CI_Publication::pause($arrOptions['publicationId']); } $return["data"]['amountCollected'] = $amountCollected; $return["data"]['quantityGoal'] = $quantityGoal; } else { CI_Publication::pause($arrOptions['publicationId']); } } $this->response($return, $status); }
public function index_post() { //checkIsLoggedIn($this); $status = 404; $return["result"] = "NOOK"; $return["data"] = ""; $datestring = "%Y/%m/%d %H:%i:%s"; $currDate = mdate($datestring, now()); $arrOptions['userFrom'] = $this->post('userFrom'); $arrOptions['userTo'] = $this->post('userTo'); $arrOptions['publication'] = $this->post('publication'); $arrOptions['conversationId'] = $this->post('conversationId'); $arrOptions['text'] = $this->post('text'); $message = new CI_Message(); $message->setUserFrom($arrOptions['userFrom']); $message->setUserTo($arrOptions['userTo']); $message->setPublication($arrOptions['publication']); $message->setConversationId($arrOptions['conversationId']); $message->setText($arrOptions['text']); if ($message->save()) { $myMessage = new stdClass(); $myMessage->id = $message->getId(); $myMessage->userTo = $message->getUserTo(); $myMessage->userFrom = $message->getUserFrom(); $myMessage->publication = $message->getPublication(); $myMessage->conversationId = $message->getConversationId(); $myMessage->FAQ = $message->getFAQ(); $myMessage->commonState = $message->getCommonState(); $myMessage->subject = $message->getSubject(); $myMessage->text = $message->getText(); $myMessage->createDate = $message->getCreateDate(); $myMessage->updateDate = $message->getUpdateDate(); $status = 200; $return["result"] = "OK"; $return["data"] = $myMessage; } $this->response($return, $status); }
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); }