Suggestions::update PHP Method

update() public method

public update ( $id, $postData )
    public function update($id, $postData)
    {
        if ($this->user->getClass() < User::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $post = $this->get($id);
        $sth = $this->db->prepare("UPDATE suggestions SET status = ? WHERE id = ?");
        $sth->bindParam(1, $postData["status"], PDO::PARAM_INT);
        $sth->bindParam(2, $id, PDO::PARAM_INT);
        $sth->execute();
        switch ($postData["status"]) {
            case 1:
                $color = "#5cb85c";
                $text = L::get("SUGGESTION_STATUS_DONE");
                break;
            case 2:
                $color = "#FF9D13";
                $text = L::get("SUGGESTION_STATUS_ACCEPTED");
                break;
            case 3:
                $color = "#d9534f";
                $text = L::get("SUGGESTION_STATUS_DENIED");
                break;
            case 4:
                $color = "#827B7B";
                $text = L::get("SUGGESTION_STATUS_NO_ACTION");
                break;
            default:
                return;
        }
        $postBody = L::get("SUGGESTION_STATUS_CHANGED_BODY", [$color, $text]);
        $this->forum->addPost($post["topicid"], array("body" => $postBody), 1);
    }

Usage Example

Ejemplo n.º 1
0
     $arr = $suggestions->get($_GET["view"] ?: 'top', (int) $_GET["limit"] ?: 10);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions/\\d+/votes'):
     $suggestions = new Suggestions($db, $user);
     $arr = $suggestions->vote($params[1], $postdata["direction"]);
     httpResponse($arr);
     break;
 case validateRoute('POST', 'suggestions'):
     $forum = new Forum($db, $user);
     $suggestions = new Suggestions($db, $user, $forum);
     httpResponse($suggestions->create($postdata));
     break;
 case validateRoute('PATCH', 'suggestions/\\d+'):
     $suggestions = new Suggestions($db, $user);
     httpResponse($suggestions->update($params[1], $postdata));
     break;
 case validateRoute('GET', 'sweTvGuide'):
     $week = (int) $_GET["week"];
     $cacheId = 'swetvguide-' . $week;
     if ($memcache && ($cached = $memcache->get($cacheId))) {
         if ($week == 0) {
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($cached);
     } else {
         $torrent = new Torrent($db, $user);
         if ($week > 3) {
             $week = 4;
         }
         $array = array();