'email' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for password recovery etc.'),
'incomingemail' => array('type' => 'varchar', 'length' => 255, 'description' => 'email address for post-by-email'),
'emailnotifysub' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of subscriptions'),
- 'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of favorites'),
+ 'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'),
'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'),
'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'),
'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'),
return $this->getProfile()->hasPendingSubscription($other);
}
- // 'update' won't write key columns, so we have to do it ourselves.
-
- function updateKeys(&$orig)
- {
- $this->_connect();
- $parts = array();
- foreach (array('nickname', 'email', 'incomingemail', 'sms', 'carrier', 'smsemail') as $k) {
- if (strcmp($this->$k, $orig->$k) != 0) {
- $parts[] = $k . ' = ' . $this->_quote($this->$k);
- }
- }
- if (count($parts) == 0) {
- // No changes
- return true;
- }
- $toupdate = implode(', ', $parts);
-
- $table = common_database_tablename($this->tableName());
- $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
- ' WHERE id = ' . $this->id;
- $orig->decache();
- $result = $this->query($qry);
- if ($result) {
- $this->encache();
- }
- return $result;
- }
-
/**
* Get the most recent notice posted by this user, if any.
*
if (!empty($code)) {
$invite = Invitation::getKV($code);
- if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
+ if ($invite instanceof Invitation && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
$user->email = $invite->address;
}
}
// initially for sites using caching, since the initial encache
// doesn't know about the defaults in the database.
$user->emailnotifysub = 1;
- $user->emailnotifyfav = 1;
$user->emailnotifynudge = 1;
$user->emailnotifymsg = 1;
$user->emailnotifyattn = 1;
return $this->getProfile()->isSilenced();
}
+ function receivesEmailNotifications()
+ {
+ // We could do this in one large if statement, but that's not as easy to read
+ // Don't send notifications if we don't know the user's email address or it is
+ // explicitly undesired by the user's own settings.
+ if (empty($this->email) || !$this->emailnotifyattn) {
+ return false;
+ }
+ // Don't send notifications to a user who is sandboxed or silenced
+ if ($this->isSandboxed() || $this->isSilenced()) {
+ return false;
+ }
+ return true;
+ }
+
function repeatedByMe($offset=0, $limit=20, $since_id=null, $max_id=null)
{
$stream = new RepeatedByMeNoticeStream($this);
$act = new Activity();
- $act->actor = ActivityObject::fromProfile($profile);
+ $act->actor = $profile->asActivityObject();
$act->verb = ActivityVerb::JOIN;
$act->objects[] = $service;
$service->title);
return $act;
}
+
+ public function delPref($namespace, $topic)
+ {
+ return $this->getProfile()->delPref($namespace, $topic);
+ }
+
+ public function getPref($namespace, $topic, $default=null)
+ {
+ return $this->getProfile()->getPref($namespace, $topic, $default);
+ }
+
+ public function getConfigPref($namespace, $topic)
+ {
+ return $this->getProfile()->getConfigPref($namespace, $topic);
+ }
+
+ public function setPref($namespace, $topic, $data)
+ {
+ return $this->getProfile()->setPref($namespace, $topic, $data);
+ }
}