Ejemplo n.º 1
0
 public static function delete($id, $topic_id)
 {
     self::checkLoggedIn();
     self::verifyRightsforDeletingOrEditingMessage($id);
     Message::delete($id);
     Redirect::to('/topics/' . $topic_id);
 }
 public function delete()
 {
     if ($this->id) {
         parent::delete();
     } else {
         throw new TheliaAdminException("Message not found", TheliaAdminException::MESSAGE_NOT_FOUND);
     }
     redirige("message.php");
 }
Ejemplo n.º 3
0
 public static function destroyMessage($id)
 {
     $message = new Message(Message::find($id));
     $user_id = $message->user_id;
     $thread_id = $message->thread_id;
     $message->delete();
     //Updating participants list
     ForumUser::changePostAmount($user_id, $thread_id, -1);
     Redirect::to('/thread/' . $message->thread_id, array('message' => 'Message deleted.'));
 }
Ejemplo n.º 4
0
 /**
  * deleteAction removes a message
  */
 public function deleteAction()
 {
     $id = $this->_getParam("id");
     if (!empty($id)) {
         require_once APPLICATION_PATH . "/model/Message.php";
         $table = new Message();
         $table->delete($table->getAdapter()->quoteInto('id = ?', $id));
         $this->_helper->redirector('index', 'message', 'default', array('deleted' => true));
         return;
     }
     $this->_helper->redirector('index', 'message');
 }
Ejemplo n.º 5
0
 private function deleteMessage($message_id)
 {
     $message = new Message($message_id);
     if ($message->reported) {
         $this->setCarryMessage('Cannot delete a reported message');
         return;
     }
     if ($message->to_user_id != \Current_User::getId()) {
         $this->setCarryMessage('Could not delete message.');
         return;
     }
     $message->delete();
 }
Ejemplo n.º 6
0
 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $rmmessages = isset($params[1]) ? $params[1] : 15;
     $channel = $message->channel;
     $num = 0;
     $channel->message_count = $rmmessages + 1;
     foreach ($channel->messages as $key => $message) {
         try {
             $message->delete();
         } catch (PartRequestFailedException $e) {
             continue;
         }
         $num++;
     }
     $message->reply("Flushed {$num} messages.");
 }
Ejemplo n.º 7
0
 /**
  * Function: delete
  * Deletes the given topic. Calls the "delete_topic" trigger and passes the <Topic> as an argument.
  *
  * Parameters:
  *     $id - The topic to delete.
  */
 static function delete($id)
 {
     $topic = new self($id);
     foreach ($topic->message as $message) {
         Message::delete($message->id);
     }
     parent::destroy(get_class(), $id);
     foreach ($topic->attachments as $attachment) {
         unlink(uploaded($attachment->path, false));
     }
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
Ejemplo n.º 8
0
 function _deleteMessages()
 {
     $msg = new Message();
     $msg->from_profile = $this->id;
     $msg->delete();
     $msg = new Message();
     $msg->to_profile = $this->id;
     $msg->delete();
 }
 function deleteAction()
 {
     // disable rendering of the view and layout so that we can just echo the AJAX output
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     if ($this->_getParam("deletemultiple") == '1') {
         // debugMessage($this->_getAllParams());
         // user is deleting more than one message
         $idsarray = $this->_getParam("messagesfordelete");
         // remove all empty keys in the array of ids to be deleted
         foreach ($idsarray as $key => $value) {
             if (isEmptyString($value)) {
                 unset($idsarray[$key]);
             }
         }
         // debugMessage($idsarray);
         $message = new MessageRecipient();
         if ($message->deleteMultiple($idsarray)) {
             debugMessage("Message(s) were successfully deleted");
         } else {
             debugMessage("An error occured in deleting your message(s)");
         }
     } else {
         // user is deleting only one message from reply page
         // the messageid being deleted
         $msgid = $this->_getParam("idfordelete");
         // debugMessage($this->_getAllParams());
         // populate message to be deleted
         $message = new Message();
         $message->populate($msgid);
         if ($message->delete()) {
             debugMessage("Message was successfully deleted");
         } else {
             debugMessage("An error occured in deleting your message");
         }
     }
     return false;
 }
Ejemplo n.º 10
0
         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);
                 }
             }
         }
     } catch (Exception $e) {
         $result = $e->getMessage();
         Tool::logger(__METHOD__, __LINE__, sprintf("数据保存失败: %s", $e->getMessage()), _LOG_ERROR);
     }
 } else {
     if ($module == "user") {
         //用户
         if ($action == "modifypwd") {
             $loginName = isset($_REQUEST["loginName"]) ? $_REQUEST["loginName"] : "";
             $password = isset($_REQUEST["password"]) ? $_REQUEST["password"] : "";
             $npassword = isset($_REQUEST["npassword"]) ? $_REQUEST["npassword"] : "";
             try {
 protected function _updateMessage($messageContent)
 {
     if ($messageContent) {
         if (!Validate::isMessage($messageContent)) {
             $this->errors[] = Tools::displayError('Invalid message');
         } else {
             if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) {
                 $message = new Message((int) $oldMessage['id_message']);
                 $message->message = $messageContent;
                 $message->update();
             } else {
                 $message = new Message();
                 $message->message = $messageContent;
                 $message->id_cart = (int) $this->context->cart->id;
                 $message->id_customer = (int) $this->context->cart->id_customer;
                 $message->add();
             }
         }
     } else {
         if ($oldMessage = Message::getMessageByCartId($this->context->cart->id)) {
             $message = new Message($oldMessage['id_message']);
             $message->delete();
         }
     }
     return true;
 }
Ejemplo n.º 12
0
 public function onProfileDeleteRelated(Profile $profile, &$related)
 {
     $msg = new Message();
     $msg->from_profile = $profile->id;
     $msg->delete();
     $msg = new Message();
     $msg->to_profile = $profile->id;
     $msg->delete();
     return true;
 }
Ejemplo n.º 13
0
<?php

//Imports
require_once 'session.php';
require_once 'db/db_conn.php';
require_once 'db/UPDATE.php';
require_once 'classes/Message.php';
if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
    http_response_code(400);
    exit;
}
if (!isset($_POST['tofrom']) || count($_POST['tofrom']) !== 1) {
    http_response_code(400);
    exit;
}
$inboxSent = $_POST['tofrom'];
$con = connect_db();
$ADK_MESSAGE = new Message();
$ADK_MESSAGE->id = intval($_POST['id']);
$ADK_MESSAGE->delete($con, $inboxSent);
if ($_SESSION['ADK_USERGROUP_CDE'] === 'HIK') {
    require_once 'classes/Hiker.php';
    Hiker::updateLastActive($con, intval($_SESSION['ADK_USER_ID']));
}
$con->close();
http_response_code(200);
Ejemplo n.º 14
0
 /**
  * Delete a message
  * @param int $message the message ID
  * @return void
  */
 private function deleteMessage($message)
 {
     require_once FRAMEWORK_PATH . 'models/message.php';
     $message = new Message($this->registry, $message);
     if ($message->getRecipient() == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
         if ($message->delete()) {
             $url = $this->registry->getObject('url')->buildURL(array(), 'messages', false);
             $this->registry->redirectUser($url, 'Message deleted', 'The message has been removed from your inbox');
         } else {
             $this->registry->errorPage('Sorry...', 'An error occured while trying to delete the message');
         }
     } else {
         $this->registry->errorPage('Access denied', 'Sorry, you are not allowed to delete that message');
     }
 }
 protected function _updateMessage($messageContent)
 {
     if ($messageContent) {
         if (!Validate::isMessage($messageContent)) {
             $this->errors[] = Tools::displayError('Invalid message');
         } elseif ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
             $message = new Message((int) $oldMessage['id_message']);
             $message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
             $message->update();
         } else {
             $message = new Message();
             $message->message = htmlentities($messageContent, ENT_COMPAT, 'UTF-8');
             $message->id_cart = (int) self::$cart->id;
             $message->id_customer = (int) self::$cart->id_customer;
             $message->add();
         }
     } else {
         if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
             $message = new Message((int) $oldMessage['id_message']);
             $message->delete();
         }
     }
     return true;
 }
Ejemplo n.º 16
0
<?php

require_once "../initialize.php";
$message = "";
if (isset($_POST['object'])) {
    $id = $_POST["id"];
    if ($_POST['object'] == "user") {
        User::delete($id);
        $message = "success";
    } else {
        if ($_POST['object'] == "message") {
            Message::delete($id);
            $message = "success";
        } else {
            $message = "Object Specified Does Not Exists";
        }
    }
} else {
    $message = "No Create Object Specified";
}
echo $message;
Ejemplo n.º 17
0
 public function actionDelete()
 {
     RoutingEngine::setPage("Messages | runnDAILY", "PV__300");
     if (!isset($_POST["msg_convo_id"])) {
         Page::redirect("/messages");
     }
     $message = new Message($_POST);
     $read_count = Message::markConvoRead($message->convo_id);
     if ($read_count > 0) {
         Message::updateCount(User::$current_user->uid, -$read_count);
         User::$current_user->msg_new -= $read_count;
         RoutingEngine::getInstance()->persistUserData();
     }
     $message->delete();
     Page::redirect("/messages");
 }
Ejemplo n.º 18
0
 public function destroy_message()
 {
     if (!isset($_POST['message_id'])) {
         error(__("Error"), __("No message ID specified.", "discuss"));
     }
     $message = new Message($_POST['message_id']);
     if ($message->no_results) {
         error(__("Error"), __("Invalid message ID specified.", "discuss"));
     }
     if (!$message->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this message.", "discuss"));
     }
     Message::delete($message->id);
     Flash::notice(__("Message deleted.", "discuss"), $message->topic->url());
 }
Ejemplo n.º 19
0
 /**
  * test deleting a message that does not exist
  *
  * @expectedException PDOException
  */
 public function testDeleteInvalidMessage()
 {
     //create message with non-null id, and hope it fails
     $message = new Message(null, $this->listing->getListingId(), $this->organization->getOrgId(), $this->VALID_MESSAGE_TEXT);
     $message->delete($this->getPDO());
 }
Ejemplo n.º 20
0
function ajax_delete_message()
{
    if (Auth::guest()) {
        exit;
    }
    $id = isset($_POST['id']) ? $_POST['id'] : 0;
    $userId = Auth::user()->id;
    if (Message::delete($userId, $id)) {
        json_message(true);
    } else {
        json_message(trans('errors.unexpected'), false);
    }
}