Exemplo n.º 1
0
 private function loadInfo($messageid, $count = false)
 {
     //$sql = "SELECT * FROM messages m WHERE m.msg_id=$messageid";
     $db = new SCDB();
     //$messageinfo = $db->queryArray($sql);
     $messageinfo = $db->q(array("*"), array("messages m"), array("m.msg_id" => $messageid));
     if (sizeof($messageinfo)) {
         $this->fromArray($messageinfo);
     } else {
         throw new MessageException("Message not found", 404);
     }
 }
Exemplo n.º 2
0
 public function getViewCounts()
 {
     $this->view_counts = array();
     $this->view_ids = array();
     $db = new SCDB();
     $view_counts = $db->q(array("*"), array("viewed"), array("view_user_id" => $this->user->userid, "view_msg_id" => $this->threads));
     if (sizeof($view_counts)) {
         foreach ($view_counts as $id => $view_count) {
             $this->view_counts[$view_count["view_msg_id"]] = $view_count["view_msg_count"];
             $this->view_ids[$view_count["view_msg_id"]] = $view_count["view_id"];
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 public function loadMembers($only_receive_emails = false)
 {
     if (!$this->boardid) {
         throw new MembershipSetException("Load Members can only be called if board id is set", 400);
     }
     $db = new SCDB();
     $conditions_array = array("mem_board_id" => $this->boardid, "brd_id" => "mem_board_id", "mem_user_id" => "user_id");
     if ($only_receive_emails) {
         $conditions_array["mem_receives_emails"] = 1;
     }
     $memberships = $db->q(array("*"), array("memberships", "boards", "users"), $conditions_array);
     foreach ($memberships as $id => $membership) {
         $new_membership = new SCMembership($membership);
         $new_membership->hideBoard();
         $new_membership->board->hidecreator = true;
         $new_membership->board->hidethreads = true;
         $new_membership->user->hideBoards = true;
         $this->memberships[] = $new_membership;
     }
     $this->hasmemberships = sizeof($memberships);
     return $this;
 }
Exemplo n.º 4
0
 public function loadThreads($start = false, $num = false, $hidemessages = false)
 {
     //$sql = "SELECT * FROM messages m, users u WHERE m.msg_board_id=".$this->boardid." AND m.msg_thread=0 AND m.msg_author=u.user_id ORDER BY m.msg_id DESC LIMIT $start, " . ($start + $num);
     $db = new SCDB();
     //$threads = $db->queryArray($sql);
     if ($start && !$num) {
         $threads = $db->q(array("*"), array("messages m", "users u"), array("m.msg_board_id" => $this->boardid, "m.msg_thread" => 0, "m.msg_author" => "u.user_id", "m.msg_id>" => $start + 1), array("ORDER BY m.msg_id DESC"));
     } else {
         if (!$start && !$num) {
             if (!$start) {
                 $start = 0;
             }
             if (!$num) {
                 $num = 10;
             }
         }
         $threads = $db->q(array("*"), array("messages m", "users u"), array("m.msg_board_id" => $this->boardid, "m.msg_thread" => 0, "m.msg_author" => "u.user_id"), array("ORDER BY m.msg_id DESC LIMIT {$start}, " . ($start + $num)));
     }
     if (sizeof($threads)) {
         foreach ($threads as $id => $thread) {
             $threads_in[] = $thread["msg_id"];
             $temp_threads[$thread["msg_id"]] = new SCThread($thread);
         }
         //$sql = "SELECT count(msg_id) as the_count, msg_thread FROM messages WHERE msg_thread IN (" . implode(",", $threads_in) . ") GROUP BY msg_thread ORDER BY msg_thread DESC";
         //$thread_counts = $db->queryArray($sql);
         $thread_counts = $db->q(array("count(msg_id) as the_count", "msg_thread"), array("messages"), array("msg_thread" => $threads_in), array("GROUP BY msg_thread", "ORDER BY msg_thread DESC"));
         if (sizeof($thread_counts)) {
             foreach ($thread_counts as $id => $thread_count) {
                 $temp_threads[$thread_count["msg_thread"]]->message_count = $thread_count["the_count"];
             }
         }
         $this->threadset = array();
         foreach ($temp_threads as $id => $thread) {
             if ($hidemessages) {
                 $thread->hidemessages = $hidemessages;
             }
             $this->threadset[] = $thread;
         }
         //echo sizeof($temp_threads);
     }
     return $this;
 }
Exemplo n.º 5
0
 public function hasMessage($messageid)
 {
     if ($messageid = $this->messageid) {
         return true;
     }
     //$sql = "SELECT * from messages WHERE msg_id=$messageid AND msg_thread=".$this->messageid;
     $db = new SCDB();
     $hasMessage = $db->q(array("*"), array("messages"), array("msg_id" => $message_id, "msg_thread" => $this->messageid));
     if (sizeof($hasMessage) && $hasMessage[0]["msg_id"] == $messageid) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 6
0
 public function getCryptedPw()
 {
     if ($this->userid) {
         $db = new SCDB();
         $user_data = $db->q(array("user_password"), array("users"), array("user_id" => $this->userid));
         if (sizeof($user_data)) {
             return $user_data[0]["user_password"];
         }
         return false;
     }
     return false;
 }
Exemplo n.º 7
0
 private function loadFromMembershipId($membershipid)
 {
     $db = new SCDB();
     $membership = $db->q(array("*"), array("memberships", "boards", "users"), array("mem_id" => $membershipid, "mem_board_id" => "brd_id", "mem_user_id" => "user_id"));
     if (sizeof($membership)) {
         $this->fromArray($membership);
     } else {
         throw new MembershipException("Membership not found", 404);
     }
 }