Tidying up getUser calls to profiles and some events
getUser calls are much more strict, and one place where this was found was in the (un)subscribe start/end event handlers, which resulted in making the Subscription class a bit stricter, regarding ::start and ::cancel at least. Several minor fixes in many files were made due to this. This does NOT touch the Foreign_link function, which should also have a more strict getUser call. That is a future project.
This commit is contained in:
@@ -79,16 +79,8 @@ class Subscription extends Managed_DataObject
|
||||
* @return mixed Subscription or Subscription_queue: new subscription info
|
||||
*/
|
||||
|
||||
static function start($subscriber, $other, $force=false)
|
||||
static function start(Profile $subscriber, Profile $other, $force=false)
|
||||
{
|
||||
// @fixme should we enforce this as profiles in callers instead?
|
||||
if ($subscriber instanceof User) {
|
||||
$subscriber = $subscriber->getProfile();
|
||||
}
|
||||
if ($other instanceof User) {
|
||||
$other = $other->getProfile();
|
||||
}
|
||||
|
||||
if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
|
||||
// TRANS: Exception thrown when trying to subscribe while being banned from subscribing.
|
||||
throw new Exception(_('You have been banned from subscribing.'));
|
||||
@@ -193,7 +185,7 @@ class Subscription extends Managed_DataObject
|
||||
* Cancel a subscription
|
||||
*
|
||||
*/
|
||||
function cancel($subscriber, $other)
|
||||
function cancel(Profile $subscriber, Profile $other)
|
||||
{
|
||||
if (!self::exists($subscriber, $other)) {
|
||||
// TRANS: Exception thrown when trying to unsibscribe without a subscription.
|
||||
|
Reference in New Issue
Block a user