Esempio n. 1
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $path = $pl->getParameterValue("path");
     if ($path == null || $path == '') {
         throw new ProcessException(_("Error processing the request."), "no_path");
     }
     $site = $runData->getTemp("site");
     $user = $runData->getUser();
     // check if flagged already
     $c = new Criteria();
     $c->add("user_id", $user->getUserId());
     $c->add("site_id", $site->getSiteId());
     $c->add("path", $path);
     $flag = DB_PageAbuseFlagPeer::instance()->selectOne($c);
     if ($flag) {
         $runData->contextAdd("flagged", true);
     }
 }
Esempio n. 2
0
 public function flagPageEvent($runData)
 {
     $pl = $runData->getParameterList();
     $path = $pl->getParameterValue("path");
     $toFlag = $pl->getParameterValue("flag");
     if ($path == null || $path == '') {
         throw new ProcessException(_("Error processing the request."), "no_path");
     }
     $site = $runData->getTemp("site");
     $user = $runData->getUser();
     $db = Database::connection();
     $db->begin();
     if ($toFlag) {
         // flag the page
         // check if not flagged already
         $c = new Criteria();
         $c->add("user_id", $user->getUserId());
         $c->add("site_id", $site->getSiteId());
         $c->add("path", $path);
         $flag = DB_PageAbuseFlagPeer::instance()->selectOne($c);
         if ($flag == null) {
             $flag = new DB_PageAbuseFlag();
             $flag->setUserId($user->getUserId());
             $flag->setSiteId($site->getSiteId());
             $flag->setPath($path);
             $flag->save();
             EventLogger::instance()->logFlagPage($path);
         }
     } else {
         // unflag
         $c = new Criteria();
         $c->add("user_id", $user->getUserId());
         $c->add("site_id", $site->getSiteId());
         $c->add("path", $path);
         DB_PageAbuseFlagPeer::instance()->delete($c);
         EventLogger::instance()->logUnflagPage($path);
     }
     $db->commit();
 }