From: Marcel van der Boom <marcel@hsdev.com>
Date: Wed, 19 Aug 2009 06:34:17 +0000 (+0200)
Subject: Change the notice type defines all into class constants and adapt all files.
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=418a5a95ab4831ec905dd849fa2632dec24b96da;p=quix0rs-gnu-social.git

Change the notice type defines all into class constants and adapt all files.
---

diff --git a/actions/shownotice.php b/actions/shownotice.php
index 8f2ffd6b90..fb15dddcfd 100644
--- a/actions/shownotice.php
+++ b/actions/shownotice.php
@@ -190,7 +190,7 @@ class ShownoticeAction extends OwnerDesignAction
     {
         parent::handle($args);
 
-        if ($this->notice->is_local == 0) {
+        if ($this->notice->is_local == Notice::REMOTE_OMB) {
             if (!empty($this->notice->url)) {
                 common_redirect($this->notice->url, 301);
             } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
diff --git a/classes/Notice.php b/classes/Notice.php
index ebd5e1efd5..442eb00fdb 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -29,10 +29,6 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
 define('NOTICE_CACHE_WINDOW', 61);
 
-define('NOTICE_LOCAL_PUBLIC', 1);
-define('NOTICE_REMOTE_OMB', 0);
-define('NOTICE_LOCAL_NONPUBLIC', -1);
-
 define('MAX_BOXCARS', 128);
 
 class Notice extends Memcached_DataObject
@@ -62,7 +58,11 @@ class Notice extends Memcached_DataObject
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
-    const GATEWAY = -2;
+    /* Notice types */ 
+    const LOCAL_PUBLIC    =  1;
+    const REMOTE_OMB      =  0;
+    const LOCAL_NONPUBLIC = -1;
+    const GATEWAY         = -2;
 
     function getProfile()
     {
@@ -134,7 +134,7 @@ class Notice extends Memcached_DataObject
     }
 
     static function saveNew($profile_id, $content, $source=null,
-                            $is_local=1, $reply_to=null, $uri=null, $created=null) {
+                            $is_local=Notice::LOCAL_PUBLIC, $reply_to=null, $uri=null, $created=null) {
 
         $profile = Profile::staticGet($profile_id);
 
@@ -177,7 +177,7 @@ class Notice extends Memcached_DataObject
 
         if (($blacklist && in_array($profile_id, $blacklist)) ||
             ($source && $autosource && in_array($source, $autosource))) {
-            $notice->is_local = -1;
+            $notice->is_local = Notice::LOCAL_NONPUBLIC;
         } else {
             $notice->is_local = $is_local;
         }
@@ -509,7 +509,7 @@ class Notice extends Memcached_DataObject
 
     function blowPublicCache($blowLast=false)
     {
-        if ($this->is_local == 1) {
+        if ($this->is_local == Notice::LOCAL_PUBLIC) {
             $cache = common_memcache();
             if ($cache) {
                 $cache->delete(common_cache_key('public'));
@@ -775,10 +775,11 @@ class Notice extends Memcached_DataObject
         }
 
         if (common_config('public', 'localonly')) {
-            $notice->whereAdd('is_local = 1');
+            $notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
         } else {
-            # -1 == blacklisted
-            $notice->whereAdd('is_local != -1');
+            # -1 == blacklisted, -2 == gateway (i.e. Twitter)
+            $notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
+            $notice->whereAdd('is_local !='. Notice::GATEWAY);
         }
 
         if ($since_id != 0) {
diff --git a/lib/search_engines.php b/lib/search_engines.php
index 772f41883b..7c26363fc5 100644
--- a/lib/search_engines.php
+++ b/lib/search_engines.php
@@ -120,7 +120,7 @@ class MySQLSearch extends SearchEngine
         } else if ('identica_notices' === $this->table) {
 
             // Don't show imported notices
-            $this->target->whereAdd('notice.is_local != ' . NOTICE_GATEWAY);
+            $this->target->whereAdd('notice.is_local != ' . Notice::GATEWAY);
 
             if (strtolower($q) != $q) {
                 $this->target->whereAdd("( MATCH(content) AGAINST ('" . addslashes($q) .
diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php
index 5154610725..a10ca339a7 100644
--- a/lib/unqueuemanager.php
+++ b/lib/unqueuemanager.php
@@ -79,7 +79,7 @@ class UnQueueManager
 
     function _isLocal($notice)
     {
-        return ($notice->is_local == NOTICE_LOCAL_PUBLIC ||
-                $notice->is_local == NOTICE_LOCAL_NONPUBLIC);
+        return ($notice->is_local == Notice::LOCAL_PUBLIC ||
+                $notice->is_local == Notice::LOCAL_NONPUBLIC);
     }
 }
\ No newline at end of file
diff --git a/lib/util.php b/lib/util.php
index ba37606789..748c8332f0 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -854,8 +854,8 @@ function common_enqueue_notice($notice)
         $transports[] = 'jabber';
     }
 
-    if ($notice->is_local == NOTICE_LOCAL_PUBLIC ||
-        $notice->is_local == NOTICE_LOCAL_NONPUBLIC) {
+    if ($notice->is_local == Notice::LOCAL_PUBLIC ||
+        $notice->is_local == Notice::LOCAL_NONPUBLIC) {
         $transports = array_merge($transports, $localTransports);
         if ($xmpp) {
             $transports[] = 'public';