示例#1
0
 public function execute()
 {
     $return = array("success" => false);
     $model = new LendrModelsWaitlist();
     if ($model->store()) {
         $return['success'] = true;
         $return['msg'] = JText::_('COM_LENDR_BOOK_REQUEST_SUCCESS');
     } else {
         $return['msg'] = JText::_('COM_LENDR_BOOK_REQUEST_FAILURE');
     }
     echo json_encode($return);
 }
示例#2
0
 function getItem()
 {
     $profile = JFactory::getUser($this->_user_id);
     $userDetails = JUserHelper::getProfile($this->_user_id);
     $profile->details = isset($userDetails->profile) ? $userDetails->profile : array();
     $libraryModel = new LendrModelsLibrary();
     $libraryModel->set('_user_id', $this->_user_id);
     $profile->library = $libraryModel->getItem();
     $waitlistModel = new LendrModelsWaitlist();
     $waitlistModel->set('_waitlist', TRUE);
     $profile->waitlist = $waitlistModel->getItem();
     $wishlistModel = new LendrModelsWishlist();
     $profile->wishlist = $wishlistModel->listItems();
     $profile->isMine = JFactory::getUser()->id == $profile->id ? TRUE : FALSE;
     return $profile;
 }
示例#3
0
 /**
  * Lend the book
  * @param    array   Data array of book
  * @return   object  The book object loaned
  */
 public function lend($data = null)
 {
     $data = isset($data) ? $data : JRequest::get('post');
     if (isset($data['lend']) && $data['lend'] == 1) {
         $date = date("Y-m-d H:i:s");
         $data['lent'] = 1;
         $data['lent_date'] = $date;
         $data['lent_uid'] = $data['borrower_id'];
         $waitlistData = array('waitlist_id' => $data['waitlist_id'], 'fulfilled' => 1, 'fulfilled_time' => $date, 'table' => 'Waitlist');
         $waitlistModel = new LendrModelsWaitlist();
         $waitlistModel->store($waitlistData);
     } else {
         $data['lent'] = 0;
         $data['lent_date'] = NULL;
         $data['lent_uid'] = NULL;
     }
     $row = parent::store($data);
     return $row;
 }