'description' => 'local and remote users have profiles',
'fields' => array(
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
- 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username', 'collate' => 'utf8_general_ci'),
- 'fullname' => array('type' => 'varchar', 'length' => 191, 'description' => 'display name', 'collate' => 'utf8_general_ci'),
+ 'nickname' => array('type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'nickname or username', 'collate' => 'utf8mb4_general_ci'),
+ 'fullname' => array('type' => 'varchar', 'length' => 191, 'description' => 'display name', 'collate' => 'utf8mb4_general_ci'),
'profileurl' => array('type' => 'varchar', 'length' => 191, 'description' => 'URL, cached so we dont regenerate'),
- 'homepage' => array('type' => 'varchar', 'length' => 191, 'description' => 'identifying URL', 'collate' => 'utf8_general_ci'),
- 'bio' => array('type' => 'text', 'description' => 'descriptive biography', 'collate' => 'utf8_general_ci'),
- 'location' => array('type' => 'varchar', 'length' => 191, 'description' => 'physical location', 'collate' => 'utf8_general_ci'),
+ 'homepage' => array('type' => 'varchar', 'length' => 191, 'description' => 'identifying URL', 'collate' => 'utf8mb4_general_ci'),
+ 'bio' => array('type' => 'text', 'description' => 'descriptive biography', 'collate' => 'utf8mb4_general_ci'),
+ 'location' => array('type' => 'varchar', 'length' => 191, 'description' => 'physical location', 'collate' => 'utf8mb4_general_ci'),
'lat' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'latitude'),
'lon' => array('type' => 'numeric', 'precision' => 10, 'scale' => 7, 'description' => 'longitude'),
'location_id' => array('type' => 'int', 'description' => 'location id if possible'),
return true;
}
+ // Returns false if the user has no password (which will always
+ // be the case for remote users). This can be the case for OpenID
+ // logins or other mechanisms which don't store a password hash.
+ public function hasPassword()
+ {
+ try {
+ return $this->getUser()->hasPassword();
+ } catch (NoSuchUserException $e) {
+ return false;
+ }
+ }
+
public function getObjectType()
{
// FIXME: More types... like peopletags and whatever
return null;
}
+ function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
+ {
+ return Reply::stream($this->getID(), $offset, $limit, $since_id, $before_id);
+ }
+
function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
{
$stream = new TaggedProfileNoticeStream($this, $tag);
function delete($useWhere=false)
{
+ // just in case it hadn't been done before... (usually set before adding deluser to queue handling!)
+ if (!$this->hasRole(Profile_role::DELETED)) {
+ $this->grantRole(Profile_role::DELETED);
+ }
+
$this->_deleteNotices();
$this->_deleteSubscriptions();
$this->_deleteTags();
$inst->delete();
}
+ $localuser = User::getKV('id', $this->id);
+ if ($localuser instanceof User) {
+ $localuser->delete();
+ }
+
return parent::delete($useWhere);
}
return $this->nickname;
}
+ public function getFullname()
+ {
+ return $this->fullname;
+ }
+
+ public function getHomepage()
+ {
+ return $this->homepage;
+ }
+
public function getDescription()
{
return $this->bio;
return $this;
}
+ /**
+ * Test whether the given profile is the same as the current class,
+ * for testing identities.
+ *
+ * @param Profile $other The other profile, usually from Action's $this->scoped
+ *
+ * @return boolean
+ */
+ public function sameAs(Profile $other=null)
+ {
+ if (is_null($other)) {
+ // In case $this->scoped is null or something, i.e. not a current/legitimate profile.
+ return false;
+ }
+ return $this->getID() === $other->getID();
+ }
+
/**
* This will perform shortenLinks with the connected User object.
*
public function setPref($namespace, $topic, $data) {
return Profile_prefs::setData($this, $namespace, $topic, $data);
}
+
+ public function getConnectedApps($offset=0, $limit=null)
+ {
+ return $this->getUser()->getConnectedApps($offset, $limit);
+ }
}