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


PHP Chat::save方法代码示例

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


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

示例1: addchatconfirmAction

 public function addchatconfirmAction()
 {
     $this->view->disable();
     // print_r($_POST);
     $user_id = $this->session->get('user_id');
     if ($this->request->isAjax() && isset($_POST['type_chat_mess']) && $_POST['form']['text']) {
         $chat = new Chat();
         $chu = new ChatHasUser();
         $micro = new ChatMicroDialog();
         $mess = new MessageChat();
         $chat->created_id = $user_id;
         $chat->creation_date = date("Y-m-d-H-i-s");
         $chat->save();
         $chu->chat_id = $chat->id;
         $chu->user_id = $user_id;
         $chu->save();
         $mess->chat_id = $chat->id;
         $mess->text = $_POST['form']['text'];
         $mess->author_id = $user_id;
         $mess->type = $_POST['type_chat_mess'];
         $mess->creation_date = date("Y-m-d-H-i-s");
         $mess->save();
         $micro->chat_id = $chat->id;
         $micro->base_mess_id = $mess->id;
         $micro->created_id = $user_id;
         $micro->creation_date = date("Y-m-d-H-i-s");
         $micro->save();
         $mess->micro_dialog_id = $micro->id;
         $mess->save();
         echo json_encode(array('message' => 'Тема создана', 'chat_id' => $chat->id));
     } else {
         echo json_encode(array('error' => 'Заполните поле сообщения'));
     }
 }
开发者ID:qtebest-dev,项目名称:tractor,代码行数:34,代码来源:ChatController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $chat = new Chat();
     //Validation
     $rules = array('users' => 'required', 'subject' => 'required', 'text' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('/community/chats/create')->withInput()->withErrors($validator);
     }
     $chat->subject = Input::get('subject');
     $chat->last_reply = date("Y-m-d H:i:s");
     $chat->save();
     $chat->user()->attach(Auth::user()->id);
     foreach (Input::get('users') as $id) {
         $chat->user()->attach($id);
     }
     $reply = new Reply();
     $reply->text = Input::get('text');
     $reply->chat_id = $chat->id;
     $reply->user_id = Auth::user()->id;
     $reply->save();
     //Set up notifications for this chat
     foreach ($chat->user->all() as $user) {
         $reply->notification()->save($user);
     }
     $notification = Notification::where('user_id', '=', Auth::user()->id)->where('reply_id', '=', $reply->id)->firstOrFail();
     $notification->has_read = 1;
     $notification->save();
     return Redirect::to('/community/chats')->with('flash_chat', 'Your chat has been sent')->with('alert_class', 'alert-success');
 }
开发者ID:alisha,项目名称:seed,代码行数:35,代码来源:ChatController.php

示例3: save

 function save($id = FALSE)
 {
     if ($_POST) {
         $chat = new Chat($id);
         $_POST['user_id'] = $this->session->userdata('id');
         $chat->from_array($_POST);
         $chat->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect('chats/admin/chats');
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:11,代码来源:chats.php

示例4: getLoggedInUserGuid

 function __construct()
 {
     // Check if chat already exists
     $user_one = getLoggedInUserGuid();
     $user_two = pageArray(2);
     $chat = getEntity(array("type" => "Chat", "metadata_name_value_pairs" => array(array("name" => "user_one", "value" => $user_one), array("name" => "user_two", "value" => $user_two))));
     if (!$chat) {
         $chat = getEntity(array("type" => "Chat", "metadata_name_value_pairs" => array(array("name" => "user_one", "value" => $user_two), array("name" => "user_two", "value" => $user_one))));
     }
     if (!$chat) {
         $chat = new Chat();
         $chat->user_one = $user_one;
         $chat->user_two = $user_two;
         $chat->save();
     }
     $chat->user_one_closed = false;
     $chat->user_two_closed = false;
     $chat->save();
     forward();
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:20,代码来源:CreateChatActionHandler.php

示例5: yiichat_post

 /**
  * post a message into your database.
  * @param integer $relatedID
  * @param integer $userID
  * @param string $message
  * @param mixed $data
  * @return mixed Model otherwise false
  */
 public function yiichat_post($relatedID, $userID, $message, $data)
 {
     if (!empty($message)) {
         $chat = new Chat();
         $chat->relatedID = $relatedID;
         $chat->userID = $userID;
         $chat->userLabel = $this->getIdentityName();
         $chat->text = $message;
         $chat->data = serialize($data);
         if ($chat->save()) {
             return $this->restructureChat($chat);
         }
     }
     return false;
 }
开发者ID:andryluthfi,项目名称:annotation-tools,代码行数:23,代码来源:ChatHandler.php

示例6: actionSave_chat

 /**
  * Добавление, редактирование, удаление сообщений в чате
  */
 public function actionSave_chat()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->request->isAjaxRequest) {
             $result = false;
             if (isset($_POST['idChat'])) {
                 $model = Chat::model()->findAllByPk((int) $_POST['idChat']);
             } else {
                 $model = new Chat();
             }
             switch ($_POST['action']) {
                 case 'add':
                     $model->text = trim(htmlspecialchars($_POST['text']));
                     $model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser'];
                     if ($model->save()) {
                         $model->date = date('d.m.Y H:i', $model->date);
                         $model->nameUser = empty($this->_user) ? 'Админ' : (!empty($this->_user['lastFirstName']) ? $this->_user['lastFirstName'] : $this->_user['login']);
                         $result = $model;
                     }
                     break;
                 case 'edit':
                     if ($model->update(array('active' => (int) $_POST['active']))) {
                         $result = $model;
                     }
                     break;
                 case 'delete':
                     if ($model->delete()) {
                         $result = true;
                     }
                     break;
             }
             echo CJSON::encode(array('result' => $result));
             exit;
         }
     }
 }
开发者ID:vitalya-xxx,项目名称:vitacod.ru,代码行数:39,代码来源:ChatController.php

示例7: actionPostChat

 function actionPostChat()
 {
     if (isset($_REQUEST['content'])) {
         $txt = trim($_REQUEST['content']);
         if (strlen($txt) > 0) {
             $model = new Chat();
             $model->user = Yii::app()->user->name;
             $model->content = $txt;
             $model->save(false);
         }
     }
 }
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:12,代码来源:SiteController.php

示例8: sendChat

function sendChat($pageId)
{
    $from = $_SESSION['username'];
    $to = Filter::text($_POST['to']);
    $message = $_POST['message'];
    $_SESSION['openChatBoxes'][$to] = date('Y-m-d H:i:s', time());
    $fromUsername = User::load($from)->getUsername();
    $messagesan = sanitize($message);
    if (!isset($_SESSION['chatHistory'][$to])) {
        $_SESSION['chatHistory'][$to] = '';
    }
    $_SESSION['chatHistory'][$to] .= <<<EOD
\t\t\t\t\t   {
\t\t\t"s": "1",
\t\t\t"f": "{$fromUsername}",
\t\t\t"m": "{$messagesan}"
\t   },
EOD;
    unset($_SESSION['tsChatBoxes'][$to]);
    $chat = new Chat(array('sender' => mysql_real_escape_string($from), 'recipient' => mysql_real_escape_string($to), 'message' => mysql_real_escape_string($messagesan), 'sent' => '2013-05-03 12:02:48'));
    $chat->save();
    $newId = $chat->getID();
    if (empty($_SESSION['openChatBoxes']["{$pageId}"])) {
        $_SESSION['openChatBoxes']["{$pageId}"] = $newId;
    } else {
        if ($newId - 1 == $_SESSION['openChatBoxes']["{$pageId}"]) {
            $_SESSION['openChatBoxes']["{$pageId}"] = $newId;
        }
    }
    echo formatParagraphs($messagesan, true);
    exit(0);
}
开发者ID:malimu,项目名称:Pipeline,代码行数:32,代码来源:chat.php

示例9: doActions

 function doActions($conversation_id = null, $character_id = null)
 {
     $conversation = $this->find('first', array('conditions' => array('Conversation.id' => $conversation_id)));
     if (!empty($conversation['Quest'])) {
         App::import('Model', 'Chat');
         $Chat = new Chat();
         foreach ($conversation['Quest'] as $quest) {
             switch ($quest['ActionsConversation']['type']) {
                 case "getquest":
                     $this->Quest->bindModel(array('hasMany' => array('CharactersQuest')));
                     $this->Quest->CharactersQuest->save(array('id' => null, 'quest_id' => $quest['id'], 'character_id' => $character_id, 'completed' => 'no'));
                     // Maybe this user has already the quest done, so try to update it...
                     $this->Quest->update($quest['id'], $character_id);
                     $ChatData = array();
                     $ChatData['id'] = null;
                     $ChatData['type'] = 'system';
                     $ChatData['character_id_from'] = 0;
                     $ChatData['character_id_to'] = $character_id;
                     $ChatData['message'] = sprintf(__('Quest %s accepted.', true), '[quest]' . $quest['name'] . '[/quest]');
                     $ChatData['display'] = 'yes';
                     $Chat->create();
                     $Chat->save($ChatData);
                     $this->actionHappen = true;
                     break;
                 case "completequest":
                     $this->Quest->update($quest['id'], $character_id, true);
                     $ChatData['id'] = null;
                     $ChatData['type'] = 'system';
                     $ChatData['character_id_from'] = 0;
                     $ChatData['character_id_to'] = $character_id;
                     $ChatData['message'] = sprintf(__('Quest %s completed.', true), '[quest]' . $quest['name'] . '[/quest]');
                     $ChatData['display'] = 'yes';
                     $Chat->create();
                     $Chat->save($ChatData);
                     $this->actionHappen = true;
                     break;
             }
         }
     }
     /*
     $this->bindModel(array('hasMany' => array('ActionsConversation')));
     $someActions = $this->ActionsConversation->find('all', array('conditions' => array('ActionsConversation.conversation_id' => $conversation_id)));
     if(!empty($someActions)) {
     	App::import('Model', 'Action');
     	$Action = new Action();
     	foreach($someActions as $action) {
     		$Action->perform($action['ActionsConversation']['action_id'], $character_id);
     	}
     }
     */
 }
开发者ID:MortalROs,项目名称:Naxasius-Game-Engine,代码行数:51,代码来源:conversation.php

示例10: create

 /**
  * Store a newly chat.
  *
  * @return Response
  */
 public function create()
 {
     if (!is_null($user = User::find((int) Input::get('user_id')))) {
         if (!Auth::user()->isBlocked($user->id)) {
             $result = DB::select('select c.chat_id, count(c.chat_id) as count ' . 'from chats_members c where c.chat_id in (select b.chat_id from chats_members b where b.chat_id in (select a.chat_id from chats_members a where a.user_id = ?) and b.user_id = ?) ' . 'group by c.chat_id having c.count = 2 limit 1;', array(Auth::user()->id, $user->id));
             if (count($result) > 0) {
                 $chatId = $result[0]->chat_id;
                 $chat = Chat::find($chatId);
             } else {
                 $chat = new Chat();
                 $chat->owner_id = Auth::user()->id;
                 $chat->topic = '';
                 $chat->save();
                 $chatId = $chat->id;
                 $chatMember = new ChatMember();
                 $chatMember->chat_id = $chatId;
                 $chatMember->user_id = Auth::user()->id;
                 $chatMember->save();
                 $chatMember = new ChatMember();
                 $chatMember->chat_id = $chatId;
                 $chatMember->user_id = $user->id;
                 $chatMember->save();
                 $chatHystory = new ChatHistory();
                 $chatHystory->chat_id = $chatId;
                 $chatHystory->event = 'created';
                 $chatHystory->save();
                 $chat = Chat::find($chat->id);
             }
             return $this->respond(array('chat_id' => $chat->id, 'owner_id' => $chat->owner_id, 'topic' => $chat->topic, 'timestamp' => $chat->getTimestamp(), 'users' => $chat->getUsersArray()));
         } else {
             return $this->respondInsufficientPrivileges('Can\'t send message to the user');
         }
     } else {
         return $this->respondNotFound('User doesn\'t exist');
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:41,代码来源:ChatsController.php


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