]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/tag.php
add 'invite-only' mode for registration
[quix0rs-gnu-social.git] / actions / tag.php
index 52d91d724e690c4c80e78043d406186d2cf058cf..75bf6c8bfb76267ed56850926e754f689ecfd4dc 100644 (file)
@@ -98,9 +98,9 @@ class TagAction extends StreamAction {
                #Add the aggregated columns...
                $tags->selectAdd('max(notice_id) as last_notice_id');
                if(common_config('db','type')=='pgsql') {
-                       $calc='sum(exp(-extract(epoch from (now()-created))/%f)) as weight';
+                       $calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight';
                } else {
-                       $calc='sum(exp(-(now() - created)/%f)) as weight';
+                       $calc='sum(exp(-(now() - created)/%s)) as weight';
                }
                $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
                $tags->groupBy('tag');
@@ -159,33 +159,20 @@ class TagAction extends StreamAction {
 
        function show_notices($tag) {
 
-               $tags = DB_DataObject::factory('Notice_tag');
-
-               $tags->tag = $tag;
-
-               $tags->orderBy('created DESC');
-
+               $cnt = 0;
+               
                $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
 
-               $tags->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
+               $notice = Notice_tag::getStream($tag, (($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
 
-               $cnt = $tags->find();
-
-               if ($cnt > 0) {
+               if ($notice) {
                        common_element_start('ul', array('id' => 'notices'));
-                       for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
-                               if ($tags->fetch()) {
-                                       $notice = new Notice();
-                                       $notice->id = $tags->notice_id;
-                                       $result = $notice->find(true);
-                                       if (!$result) {
-                                               continue;
-                                       }
-                                       $this->show_notice($notice);
-                               } else {
-                                       // shouldn't happen!
+                       while ($notice->fetch()) {
+                               $cnt++;
+                               if ($cnt > NOTICES_PER_PAGE) {
                                        break;
                                }
+                               $this->show_notice($notice);
                        }
                        common_element_end('ul');
                }