public function post() { $post = JRequest::get('post'); $data = json_decode($post['JSON_object']); $table = JTable::getInstance('Comment', 'JTable'); $table->created = gmdate("Y-m-d H:i:s"); $table->name = $this->plugin->get('user')->name; $table->username = $this->plugin->get('user')->username; $table->userid = $this->plugin->get('user')->id; $table->email = $this->plugin->get('user')->email; $table->comments = $data->comments; $table->pid = $data->listing_id; $table->store(); // Create rating record here $rating = JTable::getInstance('Rating', 'JTable'); $rating->reviewid = $table->id; $rating->ratings = isset($post['rating']) ? (double) $post['rating'] : 'na'; $rating->ratings_sum = is_numeric($rating->ratings) ? $rating->ratings : 0; $rating->ratings_qty = $rating->ratings == 'na' ? 0 : 1; $rating->store(); require_once JPATH_SITE . '/components/com_jreviews/jreviews/framework.php'; require_once JPATH_SITE . '/components/com_jreviews/jreviews/models/review.php'; $model = new ReviewModel(); $model->saveListingTotals($data->listing_id, 'com_content'); $this->addStream($table); if ($table->email) { $this->sendEmail($table); } JRequest::setVar('id', $table->id); $this->get(); }
function onPhotoComment($photoid, $message) { // when users comment on a photo that is related to a catch report, // add that comment to the catch report as well $db =& JFactory::getDBO(); $user =& JFactory::getUser(); // get related listings $sql = "SELECT rp.listing_id FROM #__relate_photos rp " . "LEFT JOIN #__content c ON rp.listing_id = c.id " . "WHERE rp.photo_id = '" . $photoid . "' " . "AND rp.listing_id != 0 AND c.state > 0 AND c.catid IN (13,14,15) "; $db->setQuery($sql); $listings = $db->loadResultArray(); foreach ($listings as $listing_id) { $jr_comment = array('pid' => $listing_id, 'mode' => 'com_content', 'created' => gmdate("Y-m-d H:i:s"), 'userid' => $user->id, 'name' => $user->name, 'username' => $user->username, 'email' => $user->email, 'comments' => $message, 'published' => '1', 'ipaddress' => $_SERVER['REMOTE_ADDR'], 'posts' => '0', 'vote_helpful' => '0', 'vote_total' => '0'); $sql = "INSERT INTO #__jreviews_comments (" . implode(",", array_keys($jr_comment)) . ") VALUES ('" . implode("','", $jr_comment) . "')"; $db->setQuery($sql); $db->query(); $jr_ratings = array('reviewid' => $db->insertid(), 'ratings' => 'na', 'ratings_sum' => 0, 'ratings_qty' => 0); $sql = "INSERT INTO #__jreviews_ratings (" . implode(",", array_keys($jr_ratings)) . ") VALUES ('" . implode("','", $jr_ratings) . "')"; $db->setQuery($sql); $db->query(); require_once JPATH_SITE . '/components/com_jreviews/jreviews/framework.php'; require_once JPATH_SITE . '/components/com_jreviews/jreviews/models/review.php'; $model = new ReviewModel(); $model->saveListingTotals($listing_id, 'com_content'); } }
function getReviewsTable() { $reviewModel = new ReviewModel(); $reviews = $reviewModel->getReviews(); $result = "<div style='height:400px;overflow:auto;'>\n\t\t\t\t\t<table class='tables'>\n\t\t\t\t\t <thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t <th>Id review</th>\n\t\t\t\t\t\t <th>Description</th>\n\t\t\t\t\t\t <th>Id user</th>\n\t\t\t\t\t\t <th>Id book</th>\n\t\t\t\t\t\t <th>Approved</th>\n\t\t\t\t\t\t <th>Approve review</th>\n\t\t\t\t\t\t <th>Delete review</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t </thead>\n\t\t\t\t\t <tbody>"; foreach ($reviews as $review) { $result = $result . "<tr>\n\t\t\t\t\t\t <td>{$review->idReview}</td>\n\t\t\t\t\t\t <td><div style='width:600px;height:40px;overflow:auto;'>{$review->description}</div></td>\n\t\t\t\t\t\t <td>{$review->idUser}</td>\n\t\t\t\t\t\t <td>{$review->idBook}</td>\n\t\t\t\t\t\t <td>{$review->approved}</td>\n\t\t\t\t\t\t <td>\n\t\t\t\t\t\t\t<form action='' method='post'>\n\t\t\t\t\t\t\t<!--<input type='image' src='img/check.png' alt='submit' style = 'width: 40px; height: 40px;' name='approve'/>-->\n\t\t\t\t\t\t\t<input type='hidden' name='idreview' value='{$review->idReview}' />\n\t\t\t\t\t\t\t<input type='submit' name='approve' value='' id='approve'/>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t </td>\n\t\t\t\t\t\t \n\t\t\t\t\t\t <td>\n\t\t\t\t\t\t\t<form action='' method='post'>\n\t\t\t\t\t\t\t<!--<input type='image' src='img/check.png' alt='submit' style = 'width: 40px; height: 40px;' name='approve'/>-->\n\t\t\t\t\t\t\t<input type='hidden' name='idreview' value='{$review->idReview}' />\n\t\t\t\t\t\t\t<input type='submit' name='deletereview' value='' id='deletereview'/>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t </td>\n\t\t\t\t\t\t</tr>"; } $result = $result . "</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t</div>"; return $result; }
public static function getAllowedSubmissions($intMemberId, $blnRemoveAlreadyReviewed = false) { $arrSubmissions = array(); if ($intMemberId && ($objSubmissions = static::findAll()) !== null) { while ($objSubmissions->next()) { if ($objSubmissions->published && in_array($intMemberId, deserialize($objSubmissions->allowedJids, true))) { $objReview = ReviewModel::findOneBy(array('sid=?', 'jid=?'), array($objSubmissions->id, $intMemberId)); // check for already existing reviews by the member for the current submission if (!$blnRemoveAlreadyReviewed || $blnRemoveAlreadyReviewed && (!$objReview || \Input::get('id') == $objReview->id)) { $arrSubmissions[] = $objSubmissions->current(); } } } } return $arrSubmissions; }
public static function postReview($url_parts) { require_once 'Review.model.php'; $data = array(); if (isset($_POST['sendreview'])) { $rate = $_POST['rate']; $comment = $_POST['comment']; $seller_id = $_POST['seller_id']; try { $result = ReviewModel::reviewPosted($rate, $comment, $seller_id); $data['template'] = 'reviewSuccess.html'; } catch (Exception $e) { $data['error'] = $e->getMessage(); $data['template'] = 'error.html'; } } return $data; }
*/ session_start(); include "../classes/User.php"; include "../classes/BookingDetails.php"; include "../classes/FlightSearchParameters.php"; include "../classes/FlightDetails.php"; include "../classes/Review.php"; include "../classes/Passenger.php"; include "../model/UserAccountModel.php"; include "../model/BookingModel.php"; include "../model/FlightModel.php"; include "../model/ReviewModel.php"; $userModel = new UserAccountModel(); $bookingModel = new BookingModel(); $flightModel = new FlightModel(); $reviewModel = new ReviewModel(); if ($_SESSION['action'] == "login") { $user = unserialize($_SESSION['user']); $arrayOfBookings = array(); if ($userModel->isUserPresent($user->getLoginId(), $user->getPassword()) == true) { $user = $userModel->getUserInstance($user->getLoginId(), $user->getPassword()); $_SESSION['userId'] = $user->getUserId(); $_SESSION['userMiles'] = $user->getMiles(); $_SESSION['loginName'] = $user->getLoginId(); $arrayOfBookings = $bookingModel->getBookings($user->getUserId()); $_SESSION['bookingsArray'] = serialize($arrayOfBookings); header("Location: ../view/Startup.php"); } else { $_SESSION['loginToken'] = "invalid"; header("Location: ../view/Login.php"); }