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


PHP Message::save方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a message if form has been submitted or renders the creation/update form
  */
 public function actionCreate()
 {
     if (isset($_POST['Message'])) {
         $resp = array('color' => '#FF6600', 'background_color' => '#FFFFCC', 'position' => 'top', 'removebutton' => 0);
         $model = new Message();
         $model->setAttributes($_POST['Message']);
         if ($model->save()) {
             $resp['message'] = Yii::t('translate', 'Message successfully saved');
             $resp['id'] = $model->id;
         } else {
             $errors = $this->errors($model);
             $resp['message'] = Yii::t('translate', '<p>Unable to save the message. Something went wrong!<p/>' . implode('<br/>', $errors));
         }
         echo $this->je($resp);
         Yii::app()->end();
     }
     $id = (int) Yii::app()->request->getParam('id');
     $lang = Yii::app()->request->getParam('lang');
     if ($id && $lang) {
         $model = MessageSource::model()->findByPk($id);
         if ($model) {
             $message = $model->loadMessage();
             $message->id = $model->id;
             $message->language = $lang;
             $this->renderPartial('form', array('model' => $message));
         } else {
             throw new CHttpException(400);
         }
     } else {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
 }
开发者ID:zwq,项目名称:unpei,代码行数:35,代码来源:TranslateController.php

示例2: create

 public function create()
 {
     $uid = Auth::user()->id;
     $message = new Message();
     $message->title = Input::get('title');
     $message->body = Input::get('body');
     $message->mass_message = 0;
     $message->author_id = $uid;
     if (Input::get('recipient') != null) {
         $recipient = DB::table('users')->where('email', '=', Input::get('recipient'))->first();
         $message->recipient_id = $recipient->id;
     } else {
         $message->recipient_id = null;
     }
     $message->save();
     if (Input::get('recipient') != null) {
         $email = Input::get('recipient');
         $username = $recipient->email;
         $body = Input::get('body');
         $data = ['username' => $username, 'body' => $body];
         Mail::send('emails.adminmessage', $data, function ($message) {
             $message->to(Input::get('recipient'), 'test')->subject(Input::get('title'));
         });
     }
     return Redirect::to('/user/messages');
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:26,代码来源:MessageController.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Lecture();
     if (isset($_POST['Lecture'])) {
         $model->attributes = $_POST['Lecture'];
         if (empty($model->owner_by)) {
             $model->owner_by = Yii::app()->user->getId();
         }
         if ($model->save()) {
             if (!Yii::app()->user->checkAccess('adminLecture')) {
                 $model->is_active = 0;
                 $adminUserIds = Yii::app()->db->createCommand()->select('userid')->from('authassignment')->where('itemname=:itemname', array(':itemname' => 'admin'))->queryColumn();
                 foreach ($adminUserIds as $id) {
                     $message = new Message();
                     $message->id_from = Yii::app()->user->getId();
                     $message->id_user = $id;
                     $message->subject = 'A new lecture is created';
                     $message->message = "User " . CHtml::link($this->viewer->username, $this->createUrl('account/view', array('id' => $this->viewer->getPrimaryKey()))) . " have just created the lecture " . CHtml::link($model->title, $this->createUrl('lecture/view', array('id' => $model->getPrimaryKey())));
                     $message->save();
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
         //            $model->fileIntro = $file = CUploadedFile::getInstance($model, 'fileIntro');
         //            if ($model->validate(array('fileIntro'))) {
         //                if ($file) {
         //                    $fileName = Yii::app()->params['video'] . '/' . $file->getName();
         //                    if (file_exists($fileName)) {
         //                        $fileName = Yii::app()->params['video'] . '/'
         //                                . time() . '_' . $file->getName();
         //                    }
         //                    if ($file->saveAs(strtolower($fileName), true)) {
         //                        /* $videoHelper = new CVideo();
         //                          $videoThumbnailName = $videoHelper->create_thumbnail($fileName,
         //                          Yii::app()->params['videoWidth'],
         //                          Yii::app()->params['videoHeight'],
         //                          Yii::app()->params['videoThumbnail']
         //                          );
         //                          $convertVideoFileName = $videoHelper->convertVideo($fileName);
         //
         //                          $model->path_video_intro = $convertVideoFileName;
         //                          $model->path_video_thumbnail = $videoThumbnailName; */
         //                        $model->path_video_intro = $fileName;
         //                        $model->path_video_thumbnail = Yii::app()->params['defaultLectureThumbnail'];
         //                    }
         //                }
         //                if ($model->save()) {
         //                    $this->redirect(array('view', 'id' => $model->id));
         //                }
         //            }
     }
     $params = $this->getActionParams();
     if ($params && array_key_exists('idCategory', $params)) {
         $model->id_category = (int) $params['idCategory'];
     }
     if (Yii::app()->user->checkAccess('adminLecture')) {
         $model->is_active = 1;
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:64,代码来源:LectureController.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($_ENV['SLACK_KEY'], $interactor);
     $channels = Channel::where('is_member', true)->get();
     foreach ($channels as $channel) {
         $latest = $channel->latest ?: 0;
         do {
             $response = $commander->execute('channels.history', ['channel' => $channel->sid, 'oldest' => $latest, 'count' => 1000]);
             $responseBody = $response->getBody();
             foreach ($responseBody['messages'] as $msg) {
                 $latest = $msg['ts'] > $latest ? $msg['ts'] : $latest;
                 $message = new Message();
                 foreach ($msg as $k => $v) {
                     $message->{$k} = is_string($v) ? $v : (object) $v;
                 }
                 $message->channel = $channel->sid;
                 $message->save();
             }
         } while ($responseBody['has_more']);
         $channel->latest = $latest;
         $channel->save();
     }
 }
开发者ID:kenyiu,项目名称:slacklogs,代码行数:31,代码来源:LoadMessagesCommand.php

示例5: actionCompose

 public function actionCompose($id = null)
 {
     $message = new Message();
     if (Yii::app()->request->getPost('Message')) {
         $receiverName = Yii::app()->request->getPost('receiver');
         $message->attributes = Yii::app()->request->getPost('Message');
         $message->sender_id = Yii::app()->user->getId();
         if ($message->save()) {
             Yii::app()->user->setFlash('messageModule', MessageModule::t('Message has been sent'));
             $this->redirect($this->createUrl('inbox/'));
         } else {
             if ($message->hasErrors('receiver_id')) {
                 $message->receiver_id = null;
                 $receiverName = '';
             }
         }
     } else {
         if ($id) {
             $receiver = call_user_func(array(call_user_func(array(Yii::app()->getModule('message')->userModel, 'model')), 'findByPk'), $id);
             if ($receiver) {
                 $receiverName = call_user_func(array($receiver, Yii::app()->getModule('message')->getNameMethod));
                 $message->receiver_id = $receiver->id;
             }
         }
     }
     $this->render(Yii::app()->getModule('message')->viewPath . '/compose', array('model' => $message, 'receiverName' => isset($receiverName) ? $receiverName : null));
 }
开发者ID:SoftScape,项目名称:open-school-CE,代码行数:27,代码来源:ComposeController.php

示例6: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (isset($_POST['Message'])) {
         $toUsers = explode(',', $_POST['toUsers']);
         $arrUserIds = array();
         foreach ($toUsers as $toUser) {
             $username = trim(strtok(trim($toUser), '-'));
             $user = Account::model()->findByAttributes(array('username' => $username));
             if ($user && $user->getPrimaryKey() != $this->viewer->getPrimaryKey()) {
                 $arrUserIds = array_merge($arrUserIds, array($user->getPrimaryKey()));
             }
         }
         if (!empty($arrUserIds)) {
             foreach ($arrUserIds as $userId) {
                 $model = new Message();
                 $model->subject = $_POST['Message']['subject'];
                 $model->message = $_POST['Message']['message'];
                 $model->id_from = $this->viewer->getPrimaryKey();
                 $model->id_user = $userId;
                 $model->save();
             }
         }
         Yii::app()->user->setFlash('message', Yii::t('flexiblearn', 'Your message is sent successfully !!!'));
         $this->redirect(array('manage'));
     }
     Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.autocomplete-min.js');
     Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/stylesheet/autocomplete.css');
     $this->render('create', array('model' => new Message()));
 }
开发者ID:laiello,项目名称:flexiblearning,代码行数:33,代码来源:MessageController.php

示例7: sendMessage

 /**
  * Send a Message populated with at least the following required fields:
  *   recipientId
  *   subject
  *   body
  * The following fields are optional:
  *   senderId may be null to indicate that it is a message from the system
  *   petListingId should be populated if the message pertains to a
  *     particular PetListing.
  * The other data fields of the message will be initialized automatically.
  * 
  * @param Message $message the Message to send
  */
 public function sendMessage($message)
 {
     $message->dateSent = Message::$objects->formatDateTime(new DateTime());
     $message->read = false;
     $message->save();
     // FIXME: If the user is subscribed to email notifications,
     // call emailMessage($message)
 }
开发者ID:CaffeinatedFox,项目名称:PAWS,代码行数:21,代码来源:MessagingService.php

示例8: addMessage

 public function addMessage($message, $type = Message::TYPE_INFO, $senderId = null)
 {
     $model = new Message();
     $model->text = $message;
     $model->type = $type;
     $model->date = time();
     $model->sender = $senderId;
     $model->save(false);
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:9,代码来源:MessengerModule.php

示例9: actionSend

 public function actionSend($username = null, $reply = null, $selfReply = null)
 {
     $user = new User();
     $model = new Message();
     $message = null;
     $users = array();
     $models = User::model()->findAll(array('condition' => 'FK_usertype = 1'));
     foreach ($models as $aUser) {
         $users[] = array('label' => CHtml::image($aUser->image_url, '', array('width' => '20px')) . '  ' . $aUser->first_name . ' ' . $aUser->last_name, 'value' => "\"" . $aUser->first_name . " " . $aUser->last_name . "\" <" . $aUser->username . ">");
     }
     if (isset($_POST['Message'])) {
         $model->attributes = $_POST['Message'];
         $model->FK_sender = Yii::app()->user->name;
         date_default_timezone_set('America/New_York');
         $model->date = date('Y-m-d H:i:s');
         $model->userImage = $model->fKSender->image_url;
         $model->subject = $_POST['Message']['subject'];
         $receivers = $this->getReceivers($_POST["receiver"]);
         $receiverCount = count($receivers);
         for ($i = 0; $i < $receiverCount; $i++) {
             $model->FK_receiver = $receivers[$i];
             if (User::model()->find("username=:username", array(':username' => $model->FK_receiver)) != null) {
                 $model->save();
             }
             $model = new Message();
             $model->attributes = $_POST['Message'];
             $model->FK_sender = Yii::app()->user->name;
             $model->date = date('Y-m-d H:i:s');
             $model->userImage = $model->fKSender->image_url;
             $model->subject = $_POST['Message']['subject'];
         }
         User::sendUserNotificationMessageAlart(Yii::app()->user->id, $model->FK_receiver, 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/message', 3);
         $link = CHtml::link('here', 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/message');
         $recive = User::model()->find("username=:username", array(':username' => $model->FK_receiver));
         if ($recive != NULL) {
             $message = "You just got a message from {$model->FK_sender}<br/> '{$model->message}'<br/> Access the message {$link}";
             //$html = User::replaceMessage($recive->username, $message);
             User::sendEmail($recive->email, "Virtual Job Fair Message", "Message from Virtual Job Fair", $message);
             //User::sendEmailMessageNotificationAlart($recive->email, $recive->username, $model->FK_sender, $message);
         }
         $this->redirect("/JobFair/index.php/message");
         return;
     }
     if ($reply != null) {
         $message = Message::model()->findByPK($reply);
         if (Yii::app()->user->name == $message->FK_sender) {
             $username = $message->FK_receiver;
         } else {
             $username = $message->FK_sender;
         }
         $model->subject = $message->subject;
         $model->message = "\n\n\nOn " . $message->date . ", " . $message->FK_sender . " wrote:\n" . $message->message;
     }
     $this->render('send', array('user' => $user, 'users' => $users, 'model' => $model, 'username' => $username));
 }
开发者ID:erick305,项目名称:testing,代码行数:55,代码来源:MessageController.php

示例10: createAdmin

 public function createAdmin(Request $request)
 {
     $this->validate($request, ['recipient' => 'required', 'content' => 'required']);
     $message = new Message();
     $message->sender_id = 1;
     $message->recipient_id = $request->input('recipient');
     $message->content = $request->input('content');
     $message->read = 0;
     $message->save();
     return $this->response();
 }
开发者ID:jamiehoward,项目名称:scavenger,代码行数:11,代码来源:ChallengeController.php

示例11: add_message

function add_message()
{
	global $CONF;
	$user = $_SESSION['user'];

	if ($user->getBanned()>0){
		return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
	}

	if (isset($_SESSION['message_last_flood_time'])){

		if ((time() - $_SESSION['message_last_flood_time']) < $CONF['message_time_to_wait_flood']){
			$time_to_wait = $CONF['message_time_to_wait_flood'] - (time() - $_SESSION['message_last_flood_time']);
			return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
		}

	}

	$_SESSION['message_last_flood_time']=time();

	$user = $_SESSION['user'];
	$userto=new RegUser();
	if (isset($_POST['user_to_id'])) $userto->setId($_POST['user_to_id']);
	elseif (isset($_POST['user_to_email'])) $userto->setEmail($_POST['user_to_email']);
	elseif (isset($_POST['user_to_nickname'])) $userto->setNickname($_POST['user_to_nickname']);
	else return array('ok'=>false, 'error'=>'undefined user to send');

	$message = new Message();

	$message->setUserFrom($user);
	$message->setUserTo($userto);

	$subject = strip_tags($_POST['subject']);
	if (strlen(str_replace(' ', '', $subject)) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short subject');
	$message->setSubject($subject);

	$msg = unescape_ampersand($_POST['msg']);
	if (strlen(str_replace(' ', '', strip_tags($msg))) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short message');

	$msg = strip_tags($msg, $CONF['permitted_tags_msg']);
	//$msg = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"_BLANK\" href=\"\\0\">\\0</a>", $msg); //detectando URLs
	$msg = text_linkify($msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$message->setMsg($msg);

	$result = $message->save();
	if ($result=='ok'){
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'problems with this message: '.$result);
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:54,代码来源:add_message.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $input = Input::all();
     $message = new Message();
     $message->from = $input['fromuser'];
     $message->to = $input['touser'];
     $message->message = $input['message'];
     $message->save();
     return Redirect::action('MessageController@show', array('id' => Input::get('touser')));
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:16,代码来源:MessageController.php

示例13: actionNewmessage

 public function actionNewmessage()
 {
     $message = new Message();
     if (isset($_POST['Message'])) {
         $message->attributes = $_POST['Message'];
         if ($message->save()) {
             $this->redirect(array('messages', 'id' => $message->id));
         }
     }
     $this->render('Newmessage', array('message' => $message));
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:11,代码来源:DefaultController.php

示例14: add

 public function add()
 {
     $user = $this->getUser();
     if (RequestMethods::post("share")) {
         $message = new Message(array("body" => RequestMethods::post("body"), "message" => RequestMethods::post("message"), "user" => $user['id']));
         if ($message->validate()) {
             $message->save();
             $this->redirect('/');
         }
     }
 }
开发者ID:vjroby,项目名称:library,代码行数:11,代码来源:messages.php

示例15: insertDummyData

 public function insertDummyData()
 {
     for ($i = 0; $i < 100; $i++) {
         $new_mess = new Message();
         $new_mess->from = "huy" . $i;
         $new_mess->to = "dummy" . $i;
         $new_mess->message = "test" . $i;
         $new_mess->sent_date = date('m/d/Y h:i:s');
         $new_mess->save(FALSE);
     }
 }
开发者ID:huynt57,项目名称:uet_messenger,代码行数:11,代码来源:MessageController.php


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