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


PHP Message::insert方法代码示例

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


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

示例1: saveNew

 static function saveNew($from, $to, $content, $source)
 {
     $sender = Profile::staticGet('id', $from);
     if (!$sender->hasRight(Right::NEWMESSAGE)) {
         // TRANS: Client exception thrown when a user tries to send a direct message while being banned from sending them.
         throw new ClientException(_('You are banned from sending direct messages.'));
     }
     $msg = new Message();
     $msg->from_profile = $from;
     $msg->to_profile = $to;
     $msg->content = common_shorten_links($content);
     $msg->rendered = common_render_text($content);
     $msg->created = common_sql_now();
     $msg->source = $source;
     $result = $msg->insert();
     if (!$result) {
         common_log_db_error($msg, 'INSERT', __FILE__);
         // TRANS: Message given when a message could not be stored on the server.
         return _('Could not insert message.');
     }
     $orig = clone $msg;
     $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
     $result = $msg->update($orig);
     if (!$result) {
         common_log_db_error($msg, 'UPDATE', __FILE__);
         // TRANS: Message given when a message could not be updated on the server.
         return _('Could not update message with new URI.');
     }
     return $msg;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:30,代码来源:Message.php

示例2: newMessage

function newMessage()
{
    $results = array();
    $results['pageTitle'] = "New Message";
    $results['formAction'] = "newMessage";
    if (isset($_POST['saveChanges'])) {
        $message = new Message();
        $message->fillWithForm($_POST);
        $message->insert();
        header("Location: admin.php?action=listMessages&status=changesSaved");
    } elseif (isset($_POST['cancel'])) {
        //Пользователь сбросил результаты редактирования
        header("Location: admin.php?action=listMessages");
    } else {
        //Пользователь еще не получил форму - выводим ее
        require TEMPLATE_PATH . "/admin/editMessage.php";
    }
}
开发者ID:aloget,项目名称:octopusServer,代码行数:18,代码来源:admin.php

示例3: saveNew

 static function saveNew($from, $to, $content, $source)
 {
     $msg = new Message();
     $msg->from_profile = $from;
     $msg->to_profile = $to;
     $msg->content = common_shorten_links($content);
     $msg->rendered = common_render_text($content);
     $msg->created = common_sql_now();
     $msg->source = $source;
     $result = $msg->insert();
     if (!$result) {
         common_log_db_error($msg, 'INSERT', __FILE__);
         return _('Could not insert message.');
     }
     $orig = clone $msg;
     $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
     $result = $msg->update($orig);
     if (!$result) {
         common_log_db_error($msg, 'UPDATE', __FILE__);
         return _('Could not update message with new URI.');
     }
     return $msg;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:23,代码来源:Message.php

示例4: testGetValidMessageByOrgId

 /**
  *test for grabbing a message by OrgId
  */
 public function testGetValidMessageByOrgId()
 {
     //get the count of the number of rows in the database
     $numRows = $this->getConnection()->getRowCount("message");
     //create a new message and insert into mySQL
     $message = new Message(null, $this->listing->getListingId(), $this->organization->getOrgId(), $this->VALID_MESSAGE_TEXT);
     $message->insert($this->getPDO());
     //grab data from SQL and ensure it matches
     $pdoMessage = Message::getMessageByOrgId($this->getPDO(), $message->getOrgId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("message"));
     $this->assertSame($pdoMessage[0]->getListingId(), $this->listing->getListingId());
     $this->assertSame($pdoMessage[0]->getOrgId(), $this->organization->getOrgId());
     $this->assertSame($pdoMessage[0]->getMessageText(), $this->VALID_MESSAGE_TEXT);
 }
开发者ID:brbrown59,项目名称:bread-basket,代码行数:17,代码来源:message-test.php

示例5: testPutValidMessage

 public function testPutValidMessage()
 {
     //create a new message
     $newMessage = new Message(null, $this->VALID_MESSAGE_ID, $this->VALID_LISTING_Id, $this->VALID_ORG_ID, $this->VALID_MESSAGE_ID, $this->VALID_MESSAGE_TEXT);
     $newMessage->insert($this->getPDO());
     //run a get request to establish session tokens
     $this->guzzle->get('http://bootcamp-coders.cnm.edu/~bread-basket/public_html/php/api/message/');
     //grab the data from guzzle and enforce the status match our expectations
     $response = $this->guzzle->put('http://bootcamp-coders.cnm.edu/~bread-basket/public_html/php/api/message/' . $newMessage->getMessage(), ['headers' => ['X-XRF-TOKEN' => $this->getXsrfToken()], 'json' => $newMessage]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBpdy();
     $alertLevel = json_decode($body);
     $this->assertSame(200, $alertLevel->status);
 }
开发者ID:brbrown59,项目名称:bread-basket,代码行数:14,代码来源:mess-api-test.php

示例6: catch

                                         } else {
                                             $error = $ltask[7];
                                         }
                                     } catch (Exception $e) {
                                         $error .= $e->getMessage() . "\n";
                                     }
                                 }
                             } else {
                                 if ($_POST['action'] === "addMsg") {
                                     if ($loggedin === true) {
                                         try {
                                             $msg = new Message();
                                             $msg->msg = $_POST['msg'];
                                             $msg->tid = $team->id;
                                             $msg->adm = $admin;
                                             $msg->insert();
                                         } catch (Exception $e) {
                                             $error .= $e->getMessage() . "\n";
                                         }
                                     } else {
                                         $error .= $msgboard[3] . "\n";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:zysicing,项目名称:CTFSys,代码行数:31,代码来源:base.php

示例7: InvalidArgumentException

     if (empty($requestObject->messageText) === true) {
         throw new InvalidArgumentException("Message field cannot be empty", 405);
     }
     //perform the actual put or post
     if ($method === "PUT") {
         $message = Message::getMessageByMessageId($pdo, $id);
         if ($message === null) {
             throw new RuntimeException("Message does not exist", 404);
         }
         $message = new Message($id, $requestObject->listingId, $requestObject->orgId, $requestObject->messageText);
         $message->update($pdo);
         $reply->message = "Message updated Ok";
     } else {
         if ($method === "POST") {
             $message = new Message(null, $requestObject->listingId, $requestObject->orgId, $requestObject->messageText);
             $message->insert($pdo);
             $reply->message = "Message created ok";
         }
     }
 } else {
     if ($method === "DELETE") {
         //verifyXsrf();
         $message = Message::getMessageByMessageId($pdo, $id);
         if ($message === null) {
             throw new RuntimeException("Message does not exist", 404);
         }
         $message->delete($pdo);
         $deleteObject = new stdClass();
         $deleteObject->messageId = $id;
         $reply->message = "Message deleted successfully";
     } else {
开发者ID:brbrown59,项目名称:bread-basket,代码行数:31,代码来源:index.php

示例8: confirmAction

 public function confirmAction()
 {
     $ride = $this->_getParam("ride");
     $user = $this->_getParam("username");
     if (!empty($ride) && !empty($user)) {
         require_once APPLICATION_PATH . "/model/UserRide.php";
         $table = new UserRide();
         $table->update(array('confirmation' => true), array($table->getAdapter()->quoteInto("ride = ?", $ride), $table->getAdapter()->quoteInto("user = ?", $user)));
         $date = new Zend_Date();
         $owner = Zend_Auth::getInstance()->getIdentity()->username;
         $mess['sender'] = $owner;
         $mess['receiver'] = $user;
         $mess['date'] = $date->getIso();
         $mess['subject'] = "Conferma partecipazione a viaggio";
         $mess['text'] = "{$owner} ha accettato la tua partecipazione al suo viaggio. Contattalo per accordarvi sui dettagli!";
         require_once APPLICATION_PATH . "/model/Message.php";
         $table = new Message();
         $table->insert($mess);
     }
 }
开发者ID:Kjir,项目名称:carpond,代码行数:20,代码来源:RideController.php

示例9: sprintf

 } else {
     if ($dataType == "detail" && $module == "message") {
         try {
             Tool::logger(__METHOD__, __LINE__, sprintf("action: %s", $action), _LOG_DEBUG);
             $message = new Message(_NONE);
             $message->messageId = isset($_REQUEST["id"]) ? $_REQUEST["id"] : _NONE;
             $message->email = isset($_REQUEST["email"]) ? $_REQUEST["email"] : "";
             $message->uname = Tool::unescape(isset($_REQUEST["uname"]) ? $_REQUEST["uname"] : "");
             $message->phone = isset($_REQUEST["phone"]) ? $_REQUEST["phone"] : "";
             $message->content = Tool::unescape(isset($_REQUEST["message"]) ? $_REQUEST["message"] : "");
             if ($message->messageId > 0) {
                 $message = Message::read($message);
             }
             $message->reply = isset($_REQUEST["reply"]) ? $_REQUEST["reply"] : $message->reply;
             if ($action == "insert") {
                 $newId = Message::insert($message);
             } else {
                 if ($action == "update") {
                     Message::update($message);
                     $emailResult = false;
                     //发送结果
                     include "email.php";
                     //发送邮件
                     if ($emailResult === false) {
                         $result = "邮件回复失败,请重试";
                         Tool::logger(__METHOD__, __LINE__, sprintf("回复邮件[%s]失败,请重试", $message->email), _LOG_ERROR);
                     }
                 } else {
                     if ($action == "delete") {
                         Message::delete($message);
                     }
开发者ID:BassYang1,项目名称:YueXinChina,代码行数:31,代码来源:update.php


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