本文整理汇总了PHP中Events::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::setAttributes方法的具体用法?PHP Events::setAttributes怎么用?PHP Events::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Events
的用法示例。
在下文中一共展示了Events::setAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($id)
{
$formModel = new EventCommentPublisherFormModel();
$profile = Yii::app()->params->profile;
$model = $this->controller->lookUpModel($id, 'Events');
$this->controller->dataUrl = Yii::app()->request->url;
if ($model->checkPermissions('view')) {
if (isset($_POST['EventCommentPublisherFormModel'])) {
$formModel->setAttributes($_POST['EventCommentPublisherFormModel']);
if (isset($_FILES['EventCommentPublisherFormModel'])) {
$model->photo = CUploadedFile::getInstance($model, 'photo');
}
if ($formModel->validate()) {
$event = new Events();
$event->setAttributes(array('visibility' => X2PermissionsBehavior::VISIBILITY_PUBLIC, 'user' => $profile->username, 'type' => 'structured-feed', 'associationType' => 'Events', 'associationId' => $id, 'text' => $formModel->text, 'photo' => $formModel->photo), false);
if ($event->save()) {
$formModel->text = '';
if (!isset($_FILES['EventCommentPublisherFormModel'])) {
} else {
Yii::app()->end();
}
} else {
throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
}
}
}
$dataProvider = new CActiveDataProvider('Events', array('criteria' => array('order' => 'timestamp ASC', 'condition' => "type in ('comment', 'structured-feed') AND \n associationType='Events' AND associationId={$id}"), 'pagination' => array('pageSize' => 30)));
$this->controller->render($this->pathAliasBase . 'views.mobile.viewEvent', array('model' => $model, 'dataProvider' => $dataProvider, 'formModel' => $formModel));
} else {
$this->controller->denied();
}
}
示例2: addEvent
public function addEvent($attr, $image)
{
$model = new Events();
$model->setAttributes($attr);
$model->created_at = time();
$model->updated_at = time();
$model->status = 1;
$model->images = $image;
if ($model->save(FALSE)) {
return TRUE;
}
return FALSE;
}
示例3: run
public function run()
{
$model = new EventPublisherFormModel();
$profile = Yii::app()->params->profile;
if (isset($_POST['EventPublisherFormModel'])) {
$model->setAttributes($_POST['EventPublisherFormModel']);
if (isset($_FILES['EventPublisherFormModel'])) {
$model->photo = CUploadedFile::getInstance($model, 'photo');
}
//AuxLib::debugLogR ('validating');
if ($model->validate()) {
//AuxLib::debugLogR ('valid');
$event = new Events();
$event->setAttributes(array('visibility' => X2PermissionsBehavior::VISIBILITY_PUBLIC, 'user' => $profile->username, 'type' => 'structured-feed', 'text' => $model->text, 'photo' => $model->photo), false);
if ($event->save()) {
if (!isset($_FILES['EventPublisherFormModel'])) {
//AuxLib::debugLogR ('saved');
$this->controller->redirect($this->controller->createAbsoluteUrl('/profile/mobileActivity'));
} else {
echo CJSON::encode(array('redirectUrl' => $this->controller->createAbsoluteUrl('/profile/mobileActivity')));
Yii::app()->end();
}
} else {
//AuxLib::debugLogR ('invalid');
throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
}
} else {
if (isset($_FILES['EventPublisherFormModel'])) {
throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
}
//AuxLib::debugLogR ('invalid model');
//AuxLib::debugLogR ($model->getErrors ());
}
}
$this->controller->render($this->pathAliasBase . 'views.mobile.eventPublisher', array('profile' => $profile, 'model' => $model));
}