]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/UserFlag/flagprofile.php
* i18n/L10n review.
[quix0rs-gnu-social.git] / plugins / UserFlag / flagprofile.php
index 9bce7865b8c973114d42b12dacb804473183c25f..283eea40ce157289d811ebc55f5c5071ff0631c7 100644 (file)
@@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
  * @link     http://status.net/
  */
-
 class FlagprofileAction extends ProfileFormAction
 {
     /**
@@ -50,7 +49,6 @@ class FlagprofileAction extends ProfileFormAction
      *
      * @return boolean success flag
      */
-
     function prepare($args)
     {
         if (!parent::prepare($args)) {
@@ -63,16 +61,15 @@ class FlagprofileAction extends ProfileFormAction
         assert(!empty($this->profile)); // checked above
 
         if (User_flag_profile::exists($this->profile->id,
-                                      $user->id))
-        {
-            $this->clientError(_('Flag already exists.'));
+                                      $user->id)) {
+            // TRANS: Client error when setting flag that has already been set for a profile.
+            $this->clientError(_m('Flag already exists.'));
             return false;
         }
 
         return true;
     }
 
-
     /**
      * Handle request
      *
@@ -83,13 +80,12 @@ class FlagprofileAction extends ProfileFormAction
      *
      * @return void
      */
-
     function handle($args)
     {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             $this->handlePost();
             if (!$this->boolean('ajax')) {
-                $this->returnToArgs();
+                $this->returnToPrevious();
             }
         }
     }
@@ -99,7 +95,6 @@ class FlagprofileAction extends ProfileFormAction
      *
      * @return void
      */
-
     function handlePost()
     {
         $user = common_current_user();
@@ -107,35 +102,33 @@ class FlagprofileAction extends ProfileFormAction
         assert(!empty($user));
         assert(!empty($this->profile));
 
-        $ufp = new User_flag_profile();
-
-        $ufp->profile_id = $this->profile->id;
-        $ufp->user_id    = $user->id;
-        $ufp->created    = common_sql_now();
-
-        if (!$ufp->insert()) {
-            throw new ServerException(sprintf(_("Couldn't flag profile '%s' for review."),
-                                              $this->profile->nickname));
-        }
+        // throws an exception on error
 
-        $ufp->free();
+        User_flag_profile::create($user->id, $this->profile->id);
 
         if ($this->boolean('ajax')) {
             $this->ajaxResults();
         }
     }
 
-    function ajaxResults() {
+    /**
+     * Return results as AJAX message
+     *
+     * @return void
+     */
+    function ajaxResults()
+    {
         header('Content-Type: text/xml;charset=utf-8');
         $this->xw->startDocument('1.0', 'UTF-8');
         $this->elementStart('html');
         $this->elementStart('head');
-        $this->element('title', null, _('Flagged for review'));
+        // TRANS: AJAX form title for a flagged profile.
+        $this->element('title', null, _m('Flagged for review'));
         $this->elementEnd('head');
         $this->elementStart('body');
-        $this->element('p', 'flagged', _('Flagged'));
+        // TRANS: Body text for AJAX form when a profile has been flagged for review.
+        $this->element('p', 'flagged', _m('Flagged'));
         $this->elementEnd('body');
         $this->elementEnd('html');
     }
 }
-