X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FRequireValidatedEmail%2FRequireValidatedEmailPlugin.php;h=b6bd6f7e5fbeae4bc8c47ca44e22652c2e8fd181;hb=5519da95fdadf61828b2ed5d8a89f59ed79fdff0;hp=6c0ef37d519b4f44d5d4b0636069ec6964fbe71e;hpb=1e3d5f80258811ce1c2154fcd971297e24264894;p=quix0rs-gnu-social.git diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php index 6c0ef37d51..b6bd6f7e5f 100644 --- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php +++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php @@ -24,6 +24,8 @@ * @package StatusNet * @author Craig Andrews * @author Brion Vibber + * @author Evan Prodromou + * @copyright 2011 StatusNet Inc. http://status.net/ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -75,6 +77,33 @@ class RequireValidatedEmailPlugin extends Plugin public $trustedOpenIDs = array(); + /** + * Whether or not to disallow login for unvalidated users. + */ + + public $disallowLogin = false; + + function onAutoload($cls) + { + $dir = dirname(__FILE__); + + switch ($cls) + { + case 'ConfirmfirstemailAction': + include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; + return false; + default: + return true; + } + } + + function onRouterInitialized($m) + { + $m->connect('main/confirmfirst/:code', + array('action' => 'confirmfirstemail')); + return true; + } + /** * Event handler for notice saves; rejects the notice * if user's address isn't validated. @@ -235,4 +264,34 @@ class RequireValidatedEmailPlugin extends Plugin } return true; } + + /** + * Prevent unvalidated folks from creating spam groups. + * + * @param Profile $profile User profile we're checking + * @param string $right rights key + * @param boolean $result if overriding, set to true/false has right + * @return boolean hook result value + */ + function onUserRightsCheck(Profile $profile, $right, &$result) + { + if ($right == Right::CREATEGROUP || + ($this->disallowLogin && ($right == Right::WEBLOGIN || $right == Right::API))) { + $user = User::staticGet('id', $profile->id); + if ($user && !$this->validated($user)) { + $result = false; + return false; + } + } + return true; + } + + function onLoginAction($action, &$login) + { + if ($action == 'confirmfirstemail') { + $login = true; + return false; + } + return true; + } }