]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/currentuserdesignaction.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / lib / currentuserdesignaction.php
index 2975256557dd72dda104664b7919363c266307b6..e84c77768569d0f13d9bdffc3b66b1f3d3ddb6fc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Base class for actions that use the current user's design
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Action
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2009-2010 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -38,32 +38,59 @@ if (!defined('LACONICA')) {
  * design. This superclass returns that design.
  *
  * @category Action
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Zach Copley    <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  *
  */
-
 class CurrentUserDesignAction extends Action
 {
+
+    protected $cur = null; // The current user
+
+    /**
+     * For initializing members of the class. Set a the
+     * current user here.
+     *
+     * @param array $argarray misc. arguments
+     *
+     * @return boolean true
+     */
+    function prepare($argarray)
+    {
+        parent::prepare($argarray);
+
+        $this->cur = common_current_user();
+
+       return true;
+    }
+
     /**
      * A design for this action
      *
-     * if the user attribute has been set, returns that user's
-     * design.
+     * Returns the design preferences for the current user.
      *
      * @return Design a design object to use
      */
-
     function getDesign()
     {
-        $cur = common_current_user();
+        if (!empty($this->cur)) {
+
+            $design = $this->cur->getDesign();
 
-        if (empty($cur)) {
-            return null;
+            if (!empty($design)) {
+                return $design;
+            }
         }
 
-        return $cur->getDesign();
+        return parent::getDesign();
+    }
+
+    function getCurrentUser()
+    {
+       return $this->cur;
     }
 }
+