]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User_group.php
Add Jiminy to notice sources
[quix0rs-gnu-social.git] / classes / User_group.php
index 38e0058c136b49b67d76b3217c6dd5c26e774da6..310ecff1ef766726197eaa06457b6a3c5cfcc405 100644 (file)
@@ -301,7 +301,8 @@ class User_group extends Memcached_DataObject
     static function maxDescription()
     {
         $desclimit = common_config('group', 'desclimit');
-        if (empty($desclimit)) {
+        // null => use global limit (distinct from 0!)
+        if (is_null($desclimit)) {
             $desclimit = common_config('site', 'textlimit');
         }
         return $desclimit;
@@ -310,6 +311,47 @@ class User_group extends Memcached_DataObject
     static function descriptionTooLong($desc)
     {
         $desclimit = self::maxDescription();
-        return (!empty($desclimit) && !empty($desc) && (mb_strlen($desc) > $desclimit));
+        return ($desclimit > 0 && !empty($desc) && (mb_strlen($desc) > $desclimit));
+    }
+
+    function asAtomEntry($namespace=false, $source=false)
+    {
+        $xs = new XMLStringer(true);
+
+        if ($namespace) {
+            $attrs = array('xmlns' => 'http://www.w3.org/2005/Atom',
+                           'xmlns:thr' => 'http://purl.org/syndication/thread/1.0');
+        } else {
+            $attrs = array();
+        }
+
+        $xs->elementStart('entry', $attrs);
+
+        if ($source) {
+            $xs->elementStart('source');
+            $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name'));
+            $xs->element('link', array('href' => $this->permalink()));
+        }
+
+        if ($source) {
+            $xs->elementEnd('source');
+        }
+
+        $xs->element('title', null, $this->nickname);
+        $xs->element('summary', null, $this->description);
+
+        $xs->element('link', array('rel' => 'alternate',
+                                   'href' => $this->permalink()));
+
+        $xs->element('id', null, $this->permalink());
+
+        $xs->element('published', null, common_date_w3dtf($this->created));
+        $xs->element('updated', null, common_date_w3dtf($this->modified));
+
+        $xs->element('content', array('type' => 'html'), $this->description);
+
+        $xs->elementEnd('entry');
+
+        return $xs->getString();
     }
 }