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

This commit is contained in:
Marcel van der Boom 2009-08-19 08:34:17 +02:00 committed by Craig Andrews
parent 0d06055f40
commit 418a5a95ab
5 changed files with 18 additions and 17 deletions

View File

@ -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)) {

View File

@ -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,6 +58,10 @@ class Notice extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
/* 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) {

View File

@ -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) .

View File

@ -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);
}
}

View File

@ -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';