]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/groupdesignsettings.php
Merge branch '0.9.x'
[quix0rs-gnu-social.git] / actions / groupdesignsettings.php
index b87b7d156a3f9ae511da3e037a1c2531f4fa5aa1..3ef5e20e442420d4ab40ecaf5da8bb95440220c3 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,7 +163,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return nothing
      */
-
     function showLocalNav()
     {
         $nav = new GroupNav($this, $this->group);
@@ -170,20 +174,14 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return Design
      */
-
     function getWorkingDesign()
     {
-
         $design = null;
 
         if (isset($this->group)) {
             $design = $this->group->getDesign();
         }
 
-        if (empty($design)) {
-            $design = $this->defaultDesign();
-        }
-
         return $design;
     }
 
@@ -194,10 +192,15 @@ class GroupDesignSettingsAction extends DesignSettingsAction
      *
      * @return void
      */
-
     function showContent()
     {
-        $this->showDesignForm($this->getWorkingDesign());
+        $design = $this->getWorkingDesign();
+
+        if (empty($design)) {
+            $design = Design::siteDesign();
+        }
+
+        $this->showDesignForm($design);
     }
 
     /**
@@ -205,17 +208,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;
@@ -242,7 +242,6 @@ class GroupDesignSettingsAction extends DesignSettingsAction
         $design = $this->group->getDesign();
 
         if (!empty($design)) {
-
             // update design
 
             $original = clone($design);
@@ -259,12 +258,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
@@ -283,7 +281,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;
             }
 
@@ -293,18 +292,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);
     }
-
 }