function __construct() { parent::__construct(); $app = JFactory::getApplication(); $this->_waitlist_id = $app->input->get('waitlist_id', null); $this->_user_id = $app->input->get('user_id', JFactory::getUser()->id); }
function __construct() { $app = JFactory::getApplication(); //If no User ID is set to current logged in user $this->_user_id = $app->input->get('profile_id', JFactory::getUser()->id); parent::__construct(); }
function listItems() { $bookModel = new LendrModelsBook(); $libraries = parent::listItems(); $n = count($libraries); for ($i = 0; $i < $n; $i++) { $library = $libraries[$i]; $bookModel->_library_id = $library->id; $library->books = $bookModel->listItems(); } return $libraries; }
function store() { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $data['table'] = 'wishlist'; $data['user_id'] = JFactory::getUser()->id; $data['book_id'] = $app->input->get('book_id'); $query = $db->getQuery(TRUE); $query->select('COUNT(*)'); $query->from('#__lendr_wishlists'); $query->where('user_id = ' . $db->q($data['user_id'])); $query->where('book_id = ' . $db->q($data['book_id'])); $db->setQuery($query); $existing = $db->loadResult(); if ($existing == 0) { parent::store($data); } return true; }
function __construct() { parent::__construct(); }
/** * Override the default store * */ public function store() { $row = parent::store(); $row->email = JUser::getInstance($row->user_id)->get('email'); return $row; }
/** * 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; }