本文整理汇总了PHP中Review::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::validate方法的具体用法?PHP Review::validate怎么用?PHP Review::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doValidate
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aSeries !== null) {
if (!$this->aSeries->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aSeries->getValidationFailures());
}
}
if ($this->aReview !== null) {
if (!$this->aReview->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aReview->getValidationFailures());
}
}
if ($this->aScore !== null) {
if (!$this->aScore->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aScore->getValidationFailures());
}
}
if (($retval = ModelPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collConfigs !== null) {
foreach ($this->collConfigs as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collReviews !== null) {
foreach ($this->collReviews as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collScores !== null) {
foreach ($this->collScores as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
if ($this->collUserMetas !== null) {
foreach ($this->collUserMetas as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return !empty($failureMap) ? $failureMap : true;
}
示例2: actionCreate
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));
}
示例3: actionView
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']));
}
示例4: actionReview
/**
* AJAX response for review AJAX request.
*/
public function actionReview()
{
$review = new Review();
$review->attributes = $_POST['Review'];
if ($review->validate()) {
$noteId = $_POST['note_id'];
$model = $this->loadModel($noteId);
$model->addReview($review, Yii::app()->user->id);
echo $this->renderPartial('_review', array('data' => $review), true);
}
}
示例5: actionReviewAdd
public function actionReviewAdd($response_id)
{
if (Yii::app()->user->isGuest) {
throw new CHttpException(403);
}
$Response = Response::model()->findByPK($response_id);
if (is_null($Response)) {
throw new CHttpException(403);
}
$profile = Yii::app()->user->getProfile();
$Company = $profile->company;
if ($Company->isBlocked()) {
$this->render('reviewaddblock', ['Response' => $Response, 'CompanyPartner' => null]);
return;
}
$CompanyPartnerId = null;
if ($Company->id == $Response->from_company_id) {
$CompanyPartnerId = $Response->to_company_id;
} else {
if ($Company->id == $Response->to_company_id) {
$CompanyPartnerId = $Response->from_company_id;
} else {
// компания не принадлежит к этой сделке
throw new CHttpException(403);
}
}
$CompanyPartner = Company::model()->findByPk($CompanyPartnerId);
if ($CompanyPartner->isBlocked()) {
$this->render('reviewaddblock', ['Response' => $Response, 'CompanyPartner' => $CompanyPartner]);
return;
}
if (!$Response->isCompaniesReadyForReviews()) {
Yii::log("actionReviewAdd companies NOT ready for review", "info");
throw new CHttpException(403);
}
$Review = Review::model()->findByAttributes(['response_id' => $response_id, 'from_company_id' => $Company->id]);
if (is_null($Review)) {
$Review = new Review();
}
//$Response = Response::model()->findByPk($response_id);
if (isset($_POST['Review'])) {
$Review->setAttributes($_POST['Review'], false);
$Review->from_company_id = $Company->id;
if ($Response->to_company->id == $Company->id) {
$CompanyTo = $Response->from_company;
} else {
$CompanyTo = $Response->to_company;
}
$Review->to_company_id = $CompanyTo->id;
$Review->response_id = $Response->response_id;
if ($Review->validate()) {
$Review->save();
if (isset($_POST['photos'])) {
$Review->setPhoto($_POST['photos']);
}
$Review->setscenario('valid_photo');
if ($Review->validate()) {
//$this->redirect('/cabinet/deal/'.$Response->response_id);
$this->redirect('/response/' . $Response->response_id);
}
}
}
$mainAssets = Yii::app()->getTheme()->getAssetsUrl();
Yii::app()->getClientScript()->registerCssFile($mainAssets . '/css/review.css');
$this->render('reviewadd', ['Review' => $Review, 'Response' => $Response]);
}