当前位置: 首页>>代码示例>>PHP>>正文


PHP Messages::unsetAttributes方法代码示例

本文整理汇总了PHP中Messages::unsetAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Messages::unsetAttributes方法的具体用法?PHP Messages::unsetAttributes怎么用?PHP Messages::unsetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Messages的用法示例。


在下文中一共展示了Messages::unsetAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionAdmin

 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $dataProvider = new CActiveDataProvider('Messages');
     $model = new Messages('search');
     $user = new Users();
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Messages'])) {
         $model->attributes = $_GET['Messages'];
     }
     $this->render('index', array('model' => $model, 'user' => $user->model()->findByPk(Yii::app()->user->id), 'dataProvider' => $dataProvider));
 }
开发者ID:schur-maksim,项目名称:happymoments.ua,代码行数:15,代码来源:MessagesController.php

示例2: actionAdmin

 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new Messages('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Messages'])) {
         $model->attributes = $_GET['Messages'];
     }
     $this->render('admin', array('model' => $model));
 }
开发者ID:kosenka,项目名称:yboard,代码行数:13,代码来源:MessagesController.php

示例3: actionSendMessages

 public function actionSendMessages()
 {
     $itemsSelected = Yii::app()->request->getParam('itemsSelected');
     $errorsSend = array();
     $messageModel = new Messages();
     $this->performAjaxValidation($messageModel);
     if (isset($_POST['Messages'])) {
         $messageModel->attributes = $_POST['Messages'];
         if ($messageModel->validate()) {
             if (is_array($itemsSelected) && count($itemsSelected)) {
                 ########################################################################
                 // check file errors
                 $fileErrors = array();
                 if (count($itemsSelected) > Mailing::MAILING_USERS_LIMIT) {
                     Yii::app()->user->setFlash('error', Yii::t('module_messages', 'max_newsletter_limit', array('{n}' => Mailing::MAILING_USERS_LIMIT)));
                     $fileErrors[] = 3;
                 }
                 $files = CUploadedFile::getInstancesByName('files');
                 if (isset($files) && count($files) > 0) {
                     foreach ($files as $file) {
                         $fName = $file->name;
                         $fSize = $file->size;
                         // check file size
                         if ($fSize > $messageModel->fileMaxSize) {
                             Yii::app()->user->setFlash('error', Yii::t('module_messages', 'Size {fName} exceeds the allowed (specified in php.ini) size {fileMaxSize} bytes.', array('{fName}' => $fName, 'fileMaxSize' => $messageModel->fileMaxSize)));
                             $fileErrors[] = 1;
                         }
                         // check file extension
                         $pathInfo = pathinfo($fName);
                         $fileName = $pathInfo['filename'];
                         $fileExt = strtolower($pathInfo['extension']);
                         $supportExtArr = explode(',', $messageModel->supportExt);
                         $supportExtArr = array_map('trim', $supportExtArr);
                         if (!in_array($fileExt, $supportExtArr)) {
                             Yii::app()->user->setFlash('error', Yii::t('module_messages', 'File extension: {fName} is not valid.', array('{fName}' => $fName)));
                             $fileErrors[] = 2;
                         }
                     }
                 }
                 if (count($fileErrors)) {
                     $this->redirect(array('admin'));
                     Yii::app()->end;
                 }
                 ########################################################################
                 // pre files
                 $filesPre = array();
                 $files = CUploadedFile::getInstancesByName('files');
                 $m = 1;
                 if (isset($files) && count($files) > 0) {
                     foreach ($files as $file) {
                         $m++;
                         $fName = $file->name;
                         // check file extension
                         $pathInfo = pathinfo($fName);
                         $fileName = $pathInfo['filename'];
                         $fileExt = strtolower($pathInfo['extension']);
                         // save file
                         $fullFileName = '_' . md5(uniqid()) . '.' . $fileExt;
                         $file->saveAs($messageModel->uploadPath . '/' . $fullFileName);
                         $filesPre[] = array('file_id' => $m, 'file_path' => $fullFileName, 'orig_file_path' => $fileName . '.' . $fileExt);
                     }
                 }
                 foreach ($itemsSelected as $item) {
                     $userModel = User::model()->findByPk($item);
                     if ($userModel) {
                         $messageModel = new Messages();
                         $messageModel->attributes = $_POST['Messages'];
                         $messageModel->message = str_replace('{username}', $userModel->username, $messageModel->message);
                         $messageModel->id_userFrom = Yii::app()->user->id;
                         $messageModel->id_userTo = $item;
                         $messageModel->is_read = Messages::STATUS_UNREAD_USER;
                         $messageModel->allowHtml = 1;
                         if ($messageModel->save(false)) {
                             // save file
                             if ($filesPre && count($filesPre)) {
                                 foreach ($filesPre as $fileOne) {
                                     $messageFile = new MessagesFiles();
                                     $messageFile->file_id = Yii::app()->user->id . $messageModel->id . $fileOne['file_id'];
                                     $messageFile->id_message = $messageModel->id;
                                     $messageFile->file_path = $fileOne['file_path'];
                                     $messageFile->orig_file_path = $fileOne['orig_file_path'];
                                     $messageFile->save();
                                 }
                             }
                         }
                     }
                 }
                 $messageModel->unsetAttributes();
                 if (!count($errorsSend)) {
                     Yii::app()->user->setFlash('success', tt('Message sent to the users', 'messages'));
                     $this->redirect(array('admin'));
                 } else {
                     Yii::app()->user->setFlash('error', tt('Message not sent to the users: ', 'messages') . ' ' . implode(', ', $errorsSend));
                     $this->redirect(array('admin'));
                 }
             } else {
                 Yii::app()->user->setFlash('error', tt('check_users_send', 'messages'));
                 $this->redirect(array('admin'));
             }
         } else {
//.........这里部分代码省略.........
开发者ID:barricade86,项目名称:raui,代码行数:101,代码来源:MailingController.php


注:本文中的Messages::unsetAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。