X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser.php;h=e4928eb34af7200f39a5fbd15a5ca16a1367abaf;hb=98af7402c7d4b6fba268dcba7fd26fa285c413c6;hp=78815a72ea972b1ac4c69fa93fe04c5ccdde9fd6;hpb=b19c86bd0065ee3a13ced9be3244d8dc007d2ee6;p=quix0rs-gnu-social.git diff --git a/classes/User.php b/classes/User.php index 78815a72ea..e4928eb34a 100644 --- a/classes/User.php +++ b/classes/User.php @@ -34,9 +34,20 @@ class User extends DB_DataObject public $nickname; // varchar(64) unique_key public $password; // varchar(255) public $email; // varchar(255) unique_key + public $incomingemail; // varchar(255) unique_key + public $emailnotifysub; // tinyint(1) default_1 + public $emailpost; // tinyint(1) default_1 public $jabber; // varchar(255) unique_key + public $jabbernotify; // tinyint(1) + public $jabberreplies; // tinyint(1) + public $updatefrompresence; // tinyint(1) public $sms; // varchar(64) unique_key + public $carrier; // int(4) + public $smsnotify; // tinyint(1) + public $smsreplies; // tinyint(1) + public $smsemail; // varchar(255) public $uri; // varchar(255) unique_key + public $autosubscribe; // tinyint(1) public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP @@ -65,10 +76,10 @@ class User extends DB_DataObject } # 'update' won't write key columns, so we have to do it ourselves. - + function updateKeys(&$orig) { $parts = array(); - foreach (array('nickname', 'email') as $k) { + foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail') as $k) { if (strcmp($this->$k, $orig->$k) != 0) { $parts[] = $k . ' = ' . $this->_quote($this->$k); } @@ -78,8 +89,43 @@ class User extends DB_DataObject return true; } $toupdate = implode(', ', $parts); - $qry = 'UPDATE ' . $this->tableName() . ' SET ' . $toupdate . + $qry = 'UPDATE ' . $this->tableName() . ' SET ' . $toupdate . ' WHERE id = ' . $this->id; return $this->query($qry); } + + function allowed_nickname($nickname) { + # XXX: should already be validated for size, content, etc. + static $blacklist = array('rss', 'xrds', 'doc', 'main', + 'settings', 'notice', 'user', + 'search', 'avatar'); + $merged = array_merge($blacklist, common_config('nickname', 'blacklist')); + return !in_array($nickname, $merged); + } + + function getCurrentNotice($dt=NULL) { + $profile = $this->getProfile(); + if (!$profile) { + return NULL; + } + return $profile->getCurrentNotice($dt); + } + + function getCarrier() { + return Sms_carrier::staticGet($this->carrier); + } + + function subscribeTo($other) { + $sub = new Subscription(); + $sub->subscriber = $this->id; + $sub->subscribed = $other->id; + + $sub->created = DB_DataObject_Cast::dateTime(); # current time + + if (!$sub->insert()) { + return false; + } + + return true; + } }