public static function schemaDef()
{
- return array(
+ $def = array(
'fields' => array(
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'),
- 'content' => array('type' => 'text', 'description' => 'update content'),
+ 'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8_general_ci'),
'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
'repeat_of' => array('type' => 'int', 'description' => 'notice this is a repeat of'),
'object_type' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams object type', 'default' => 'http://activitystrea.ms/schema/1.0/note'),
+ 'verb' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'),
'scope' => array('type' => 'int',
- 'default' => '1',
- 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'),
+ 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers; null = default'),
),
'primary key' => array('id'),
'unique keys' => array(
'notice_created_idx' => array('created'),
'notice_replyto_idx' => array('reply_to'),
'notice_repeatof_idx' => array('repeat_of'),
- ),
- 'fulltext indexes' => array(
- 'content' => array('content'),
)
);
+
+ if (common_config('search', 'type') == 'fulltext') {
+ $def['fulltext indexes'] = array('content' => array('content'));
+ }
+
+ return $def;
}
function multiGet($kc, $kvs, $skipNulls=true)
if (empty($verb)) {
if (!empty($notice->repeat_of)) {
$notice->verb = ActivityVerb::SHARE;
- $notice->object_type = ActivityVerb::ACTIVITY;
+ $notice->object_type = ActivityObject::ACTIVITY;
} else {
$notice->verb = ActivityVerb::POST;
}
if (!empty($this->repeat_of)) {
$repeat = Notice::staticGet('id', $this->repeat_of);
- $ctx->forwardID = $repeat->uri;
- $ctx->forwardUrl = $repeat->bestUrl();
+ if (!empty($repeat)) {
+ $ctx->forwardID = $repeat->uri;
+ $ctx->forwardUrl = $repeat->bestUrl();
+ }
}
$act->context = $ctx;
protected function _inScope($profile)
{
+ if (!is_null($this->scope)) {
+ $scope = $this->scope;
+ } else {
+ $scope = self::defaultScope();
+ }
+
// If there's no scope, anyone (even anon) is in scope.
- if ($this->scope == 0) {
+ if ($scope == 0) {
return true;
}
// Only for users on this site
- if ($this->scope & Notice::SITE_SCOPE) {
+ if ($scope & Notice::SITE_SCOPE) {
$user = $profile->getUser();
if (empty($user)) {
return false;
// Only for users mentioned in the notice
- if ($this->scope & Notice::ADDRESSEE_SCOPE) {
+ if ($scope & Notice::ADDRESSEE_SCOPE) {
$repl = Reply::pkeyGet(array('notice_id' => $this->id,
'profile_id' => $profile->id));
// Only for members of the given group
- if ($this->scope & Notice::GROUP_SCOPE) {
+ if ($scope & Notice::GROUP_SCOPE) {
// XXX: just query for the single membership
// Only for followers of the author
- if ($this->scope & Notice::FOLLOWER_SCOPE) {
+ if ($scope & Notice::FOLLOWER_SCOPE) {
$author = $this->getProfile();
if (!Subscription::exists($profile, $author)) {
return false;
return $this->_faves;
}
- function _setFaves(&$faves)
+ function _setFaves($faves)
{
$this->_faves = $faves;
}
}
foreach ($notices as $notice) {
$faves = $faveMap[$notice->id];
- $notice->_setFaves(&$faves);
+ $notice->_setFaves($faves);
}
}
return $this->_repeats;
}
- function _setRepeats(&$repeats)
+ function _setRepeats($repeats)
{
$this->_repeats = $repeats;
}
$repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', $ids);
foreach ($notices as $notice) {
$repeats = $repeatMap[$notice->id];
- $notice->_setRepeats(&$repeats);
+ $notice->_setRepeats($repeats);
}
}
}