model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Review
$className string active record class name.
return Review the static model class
 public function loadModel($id)
 {
     $model = Review::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 public function run()
 {
     $models = Review::model()->published()->findAll(array('order' => 't.sort ASC'));
     if (empty($models)) {
         return;
     }
     $this->render($this->view, array('models' => $models));
 }
Ejemplo n.º 5
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $count = Review::model()->count($criteria);
     $pages = new CPagination($count);
     // results per page
     $pages->pageSize = Yii::app()->settings->getValue('config_admin_limit');
     $pages->applyLimit($criteria);
     $reviews = Review::model()->findAll($criteria);
     $this->render('index', array('reviews' => $reviews, 'pages' => $pages));
 }
Ejemplo n.º 6
0
 public function reviewData()
 {
     if (isset($this->_itemId)) {
         if ($this->_rating != 0) {
             $model = Review::model()->reviewFind($this->_itemId, $this->_entityId, $this->_rating);
         } else {
             $model = Review::model()->reviewFind($this->_itemId, $this->_entityId, '');
         }
         return $model;
     }
 }
 public function actionDetail()
 {
     if (isset($_REQUEST['status'])) {
         switch ($_REQUEST['status']) {
             case 'close':
                 Review::model()->updateByPk($_GET['id'], ['status' => 'close']);
                 break;
             case 'delete':
                 Review::model()->updateByPk($_GET['id'], ['status' => 'delete']);
                 break;
         }
     }
     $this->render('review', ['Review' => Review::model()->findByPk(['review_id' => $_GET['id']])]);
 }
Ejemplo n.º 8
0
 /**
  * Tests the create review action.
  */
 public function testCreate()
 {
     $note = $this->notes('note1');
     $student = $this->students('student1');
     $content = 'Test review content.';
     $review = new Review();
     $review->setAttributes(array('content' => $content));
     $this->assertTrue($note->addReview($review, $student->id));
     $newReview = Review::model()->findByPk($review->id);
     $this->assertNotNull($newReview);
     $this->assertTrue($newReview instanceof Review);
     $this->assertEquals($content, $newReview->content);
     $this->assertEquals($note->id, $newReview->note_id);
     $this->assertEquals($student->id, $newReview->student_id);
     $this->assertNotEquals('0000-00-00 00:00:00', $newReview->timestamp);
 }
Ejemplo n.º 9
0
 public function actionEdit()
 {
     $id = $this->iGet('id');
     $model = Review::model()->findByPk($id);
     if ($model === null) {
         $this->redirect(Yii::app()->request->urlReferrer);
     }
     if (isset($_POST['Review'])) {
         $model->attributes = $_POST['Review'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', '更新评价成功');
             $this->redirect($this->getReferrer());
         }
     }
     $model->formatDate();
     $this->render('edit', array('model' => $model));
 }
Ejemplo n.º 10
0
 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']));
 }
 public function run()
 {
     if (!Yii::app()->getUser()->getIsGuest() && !is_null($this->Response) && is_a($this->Response, 'Response') && $this->Response->isCompaniesReadyForReviews()) {
         $currentUserCompanyId = Yii::app()->user->getProfile()->company_id;
         if ($currentUserCompanyId == $this->Response->from_company_id) {
             $companyForReview = $this->Response->to_company_id;
         } else {
             $companyForReview = $this->Response->from_company_id;
         }
         $Company = Company::model()->findByPk($companyForReview);
         Yii::app()->getModule('rbac');
         Yii::app()->getModule('dictionary');
         Yii::app()->getModule('cabinet');
         // from_company_id to_company_id response_id
         $Review = Review::model()->findByAttributes(['response_id' => $this->Response->response_id, 'from_company_id' => $currentUserCompanyId, 'to_company_id' => $companyForReview]);
         if (is_null($Review)) {
             $labelCreateReview = Yii::t('default', 'Оставить отзыв');
         } else {
             $labelCreateReview = Yii::t('default', 'Посмотреть свой отзыв');
         }
         $this->render('index', ['Response' => $this->Response, 'labelCreateReview' => $labelCreateReview]);
     }
 }
Ejemplo n.º 12
0
" >
            </div>
            <a href="#none" class="btn-reply-customer" style="cursor:pointer;" data-replyid="<?php 
print_r($review_id);
?>
" reply_list_b_id="<?php 
echo $i;
?>
">&nbsp&nbspreply</a>
            <div class="clr">
            </div>
        </div>
    </div>
</div>
<?php 
$review = Review::model()->reviewFind($review_id, Review::ENTITY_REVIEW, '');
$reviewDatas = $review[0];
$reviewCount = count($reviewDatas);
$pages = $review[1];
if ($reviewCount > 0) {
    foreach ($reviewDatas as $reviewData) {
        if (isset($reviewData->content)) {
            ?>
        <div class="item-reply" style="display: block;">
    <div class="reply-list">
        <div class="reply-con">
            <span class="u-name"><a><?php 
            $customer = User::model()->find(array('select' => 'username', 'condition' => 'id=?', 'params' => array($reviewData->customer_id)));
            print_r($customer['username']);
            ?>
Ejemplo n.º 13
0
 /**
  * Get user review for this good
  * @return Review user review for this good
  */
 public function GetReview()
 {
     $review = Review::model()->findByAttributes(array('good_id' => $this->id, 'user_id' => Yii::app()->user->id));
     return $review;
 }
Ejemplo n.º 14
0
 public function afterDelete()
 {
     // delete dependencies
     ProductAttribute::model()->deleteAll("product_id={$this->cacheId}");
     ProductDescription::model()->deleteAll("product_id={$this->cacheId}");
     ProductDiscount::model()->deleteAll("product_id={$this->cacheId}");
     ProductFilter::model()->deleteAll("product_id={$this->cacheId}");
     ProductImage::model()->deleteAll("product_id={$this->cacheId}");
     ProductOption::model()->deleteAll("product_id={$this->cacheId}");
     ProductOptionValue::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("related_id={$this->cacheId}");
     ProductReward::model()->deleteAll("product_id={$this->cacheId}");
     ProductSpecial::model()->deleteAll("product_id={$this->cacheId}");
     ProductToCategory::model()->deleteAll("product_id={$this->cacheId}");
     ProductToDownload::model()->deleteAll("product_id={$this->cacheId}");
     ProductToLayout::model()->deleteAll("product_id={$this->cacheId}");
     ProductToStore::model()->deleteAll("product_id={$this->cacheId}");
     Review::model()->deleteAll("product_id={$this->cacheId}");
     UrlAlias::model()->deleteAll("query='product_id={$this->cacheId}'");
     parent::afterDelete();
 }
Ejemplo n.º 15
0
 /**
  * Закрытие отрицательных отзывов, если на них не отреагировали в течении N-дней
  */
 public function actionReviewClose()
 {
     $days_fc = 10;
     if (isset(Yii::app()->params['days_for_close_negative_reviews_wo_arbitration'])) {
         $days_fc = Yii::app()->params['days_for_close_negative_reviews_wo_arbitration'];
     }
     $criteria = new CDbCriteria();
     $criteria->addCondition("DAY(NOW())-DAY(`create`) >= :days_fc");
     $criteria->params['days_fc'] = $days_fc;
     $criteria->addColumnCondition(['rating' => 'negative', 'status' => 'new']);
     Yii::app()->getModule('rbac');
     Yii::app()->getModule('dictionary');
     Yii::app()->getModule('cabinet');
     //        $arrReviews = Review::model()->findAll($criteria);
     //        Yii::log("actionReviewClose count=[".count( $arrReviews )."]","info");
     //        foreach( $arrReviews as $v ) {
     //            Yii::log("actionReviewClose v=[".print_r( $v->attributes )."]","info");
     //        }
     Review::model()->updateAll(['status' => 'close'], $criteria);
 }
Ejemplo n.º 16
0
<div class="comments-tree">
	<?php 
$i = 0;
$criteria = new CDbCriteria();
$criteria->compare('good_id', $good->id);
$criteria->order = 'RAND()';
$reviews = Review::model()->findAll($criteria);
foreach ($reviews as $review) {
    $this->renderPartial('//review/review', array('review' => $review));
    $i++;
    if ($i >= 2) {
        break;
    }
}
if (count($good->reviews) > 2) {
    echo CHtml::ajaxLink('Все отзывы', $this->createUrl('review/allreviews'), array('type' => 'POST', 'data' => 'good_id=' . $good->id, 'success' => 'function(data){
						$(".comments-tree").html(data);
					}'));
    echo ' ' . count($good->reviews);
}
?>
</div>
Ejemplo n.º 17
0
            <?php 
echo date('Y-m-d   H:i:s', $review->create_at);
?>
        </dd>
    </div>


    <div class="btns">
        <a class="btn-reply" data-id="<?php 
print_r($review->review_id);
?>
" >
            回复(
            <em>
                <?php 
$num = Review::model()->reviewSummary($review->review_id, Review::ENTITY_REVIEW, '4');
echo $num;
?>
            </em>
            )
        </a>
    </div>
        <div id="reply" reply-id="<?php 
print_r($review->review_id);
?>
" style="display: block">
            <div class="reply-list" reply_list_id="0">
                <div class="reply-wrap">
                    <p><em>回复:&nbsp</em><span class="u-name"><?php 
print_r($customer['username']);
?>
Ejemplo n.º 18
0
                    <span><?php 
echo Review::model()->countByAttributes(['to_company_id' => $companyId, 'rating' => 'neutral']);
?>
</span>
                    <a href="<?php 
echo $reviewLink;
?>
">
                        <?php 
echo Yii::t('default', 'Нейтральные');
?>
                    </a>
                </div>
                <div class="negative">
                    <span><?php 
echo Review::model()->countByAttributes(['to_company_id' => $companyId, 'rating' => 'negative']);
?>
</span>
                    <a href="<?php 
echo $reviewLink;
?>
">
                        <?php 
echo Yii::t('default', 'Отрицательные');
?>
                    </a>
                </div>
            </div>
        <?php 
if ($contact == true) {
    ?>
Ejemplo n.º 19
0
$students = $review->students;
?>
		<?php 
echo $students->name;
//$form->textField($model,'student_id',array('size'=>10,'maxlength'=>10,'readonly'=>'readonly'));
?>
		</td>
	</tr>
	
	<tr>
		<td class="tb_title">被评论导师:</td>
    </tr>
    <tr >
		<td >
		<?php 
$review = Review::model()->findByPk($model->id);
$teachers = $review->teachers;
?>
		<?php 
echo $teachers->name;
//$form->textField($model,'teacher_id',array('size'=>10,'maxlength'=>10,'readonly'=>'readonly'));
?>
		</td>
	</tr>

	<tr class="submit">
      <td > <input name="submit" type="submit" id="submit" value="提交" class="button" /></td>
   </tr>
</table>

<script type="text/javascript">
Ejemplo n.º 20
0
                    <th><?php 
echo Yii::t('dashboard', 'Customers Awaiting Approval');
?>
:</th>
                    <td><?php 
echo Customer::model()->countByAttributes(array('approved' => Customer::APPROVED_NO));
?>
</td>
                </tr>
                <tr>
                    <th><?php 
echo Yii::t('dashboard', 'Reviews Awaiting Approval');
?>
:</th>
                    <td><?php 
echo Review::model()->countByAttributes(array('status' => Review::STATUS_PENDING));
?>
</td>
                </tr>
                <tr>
                    <th><?php 
echo Yii::t('dashboard', 'No. of Affiliates');
?>
:</th>
                    <td><?php 
echo Affiliate::model()->count();
?>
</td>
                </tr>
                <tr>
                    <th><?php 
Ejemplo n.º 21
0
 public function getClinics($limit, $offset)
 {
     $retVal = array();
     $criteria = new CDbCriteria();
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $criteria->order = 'clinic_id DESC';
     $data = Clinics::model()->findAll($criteria);
     $attrs = $this->attributeLabels();
     foreach ($data as $item) {
         $itemArr = array();
         foreach ($attrs as $key => $value) {
             $itemArr[$key] = $item->{$key};
         }
         $itemArr['stars'] = Review::model()->sumRating($item->clinic_id, 3);
         $itemArr['reviews'] = Review::model()->countReview($item->clinic_id, 3);
         $retVal[] = $itemArr;
     }
     return $retVal;
 }
Ejemplo n.º 22
0
 public function actionArbitrate($id)
 {
     $Review = Review::model()->findByPk($id);
     $Review->status = 'arbitration';
     $Review->save();
     $this->redirect('/cabinet/review/' . $id);
 }
Ejemplo n.º 23
0
<?php

/**
 * Created by cangzhou.
 * email:wucangzhou@gmail.com
 * Date: 12/17/13
 * Time: 2:47 PM
 */
$review = $this->reviewData();
$reviewData = $review[0];
$reviewCount = count($reviewData);
$pages = $review[1];
$reviewNum = Review::model()->reviewSummary($this->_itemId, $this->_entityId, '1');
$picReviewCount = Review::model()->reviewSummary($this->_itemId, $this->_entityId, '2');
if ($reviewCount >= 1) {
    $positiveRate = $reviewNum[1] / $reviewCount;
    $neutralRate = $reviewNum[2] / $reviewCount;
    $negativeRate = $reviewNum[3] / $reviewCount;
} else {
    $positiveRate = 0;
    $neutralRate = 0;
    $negativeRate = 0;
}
?>
<div id="review" url="<?php 
echo Yii::app()->baseUrl;
?>
" product_id="<?php 
echo $this->_itemId;
?>
">
Ejemplo n.º 24
0
 public function addReview($user_id, $object_id, $comment, $rating, $object_type)
 {
     $check = Review::model()->findByAttributes(array('user_id' => $user_id, 'object_id' => $object_id, 'object_type' => $object_type));
     if ($check) {
         $check->review = $comment;
         $check->rate = $rating;
         $check->time = time();
         if ($check->save(FALSE)) {
             ResponseHelper::JsonReturnSuccess($check, "Success");
         } else {
             ResponseHelper::JsonReturnError("", "Failed");
         }
     } else {
         $model = new Review();
         $model->user_id = $user_id;
         $model->review = $comment;
         $model->object_id = $object_id;
         $model->object_type = $object_type;
         $model->rate = $rating;
         $model->time = time();
         if ($model->save(FALSE)) {
             ResponseHelper::JsonReturnSuccess($model, "Success");
         } else {
             ResponseHelper::JsonReturnError("", "Failed");
         }
     }
 }
Ejemplo n.º 25
0
 public function countRating($object_id, $object_type)
 {
     $count = Review::model()->countByAttributes(array("object_id" => $object_id, "object_type" => $object_type));
     $sum = Review::model()->sumRating($object_id, $object_type);
     if ($count == 0) {
         return 0;
     } else {
         return $sum / $count;
     }
 }
Ejemplo n.º 26
0
    echo $row->id;
    ?>
">
        <?php 
    echo $row->id;
    ?>
</td>

      <td><?php 
    $review = Review::model()->findByPk($row->id);
    $students = $review->students;
    echo $students->name;
    ?>
	  </td>
	  <td><?php 
    $review = Review::model()->findByPk($row->id);
    $teachers = $review->teachers;
    echo $teachers->name;
    ?>
	  </td>
	  <td><?php 
    echo mb_substr($row->contents, '0', '20', 'utf-8');
    ?>
</td>
      <td ><a href="<?php 
    echo $this->createUrl('update', array('id' => $row->id));
    ?>
"><img src="<?php 
    echo $this->_baseUrl;
    ?>
/static/admin/images/update.png" align="absmiddle" /></a>&nbsp;&nbsp;<a href="<?php 
Ejemplo n.º 27
0
 public function getNearPharmacy($lat, $lng, $limit, $offset)
 {
     $retVal = array();
     $criteria = new CDbCriteria();
     if (!empty($lat) && !empty($lng)) {
         $criteria->select = "t.*, (2 * (3959 * ATAN2(\n          SQRT(\n            POWER(SIN((RADIANS(" . $lat . " - `t`.`laititude` ) ) / 2 ), 2 ) +\n            COS(RADIANS(`t`.`laititude`)) *\n            COS(RADIANS(" . $lat . ")) *\n            POWER(SIN((RADIANS(" . $lng . " - `t`.`longitude` ) ) / 2 ), 2 )\n          ),\n          SQRT(1-(\n            POWER(SIN((RADIANS(" . $lat . " - `t`.`laititude` ) ) / 2 ), 2 ) +\n            COS(RADIANS(`t`.`laititude`)) *\n            COS(RADIANS(" . $lat . ")) *\n            POWER(SIN((RADIANS(" . $lng . " - `t`.`longitude` ) ) / 2 ), 2 )\n          ))\n        )\n      )) as\n            distance";
         $criteria->having = 'distance < 3';
         $criteria->group = 't.id';
     }
     $criteria->order = 'distance ASC';
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $data = Pharmacy::model()->findAll($criteria);
     $attrs = $this->attributeLabels();
     foreach ($data as $item) {
         $itemArr = array();
         foreach ($attrs as $key => $value) {
             $itemArr[$key] = $item->{$key};
         }
         $itemArr['stars'] = Review::model()->sumRating($item->id, 2);
         $itemArr['reviews'] = Review::model()->countReview($item->id, 2);
         $retVal[] = $itemArr;
     }
     return $retVal;
 }
Ejemplo n.º 28
0
    /**
     * 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 $id the ID of the model to be loaded
     * @return Book the loaded model
     * @throws CHttpException
     */
    public function loadModel($id)
    {
        $model = Book::model()->findByPk($id);
        $rubrics = Rubric::model()->findAllBySql('
		SELECT r.title
		FROM db_rubric AS r
		INNER JOIN db_rubrics_books AS rb
		ON rb.rubric_id = r.id
		WHERE rb.book_id = ' . $id);
        $string = '';
        foreach ($rubrics as $rubric) {
            $string .= $rubric->title . ', ';
        }
        $model['rubric'] = substr($string, 0, strlen($string) - 2);
        unset($string);
        $model['comments'] = Comment::model()->findAllBySql('
		SELECT *
		FROM db_comment AS c
		INNER JOIN db_comments_books AS cb
		ON cb.commnet_id = c.id
		WHERE cb.book_id = ' . $id);
        $model['review'] = Review::model()->findAllBySql('
		SELECT *
		FROM db_review AS r
		INNER JOIN db_reviews_books AS rb
		ON rb.review_id = r.id
		WHERE rb.book_id = ' . $id);
        $model['files'] = Files::model()->findAllBySql('
		SELECT f.type, f.title
		FROM db_files AS f
		WHERE f.book_id = ' . $id);
        if ($model === null) {
            throw new CHttpException(404, 'The requested page does not exist.');
        }
        return $model;
    }