Esempio n. 1
0
 public static function GetByAssoc($values)
 {
     $message = new Message();
     $message->ID = $values["message_id"];
     $message->Sender = User::GetByID($values["message_sender"]);
     $message->Title = $values["message_title"];
     $message->Content = strrepl($values["message_content"]);
     $message->Timestamp = $values["message_timestamp"];
     $message->Status = $values["message_status"];
     if (!$message->IsAuthenticated()) {
         return null;
     }
     return $message;
 }
 public static function GetByAssoc($values)
 {
     $message = new ShoutoutMessage();
     $message->ID = $values["message_id"];
     $message->Sender = User::GetByID($values["message_sender_id"]);
     $message->Receiver = User::GetByID($values["message_receiver_id"]);
     $message->Content = strrepl($values["message_content"]);
     $message->Timestamp = $values["message_timestamp"];
     $message->Visibility = ShoutoutMessageVisibility::FromIndex($values["message_visibility"]);
     $CurrentUser = User::GetCurrent();
     if ($CurrentUser->ID != $message->Sender->ID) {
         switch ($message->Visibility) {
             case ShoutoutMessageVisibility::Hidden:
                 return null;
             case ShoutoutMessageVisibility::Friends:
                 // only friends of the person posting it can see the post
                 if ($CurrentUser == null) {
                     return null;
                 }
                 if (!$CurrentUser->HasFriend($message->Sender)) {
                     return null;
                 }
                 break;
             case ShoutoutMessageVisibility::Network:
                 // everyone on Psychatica can see the post (i.e., must be logged in)
                 if ($CurrentUser == null) {
                     return null;
                 }
                 break;
             case ShoutoutMessageVisibility::Everyone:
                 // entire Internet can see the post
                 break;
             case ShoutoutMessageVisibility::Blacklist:
                 // friends only
                 return null;
             case ShoutoutMessageVisibility::Whitelist:
                 // friends only
                 return null;
         }
     }
     return $message;
 }