/**
  * Create a new flag
  *
  * @param integer $user_id    ID of user who's flagging
  * @param integer $profile_id ID of profile being flagged
  *
  * @return boolean success flag
  */
 static function create($user_id, $profile_id)
 {
     $ufp = new User_flag_profile();
     $ufp->profile_id = $profile_id;
     $ufp->user_id = $user_id;
     $ufp->created = common_sql_now();
     if (!$ufp->insert()) {
         $msg = sprintf(_("Couldn't flag profile '%d' for review."), $profile_id);
         throw new ServerException($msg);
     }
     $ufp->free();
     return true;
 }
Exemplo n.º 2
0
 /**
  * Create a new flag
  *
  * @param integer $user_id    ID of user who's flagging
  * @param integer $profile_id ID of profile being flagged
  *
  * @return boolean success flag
  */
 static function create($user_id, $profile_id)
 {
     $ufp = new User_flag_profile();
     $ufp->profile_id = $profile_id;
     $ufp->user_id = $user_id;
     $ufp->created = common_sql_now();
     if (!$ufp->insert()) {
         // TRANS: Server exception.
         $msg = sprintf(_m('Couldn\'t flag profile "%d" for review.'), $profile_id);
         throw new ServerException($msg);
     }
     $ufp->free();
     return true;
 }
Exemplo n.º 3
0
 /**
  * Retrieve this action's profiles
  *
  * @return Profile $profile Profile query results
  */
 function getProfiles()
 {
     $ufp = new User_flag_profile();
     $ufp->selectAdd();
     $ufp->selectAdd('profile_id');
     $ufp->selectAdd('count(*) as flag_count');
     $ufp->whereAdd('cleared is NULL');
     $ufp->groupBy('profile_id');
     $ufp->orderBy('flag_count DESC, profile_id DESC');
     $offset = ($this->page - 1) * PROFILES_PER_PAGE;
     $limit = PROFILES_PER_PAGE + 1;
     $ufp->limit($offset, $limit);
     $profiles = array();
     if ($ufp->find()) {
         while ($ufp->fetch()) {
             $profile = Profile::staticGet('id', $ufp->profile_id);
             if (!empty($profile)) {
                 $profiles[] = $profile;
             }
         }
     }
     $ufp->free();
     return new ArrayWrapper($profiles);
 }
Exemplo n.º 4
0
 /**
  * Handle POST
  *
  * Executes the actions; deletes all flags
  *
  * @return void
  */
 function handlePost()
 {
     $ufp = new User_flag_profile();
     $result = $ufp->query('UPDATE user_flag_profile ' . 'SET cleared = now() ' . 'WHERE cleared is null ' . 'AND profile_id = ' . $this->profile->id);
     if ($result == false) {
         // TRANS: Server exception given when flags could not be cleared.
         $msg = sprintf(_m('Couldn\'t clear flags for profile "%s".'), $this->profile->nickname);
         throw new ServerException($msg);
     }
     $ufp->free();
     if ($this->boolean('ajax')) {
         $this->ajaxResults();
     }
 }
 /**
  * Handle POST
  *
  * Executes the actions; deletes all flags
  *
  * @return void
  */
 function handlePost()
 {
     $ufp = new User_flag_profile();
     $result = $ufp->query('UPDATE user_flag_profile ' . 'SET cleared = now() ' . 'WHERE cleared is null ' . 'AND profile_id = ' . $this->profile->id);
     if ($result == false) {
         $msg = sprintf(_("Couldn't clear flags for profile '%s'."), $this->profile->nickname);
         throw new ServerException($msg);
     }
     $ufp->free();
     if ($this->boolean('ajax')) {
         $this->ajaxResults();
     }
 }