當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Messages::save方法代碼示例

本文整理匯總了PHP中Messages::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Messages::save方法的具體用法?PHP Messages::save怎麽用?PHP Messages::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Messages的用法示例。


在下文中一共展示了Messages::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionSavemessage

 public function actionSavemessage()
 {
     $subject = Yii::app()->Ini->v('subject');
     $message = Yii::app()->Ini->v('message');
     $to_usertype = Yii::app()->Ini->v('to_usertype');
     $from_id = Yii::app()->user->getId();
     $from_user_type = Yii::app()->user->role;
     $to_id = Yii::app()->Ini->v('receiver_id');
     $sent_date = date("Y-m-d H:i:s");
     $messages = new Messages();
     $messages->subject = $subject;
     $messages->message = $message;
     $messages->from_id = $from_id;
     $messages->to_id = $to_id;
     $messages->to_user_type = 'to_usertype';
     $messages->from_user_type = $from_user_type;
     $messages->date_sent = $sent_date;
     $this->sendEmailNotification($subject, $message, $to_id, Yii::app()->name);
     if ($messages->save()) {
         $status = array('success' => true);
     } else {
         $status = array('success' => false, 'error_message' => print_r($messages->getErrors()));
     }
     $this->renderJSON($status);
 }
開發者ID:seph-krueger,項目名稱:handyman,代碼行數:25,代碼來源:HomeownerController.php

示例2: action_delete

 public function action_delete()
 {
     $id = $this->request->param('id');
     DB::delete('address')->where('id', '=', $id)->execute();
     Messages::save('Address was successfully deleted!', 'info');
     $this->redirect('/address');
 }
開發者ID:Alex-AG,項目名稱:exeltek-po,代碼行數:7,代碼來源:Address.php

示例3: actionCreate

 /** Receives the form submission from the new action and creates the new object. */
 public function actionCreate()
 {
     // create a new message
     $messages = new Messages();
     $name = $messages->generateNewName($this->request->getPost());
     if (empty($name)) {
         $this->flashFail = 'The message cannot be blank';
         $this->redirectTo('topics/new');
     }
     $stamp = date("Y-m-d H:i:s", mktime());
     $save['name'] = $this->userRow['name'];
     // create new topic
     $save['name'] = $this->request->getPost('name');
     $save['created_at'] = $save['updated_at'] = $stamp;
     $save['created_by'] = $this->userRow['name'];
     $save['is_archived'] = 0;
     $topicId = $this->topics->save($save);
     // create new message... read by us
     $newId = $messages->save(array('topics_id' => $topicId, 'created_at' => $stamp, 'name' => $name, 'user' => $this->userRow['name'], 'read_by' => "!{$this->userRow['id']}!"));
     // create new mailer
     //$mailer = new Mailer();
     // save the text
     $nodes = new Nodes();
     $nodes->saveMessage(0, $this->request->getPost(0), $topicId, $newId, $this->userRow['name'], $mailer);
     // send email to all recipients
     //$users = new Users();
     //foreach ($users->select('email')->findAll() as $user) $recipients[] = $user['email'];
     //$mailer->sendMessage($recipients, $newId, $topicId, $this->topics);
     // redirect to the new message
     $this->redirectTo("messages/show/{$topicId}/{$newId}");
 }
開發者ID:radekstepan,項目名稱:Fireside,代碼行數:32,代碼來源:TopicsPresenter.php

示例4: action_index

 public function action_index()
 {
     if (!Group::current('allow_assign')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $ids = array_keys(Arr::get($_POST, 'job', array()));
     if (!$ids) {
         Messages::save('Please, select at least one job!');
     } else {
         $jobs = Database_Mongo::collection('jobs');
         $result = $jobs->find(array('_id' => array('$in' => $ids)));
         $count = 0;
         foreach ($result as $job) {
             if (Arr::get($job, 'status') == Enums::STATUS_ARCHIVE || Arr::get($job, 'status') == Enums::STATUS_COMPLETE || Arr::get($job, 'status') == Enums::STATUS_PENDING) {
                 if ($job['status'] == Enums::STATUS_PENDING) {
                     $submissions = Database_Mongo::collection('submissions')->find(array('job_key' => $job['_id'], 'active' => 1))->count();
                     if ($submissions) {
                         continue;
                     }
                 }
                 $update = array('$set' => array('last_update' => time()));
                 if (Arr::get($job, 'assigned')) {
                     $update['$set']['status'] = Enums::STATUS_ALLOC;
                 } else {
                     $update['$unset']['status'] = 1;
                 }
                 $jobs->update(array('_id' => $job['_id']), $update);
                 $count++;
             }
         }
         Messages::save($count . ' jobs were succesfully reset to initial state', 'success');
     }
     $this->redirect('/search');
 }
開發者ID:nikulinsanya,項目名稱:exeltek,代碼行數:34,代碼來源:Reset.php

示例5: action_index

 public function action_index()
 {
     if (!Group::current('allow_assign')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $ids = array_keys(Arr::get($_POST, 'job', array()));
     if (!$ids) {
         Messages::save('Please, select at least one job!');
     } else {
         $jobs = Database_Mongo::collection('jobs');
         $submissions = Database_Mongo::collection('submissions')->distinct('job_key', array('job_key' => array('$in' => $ids), 'active' => 1));
         $ids = array_values(array_diff($ids, $submissions));
         $result = Database_Mongo::collection('jobs')->find(array('_id' => array('$in' => $ids)));
         print_r($result->explain());
         $count = 0;
         foreach ($result as $job) {
             if (!in_array(Arr::get($job, 'status'), array(Enums::STATUS_ARCHIVE, Enums::STATUS_COMPLETE))) {
                 $jobs->update(array('_id' => $job['_id']), array('$set' => array('last_update' => time(), 'status' => Enums::STATUS_COMPLETE)));
                 $count++;
             }
         }
         Messages::save($count . ' jobs were succesfully completed', 'success');
     }
     $this->redirect('/search');
 }
開發者ID:nikulinsanya,項目名稱:exeltek,代碼行數:25,代碼來源:Complete.php

示例6: createMessage

 public static function createMessage($fromUserId, $toUserId, $data)
 {
     $messages = new Messages();
     $messages->from_user_id = $fromUserId;
     $messages->to_user_id = $toUserId;
     $messages->attributes = $data;
     return $messages->save();
 }
開發者ID:romeo14,項目名稱:pow,代碼行數:8,代碼來源:MessagesApi.php

示例7: action_delete

 public function action_delete()
 {
     $id = $this->request->param('id');
     if (!Group::get(User::get($id, 'group_id'), 'is_admin')) {
         DB::delete('users')->where('id', '=', $id)->execute();
         Messages::save('User successfully deleted!', 'info');
     }
     $this->redirect('/security/users');
 }
開發者ID:nikulinsanya,項目名稱:exeltek,代碼行數:9,代碼來源:Users.php

示例8: save

 public function save()
 {
     $message = new Messages();
     $message->sender_id = Yii::app()->user->id;
     $message->receiver_id = $this->receiver_id;
     $message->text = $this->text;
     $message->is_new = TRUE;
     $message->save();
 }
開發者ID:andrelinoge,項目名稱:rezydent,代碼行數:9,代碼來源:MessageForm.php

示例9: action_delete

 public function action_delete()
 {
     if (!User::current('is_admin') && !Group::current('item_remove')) {
         throw new HTTP_Exception_403('Forbidden');
     }
     $id = $this->request->param('id');
     DB::delete('items')->where('id', '=', $id)->execute();
     Messages::save('Item was successfully deleted!', 'info');
     $this->redirect('/items');
 }
開發者ID:Alex-AG,項目名稱:exeltek-po,代碼行數:10,代碼來源:Items.php

示例10: action_delete

 public function action_delete()
 {
     $id = $this->request->param('id');
     $users = DB::select('id')->from('users')->where('company_id', '=', $id)->limit(1)->execute()->get('id');
     if (!$users) {
         DB::delete('companies')->where('id', '=', $id)->execute();
         Messages::save('Company successfully deleted!', 'info');
     }
     $this->redirect('/security/companies');
 }
開發者ID:nikulinsanya,項目名稱:exeltek,代碼行數:10,代碼來源:Companies.php

示例11: render

 function render()
 {
     $message = new Messages($this->db);
     $message->key = 'Second message';
     $message->message = 'This is the second message inserted from code';
     $message->save();
     $messages = new Messages($this->db);
     $msg = $messages->all()[0];
     $this->f3->set('msg', $msg);
     $template = new Template();
     echo $template->render('template.htm');
 }
開發者ID:bandjam,項目名稱:site-base,代碼行數:12,代碼來源:MainController.php

示例12: action_index

 public function action_index()
 {
     $id = strval(Arr::get($_GET, 'id'));
     $job = Database_Mongo::collection('jobs')->findOne(array('_id' => $id), array('data' => 1));
     if (!$job) {
         throw new HTTP_Exception_404('Not found');
     }
     $point = strval(Arr::get($_GET, 'point'));
     $archive = Database_Mongo::collection('archive')->findOne(array('_id' => new MongoId($point)), array('update_time' => 1));
     if (!$archive) {
         throw new HTTP_Exception_404('Not found');
     }
     $result = Database_Mongo::collection('archive')->find(array('job_key' => $id, 'update_time' => array('$gt' => $archive['update_time'])))->sort(array('update_time' => -1));
     $ids = array();
     $values = array();
     foreach ($result as $item) {
         $ids[] = $item['_id'];
         foreach (Arr::get($item, 'data', array()) as $key => $data) {
             $job['data'][$key] = $values[$key] = $data['old_value'];
         }
     }
     foreach ($values as $key => $value) {
         if ($value) {
             $new['$set']['data.' . $key] = $value;
         } else {
             $new['$unset']['data.' . $key] = 1;
         }
     }
     if ($new) {
         $new['$set']['last_update'] = $archive['update_time'];
     }
     $submissions = array();
     $result = Database_Mongo::collection('submissions')->find(array('job_key' => $id, 'process_time' => array('$gt' => $archive['update_time'])));
     foreach ($result as $item) {
         if (Arr::path($job, $item['key'], '') != $item['value']) {
             $submissions[] = $item['_id'];
         }
     }
     if ($new) {
         Database_Mongo::collection('submissions')->update(array('_id' => array('$in' => $submissions)), array('$unset' => array('process_time' => 1), '$set' => array('active' => 1)));
         Database_Mongo::collection('jobs')->update(array('_id' => $id), $new);
         Database_Mongo::collection('archive')->remove(array('_id' => array('$in' => $ids)));
     }
     $message = '';
     if (count($ids)) {
         $message .= count($ids) . ' changes were removed. ';
     }
     if (count($submissions)) {
         $message .= count($submissions) . ' submissions were unapproved. ';
     }
     Messages::save('Ticket ' . $id . ' successfully rolled back to ' . date('d-m-Y H:i', $archive['update_time']) . '. ' . $message);
     die(json_encode(array('success' => true)));
 }
開發者ID:nikulinsanya,項目名稱:exeltek,代碼行數:53,代碼來源:Timemachine.php

示例13: action_delete

 public function action_delete()
 {
     $id = $this->request->param('id');
     if (!User::get($id, 'is_admin')) {
         Database::instance()->begin();
         DB::delete('company_notifications')->where('user_id', '=', $id)->execute();
         DB::delete('users')->where('id', '=', $id)->execute();
         Database::instance()->commit();
         Messages::save('User successfully deleted!', 'info');
     }
     $this->redirect('/users');
 }
開發者ID:Alex-AG,項目名稱:exeltek-mima,代碼行數:12,代碼來源:Users.php

示例14: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Messages();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Messages'])) {
         $model->attributes = $_POST['Messages'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->renderPartial('create', array('model' => $model));
 }
開發者ID:holyshved,項目名稱:guestbook,代碼行數:17,代碼來源:MessagesController.php

示例15: action_delete

 public function action_delete()
 {
     $id = $this->request->param('id');
     $users = DB::select('id')->from('users')->where('company_id', '=', $id)->limit(1)->execute()->get('id');
     if (!$users) {
         Database::instance()->begin();
         DB::delete('company_notifications')->where('company_id', '=', $id)->execute();
         DB::delete('companies')->where('id', '=', $id)->execute();
         Database::instance()->commit();
         Messages::save('Company successfully deleted!', 'info');
     }
     $this->redirect('/companies');
 }
開發者ID:Alex-AG,項目名稱:exeltek-mima,代碼行數:13,代碼來源:Companies.php


注:本文中的Messages::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。