Exemplo n.º 1
0
 public function setViewCount($count, $threadid = false)
 {
     $thread = $this->threads;
     if (is_array($this->threads)) {
         if ($threadid) {
             $thread = $this->threads[$thread];
         } else {
             throw new ViewedException("You have to specify a single thread to update the view count for");
         }
     }
     $db = new SCDB();
     if (isset($this->view_ids[$thread])) {
         $update_array = array("view_msg_count" => $count);
         $where = "WHERE view_id = " . $this->view_ids[$thread];
         $db->updateFromArray($update_array, "viewed", $where);
         if (mysql_error($db->conn) !== "") {
             throw new ViewedException(mysql_error($db->conn));
         }
     } else {
         $insert_array = array("view_user_id" => $this->user->userid, "view_msg_count" => $count, "view_msg_id" => $thread);
         $db->insertFromArray($insert_array, "viewed");
         $view_id = mysql_insert_id($db->conn);
         if ($view_id) {
             $this->view_ids[$thread] = $view_id;
         } else {
             throw new ViewedException(mysql_error($db->conn));
         }
     }
     $this->view_counts[$thread] = $count;
     return $this;
 }
Exemplo n.º 2
0
 public function save()
 {
     if (!$this->existing) {
         throw new Exception("This is not existing user... you must call create, not save", 401);
     }
     $update_array = $this->toArray(true);
     $db = new SCDB();
     $db->updateFromArray($update_array, "users", "WHERE user_id=" . $this->userid);
     if (mysql_error($db->conn) !== "") {
         throw new UserException(mysql_error($db->conn));
     }
     $user = new SCUser($this->userid);
     $this->fromArray($user->toArray());
     return $this;
 }
Exemplo n.º 3
0
 public function save()
 {
     if (!$this->userid) {
         throw new MembershipException("You can not save a memebership without a userid", 400);
     }
     if (!$this->boardid) {
         throw new MembershipException("You can not save a memebership without a boardid", 400);
     }
     $db = new SCDB();
     $update_array = array("mem_user_id" => $this->userid, "mem_board_id" => $this->boardid, "mem_admin_level" => $this->admin_level, "mem_joindate" => $this->join_date, "mem_receives_emails" => $this->receives_emails);
     $where = " WHERE mem_id = " . $this->membershipid;
     $db->updateFromArray($update_array, "memberships", $where);
     if (mysql_error($db->conn) !== "") {
         throw new MembershipException(mysql_error($db->conn));
     }
     //$membership = new SCMembership($this->membershipid);
     //$this->fromArray($membership->toArray());
     return $this;
 }
Exemplo n.º 4
0
 public function setAccepted()
 {
     $db = new SCDB();
     //$sql = "UPDATE invitations set inv_accepted=1 WHERE inv_id=".$this->id;
     $update_array = array("inv_accepted" => 1);
     $db->updateFromArray($update_array, "invitations", "WHERE inv_id=" . $this->id);
     if (mysql_error($db->conn) !== "") {
         throw new UserException(mysql_error($db->conn));
     }
     return true;
 }