コード例 #1
0
ファイル: AppsController.php プロジェクト: IASA-GR/appdb-core
 public function revokeratingAction()
 {
     $this->_helper->layout->disableLayout();
     $ratings = new Default_Model_AppRatings();
     if ($this->session->userid === null) {
         $r = json_decode($_COOKIE['ratings'], true);
         $ratingid = $r['app' . $this->_getParam("appid")];
         $ratings->filter->id->equals($ratingid);
     } else {
         $ratings->filter->appid->equals($this->_getParam("appid"))->and($ratings->filter->submitterid->equals($this->session->userid));
     }
     if (count($ratings->refresh()->items) > 0) {
         $id = $ratings->items[0]->id;
         $ratings->remove($ratings->items[0]);
         $apps = new Default_Model_Applications();
         $apps->filter->id = $this->_getParam("appid");
         echo '{"id":"' . $id . '","average":"' . $apps->items[0]->rating . '"}';
     }
 }
コード例 #2
0
 public function ratingsAction()
 {
     $format = $this->_getParam("format");
     if ($format === "json") {
         $format = "xml";
     }
     $this->_helper->layout->disableLayout();
     $ratings = new Default_Model_AppRatings();
     $ratings->filter->appid->equals($this->_getParam("id"));
     $this->view->entries = $ratings->refresh($format)->items;
 }