X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FSubscriptionThrottle%2FSubscriptionThrottlePlugin.php;h=fec91afdb78d859efd0ed72be1028802e079596f;hb=7d53b5ee04f0325d5b43c977a52a66b78f24994b;hp=e898ce9ae0a376d592c8e5ae4d3a369d4b16d535;hpb=1e73ba00bdd37f46415eb45b1b904dc894fb801c;p=quix0rs-gnu-social.git diff --git a/plugins/SubscriptionThrottle/SubscriptionThrottlePlugin.php b/plugins/SubscriptionThrottle/SubscriptionThrottlePlugin.php index e898ce9ae0..fec91afdb7 100644 --- a/plugins/SubscriptionThrottle/SubscriptionThrottlePlugin.php +++ b/plugins/SubscriptionThrottle/SubscriptionThrottlePlugin.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class SubscriptionThrottlePlugin extends Plugin { public $subLimits = array(86400 => 100, @@ -56,22 +55,22 @@ class SubscriptionThrottlePlugin extends Plugin /** * Filter subscriptions to see if they're coming too fast. * - * @param User $user The user subscribing - * @param User $other The user being subscribed to + * @param Profile $profile The profile subscribing + * @param Profile $other The profile being subscribed to * * @return boolean hook value */ - - function onStartSubscribe($user, $other) + function onStartSubscribe(Profile $profile, $other) { foreach ($this->subLimits as $seconds => $limit) { - $sub = $this->_getNthSub($user, $limit); + $sub = $this->_getNthSub($profile, $limit); if (!empty($sub)) { $subtime = strtotime($sub->created); $now = time(); if ($now - $subtime < $seconds) { - throw new Exception(_m("Too many subscriptions. Take a break and try again later.")); + // TRANS: Exception thrown when subscribing too quickly. + throw new Exception(_m('Too many subscriptions. Take a break and try again later.')); } } } @@ -82,22 +81,22 @@ class SubscriptionThrottlePlugin extends Plugin /** * Filter group joins to see if they're coming too fast. * - * @param Group $group The group being joined - * @param User $user The user joining + * @param Group $group The group being joined + * @param Profile $profile The profile joining * * @return boolean hook value */ - - function onStartJoinGroup($group, $user) + function onStartJoinGroup($group, $profile) { foreach ($this->groupLimits as $seconds => $limit) { - $mem = $this->_getNthMem($user, $limit); + $mem = $this->_getNthMem($profile, $limit); if (!empty($mem)) { $jointime = strtotime($mem->created); $now = time(); if ($now - $jointime < $seconds) { - throw new Exception(_m("Too many memberships. Take a break and try again later.")); + // TRANS: Exception thrown when joing groups too quickly. + throw new Exception(_m('Too many memberships. Take a break and try again later.')); } } } @@ -106,19 +105,18 @@ class SubscriptionThrottlePlugin extends Plugin } /** - * Get the Nth most recent subscription for this user + * Get the Nth most recent subscription for this profile * - * @param User $user The user to get subscriptions for - * @param integer $n How far to count back + * @param Profile $profile profile to get subscriptions for + * @param integer $n How far to count back * * @return Subscription a subscription or null */ - - private function _getNthSub($user, $n) + private function _getNthSub(Profile $profile, $n) { $sub = new Subscription(); - $sub->subscriber = $user->id; + $sub->subscriber = $profile->id; $sub->orderBy('created DESC'); $sub->limit($n - 1, 1); @@ -130,19 +128,18 @@ class SubscriptionThrottlePlugin extends Plugin } /** - * Get the Nth most recent group membership for this user + * Get the Nth most recent group membership for this profile * - * @param User $user The user to get memberships for - * @param integer $n How far to count back + * @param Profile $profile The user to get memberships for + * @param integer $n How far to count back * * @return Group_member a membership or null */ - - private function _getNthMem($user, $n) + private function _getNthMem(Profile $profile, $n) { $mem = new Group_member(); - $mem->profile_id = $user->id; + $mem->profile_id = $profile->id; $mem->orderBy('created DESC'); $mem->limit($n - 1, 1); @@ -160,16 +157,15 @@ class SubscriptionThrottlePlugin extends Plugin * * @return boolean hook value */ - - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'SubscriptionThrottle', - 'version' => STATUSNET_VERSION, + 'version' => GNUSOCIAL_VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:SubscriptionThrottle', 'rawdescription' => + // TRANS: Plugin description. _m('Configurable limits for subscriptions and group memberships.')); return true; } } -