ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10057


Ignore:
Timestamp:
Jan 10, 2009, 12:35:40 AM (12 years ago)
Author:
maki
Message:

#3408 add readable message check

Location:
OpenPNE3/plugins/opMessagePlugin/trunk/lib/action
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opMessagePlugin/trunk/lib/action/opMessagePluginActions.class.php

    r10053 r10057  
    3434    return true;
    3535  }
     36 
     37  protected function isReadable($type)
     38  {
     39    if (!$this->message) {
     40      return false;
     41    }
     42    if ($this->message->getIsSender($this->getUser()->getMemberId()) === 0
     43        && $this->message->getIsReceiver($this->getUser()->getMemberId()) === 0) {
     44        return false;
     45    }
     46    switch ($type) {
     47      case "receive":
     48        if ($this->message->getIsReceiver($this->getUser()->getMemberId()) === 0) {
     49          return false;
     50        }
     51        $read_message = MessageSendListPeer::getMessageByReferences(
     52                                                  $this->getUser()->getMemberId(), $this->message->getId());
     53        if (!$read_message) {
     54          return false;
     55        }
     56        return $read_message;
     57      case "send":
     58        if ($this->message->getIsSender($this->getUser()->getMemberId()) === 0) {
     59          return false;
     60        }
     61        return true;
     62      case "dust":
     63        $deleted_message = DeletedMessagePeer::getDeletedMessageByMessageId(
     64                                                  $this->getUser()->getMemberId(), $this->message->getId());
     65        if (!$deleted_message) {
     66          $deleted_message = DeletedMessagePeer::getDeletedMessageByMessageSendListId(
     67                                                  $this->getUser()->getMemberId(), $this->message->getId());
     68        }
     69        if (!$deleted_message) {
     70          return false;
     71        }
     72        return $deleted_message;
     73    }
     74  }
    3675}
  • OpenPNE3/plugins/opMessagePlugin/trunk/lib/action/opMessagePluginMessageActions.class.php

    r10053 r10057  
    8989  {
    9090    $this->message = SendMessageDataPeer::retrieveByPk($request->getParameter('id'));
    91     $this->forward404unless($this->message);
    92     if ($this->message->getIsSender($this->getUser()->getMemberId()) == 0
    93         && $this->message->getIsReceiver($this->getUser()->getMemberId()) == 0) {
    94         $this->forward404();
    95     }
    96     if ($this->message->getIsReceiver($this->getUser()->getMemberId()) == 1) {
    97         $read_message = MessageSendListPeer::getMessageByReferences(
    98                                                   $this->getUser()->getMemberId(), $this->message->getId());
    99         $read_message->readMessage();
    100     }
     91    $this->forward404unless($message = $this->isReadable($request->getParameter('type')));
    10192    switch ($request->getParameter('type')) {
    10293      case "receive":
    103         $this->deleteButton = '@deleteReceiveMessage?id='.$read_message->getId();
     94        $this->deleteButton = '@deleteReceiveMessage?id='.$message->getId();
    10495        break;
    10596      case "send":
     
    10798        break;
    10899      case "dust":
    109         $deleted_message = DeletedMessagePeer::getDeletedMessageByMessageId(
    110                                                   $this->getUser()->getMemberId(), $this->message->getId());
    111         if (!$deleted_message) {
    112           $deleted_message = DeletedMessagePeer::getDeletedMessageByMessageSendListId(
    113                                                   $this->getUser()->getMemberId(), $this->message->getId());
    114         }
    115         $this->deleteButton = '@deleteDustMessage?id='.$deleted_message->getId();
    116         $this->deletedId = $deleted_message->getId();
     100        $this->deleteButton = '@deleteDustMessage?id='.$message->getId();
     101        $this->deletedId = $message->getId();
    117102    }
    118103  }
Note: See TracChangeset for help on using the changeset viewer.