]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/groupdesignsettings.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / actions / groupdesignsettings.php
index 1c998efe1e215772beb8e96facbd4084341ab7ff..798064d16ca106e009929771e1cdeeaeb77f3ad0 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * StatusNet, the distributed open-source microblogging tool
  *
- * Change user password
+ * Saves a design for a given group.
  *
  * PHP version 5
  *
@@ -46,7 +46,6 @@ require_once INSTALLDIR . '/lib/designsettings.php';
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 class GroupDesignSettingsAction extends DesignSettingsAction
 {
     var $group = null;
@@ -59,12 +58,12 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return boolean true
      */
-
     function prepare($args)
     {
         parent::prepare($args);
 
         if (!common_logged_in()) {
+            // TRANS: Client error displayed trying to change group design settings while not logged in.
             $this->clientError(_('You must be logged in to edit a group.'));
             return false;
         }
@@ -81,7 +80,8 @@ class GroupDesignSettingsAction extends DesignSettingsAction
         }
 
         if (!$nickname) {
-            $this->clientError(_('No nickname'), 404);
+            // TRANS: Client error displayed trying to change group design settings without providing a group nickname.
+            $this->clientError(_('No nickname.'), 404);
             return false;
         }
 
@@ -90,18 +90,23 @@ class GroupDesignSettingsAction extends DesignSettingsAction
         if ($groupid) {
             $this->group = User_group::staticGet('id', $groupid);
         } else {
-            $this->group = User_group::staticGet('nickname', $nickname);
+            $local = Local_group::staticGet('nickname', $nickname);
+            if ($local) {
+                $this->group = User_group::staticGet('id', $local->group_id);
+            }
         }
 
         if (!$this->group) {
-            $this->clientError(_('No such group'), 404);
+            // TRANS: Client error displayed trying to change group design settings while providing a nickname for a non-existing group.
+            $this->clientError(_('No such group.'), 404);
             return false;
         }
 
         $cur = common_current_user();
 
         if (!$cur->isAdmin($this->group)) {
-            $this->clientError(_('You must be an admin to edit the group'), 403);
+            // TRANS: Client error displayed trying to change group design settings without being a (group) admin.
+            $this->clientError(_('You must be an admin to edit the group.'), 403);
             return false;
         }
 
@@ -119,7 +124,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return Design a design object to use
      */
-
     function getDesign()
     {
 
@@ -138,6 +142,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction
 
     function title()
     {
+        // TRANS: Title group design settings page.
         return _('Group design');
     }
 
@@ -146,9 +151,9 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return instructions for use
      */
-
     function getInstructions()
     {
+        // TRANS: Instructions for group design settings page.
         return _('Customize the way your group looks ' .
         'with a background image and a colour palette of your choice.');
     }
@@ -158,19 +163,27 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return nothing
      */
-
-    function showLocalNav()
+    function showObjectNav()
     {
         $nav = new GroupNav($this, $this->group);
         $nav->show();
     }
 
+    /**
+     * Override to show default nav stuff
+     *
+     * @return nothing
+     */
+    function showLocalNav()
+    {
+        Action::showLocalNav();
+    }
+
     /**
      * Get the design we want to edit
      *
      * @return Design
      */
-
     function getWorkingDesign()
     {
         $design = null;
@@ -189,7 +202,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return void
      */
-
     function showContent()
     {
         $design = $this->getWorkingDesign();
@@ -206,17 +218,14 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return void
      */
-
     function saveDesign()
     {
         try {
-
             $bgcolor = new WebColor($this->trimmed('design_background'));
             $ccolor  = new WebColor($this->trimmed('design_content'));
             $sbcolor = new WebColor($this->trimmed('design_sidebar'));
             $tcolor  = new WebColor($this->trimmed('design_text'));
             $lcolor  = new WebColor($this->trimmed('design_links'));
-
         } catch (WebColorException $e) {
             $this->showForm($e->getMessage());
             return;
@@ -243,7 +252,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
         $design = $this->group->getDesign();
 
         if (!empty($design)) {
-
             // update design
 
             $original = clone($design);
@@ -260,12 +268,11 @@ class GroupDesignSettingsAction extends DesignSettingsAction
 
             if ($result === false) {
                 common_log_db_error($design, 'UPDATE', __FILE__);
-                $this->showForm(_('Couldn\'t update your design.'));
+                // TRANS: Form validation error displayed when group design settings could not be updated because of an application issue.
+                $this->showForm(_('Unable to update your design settings.'));
                 return;
             }
-
         } else {
-
             $this->group->query('BEGIN');
 
             // save new design
@@ -284,7 +291,8 @@ class GroupDesignSettingsAction extends DesignSettingsAction
 
             if (empty($id)) {
                 common_log_db_error($id, 'INSERT', __FILE__);
-                $this->showForm(_('Unable to save your design settings!'));
+                // TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
+                $this->showForm(_('Unable to save your design settings.'));
                 return;
             }
 
@@ -294,18 +302,18 @@ class GroupDesignSettingsAction extends DesignSettingsAction
 
             if (empty($result)) {
                 common_log_db_error($original, 'UPDATE', __FILE__);
-                $this->showForm(_('Unable to save your design settings!'));
+                // TRANS: Form validation error displayed when group design settings could not be saved because of an application issue.
+                $this->showForm(_('Unable to save your design settings.'));
                 $this->group->query('ROLLBACK');
                 return;
             }
 
             $this->group->query('COMMIT');
-
         }
 
         $this->saveBackgroundImage($design);
 
+        // TRANS: Form text to confirm saved group design settings.
         $this->showForm(_('Design preferences saved.'), true);
     }
-
 }