src/snac/server/ServerExecutor.php
/**
     * Archive Message
     *
     * Archives the message with given message id if it exists and the user has
     * permission to archive this message (sender or recipient).  Note, this method
     * only sets the delete flag; a message is never actually deleted.
     *
     * @param string[] $input Input array from the Server object
     * @throws \snac\exceptions\SNACInputException
     * @throws \snac\exceptions\SNACPermissionException
     * @return string[] The response to send to the client
     */
Archive Message
Archives the message with given message id if it exists and the user has
permission to archive this message (sender or recipient).  Note, this method
only sets the delete flag; a message is never actually deleted.


Archive Message Archives the message with given message id if it exists and the user has permission to archive this message ( sender or recipient ) . Note this method only sets the delete flag ; a message is never actually deleted .
public function archiveMessage(&$input) {
        if (!isset($input["messageid"])) {
            throw new \snac\exceptions\SNACInputException("No message ID given to archive", 400);
        }
        $response = array();
        $message = $this->uStore->getMessageByID($input["messageid"]);
        if ($message === false) {
            throw new \snac\exceptions\SNACInputException("Message does not exist", 404);
        }
        $this->logger->addDebug("Archiving message", $message->toArray());
        if (($message->getToUser() !== null && $message->getToUser()->getUserID() === $this->user->getUserID()) ||
            ($message->getFromUser() !== null && $message->getFromUser()->getUserID() === $this->user->getUserID())) {
                $response["message"] = $message->toArray();
        } else {
            throw new \snac\exceptions\SNACPermissionException("User does not have permission to archive the message.", 403);
        }
        $this->logger->addDebug("Starting to archive");
        $success = $this->uStore->archiveMessage($message);
        $this->logger->addDebug("Done archiving");
        if ($success)
            $response["result"] = "success";
        else
            $response["result"] = "failure";
        $this->logger->addDebug("Archived", $response);
        return $response;
    }
public function archiveMessage ( & $ input ) { if ( ! isset ( $ input [ " messageid " ] ) ) { throw new \ snac \ exceptions \ SNACInputException ( " No message ID given to archive " , 400 ) ; } $ response = array ( ) ; $ message = $ this -> uStore -> getMessageByID ( $ input [ " messageid " ] ) ; if ( $ message === false ) { throw new \ snac \ exceptions \ SNACInputException ( " Message does not exist " , 404 ) ; } $ this -> logger -> addDebug ( " Archiving message " , $ message -> toArray ( ) ) ; if ( ( $ message -> getToUser ( ) !== null && $ message -> getToUser ( ) -> getUserID ( ) === $ this -> user -> getUserID ( ) ) || ( $ message -> getFromUser ( ) !== null && $ message -> getFromUser ( ) -> getUserID ( ) === $ this -> user -> getUserID ( ) ) ) { $ response [ " message " ] = $ message -> toArray ( ) ; } else { throw new \ snac \ exceptions \ SNACPermissionException ( " User does not have permission to archive the message. " , 403 ) ; } $ this -> logger -> addDebug ( " Starting to archive " ) ; $ success = $ this -> uStore -> archiveMessage ( $ message ) ; $ this -> logger -> addDebug ( " Done archiving " ) ; if ( $ success ) $ response [ " result " ] = " success " ; else $ response [ " result " ] = " failure " ; $ this -> logger -> addDebug ( " Archived " , $ response ) ; return $ response ; }
Archive Message
 Archives the message with given message id if it exists and the user has
 permission to archive this message (sender or recipient).
Archive Message Archives the message with given message id if it exists and the user has permission to archive this message ( sender or recipient ) .