]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/subscribers.php
Workaround for Facebook data store API behavior regression, fixes saving
[quix0rs-gnu-social.git] / actions / subscribers.php
index be9df2b124732894028a6c7a70573d3c42f9c174..f7d08d9d0b03d35493368982a18214c831af709c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * List a user's subscribers
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Social
- * @package   Laconica
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @author    Sarven Capadisli <csarven@controlyourself.ca>
- * @copyright 2008-2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @copyright 2008-2009 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);
 }
 
@@ -36,10 +36,10 @@ if (!defined('LACONICA')) {
  * List a user's subscribers
  *
  * @category Social
- * @package  Laconica
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Evan Prodromou <evan@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 SubscribersAction extends GalleryAction
@@ -72,9 +72,13 @@ class SubscribersAction extends GalleryAction
 
     function showContent()
     {
+        parent::showContent();
+
         $offset = ($this->page-1) * PROFILES_PER_PAGE;
         $limit =  PROFILES_PER_PAGE + 1;
 
+        $cnt = 0;
+
         if ($this->tag) {
             $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
         } else {
@@ -83,7 +87,10 @@ class SubscribersAction extends GalleryAction
 
         if ($subscribers) {
             $subscribers_list = new SubscribersList($subscribers, $this->user, $this);
-            $subscribers_list->show();
+            $cnt = $subscribers_list->show();
+            if (0 == $cnt) {
+                $this->showEmptyListMessage();
+            }
         }
 
         $subscribers->free();
@@ -92,15 +99,67 @@ class SubscribersAction extends GalleryAction
                           $this->page, 'subscribers',
                           array('nickname' => $this->user->nickname));
     }
+
+    function showEmptyListMessage()
+    {
+        if (common_logged_in()) {
+            $current_user = common_current_user();
+            if ($this->user->id === $current_user->id) {
+                $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor');
+            } else {
+                $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->user->nickname);
+            }
+        }
+        else {
+            $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.%s%%%%) and be the first?'),
+                               $this->user->nickname,
+                               (!common_config('site','openidonly')) ? 'register' : 'openidlogin');
+        }
+
+        $this->elementStart('div', 'guide');
+        $this->raw(common_markup_to_html($message));
+        $this->elementEnd('div');
+    }
+
+    function showSections()
+    {
+        parent::showSections();
+        $cloud = new SubscribersPeopleTagCloudSection($this);
+        $cloud->show();
+
+        $cloud2 = new SubscribersPeopleSelfTagCloudSection($this);
+        $cloud2->show();
+    }
+}
+
+class SubscribersList extends SubscriptionList
+{
+    function newListItem($profile)
+    {
+        return new SubscribersListItem($profile, $this->owner, $this->action);
+    }
 }
 
-class SubscribersList extends ProfileList
+class SubscribersListItem extends SubscriptionListItem
 {
-    function showOwnerControls($profile)
+    function showActions()
     {
-        $bf = new BlockForm($this->out, $profile,
-                            array('action' => 'subscribers',
-                                  'nickname' => $this->owner->nickname));
-        $bf->show();
+        $this->startActions();
+        $this->showSubscribeButton();
+        // Relevant code!
+        $this->showBlockForm();
+        $this->endActions();
+    }
+
+    function showBlockForm()
+    {
+        $user = common_current_user();
+
+        if (!empty($user) && $this->owner->id == $user->id) {
+            $bf = new BlockForm($this->out, $this->profile,
+                                array('action' => 'subscribers',
+                                      'nickname' => $this->owner->nickname));
+            $bf->show();
+        }
     }
 }