]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Status_network.php
Merge branch 'master' into testing - drop debug statements
[quix0rs-gnu-social.git] / classes / Status_network.php
index ef8e1ed4314a91e9aa192bb2f9431c04543d1f96..4bda24b6a02d253aeb03ad2efdf65605da0ee65d 100644 (file)
@@ -39,15 +39,26 @@ class Status_network extends DB_DataObject
     public $logo;                            // varchar(255)
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
+    public $tags;                            // text
 
     /* Static get */
-    function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Status_network',$k,$v); }
+    function staticGet($k,$v=NULL) {
+        $i = DB_DataObject::staticGet('Status_network',$k,$v);
+
+        // Don't use local process cache; if we're fetching multiple
+        // times it's because we're reloading it in a long-running
+        // process; we need a fresh copy!
+        global $_DB_DATAOBJECT;
+        unset($_DB_DATAOBJECT['CACHE']['status_network']);
+        return $i;
+    }
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
     static $cache = null;
     static $base = null;
+    static $wildcard = null;
 
     /**
      * @param string $dbhost
@@ -187,7 +198,12 @@ class Status_network extends DB_DataObject
 
             $config['db']['database'] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
 
-            $config['site']['name']   = $sn->sitename;
+            $config['site']['name'] = $sn->sitename;
+            $config['site']['nickname'] = $sn->nickname;
+
+            self::$wildcard = $wildcard;
+
+            $config['site']['wildcard'] =& self::$wildcard;
 
             if (!empty($sn->hostname)) {
                 $config['site']['server'] = $sn->hostname;
@@ -230,4 +246,32 @@ class Status_network extends DB_DataObject
 
         exit;
     }
+
+    function getServerName()
+    {
+        if (!empty($this->hostname)) {
+            return $this->hostname;
+        } else {
+            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());
+    }
 }