public static function updateReview() { // Process updating review $reviews = ReviewsDB::getReviewsBy('reviewId', $_SESSION['arguments']); if (empty($reviews)) { HomeView::show(); header('Location: /' . $_SESSION['base']); } elseif ($_SERVER["REQUEST_METHOD"] == "GET") { $_SESSION['reviews'] = $reviews; ReviewView::showUpdate(); } else { $parms = $reviews[0]->getParameters(); $parms['score'] = array_key_exists('score', $_POST) ? $_POST['score'] : $reviews[0]->getScore(); $parms['review'] = array_key_exists('review', $_POST) ? $_POST['review'] : $reviews[0]->getReview(); $newReview = new Review($parms); $newReview->setReviewId($reviews[0]->getReviewId()); $review = ReviewsDB::updateReview($newReview); if ($review->getErrorCount() != 0) { $_SESSION['reviews'] = array($newReview); ReviewView::showUpdate(); } else { HomeView::show(); header('Location: /' . $_SESSION['base']); } } }
public function actionIndex() { $model = new Review(); $model->unsetAttributes(); $model->attributes = $this->aRequest('Review'); $this->render('index', array('model' => $model)); }
/** * Converts the response in JSON format to the list of value objects i.e * Review * * @param json * - response in JSON format * * @return List of Review object filled with json data * */ function buildArrayResponse($json) { $reviewList = array(); $reviewsJSONObject = $this->getServiceJSONObject("reviews", $json); if ($reviewsJSONObject->__get("review") instanceof JSONObject) { $reviewJSONObject = $reviewsJSONObject->__get("review"); $reviewJSONObject = new JSONObject($reviewJSONObject); $reviewObj = new Review(); $reviewObj->setStrResponse($json); $reviewObj->setResponseSuccess($this->isRespponseSuccess($json)); $this->buildObjectFromJSONTree($reviewObj, $reviewJSONObject); array_push($reviewList, $reviewObj); } else { // There is an Array of attribute $reviewJSONArray = $reviewsJSONObject->getJSONArray("review"); for ($i = 0; $i < count($reviewJSONArray); $i++) { $reviewJSONObj = $reviewJSONArray[$i]; $reviewObj = new Review(); $reviewObj->setStrResponse($json); $reviewJSONObj = new JSONObject($reviewJSONObj); $reviewObj->setResponseSuccess($this->isRespponseSuccess($json)); $this->buildObjectFromJSONTree($reviewObj, $reviewJSONObj); array_push($reviewList, $reviewObj); } } return $reviewList; }
/** * Tests the create review action with invalid input. */ public function testCreateInvalid() { $note = $this->notes('note1'); $student = $this->students('student1'); // Empty content $review = new Review(); $review->setAttributes(array('content' => null)); $this->assertFalse($note->addReview($review, $student->id)); }
public function review(Request $request, $id) { $validation = Validator::make($request->all(), ['rating' => 'required|between:1,10', 'title' => 'required|min:5', 'description' => 'required|min:5']); if ($validation->fails()) { return redirect('dvds/' . $id)->withInput()->withErrors($validation); } $review = new Review(['rating' => $request->input('rating'), 'title' => $request->input('title'), 'description' => $request->input('description'), 'dvd_id' => $id]); $review->save(); return redirect('dvds/' . $id)->with('success', true); }
public static function load_many_from_query($sql, $args) { $sth = Dal::query($sql, $args); $items = array(); while ($r = Dal::row_assoc($sth)) { $rev = new Review(); $rev->load_from_row($r); $items[] = $rev; } return $items; }
public static function getReviewsArray($rowSets) { // Return an array of Review objects extracted from $rowSets $reviews = array(); foreach ($rowSets as $reviewRow) { $review = new Review($reviewRow); $review->setReviewId($reviewRow['reviewId']); array_push($reviews, $review); } return $reviews; }
public function testBeforeToHtmlWhenQuoteIsVirtual() { $quote = $this->_getQuoteMock(); $quote->expects($this->any())->method('getIsVirtual')->will($this->returnValue(true)); $this->model->setQuote($quote); $this->model->toHtml(); $this->assertEquals($this->model->getPaymentMethodTitle(), $quote->getPayment()->getMethodInstance()->getTitle()); $this->assertFalse($this->model->getShippingRateRequired()); $this->assertContains('paypal/express/edit', $this->model->getEditUrl()); $this->assertContains('paypal/express/placeOrder', $this->model->getPlaceOrderUrl()); }
public function index() { if ($this->c_user->isTrialPlanEnds()) { $this->addFlash(lang('subscription_ends_error', [site_url('subscript/plans')]), 'error'); } // UNCOMMENT TO USE // get average google rank for all keywords for chart in range $keyword_rank = Keyword::average_for_range($this->c_user->id, '-30 days', 'today'); // average result for all the range $keywords_trending = Keyword::average_for_range($this->c_user->id, '-30 days', 'today', FALSE); // average for each day in range // analytics data $google_access_token = Access_token::getByTypeAndUserId('googlea', $this->c_user->id); list($ga_visits_chart, $ga_visits_count) = $google_access_token->google_analytics_dashboard_visits(); $review = new Review(); $last_reviews_count = $review->last_period_count($this->c_user->id, $this->profile->id); $review->clear(); $social_values = Social_value::inst(); $social_values->set_values($this->c_user->id, $this->profile->id, array('from' => date('Y-m-d', strtotime('-30 days')), 'to' => date('Y-m-d', time()))); $all_socials_data = $social_values->get_data(); $monthly_trending = array('reviews' => $review->last_month_trending($this->c_user->id, $this->profile->id), 'traffic' => $ga_visits_chart, 'keywords' => $keywords_trending, 'twitter_followers' => $all_socials_data['twitter'], 'facebook_likes' => $all_socials_data['facebook']); $keywordsForHighlight = Mention_keyword::inst()->get_for_highlight($this->c_user->id, 0); CssJs::getInst()->add_js('www.google.com/jsapi', 'external', 'footer'); CssJs::getInst()->add_js(array('libs/lodash.compat.js', 'libs/highcharts/highcharts.js'))->c_js(); $opportunities = $this->getOpportunities(); if (!empty($opportunities['web_radar'])) { CssJs::getInst()->add_js('controller/webradar/index.js'); } JsSettings::instance()->add(array('monthly_trending' => $monthly_trending, 'dashboard' => true, 'keywords' => $keywordsForHighlight, 'opportunities' => $opportunities)); $summary = array('reviews' => (int) $last_reviews_count, 'fb_likes' => (int) $all_socials_data['likes_count'], 'twiter_followers' => (int) $all_socials_data['followers_count'], 'web_traffic' => (int) $ga_visits_count, 'google_rank' => (int) round($keyword_rank, 3)); $this->isSupportScheduledPosts = $this->getAAC()->isGrantedPlan('scheduled_posts'); $this->load->helper('my_url_helper'); $this->template->set('isSupportScheduledPosts', $this->isSupportScheduledPosts); $this->template->set('socials', Social_post::getActiveSocials($this->profile->id)); $this->is_user_set_timezone = User_timezone::is_user_set_timezone($this->c_user->id); JsSettings::instance()->add(array('twitterLimits' => array('maxLength' => 140, 'midLength' => 117, 'lowLength' => 94), 'twitterLimitsText' => lang('twitter_error'), 'linkedinLimits' => array('maxLength' => 400), 'linkedinLimitsText' => lang('linkedin_error'))); CssJs::getInst()->add_css(array('custom/pick-a-color-1.css')); CssJs::getInst()->add_js(array('libs/jq.file-uploader/jquery.iframe-transport.js', 'libs/jq.file-uploader/jquery.fileupload.js', 'libs/fabric/fabric.min.js', 'libs/fabric/StackBlur.js', 'libs/color/tinycolor-0.9.15.min.js', 'libs/color/pick-a-color-1.2.3.min.js')); CssJs::getInst()->c_js('social/create', 'post_update'); CssJs::getInst()->c_js('social/create', 'post_cron'); CssJs::getInst()->c_js('social/create', 'post_attachment'); CssJs::getInst()->c_js('social/create', 'social_limiter'); CssJs::getInst()->c_js('social/create', 'schedule_block'); CssJs::getInst()->c_js('social/create', 'bulk_upload'); $this->template->set('is_user_set_timezone', User_timezone::is_user_set_timezone($this->c_user->id)); $user_posts = Social_post::inst()->get_user_scheduled_posts($this->c_user->id, $this->profile->id, 1, 3, 'all'); $this->template->set('posts', $user_posts); $this->load->helper('Image_designer_helper'); $this->template->set('imageDesignerImages', Image_designer::getImages()); $this->template->set('summary', $summary); $this->template->set('opportunities', $opportunities); $this->template->set('need_welcome_notification', User_notification::needShowNotification($this->c_user->id, User_notification::WELCOME)); $this->template->render(); }
public function actionCreate() { $model = new Review(); if (isset($_POST['Review'])) { $model->attributes = $_POST['Review']; if ($model->validate() && $model->save()) { $this->redirect(array('index')); } } $statuses = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled')); $this->render('create', array('model' => $model, 'statuses' => $statuses)); }
public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $review = new Review($_POST); if ($review->getErrorCount() == 0) { HomeView::show(null); } else { ReviewView::show($review); } } else { // Initial link ReviewView::show(null); } }
/** * 录入 * */ public function actionCreate() { parent::_acl(); $model = new Review(); if (isset($_POST['Review'])) { $acl = $this->_gets->getPost('acl'); $model->attributes = $_POST['Review']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入内容,ID:' . $model->id)); $this->redirect(array('index')); } } $this->render('review_create', array('model' => $model)); }
public function grabber(array $directory_user) { log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Reviews grabber'); try { $directoryUser = new Directory_User($directory_user['id']); if (!$directoryUser->exists()) { throw new Exception('Directory_User id:' . $directory_user['id'] . ' doesn\'t exist'); } $directory = $directoryUser->directory->get(); if (!$directory->exists()) { throw new Exception('Directory id:' . $directory_user['directory_id'] . ' doesn\'t exist'); } if (!$directory->status) { throw new Exception('Directory id:' . $directory_user['directory_id'] . ' is disabled'); } $link = !empty($directory_user['additional']) ? $directory_user['additional'] : $directory_user['link']; log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Try to grabb - ' . $directory->name); $aac = $this->getAAC(); $user = new User($directory_user['user_id']); if (!$user->exists()) { return; } $aac->setUser($user); $directory_parcer = Directory_Parser::factory($directory->type)->set_url($link); $reviews = $directory_parcer->get_reviews(); /** * Store additional data to */ if ($directory_parcer instanceof Directory_Interface_UserStorage) { $directoryUser->setAdditional($directory_parcer->getDataToStore())->save(); } } catch (Exception $e) { log_message('TASK_ERROR', __FUNCTION__ . ' > ' . 'Reviews: ' . $e->getMessage()); throw $e; } //$today_midnight = strtotime('-7 day midnight'); $today_midnight = strtotime('-14 day midnight'); if (is_array($reviews) && !empty($reviews)) { foreach ($reviews as $_review) { $review_model = new Review(); $review_model->from_array($_review); $review_model->user_id = $directory_user['user_id']; $review_model->directory_id = $directory_user['directory_id']; $review_model->profile_id = $directory_user['profile_id']; $review_model->posted_date = date('Y-m-d', $_review['posted']); $review_model->save(); log_message('TASK_DEBUG', __FUNCTION__ . ' > ' . 'Review saved'); } } }
function test_getAll() { //Arrange $review = "Pizza was dope"; $restaurant_id = 1; $test_review = new Review($review, $restaurant_id); $test_review->save(); $review2 = "DAMN DAT GRILLED CHEESE IS FIRE"; $restaurant_id2 = 2; $test_review2 = new Review($review2, $restaurant_id2); $test_review2->save(); //Act $result = Review::getAll(); //Assert $this->assertEquals([$test_review, $test_review2], $result); }
function render_for_post() { if (empty(PA::$login_user)) { return __("Login required"); } $rev = new Review(); $rev->author_id = PA::$login_user->user_id; $rev->subject_type = $this->params["subject_type"]; $rev->subject_id = $this->params["subject_id"]; //TODO: validate subject_type and subject_id $rev->title = $this->params["title"]; $rev->body = $this->params["body"]; //TODO: ensure html is stripped properly $rev->save(); return $this->render(); }
/** * Display a listing of destinos * * @return Response */ public function postIndex() { $input = Input::all(); if (!empty($input)) { $review = new Review(); $review->cliente_id = Auth::user()->id; $review->produto_id = $input['produto_id']; $review->titulo = $input['review-titulo']; $review->texto = $input['review-texto']; $review->nota = $input['review-nota']; $review->save(); return Redirect::back()->with('success', array('Sua avaliação foi enviada e em breve sera analisada.')); } else { return Redirect::back()->with('danger', array('preencha todos os campos da avaliação.')); } }
/** * Display all comments by productId. * * @return Response */ public function index($productId) { $product = Product::where('id', $productId)->first(); $reviews = Review::where('productId', $productId)->get(); $product["reviews"] = $reviews; return $product; }
public static function copy($params) { if (!isset($params["id"])) { throw new Exception("Missing id parameter"); } // Connect to database $mysqli = FoodAppDatabase::connect(); // Copy FOOD table record $foodFields = implode(",", array_slice(static::$fieldMap, 1)); $queryString = "INSERT into food (" . $foodFields . ") "; $queryString .= "SELECT " . $foodFields . " FROM food "; $queryString .= "WHERE id='" . $params["id"] . "'"; // Run query if (!$mysqli->query($queryString)) { throw new Exception($mysqli->error); } $newFoodId = $mysqli->insert_id; // Copy Reviews Review::copy($params["id"], $newFoodId); // Copy Components FoodComponent::copy($params["id"], $newFoodId); // Copy Recipe Steps RecipeStep::copy($params["id"], $newFoodId); // Copy Complements FoodComplement::copy($params["id"], $newFoodId); // Copy Alternates FoodAlternate::copy($params["id"], $newFoodId); }
public function testUpdateReview() { $myDb = DBMaker::create('ptest'); Database::clearDB(); $db = Database::getDB('ptest', 'C:\\xampp\\myConfig.ini'); $beforeCount = count(ReviewsDB::getReviewsBy()); $reviews = ReviewsDB::getReviewsBy('reviewId', 1); $currentReview = $reviews[0]; $parms = $currentReview->getParameters(); $parms['review'] = 'new review text'; $newReview = new Review($parms); $newReview->setReviewId($currentReview->getReviewId()); $updatedReview = ReviewsDB::updateReview($newReview); $afterCount = count(ReviewsDB::getReviewsBy()); $this->assertEquals($beforeCount, $afterCount, 'The number of reviews in the database should not change after update'); $this->assertEquals($updatedReview->getReviewId(), $newReview->getReviewId(), 'The id of the updated review should remain the same'); }
public function run() { $models = Review::model()->published()->findAll(array('order' => 't.sort ASC')); if (empty($models)) { return; } $this->render($this->view, array('models' => $models)); }
public function run() { DB::table('reviews')->delete(); Review::create(array('productId' => 1, 'stars' => 5, 'body' => 'I love this product!', 'author' => '*****@*****.**')); Review::create(array('productId' => 1, 'stars' => 3, 'body' => 'Not bad for the price.', 'author' => '*****@*****.**')); Review::create(array('productId' => 2, 'stars' => 1, 'body' => 'Horrible product!', 'author' => '*****@*****.**')); Review::create(array('productId' => 2, 'stars' => 2, 'body' => 'Needs more...', 'author' => '*****@*****.**')); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Review::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionReviewDetail() { if (isset($_REQUEST['reviewId'])) { $review = Review::model()->findByPk($_REQUEST['reviewId']); $reviewReply = Review::model()->reviewFind($_REQUEST['reviewId'], 2, ''); $this->render('reviewDetail', array('review' => $review, 'reviewReply' => $reviewReply)); } }
public function loadModel($id) { $model = Review::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
function render() { $op = $this->op = @$this->module_params['op']; if ($this->op) { if (!empty($this->module_params['comment'])) { $target = new Comment2(); $target->load($this->module_params['comment']); } else { if (!empty($this->module_params['review'])) { $target = new Review(); $target->load($this->module_params['review']); } else { if (!empty($this->module_params['uid'])) { $target = new ShadowUser('videoplay'); $target->load_by_pa((int) $this->module_params['uid']); } } } switch ($op) { case "delete": if (!empty($this->module_params['uid'])) { $target->remove(); } else { $target->delete(); } break; case "hide": case "show": if (!empty($this->module_params['uid'])) { $target->toggle_active($op == 'hide' ? -1 : 1); } else { $target->toggle_active($op == 'hide' ? 0 : 1); } break; } } switch ($this->mode) { case "comments": $inner_template = dirname(__FILE__) . '/admin_content.tpl'; list($this->contents, $this->n, $this->n_pages, $this->page, $this->per_page) = Comment2::get_recent($this->per_page, $this->page); break; case "reviews": $inner_template = dirname(__FILE__) . '/admin_content.tpl'; list($this->contents, $this->n, $this->n_pages, $this->page, $this->per_page) = Review::get_recent($this->per_page, $this->page); break; case "users": $inner_template = dirname(__FILE__) . '/admin_users.tpl'; list($this->users, $this->n, $this->n_pages, $this->page, $this->per_page) = ShadowUser::admin_paged('videoplay', $this->per_page, $this->page); break; default: return "Unknown display type.<pre>" . print_r($this, 1) . "</pre>"; break; } $inner_html_gen =& new Template($inner_template, $this); $this->inner_HTML = $inner_html_gen->fetch(); $content = parent::render(); return $content; }
/** * 首页 * */ public function actionIndex() { parent::_acl(); $model = new Review(); $criteria = new CDbCriteria(); $criteria->condition = $condition; $criteria->order = 't.id ASC'; //$criteria->with = array ( 'catalog' ); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; //$pageParams = XUtils::buildCondition( $_GET, array ( 'title' , 'catalogId','titleAlias' ) ); //$pages->params = is_array( $pageParams ) ? $pageParams : array (); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('review_index', array('datalist' => $result, 'pagebar' => $pages)); }
private function createReview($row) { $r = new Review(); $r->setId($row['id']); $r->setReview($row['review']); $r->setRestaurantId($row['restaurant_id']); $r->setUserId($row['user_id']); $r->setUserName($row['firstName'] . " " . $row['lastName']); $r->setCreated($row['created_at']); return $r; }
function delete() { $reviews = Review::getAll(); foreach ($reviews as $review) { if ($review->getRestaurantId() == $this->getId()) { $review->delete(); } } $GLOBALS['DB']->exec("DELETE FROM restaurants WHERE id = {$this->getId()};"); }
public function show(User $user, Application $app) { if (\Auth::check()) { $url = str_contains($this->checkloginpage($user->name), \Auth::user()->name); } else { $url = false; } $review = Review::with('users')->where('application_id', '=', $app->id)->get(); return view('userApp.showUserApp', compact('app', 'review', 'user', 'url')); }
public function actionView($id) { $teacher = $this->loadModel($id); $this->_seoTitle = '名师 - ' . $teacher->name; $userId = $this->_cookiesGet('userId'); $userType = $this->_cookiesGet('userType'); $reviewModel = new Review(); if ($userType === 'student' and isset($_POST['Review'])) { $reviewModel->attributes = $_POST['Review']; $reviewModel->teacher_id = $id; $reviewModel->student_id = $userId; $reviewModel->ctime = time(); if ($reviewModel->validate() and $reviewModel->save()) { Yii::app()->user->setFlash('success', '保存成功'); } } $criteria = new CDbCriteria(); $books = Book::model()->findAllByAttributes(array('teacher_id' => $id)); $lessons = array(); $reviews = array(); $list = yii::app()->request->getParam('list'); if ($list === null or $list === 'lesson') { $model = Lesson::model(); $count = $model->count($criteria->addCondition("teacher_id = {$id}")); $pager = new CPagination($count); $pager->pageSize = 4; $pager->applyLimit($criteria); $lessons = $model->findAll($criteria); } else { $model = Review::model(); $count = $model->count($criteria->addCondition("teacher_id = {$id}")); $pager = new CPagination($count); $pager->pageSize = 4; $pager->applyLimit($criteria); $reviews = Yii::app()->db->createCommand()->select('s.*, r.contents, r.ctime')->from('seed_review r')->leftjoin('seed_student s', 's.id=r.student_id')->where('r.teacher_id=:teacher_id', array(':teacher_id' => $id))->order('ctime desc')->limit(4, $pager->currentPage * $pager->pageSize)->queryAll(); } //判断学员已关注老师 if ($userType === 'student') { $is_focus = StudentTeacher::model()->findByAttributes(array('student_id' => $userId, 'teacher_id' => $id)); } $this->render('view', array('is_focus' => $is_focus, 'teacher' => $teacher, 'lessons' => $lessons, 'reviews' => $reviews, 'books' => $books, 'userType' => $userType, 'reviewModel' => $reviewModel, 'count' => $count, 'pager' => $pager, 'list' => $_GET['list'])); }