Site metadata tags in status_network: single 'tags' field, pipe-separated.
$sn->tags() returns tag list as array; $sn->hasTag('blah') to check for a particular tag only Could be used to control things in config file: $sn = Status_network::setupSite($_server, $_path, $_wildcard); if (!$sn) { die("No such site"); } if ($sn->hasTag('individual')) { /* blah */ } Note memcached keys are unchanged; if tags are changed from an external tool clear: statusnet:<dbname>:status_network:<key>:<val> for <key>s 'nickname', 'hostname', and 'pathname'
This commit is contained in:
parent
e05c325722
commit
ad6f0501ff
|
@ -39,6 +39,7 @@ class Status_network extends DB_DataObject
|
||||||
public $logo; // varchar(255)
|
public $logo; // varchar(255)
|
||||||
public $created; // datetime() not_null
|
public $created; // datetime() not_null
|
||||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||||
|
public $tags; // text
|
||||||
|
|
||||||
/* Static get */
|
/* Static get */
|
||||||
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Status_network',$k,$v); }
|
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Status_network',$k,$v); }
|
||||||
|
@ -245,4 +246,23 @@ class Status_network extends DB_DataObject
|
||||||
return $this->nickname . '.' . self::$wildcard;
|
return $this->nickname . '.' . self::$wildcard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return site meta-info tags as an array
|
||||||
|
* @return array of strings
|
||||||
|
*/
|
||||||
|
function getTags()
|
||||||
|
{
|
||||||
|
return array_filter(explode("|", strval($this->tags)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this site record has a particular meta-info tag attached.
|
||||||
|
* @param string $tag
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function hasTag($tag)
|
||||||
|
{
|
||||||
|
return in_array($tag, $this->getTags());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ create table status_network (
|
||||||
theme varchar(255) comment 'theme name',
|
theme varchar(255) comment 'theme name',
|
||||||
logo varchar(255) comment 'site logo',
|
logo varchar(255) comment 'site logo',
|
||||||
|
|
||||||
|
tags text comment 'site meta-info tags (pipe-separated)',
|
||||||
|
|
||||||
created datetime not null comment 'date this record was created',
|
created datetime not null comment 'date this record was created',
|
||||||
modified timestamp comment 'date this record was modified'
|
modified timestamp comment 'date this record was modified'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user