public function __construct() { parent::__construct(); $message_id = IsSetGet(DBMessage::MESSAGE_ID); if ($message_id === false) { throw new UserActionException( "a message must be specified"); } $user_id = IsSetGet(USERS_USERID); if ($user_id === false) { $user_id = BoydsnestSession::GetInstance()->get(USERS_USERID); } if ($user_id != BoydsnestSession::GetInstance()->get(USERS_USERID) && !BoydsnestSession::GetInstance()->get(USERS_ISMASTER)) { throw new SecurityException( "you must be the master to view other users messages"); } $this->data = DBMessage::GetMessage($message_id); $this->data = $this->data[0]; $this->data[DBMessage::MESSAGE] = DBMessage::GetMessageContent($message_id); $this->data[USERS_USERID] = $this->data[DBMessage::ORIGIN_ID]; }
public function do_action() { DBMessage::DeleteMessagesForOrigin( $this->message_ids, USERS, BoydsnestSession::GetInstance()->get(USERS_USERID)); }
public function __construct() { if (!BoydsnestSession::GetInstance()->get(USERS_CANMESSAGE)) { throw new SecurityException( "you are not allowed to send messages"); } $message = IsSetPost(DBMessage::MESSAGE); $title = IsSetPost(DBMessage::TITLE); $users_to = IsSetPost(DBMessage::FCORE_MESSAGE_TOS); $user_from = BoydsnestSession::GetInstance()->get(USERS_USERID); if ($message === false) { $message = ''; } if ($title === false || $title == '') { $title = "none"; } if (!is_array($users_to) || sizeof($users_to) == 0) { throw new UserActionException("no user to is specified"); } if ($user_from === false) { throw new UserActionException("cannot find user from id"); } try { DBMessage::CreateMessage( $message, $title, array( DBMessage::ORIGIN_ID => $user_from, DBMessage::ORIGIN_TYPE => USERS ), $users_to); } catch(Exception $e) { throw new UserActionException($e->getMessage()); } }
DBMessage::DeleteMessagesForOrigin($message_id, "test", 3); DBMessage::DeleteMessagesForOrigin($message_id, "test", 4); $messages = DBMessage::GetMessage($message_id); if (sizeof($messages) == 2) { echo __LINE__.": passed message delete for origin test 3"; } else { echo __LINE__.": failed message delete for origin test 3"; echo "<br />"; var_export($messages); } htmlln(); DBMessage::DeleteMessagesForOrigin($message_id, "test", 5); $messages = DBMessage::GetMessage($message_id); if ($messages == null) { echo __LINE__.": passed message delete for origin test 4"; } else { echo __LINE__.": failed message delete for origin test 4"; echo "<br />"; var_export($messages); } htmlln(); DBMessage::ForceDeleteMessageOfOriginType("test"); ?>
public function do_action() { try { $data = false; switch($this->origin) { case 'to': $data = DBMessage::GetMessageLimitedByForOriginsTo( USERS, $this->user_id, $this->start, $this->amount); break; case 'from': $data = DBMessage::GetMessageLimitedByForOriginsFrom( USERS, $this->user_id, $this->start, $this->amount); break; default: throw new UserActionException( "invalid message origin.. must be to or from"); } if ($data == null || $data === false) { return; } $user_ids = array(); foreach($data as $message) { if (array_search($message[DBMessage::ORIGIN_ID], $user_ids) === false) { array_push($user_ids, $message[DBMessage::ORIGIN_ID]); } } $user_names = $this->user_factory->select( $user_ids, array( DBFactory::SELECT_GET_ONLY => array( USERS_USERID, USERS_USERNAME ) )); $user_includes = array(); foreach($user_names as $name) { $user_includes[$name[USERS_USERID]] = $name[USERS_USERNAME]; } $this->data = array(); foreach($data as $message) { $insert = $message; $insert[USERS_USERID] = $message[DBMessage::ORIGIN_ID]; if (isset($user_includes[$name[USERS_USERID]])) { $insert[USERS_USERNAME] = $user_includes[$name[USERS_USERID]]; } else { $insert[USERS_USERNAME] = "unknown"; } $this->data[] = $insert; } } catch(Exception $e) { throw new UserActionException($e->getMessage()); } }