forked from GNUsocial/gnu-social
Merge branch '0.9.x' into 1.0.x
This commit is contained in:
commit
e211e6228d
17
EVENTS.txt
17
EVENTS.txt
@ -987,9 +987,12 @@ EndRevokeRole: when a role has been revoked
|
|||||||
|
|
||||||
StartAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
StartAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
||||||
- &$activity: received activity
|
- &$activity: received activity
|
||||||
|
- $user: user publishing the entry
|
||||||
|
- &$notice: notice created; initially null, can be set
|
||||||
|
|
||||||
EndAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
EndAtomPubNewActivity: When a new activity comes in through Atom Pub API
|
||||||
- $activity: received activity
|
- $activity: received activity
|
||||||
|
- $user: user publishing the entry
|
||||||
- $notice: notice that was created
|
- $notice: notice that was created
|
||||||
|
|
||||||
StartXrdActionAliases: About to set aliases for the XRD object for a user
|
StartXrdActionAliases: About to set aliases for the XRD object for a user
|
||||||
@ -1041,3 +1044,17 @@ StartActivityObjectFromGroup: When converting a group to an activity:object
|
|||||||
EndActivityObjectFromGroup: After converting a group to an activity:object
|
EndActivityObjectFromGroup: After converting a group to an activity:object
|
||||||
- $group: The group being converted
|
- $group: The group being converted
|
||||||
- &$object: The finished object. Tweak as needed.
|
- &$object: The finished object. Tweak as needed.
|
||||||
|
|
||||||
|
StartImportActivity: when we start to import an activity
|
||||||
|
- $user: User to make the author import
|
||||||
|
- $author: Author of the feed; good for comparisons
|
||||||
|
- $activity: The current activity
|
||||||
|
- $trusted: How "trusted" the process is
|
||||||
|
- &$done: Return value; whether to continue
|
||||||
|
|
||||||
|
EndImportActivity: when we finish importing an activity
|
||||||
|
- $user: User to make the author import
|
||||||
|
- $author: Author of the feed; good for comparisons
|
||||||
|
- $activity: The current activity
|
||||||
|
- $trusted: How "trusted" the process is
|
||||||
|
|
||||||
|
@ -324,7 +324,9 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
$activity = new Activity($dom->documentElement);
|
$activity = new Activity($dom->documentElement);
|
||||||
|
|
||||||
if (Event::handle('StartAtomPubNewActivity', array(&$activity))) {
|
$saved = null;
|
||||||
|
|
||||||
|
if (Event::handle('StartAtomPubNewActivity', array(&$activity, $this->user, &$saved))) {
|
||||||
|
|
||||||
if ($activity->verb != ActivityVerb::POST) {
|
if ($activity->verb != ActivityVerb::POST) {
|
||||||
// TRANS: Client error displayed when not using the POST verb.
|
// TRANS: Client error displayed when not using the POST verb.
|
||||||
@ -347,7 +349,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
$saved = $this->postNote($activity);
|
$saved = $this->postNote($activity);
|
||||||
|
|
||||||
Event::handle('EndAtomPubNewActivity', array($activity, $saved));
|
Event::handle('EndAtomPubNewActivity', array($activity, $this->user, $saved));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($saved)) {
|
if (!empty($saved)) {
|
||||||
|
@ -66,6 +66,13 @@ class NewgroupAction extends Action
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
if (!$profile->hasRight(Right::CREATEGROUP)) {
|
||||||
|
// TRANS: Client exception thrown when a user tries to create a group while banned.
|
||||||
|
throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +109,11 @@ class Notice extends Memcached_DataObject
|
|||||||
// @fixme we have some cases where things get re-run and so the
|
// @fixme we have some cases where things get re-run and so the
|
||||||
// insert fails.
|
// insert fails.
|
||||||
$deleted = Deleted_notice::staticGet('id', $this->id);
|
$deleted = Deleted_notice::staticGet('id', $this->id);
|
||||||
|
|
||||||
|
if (!$deleted) {
|
||||||
|
$deleted = Deleted_notice::staticGet('uri', $this->uri);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$deleted) {
|
if (!$deleted) {
|
||||||
$deleted = new Deleted_notice();
|
$deleted = new Deleted_notice();
|
||||||
|
|
||||||
@ -2033,7 +2038,7 @@ class Notice extends Memcached_DataObject
|
|||||||
*/
|
*/
|
||||||
public static function addWhereSinceId(DB_DataObject $obj, $id, $idField='id', $createdField='created')
|
public static function addWhereSinceId(DB_DataObject $obj, $id, $idField='id', $createdField='created')
|
||||||
{
|
{
|
||||||
$since = self::whereSinceId($id);
|
$since = self::whereSinceId($id, $idField, $createdField);
|
||||||
if ($since) {
|
if ($since) {
|
||||||
$obj->whereAdd($since);
|
$obj->whereAdd($since);
|
||||||
}
|
}
|
||||||
@ -2072,7 +2077,7 @@ class Notice extends Memcached_DataObject
|
|||||||
*/
|
*/
|
||||||
public static function addWhereMaxId(DB_DataObject $obj, $id, $idField='id', $createdField='created')
|
public static function addWhereMaxId(DB_DataObject $obj, $id, $idField='id', $createdField='created')
|
||||||
{
|
{
|
||||||
$max = self::whereMaxId($id);
|
$max = self::whereMaxId($id, $idField, $createdField);
|
||||||
if ($max) {
|
if ($max) {
|
||||||
$obj->whereAdd($max);
|
$obj->whereAdd($max);
|
||||||
}
|
}
|
||||||
|
@ -850,6 +850,7 @@ class Profile extends Memcached_DataObject
|
|||||||
case Right::NEWNOTICE:
|
case Right::NEWNOTICE:
|
||||||
case Right::NEWMESSAGE:
|
case Right::NEWMESSAGE:
|
||||||
case Right::SUBSCRIBE:
|
case Right::SUBSCRIBE:
|
||||||
|
case Right::CREATEGROUP:
|
||||||
$result = !$this->isSilenced();
|
$result = !$this->isSilenced();
|
||||||
break;
|
break;
|
||||||
case Right::PUBLICNOTICE:
|
case Right::PUBLICNOTICE:
|
||||||
|
@ -476,6 +476,16 @@ class User_group extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function register($fields) {
|
static function register($fields) {
|
||||||
|
if (!empty($fields['userid'])) {
|
||||||
|
$profile = Profile::staticGet('id', $fields['userid']);
|
||||||
|
if ($profile && !$profile->hasRight(Right::CREATEGROUP)) {
|
||||||
|
common_log(LOG_WARNING, "Attempted group creation from banned user: " . $profile->nickname);
|
||||||
|
|
||||||
|
// TRANS: Client exception thrown when a user tries to create a group while banned.
|
||||||
|
throw new ClientException(_('You are not allowed to create groups on this site.'), 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MAGICALLY put fields into current scope
|
// MAGICALLY put fields into current scope
|
||||||
|
|
||||||
extract($fields);
|
extract($fields);
|
||||||
|
@ -63,31 +63,40 @@ class ActivityImporter extends QueueHandler
|
|||||||
|
|
||||||
$this->trusted = $trusted;
|
$this->trusted = $trusted;
|
||||||
|
|
||||||
try {
|
$done = null;
|
||||||
switch ($activity->verb) {
|
|
||||||
case ActivityVerb::FOLLOW:
|
if (Event::handle('StartImportActivity',
|
||||||
$this->subscribeProfile($user, $author, $activity);
|
array($user, $author, $activity, $trusted, &$done))) {
|
||||||
break;
|
|
||||||
case ActivityVerb::JOIN:
|
try {
|
||||||
$this->joinGroup($user, $activity);
|
switch ($activity->verb) {
|
||||||
break;
|
case ActivityVerb::FOLLOW:
|
||||||
case ActivityVerb::POST:
|
$this->subscribeProfile($user, $author, $activity);
|
||||||
$this->postNote($user, $author, $activity);
|
break;
|
||||||
break;
|
case ActivityVerb::JOIN:
|
||||||
default:
|
$this->joinGroup($user, $activity);
|
||||||
throw new Exception("Unknown verb: {$activity->verb}");
|
break;
|
||||||
|
case ActivityVerb::POST:
|
||||||
|
$this->postNote($user, $author, $activity);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ClientException("Unknown verb: {$activity->verb}");
|
||||||
|
}
|
||||||
|
Event::handle('EndImportActivity',
|
||||||
|
array($user, $author, $activity, $trusted));
|
||||||
|
$done = true;
|
||||||
|
} catch (ClientException $ce) {
|
||||||
|
common_log(LOG_WARNING, $ce->getMessage());
|
||||||
|
$done = true;
|
||||||
|
} catch (ServerException $se) {
|
||||||
|
common_log(LOG_ERR, $se->getMessage());
|
||||||
|
$done = false;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
common_log(LOG_ERR, $e->getMessage());
|
||||||
|
$done = false;
|
||||||
}
|
}
|
||||||
} catch (ClientException $ce) {
|
|
||||||
common_log(LOG_WARNING, $ce->getMessage());
|
|
||||||
return true;
|
|
||||||
} catch (ServerException $se) {
|
|
||||||
common_log(LOG_ERR, $se->getMessage());
|
|
||||||
return false;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
common_log(LOG_ERR, $e->getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return $done;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribeProfile($user, $author, $activity)
|
function subscribeProfile($user, $author, $activity)
|
||||||
|
@ -65,5 +65,6 @@ class Right
|
|||||||
const RESTOREACCOUNT = 'restoreaccount';
|
const RESTOREACCOUNT = 'restoreaccount';
|
||||||
const DELETEACCOUNT = 'deleteaccount';
|
const DELETEACCOUNT = 'deleteaccount';
|
||||||
const MOVEACCOUNT = 'moveaccount';
|
const MOVEACCOUNT = 'moveaccount';
|
||||||
|
const CREATEGROUP = 'creategroup';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user