]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - classes/Status_network.php
update User.php with new design-related fields
[quix0rs-gnu-social.git] / classes / Status_network.php
1 <?php
2 /**
3  * Table Definition for status_network
4  */
5
6 class Status_network extends DB_DataObject
7 {
8     ###START_AUTOCODE
9     /* the code below is auto generated do not remove the above tag */
10
11     public $__table = 'status_network';                  // table name
12     public $nickname;                        // varchar(64)  primary_key not_null
13     public $hostname;                        // varchar(255)  unique_key
14     public $pathname;                        // varchar(255)  unique_key
15     public $sitename;                        // varchar(255)
16     public $dbhost;                          // varchar(255)
17     public $dbuser;                          // varchar(255)
18     public $dbpass;                          // varchar(255)
19     public $dbname;                          // varchar(255)
20     public $created;                         // datetime()   not_null
21     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
22
23     /* Static get */
24     function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Status_network',$k,$v); }
25
26     /* the code above is auto generated do not remove the tag below */
27     ###END_AUTOCODE
28
29     static function setupDB($dbhost, $dbuser, $dbpass, $dbname)
30     {
31         global $config;
32
33         $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
34         $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/statusnet.ini';
35         $config['db']['table_status_network'] = $dbname;
36
37         return true;
38     }
39
40     static function setupSite($servername, $pathname)
41     {
42         global $config;
43
44         $parts = explode('.', $servername);
45
46         $sn = Status_network::staticGet('nickname', $parts[0]);
47
48         if (!empty($sn)) {
49             $dbhost = (empty($sn->dbhost)) ? 'localhost' : $sn->dbhost;
50             $dbuser = (empty($sn->dbuser)) ? $sn->nickname : $sn->dbuser;
51             $dbpass = $sn->dbpass;
52             $dbname = (empty($sn->dbname)) ? $sn->nickname : $sn->dbname;
53
54             $config['db']['database'] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname";
55             $config['site']['name'] = $sn->sitename;
56             return true;
57         } else {
58             return false;
59         }
60     }
61 }