@@ -16,16 +16,16 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | function smarty_modifier_date($input) |
| 18 | 18 | { |
| 19 | - if (gettype($input) === 'object' |
|
| 20 | - && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
| 21 | - ) { |
|
| 22 | - /** @var $date DateTime|DateTimeImmutable */ |
|
| 23 | - $date = $input; |
|
| 24 | - $dateString = $date->format('Y-m-d H:i:s'); |
|
| 19 | + if (gettype($input) === 'object' |
|
| 20 | + && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
| 21 | + ) { |
|
| 22 | + /** @var $date DateTime|DateTimeImmutable */ |
|
| 23 | + $date = $input; |
|
| 24 | + $dateString = $date->format('Y-m-d H:i:s'); |
|
| 25 | 25 | |
| 26 | - return $dateString; |
|
| 27 | - } |
|
| 28 | - else { |
|
| 29 | - return $input; |
|
| 30 | - } |
|
| 26 | + return $dateString; |
|
| 27 | + } |
|
| 28 | + else { |
|
| 29 | + return $input; |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -13,87 +13,87 @@ |
||
| 13 | 13 | |
| 14 | 14 | class LogSearchHelper extends SearchHelperBase |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * LogSearchHelper constructor. |
|
| 18 | - * |
|
| 19 | - * @param PdoDatabase $database |
|
| 20 | - */ |
|
| 21 | - protected function __construct(PdoDatabase $database) |
|
| 22 | - { |
|
| 23 | - parent::__construct($database, 'log', Log::class, 'timestamp DESC'); |
|
| 24 | - } |
|
| 16 | + /** |
|
| 17 | + * LogSearchHelper constructor. |
|
| 18 | + * |
|
| 19 | + * @param PdoDatabase $database |
|
| 20 | + */ |
|
| 21 | + protected function __construct(PdoDatabase $database) |
|
| 22 | + { |
|
| 23 | + parent::__construct($database, 'log', Log::class, 'timestamp DESC'); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Initiates a search for requests |
|
| 28 | - * |
|
| 29 | - * @param PdoDatabase $database |
|
| 30 | - * |
|
| 31 | - * @return LogSearchHelper |
|
| 32 | - */ |
|
| 33 | - public static function get(PdoDatabase $database) |
|
| 34 | - { |
|
| 35 | - $helper = new LogSearchHelper($database); |
|
| 26 | + /** |
|
| 27 | + * Initiates a search for requests |
|
| 28 | + * |
|
| 29 | + * @param PdoDatabase $database |
|
| 30 | + * |
|
| 31 | + * @return LogSearchHelper |
|
| 32 | + */ |
|
| 33 | + public static function get(PdoDatabase $database) |
|
| 34 | + { |
|
| 35 | + $helper = new LogSearchHelper($database); |
|
| 36 | 36 | |
| 37 | - return $helper; |
|
| 38 | - } |
|
| 37 | + return $helper; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Filters the results by user |
|
| 42 | - * |
|
| 43 | - * @param int $userId |
|
| 44 | - * |
|
| 45 | - * @return $this |
|
| 46 | - */ |
|
| 47 | - public function byUser($userId) |
|
| 48 | - { |
|
| 49 | - $this->whereClause .= ' AND user = ?'; |
|
| 50 | - $this->parameterList[] = $userId; |
|
| 40 | + /** |
|
| 41 | + * Filters the results by user |
|
| 42 | + * |
|
| 43 | + * @param int $userId |
|
| 44 | + * |
|
| 45 | + * @return $this |
|
| 46 | + */ |
|
| 47 | + public function byUser($userId) |
|
| 48 | + { |
|
| 49 | + $this->whereClause .= ' AND user = ?'; |
|
| 50 | + $this->parameterList[] = $userId; |
|
| 51 | 51 | |
| 52 | - return $this; |
|
| 53 | - } |
|
| 52 | + return $this; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Filters the results by log action |
|
| 57 | - * |
|
| 58 | - * @param string $action |
|
| 59 | - * |
|
| 60 | - * @return $this |
|
| 61 | - */ |
|
| 62 | - public function byAction($action) |
|
| 63 | - { |
|
| 64 | - $this->whereClause .= ' AND action = ?'; |
|
| 65 | - $this->parameterList[] = $action; |
|
| 55 | + /** |
|
| 56 | + * Filters the results by log action |
|
| 57 | + * |
|
| 58 | + * @param string $action |
|
| 59 | + * |
|
| 60 | + * @return $this |
|
| 61 | + */ |
|
| 62 | + public function byAction($action) |
|
| 63 | + { |
|
| 64 | + $this->whereClause .= ' AND action = ?'; |
|
| 65 | + $this->parameterList[] = $action; |
|
| 66 | 66 | |
| 67 | - return $this; |
|
| 68 | - } |
|
| 67 | + return $this; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Filters the results by object type |
|
| 72 | - * |
|
| 73 | - * @param string $objectType |
|
| 74 | - * |
|
| 75 | - * @return $this |
|
| 76 | - */ |
|
| 77 | - public function byObjectType($objectType) |
|
| 78 | - { |
|
| 79 | - $this->whereClause .= ' AND objecttype = ?'; |
|
| 80 | - $this->parameterList[] = $objectType; |
|
| 70 | + /** |
|
| 71 | + * Filters the results by object type |
|
| 72 | + * |
|
| 73 | + * @param string $objectType |
|
| 74 | + * |
|
| 75 | + * @return $this |
|
| 76 | + */ |
|
| 77 | + public function byObjectType($objectType) |
|
| 78 | + { |
|
| 79 | + $this->whereClause .= ' AND objecttype = ?'; |
|
| 80 | + $this->parameterList[] = $objectType; |
|
| 81 | 81 | |
| 82 | - return $this; |
|
| 83 | - } |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Filters the results by object type |
|
| 87 | - * |
|
| 88 | - * @param integer $objectId |
|
| 89 | - * |
|
| 90 | - * @return $this |
|
| 91 | - */ |
|
| 92 | - public function byObjectId($objectId) |
|
| 93 | - { |
|
| 94 | - $this->whereClause .= ' AND objectid = ?'; |
|
| 95 | - $this->parameterList[] = $objectId; |
|
| 85 | + /** |
|
| 86 | + * Filters the results by object type |
|
| 87 | + * |
|
| 88 | + * @param integer $objectId |
|
| 89 | + * |
|
| 90 | + * @return $this |
|
| 91 | + */ |
|
| 92 | + public function byObjectId($objectId) |
|
| 93 | + { |
|
| 94 | + $this->whereClause .= ' AND objectid = ?'; |
|
| 95 | + $this->parameterList[] = $objectId; |
|
| 96 | 96 | |
| 97 | - return $this; |
|
| 98 | - } |
|
| 97 | + return $this; |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | \ No newline at end of file |
@@ -187,7 +187,8 @@ |
||
| 187 | 187 | $endpoint = $this->siteConfiguration->getMetaWikimediaWebServiceEndpoint(); |
| 188 | 188 | $response = $this->httpHelper->get($endpoint, $parameters); |
| 189 | 189 | $response = json_decode($response, true); |
| 190 | - } catch (CurlException $ex) { |
|
| 190 | + } |
|
| 191 | + catch (CurlException $ex) { |
|
| 191 | 192 | // failed getting identification status, so throw a nicer error. |
| 192 | 193 | $m = 'Could not contact metawiki API to determine user\' identification status. ' |
| 193 | 194 | . 'This is probably a transient error, so please try again.'; |
@@ -26,133 +26,133 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | class IdentificationVerifier |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * This field is an array of parameters, in key => value format, that should be appended to the Meta Wikimedia |
|
| 31 | - * Web Service Endpoint URL to query if a user is listed on the Identification Noticeboard. Note that URL encoding |
|
| 32 | - * of these values is *not* necessary; this is done automatically. |
|
| 33 | - * |
|
| 34 | - * @var string[] |
|
| 35 | - * @category Security-Critical |
|
| 36 | - */ |
|
| 37 | - private static $apiQueryParameters = array( |
|
| 38 | - 'action' => 'query', |
|
| 39 | - 'format' => 'json', |
|
| 40 | - 'prop' => 'links', |
|
| 41 | - // Populated from SiteConfiguration->getIdentificationNoticeboardPage |
|
| 42 | - 'titles' => '', |
|
| 43 | - // Username of the user to be checked, with User: prefix, goes here! Set in isIdentifiedOnWiki() |
|
| 44 | - 'pltitles' => '', |
|
| 45 | - ); |
|
| 46 | - /** @var HttpHelper */ |
|
| 47 | - private $httpHelper; |
|
| 48 | - /** @var SiteConfiguration */ |
|
| 49 | - private $siteConfiguration; |
|
| 50 | - /** @var PdoDatabase */ |
|
| 51 | - private $dbObject; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * IdentificationVerifier constructor. |
|
| 55 | - * |
|
| 56 | - * @param HttpHelper $httpHelper |
|
| 57 | - * @param SiteConfiguration $siteConfiguration |
|
| 58 | - * @param PdoDatabase $dbObject |
|
| 59 | - */ |
|
| 60 | - public function __construct(HttpHelper $httpHelper, SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
|
| 61 | - { |
|
| 62 | - $this->httpHelper = $httpHelper; |
|
| 63 | - $this->siteConfiguration = $siteConfiguration; |
|
| 64 | - $this->dbObject = $dbObject; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Checks if the given user is identified to the Wikimedia Foundation. |
|
| 69 | - * |
|
| 70 | - * @param string $onWikiName The Wikipedia username of the user |
|
| 71 | - * |
|
| 72 | - * @return bool |
|
| 73 | - * @category Security-Critical |
|
| 74 | - * @throws EnvironmentException |
|
| 75 | - */ |
|
| 76 | - public function isUserIdentified($onWikiName) |
|
| 77 | - { |
|
| 78 | - if ($this->checkIdentificationCache($onWikiName)) { |
|
| 79 | - return true; |
|
| 80 | - } |
|
| 81 | - else { |
|
| 82 | - if ($this->isIdentifiedOnWiki($onWikiName)) { |
|
| 83 | - $this->cacheIdentificationStatus($onWikiName); |
|
| 84 | - |
|
| 85 | - return true; |
|
| 86 | - } |
|
| 87 | - else { |
|
| 88 | - return false; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Checks if the given user has a valid entry in the idcache table. |
|
| 95 | - * |
|
| 96 | - * @param string $onWikiName The Wikipedia username of the user |
|
| 97 | - * |
|
| 98 | - * @return bool |
|
| 99 | - * @category Security-Critical |
|
| 100 | - */ |
|
| 101 | - private function checkIdentificationCache($onWikiName) |
|
| 102 | - { |
|
| 103 | - $interval = $this->siteConfiguration->getIdentificationCacheExpiry(); |
|
| 104 | - |
|
| 105 | - $query = <<<SQL |
|
| 29 | + /** |
|
| 30 | + * This field is an array of parameters, in key => value format, that should be appended to the Meta Wikimedia |
|
| 31 | + * Web Service Endpoint URL to query if a user is listed on the Identification Noticeboard. Note that URL encoding |
|
| 32 | + * of these values is *not* necessary; this is done automatically. |
|
| 33 | + * |
|
| 34 | + * @var string[] |
|
| 35 | + * @category Security-Critical |
|
| 36 | + */ |
|
| 37 | + private static $apiQueryParameters = array( |
|
| 38 | + 'action' => 'query', |
|
| 39 | + 'format' => 'json', |
|
| 40 | + 'prop' => 'links', |
|
| 41 | + // Populated from SiteConfiguration->getIdentificationNoticeboardPage |
|
| 42 | + 'titles' => '', |
|
| 43 | + // Username of the user to be checked, with User: prefix, goes here! Set in isIdentifiedOnWiki() |
|
| 44 | + 'pltitles' => '', |
|
| 45 | + ); |
|
| 46 | + /** @var HttpHelper */ |
|
| 47 | + private $httpHelper; |
|
| 48 | + /** @var SiteConfiguration */ |
|
| 49 | + private $siteConfiguration; |
|
| 50 | + /** @var PdoDatabase */ |
|
| 51 | + private $dbObject; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * IdentificationVerifier constructor. |
|
| 55 | + * |
|
| 56 | + * @param HttpHelper $httpHelper |
|
| 57 | + * @param SiteConfiguration $siteConfiguration |
|
| 58 | + * @param PdoDatabase $dbObject |
|
| 59 | + */ |
|
| 60 | + public function __construct(HttpHelper $httpHelper, SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
|
| 61 | + { |
|
| 62 | + $this->httpHelper = $httpHelper; |
|
| 63 | + $this->siteConfiguration = $siteConfiguration; |
|
| 64 | + $this->dbObject = $dbObject; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Checks if the given user is identified to the Wikimedia Foundation. |
|
| 69 | + * |
|
| 70 | + * @param string $onWikiName The Wikipedia username of the user |
|
| 71 | + * |
|
| 72 | + * @return bool |
|
| 73 | + * @category Security-Critical |
|
| 74 | + * @throws EnvironmentException |
|
| 75 | + */ |
|
| 76 | + public function isUserIdentified($onWikiName) |
|
| 77 | + { |
|
| 78 | + if ($this->checkIdentificationCache($onWikiName)) { |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 81 | + else { |
|
| 82 | + if ($this->isIdentifiedOnWiki($onWikiName)) { |
|
| 83 | + $this->cacheIdentificationStatus($onWikiName); |
|
| 84 | + |
|
| 85 | + return true; |
|
| 86 | + } |
|
| 87 | + else { |
|
| 88 | + return false; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Checks if the given user has a valid entry in the idcache table. |
|
| 95 | + * |
|
| 96 | + * @param string $onWikiName The Wikipedia username of the user |
|
| 97 | + * |
|
| 98 | + * @return bool |
|
| 99 | + * @category Security-Critical |
|
| 100 | + */ |
|
| 101 | + private function checkIdentificationCache($onWikiName) |
|
| 102 | + { |
|
| 103 | + $interval = $this->siteConfiguration->getIdentificationCacheExpiry(); |
|
| 104 | + |
|
| 105 | + $query = <<<SQL |
|
| 106 | 106 | SELECT COUNT(`id`) |
| 107 | 107 | FROM `idcache` |
| 108 | 108 | WHERE `onwikiusername` = :onwikiname |
| 109 | 109 | AND DATE_ADD(`checktime`, INTERVAL {$interval}) >= NOW(); |
| 110 | 110 | SQL; |
| 111 | - $stmt = $this->dbObject->prepare($query); |
|
| 112 | - $stmt->bindValue(':onwikiname', $onWikiName, PDO::PARAM_STR); |
|
| 113 | - $stmt->execute(); |
|
| 114 | - |
|
| 115 | - // Guaranteed by the query to only return a single row with a single column |
|
| 116 | - $results = $stmt->fetch(PDO::FETCH_NUM); |
|
| 117 | - |
|
| 118 | - // I don't expect this to ever be a value other than 0 or 1 since the `onwikiusername` column is declared as a |
|
| 119 | - // unique key - but meh. |
|
| 120 | - return $results[0] != 0; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Does pretty much exactly what it says on the label - this method will clear all expired idcache entries from the |
|
| 125 | - * idcache table. Meant to be called periodically by a maintenance script. |
|
| 126 | - * |
|
| 127 | - * @param SiteConfiguration $siteConfiguration |
|
| 128 | - * @param PdoDatabase $dbObject |
|
| 129 | - * |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - public static function clearExpiredCacheEntries(SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
|
| 133 | - { |
|
| 134 | - $interval = $siteConfiguration->getIdentificationCacheExpiry(); |
|
| 135 | - |
|
| 136 | - $query = <<<SQL |
|
| 111 | + $stmt = $this->dbObject->prepare($query); |
|
| 112 | + $stmt->bindValue(':onwikiname', $onWikiName, PDO::PARAM_STR); |
|
| 113 | + $stmt->execute(); |
|
| 114 | + |
|
| 115 | + // Guaranteed by the query to only return a single row with a single column |
|
| 116 | + $results = $stmt->fetch(PDO::FETCH_NUM); |
|
| 117 | + |
|
| 118 | + // I don't expect this to ever be a value other than 0 or 1 since the `onwikiusername` column is declared as a |
|
| 119 | + // unique key - but meh. |
|
| 120 | + return $results[0] != 0; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Does pretty much exactly what it says on the label - this method will clear all expired idcache entries from the |
|
| 125 | + * idcache table. Meant to be called periodically by a maintenance script. |
|
| 126 | + * |
|
| 127 | + * @param SiteConfiguration $siteConfiguration |
|
| 128 | + * @param PdoDatabase $dbObject |
|
| 129 | + * |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + public static function clearExpiredCacheEntries(SiteConfiguration $siteConfiguration, PdoDatabase $dbObject) |
|
| 133 | + { |
|
| 134 | + $interval = $siteConfiguration->getIdentificationCacheExpiry(); |
|
| 135 | + |
|
| 136 | + $query = <<<SQL |
|
| 137 | 137 | DELETE FROM `idcache` |
| 138 | 138 | WHERE DATE_ADD(`checktime`, INTERVAL {$interval}) < NOW(); |
| 139 | 139 | SQL; |
| 140 | - $dbObject->prepare($query)->execute(); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * This method will add an entry to the idcache that the given Wikipedia user has been verified as identified. This |
|
| 145 | - * is so we don't have to hit the API every single time we check. The cache entry is valid for as long as specified |
|
| 146 | - * in the ACC configuration (validity enforced by checkIdentificationCache() and clearExpiredCacheEntries()). |
|
| 147 | - * |
|
| 148 | - * @param string $onWikiName The Wikipedia username of the user |
|
| 149 | - * |
|
| 150 | - * @return void |
|
| 151 | - * @category Security-Critical |
|
| 152 | - */ |
|
| 153 | - private function cacheIdentificationStatus($onWikiName) |
|
| 154 | - { |
|
| 155 | - $query = <<<SQL |
|
| 140 | + $dbObject->prepare($query)->execute(); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * This method will add an entry to the idcache that the given Wikipedia user has been verified as identified. This |
|
| 145 | + * is so we don't have to hit the API every single time we check. The cache entry is valid for as long as specified |
|
| 146 | + * in the ACC configuration (validity enforced by checkIdentificationCache() and clearExpiredCacheEntries()). |
|
| 147 | + * |
|
| 148 | + * @param string $onWikiName The Wikipedia username of the user |
|
| 149 | + * |
|
| 150 | + * @return void |
|
| 151 | + * @category Security-Critical |
|
| 152 | + */ |
|
| 153 | + private function cacheIdentificationStatus($onWikiName) |
|
| 154 | + { |
|
| 155 | + $query = <<<SQL |
|
| 156 | 156 | INSERT INTO `idcache` |
| 157 | 157 | (`onwikiusername`) |
| 158 | 158 | VALUES |
@@ -161,45 +161,45 @@ discard block |
||
| 161 | 161 | `onwikiusername` = VALUES(`onwikiusername`), |
| 162 | 162 | `checktime` = CURRENT_TIMESTAMP; |
| 163 | 163 | SQL; |
| 164 | - $stmt = $this->dbObject->prepare($query); |
|
| 165 | - $stmt->bindValue(':onwikiname', $onWikiName, PDO::PARAM_STR); |
|
| 166 | - $stmt->execute(); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Queries the Wikimedia API to determine if the specified user is listed on the identification noticeboard. |
|
| 171 | - * |
|
| 172 | - * @param string $onWikiName The Wikipedia username of the user |
|
| 173 | - * |
|
| 174 | - * @return bool |
|
| 175 | - * @throws EnvironmentException |
|
| 176 | - * @category Security-Critical |
|
| 177 | - */ |
|
| 178 | - private function isIdentifiedOnWiki($onWikiName) |
|
| 179 | - { |
|
| 180 | - $strings = new StringFunctions(); |
|
| 181 | - |
|
| 182 | - // First character of Wikipedia usernames is always capitalized. |
|
| 183 | - $onWikiName = $strings->ucfirst($onWikiName); |
|
| 184 | - |
|
| 185 | - $parameters = self::$apiQueryParameters; |
|
| 186 | - $parameters['pltitles'] = "User:" . $onWikiName; |
|
| 187 | - $parameters['titles'] = $this->siteConfiguration->getIdentificationNoticeboardPage(); |
|
| 188 | - |
|
| 189 | - try { |
|
| 190 | - $endpoint = $this->siteConfiguration->getMetaWikimediaWebServiceEndpoint(); |
|
| 191 | - $response = $this->httpHelper->get($endpoint, $parameters); |
|
| 192 | - $response = json_decode($response, true); |
|
| 193 | - } catch (CurlException $ex) { |
|
| 194 | - // failed getting identification status, so throw a nicer error. |
|
| 195 | - $m = 'Could not contact metawiki API to determine user\' identification status. ' |
|
| 196 | - . 'This is probably a transient error, so please try again.'; |
|
| 197 | - |
|
| 198 | - throw new EnvironmentException($m, 0, $ex); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - $page = @array_pop($response['query']['pages']); |
|
| 202 | - |
|
| 203 | - return @$page['links'][0]['title'] === "User:" . $onWikiName; |
|
| 204 | - } |
|
| 164 | + $stmt = $this->dbObject->prepare($query); |
|
| 165 | + $stmt->bindValue(':onwikiname', $onWikiName, PDO::PARAM_STR); |
|
| 166 | + $stmt->execute(); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Queries the Wikimedia API to determine if the specified user is listed on the identification noticeboard. |
|
| 171 | + * |
|
| 172 | + * @param string $onWikiName The Wikipedia username of the user |
|
| 173 | + * |
|
| 174 | + * @return bool |
|
| 175 | + * @throws EnvironmentException |
|
| 176 | + * @category Security-Critical |
|
| 177 | + */ |
|
| 178 | + private function isIdentifiedOnWiki($onWikiName) |
|
| 179 | + { |
|
| 180 | + $strings = new StringFunctions(); |
|
| 181 | + |
|
| 182 | + // First character of Wikipedia usernames is always capitalized. |
|
| 183 | + $onWikiName = $strings->ucfirst($onWikiName); |
|
| 184 | + |
|
| 185 | + $parameters = self::$apiQueryParameters; |
|
| 186 | + $parameters['pltitles'] = "User:" . $onWikiName; |
|
| 187 | + $parameters['titles'] = $this->siteConfiguration->getIdentificationNoticeboardPage(); |
|
| 188 | + |
|
| 189 | + try { |
|
| 190 | + $endpoint = $this->siteConfiguration->getMetaWikimediaWebServiceEndpoint(); |
|
| 191 | + $response = $this->httpHelper->get($endpoint, $parameters); |
|
| 192 | + $response = json_decode($response, true); |
|
| 193 | + } catch (CurlException $ex) { |
|
| 194 | + // failed getting identification status, so throw a nicer error. |
|
| 195 | + $m = 'Could not contact metawiki API to determine user\' identification status. ' |
|
| 196 | + . 'This is probably a transient error, so please try again.'; |
|
| 197 | + |
|
| 198 | + throw new EnvironmentException($m, 0, $ex); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + $page = @array_pop($response['query']['pages']); |
|
| 202 | + |
|
| 203 | + return @$page['links'][0]['title'] === "User:" . $onWikiName; |
|
| 204 | + } |
|
| 205 | 205 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $onWikiName = $strings->ucfirst($onWikiName); |
| 184 | 184 | |
| 185 | 185 | $parameters = self::$apiQueryParameters; |
| 186 | - $parameters['pltitles'] = "User:" . $onWikiName; |
|
| 186 | + $parameters['pltitles'] = "User:".$onWikiName; |
|
| 187 | 187 | $parameters['titles'] = $this->siteConfiguration->getIdentificationNoticeboardPage(); |
| 188 | 188 | |
| 189 | 189 | try { |
@@ -200,6 +200,6 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | $page = @array_pop($response['query']['pages']); |
| 202 | 202 | |
| 203 | - return @$page['links'][0]['title'] === "User:" . $onWikiName; |
|
| 203 | + return @$page['links'][0]['title'] === "User:".$onWikiName; |
|
| 204 | 204 | } |
| 205 | 205 | } |
@@ -14,200 +14,200 @@ |
||
| 14 | 14 | |
| 15 | 15 | final class SecurityManager |
| 16 | 16 | { |
| 17 | - const ALLOWED = 1; |
|
| 18 | - const ERROR_NOT_IDENTIFIED = 2; |
|
| 19 | - const ERROR_DENIED = 3; |
|
| 20 | - /** @var IdentificationVerifier */ |
|
| 21 | - private $identificationVerifier; |
|
| 22 | - /** |
|
| 23 | - * @var RoleConfiguration |
|
| 24 | - */ |
|
| 25 | - private $roleConfiguration; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * SecurityManager constructor. |
|
| 29 | - * |
|
| 30 | - * @param IdentificationVerifier $identificationVerifier |
|
| 31 | - * @param RoleConfiguration $roleConfiguration |
|
| 32 | - */ |
|
| 33 | - public function __construct( |
|
| 34 | - IdentificationVerifier $identificationVerifier, |
|
| 35 | - RoleConfiguration $roleConfiguration |
|
| 36 | - ) { |
|
| 37 | - $this->identificationVerifier = $identificationVerifier; |
|
| 38 | - $this->roleConfiguration = $roleConfiguration; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Tests if a user is allowed to perform an action. |
|
| 43 | - * |
|
| 44 | - * This method should form a hard, deterministic security barrier, and only return true if it is absolutely sure |
|
| 45 | - * that a user should have access to something. |
|
| 46 | - * |
|
| 47 | - * @param string $page |
|
| 48 | - * @param string $route |
|
| 49 | - * @param User $user |
|
| 50 | - * |
|
| 51 | - * @return int |
|
| 52 | - * |
|
| 53 | - * @category Security-Critical |
|
| 54 | - */ |
|
| 55 | - public function allows($page, $route, User $user) |
|
| 56 | - { |
|
| 57 | - $this->getActiveRoles($user, $activeRoles, $inactiveRoles); |
|
| 58 | - |
|
| 59 | - $availableRights = $this->flattenRoles($activeRoles); |
|
| 60 | - $testResult = $this->findResult($availableRights, $page, $route); |
|
| 61 | - |
|
| 62 | - if ($testResult !== null) { |
|
| 63 | - // We got a firm result here, so just return it. |
|
| 64 | - return $testResult; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // No firm result yet, so continue testing the inactive roles so we can give a better error. |
|
| 68 | - $inactiveRights = $this->flattenRoles($inactiveRoles); |
|
| 69 | - $testResult = $this->findResult($inactiveRights, $page, $route); |
|
| 70 | - |
|
| 71 | - if ($testResult === self::ALLOWED) { |
|
| 72 | - // The user is allowed to access this, but their role is inactive. |
|
| 73 | - return self::ERROR_NOT_IDENTIFIED; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // Other options from the secondary test are denied and inconclusive, which at this point defaults to denied. |
|
| 77 | - return self::ERROR_DENIED; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @param array $pseudoRole The role (flattened) to check |
|
| 82 | - * @param string $page The page class to check |
|
| 83 | - * @param string $route The page route to check |
|
| 84 | - * |
|
| 85 | - * @return int|null |
|
| 86 | - */ |
|
| 87 | - private function findResult($pseudoRole, $page, $route) |
|
| 88 | - { |
|
| 89 | - if (isset($pseudoRole[$page])) { |
|
| 90 | - // check for deny on catch-all route |
|
| 91 | - if (isset($pseudoRole[$page][RoleConfiguration::ALL])) { |
|
| 92 | - if ($pseudoRole[$page][RoleConfiguration::ALL] === RoleConfiguration::ACCESS_DENY) { |
|
| 93 | - return self::ERROR_DENIED; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // check normal route |
|
| 98 | - if (isset($pseudoRole[$page][$route])) { |
|
| 99 | - if ($pseudoRole[$page][$route] === RoleConfiguration::ACCESS_DENY) { |
|
| 100 | - return self::ERROR_DENIED; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if ($pseudoRole[$page][$route] === RoleConfiguration::ACCESS_ALLOW) { |
|
| 104 | - return self::ALLOWED; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // check for allowed on catch-all route |
|
| 109 | - if (isset($pseudoRole[$page][RoleConfiguration::ALL])) { |
|
| 110 | - if ($pseudoRole[$page][RoleConfiguration::ALL] === RoleConfiguration::ACCESS_ALLOW) { |
|
| 111 | - return self::ALLOWED; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // return indeterminate result |
|
| 117 | - return null; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Takes an array of roles and flattens the values to a single set. |
|
| 122 | - * |
|
| 123 | - * @param array $activeRoles |
|
| 124 | - * |
|
| 125 | - * @return array |
|
| 126 | - */ |
|
| 127 | - private function flattenRoles($activeRoles) |
|
| 128 | - { |
|
| 129 | - $result = array(); |
|
| 130 | - |
|
| 131 | - $roleConfig = $this->roleConfiguration->getApplicableRoles($activeRoles); |
|
| 132 | - |
|
| 133 | - // Iterate over every page in every role |
|
| 134 | - foreach ($roleConfig as $role) { |
|
| 135 | - foreach ($role as $page => $pageRights) { |
|
| 136 | - // Create holder in result for this page |
|
| 137 | - if (!isset($result[$page])) { |
|
| 138 | - $result[$page] = array(); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - foreach ($pageRights as $action => $permission) { |
|
| 142 | - // Deny takes precedence, so if it's set, don't change it. |
|
| 143 | - if (isset($result[$page][$action])) { |
|
| 144 | - if ($result[$page][$action] === RoleConfiguration::ACCESS_DENY) { |
|
| 145 | - continue; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - if ($permission === RoleConfiguration::ACCESS_DEFAULT) { |
|
| 150 | - // Configured to do precisely nothing. |
|
| 151 | - continue; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - $result[$page][$action] = $permission; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - return $result; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param User $user |
|
| 164 | - * @param array $activeRoles |
|
| 165 | - * @param array $inactiveRoles |
|
| 166 | - */ |
|
| 167 | - public function getActiveRoles(User $user, &$activeRoles, &$inactiveRoles) |
|
| 168 | - { |
|
| 169 | - // Default to the community user here, because the main user is logged out |
|
| 170 | - $identified = false; |
|
| 171 | - $userRoles = array('public'); |
|
| 172 | - |
|
| 173 | - // if we're not the community user, get our real rights. |
|
| 174 | - if (!$user->isCommunityUser()) { |
|
| 175 | - // Check the user's status - only active users are allowed the effects of roles |
|
| 176 | - |
|
| 177 | - $userRoles[] = 'loggedIn'; |
|
| 178 | - |
|
| 179 | - if ($user->isActive()) { |
|
| 180 | - $ur = UserRole::getForUser($user->getId(), $user->getDatabase()); |
|
| 181 | - |
|
| 182 | - // NOTE: public is still in this array. |
|
| 183 | - foreach ($ur as $r) { |
|
| 184 | - $userRoles[] = $r->getRole(); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $identified = $user->isIdentified($this->identificationVerifier); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - $activeRoles = array(); |
|
| 192 | - $inactiveRoles = array(); |
|
| 193 | - |
|
| 194 | - /** @var string $v */ |
|
| 195 | - foreach ($userRoles as $v) { |
|
| 196 | - if ($this->roleConfiguration->roleNeedsIdentification($v)) { |
|
| 197 | - if ($identified) { |
|
| 198 | - $activeRoles[] = $v; |
|
| 199 | - } |
|
| 200 | - else { |
|
| 201 | - $inactiveRoles[] = $v; |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - else { |
|
| 205 | - $activeRoles[] = $v; |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - public function getRoleConfiguration(){ |
|
| 211 | - return $this->roleConfiguration; |
|
| 212 | - } |
|
| 17 | + const ALLOWED = 1; |
|
| 18 | + const ERROR_NOT_IDENTIFIED = 2; |
|
| 19 | + const ERROR_DENIED = 3; |
|
| 20 | + /** @var IdentificationVerifier */ |
|
| 21 | + private $identificationVerifier; |
|
| 22 | + /** |
|
| 23 | + * @var RoleConfiguration |
|
| 24 | + */ |
|
| 25 | + private $roleConfiguration; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * SecurityManager constructor. |
|
| 29 | + * |
|
| 30 | + * @param IdentificationVerifier $identificationVerifier |
|
| 31 | + * @param RoleConfiguration $roleConfiguration |
|
| 32 | + */ |
|
| 33 | + public function __construct( |
|
| 34 | + IdentificationVerifier $identificationVerifier, |
|
| 35 | + RoleConfiguration $roleConfiguration |
|
| 36 | + ) { |
|
| 37 | + $this->identificationVerifier = $identificationVerifier; |
|
| 38 | + $this->roleConfiguration = $roleConfiguration; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Tests if a user is allowed to perform an action. |
|
| 43 | + * |
|
| 44 | + * This method should form a hard, deterministic security barrier, and only return true if it is absolutely sure |
|
| 45 | + * that a user should have access to something. |
|
| 46 | + * |
|
| 47 | + * @param string $page |
|
| 48 | + * @param string $route |
|
| 49 | + * @param User $user |
|
| 50 | + * |
|
| 51 | + * @return int |
|
| 52 | + * |
|
| 53 | + * @category Security-Critical |
|
| 54 | + */ |
|
| 55 | + public function allows($page, $route, User $user) |
|
| 56 | + { |
|
| 57 | + $this->getActiveRoles($user, $activeRoles, $inactiveRoles); |
|
| 58 | + |
|
| 59 | + $availableRights = $this->flattenRoles($activeRoles); |
|
| 60 | + $testResult = $this->findResult($availableRights, $page, $route); |
|
| 61 | + |
|
| 62 | + if ($testResult !== null) { |
|
| 63 | + // We got a firm result here, so just return it. |
|
| 64 | + return $testResult; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // No firm result yet, so continue testing the inactive roles so we can give a better error. |
|
| 68 | + $inactiveRights = $this->flattenRoles($inactiveRoles); |
|
| 69 | + $testResult = $this->findResult($inactiveRights, $page, $route); |
|
| 70 | + |
|
| 71 | + if ($testResult === self::ALLOWED) { |
|
| 72 | + // The user is allowed to access this, but their role is inactive. |
|
| 73 | + return self::ERROR_NOT_IDENTIFIED; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // Other options from the secondary test are denied and inconclusive, which at this point defaults to denied. |
|
| 77 | + return self::ERROR_DENIED; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @param array $pseudoRole The role (flattened) to check |
|
| 82 | + * @param string $page The page class to check |
|
| 83 | + * @param string $route The page route to check |
|
| 84 | + * |
|
| 85 | + * @return int|null |
|
| 86 | + */ |
|
| 87 | + private function findResult($pseudoRole, $page, $route) |
|
| 88 | + { |
|
| 89 | + if (isset($pseudoRole[$page])) { |
|
| 90 | + // check for deny on catch-all route |
|
| 91 | + if (isset($pseudoRole[$page][RoleConfiguration::ALL])) { |
|
| 92 | + if ($pseudoRole[$page][RoleConfiguration::ALL] === RoleConfiguration::ACCESS_DENY) { |
|
| 93 | + return self::ERROR_DENIED; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // check normal route |
|
| 98 | + if (isset($pseudoRole[$page][$route])) { |
|
| 99 | + if ($pseudoRole[$page][$route] === RoleConfiguration::ACCESS_DENY) { |
|
| 100 | + return self::ERROR_DENIED; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if ($pseudoRole[$page][$route] === RoleConfiguration::ACCESS_ALLOW) { |
|
| 104 | + return self::ALLOWED; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // check for allowed on catch-all route |
|
| 109 | + if (isset($pseudoRole[$page][RoleConfiguration::ALL])) { |
|
| 110 | + if ($pseudoRole[$page][RoleConfiguration::ALL] === RoleConfiguration::ACCESS_ALLOW) { |
|
| 111 | + return self::ALLOWED; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // return indeterminate result |
|
| 117 | + return null; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Takes an array of roles and flattens the values to a single set. |
|
| 122 | + * |
|
| 123 | + * @param array $activeRoles |
|
| 124 | + * |
|
| 125 | + * @return array |
|
| 126 | + */ |
|
| 127 | + private function flattenRoles($activeRoles) |
|
| 128 | + { |
|
| 129 | + $result = array(); |
|
| 130 | + |
|
| 131 | + $roleConfig = $this->roleConfiguration->getApplicableRoles($activeRoles); |
|
| 132 | + |
|
| 133 | + // Iterate over every page in every role |
|
| 134 | + foreach ($roleConfig as $role) { |
|
| 135 | + foreach ($role as $page => $pageRights) { |
|
| 136 | + // Create holder in result for this page |
|
| 137 | + if (!isset($result[$page])) { |
|
| 138 | + $result[$page] = array(); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + foreach ($pageRights as $action => $permission) { |
|
| 142 | + // Deny takes precedence, so if it's set, don't change it. |
|
| 143 | + if (isset($result[$page][$action])) { |
|
| 144 | + if ($result[$page][$action] === RoleConfiguration::ACCESS_DENY) { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + if ($permission === RoleConfiguration::ACCESS_DEFAULT) { |
|
| 150 | + // Configured to do precisely nothing. |
|
| 151 | + continue; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + $result[$page][$action] = $permission; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + return $result; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param User $user |
|
| 164 | + * @param array $activeRoles |
|
| 165 | + * @param array $inactiveRoles |
|
| 166 | + */ |
|
| 167 | + public function getActiveRoles(User $user, &$activeRoles, &$inactiveRoles) |
|
| 168 | + { |
|
| 169 | + // Default to the community user here, because the main user is logged out |
|
| 170 | + $identified = false; |
|
| 171 | + $userRoles = array('public'); |
|
| 172 | + |
|
| 173 | + // if we're not the community user, get our real rights. |
|
| 174 | + if (!$user->isCommunityUser()) { |
|
| 175 | + // Check the user's status - only active users are allowed the effects of roles |
|
| 176 | + |
|
| 177 | + $userRoles[] = 'loggedIn'; |
|
| 178 | + |
|
| 179 | + if ($user->isActive()) { |
|
| 180 | + $ur = UserRole::getForUser($user->getId(), $user->getDatabase()); |
|
| 181 | + |
|
| 182 | + // NOTE: public is still in this array. |
|
| 183 | + foreach ($ur as $r) { |
|
| 184 | + $userRoles[] = $r->getRole(); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $identified = $user->isIdentified($this->identificationVerifier); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + $activeRoles = array(); |
|
| 192 | + $inactiveRoles = array(); |
|
| 193 | + |
|
| 194 | + /** @var string $v */ |
|
| 195 | + foreach ($userRoles as $v) { |
|
| 196 | + if ($this->roleConfiguration->roleNeedsIdentification($v)) { |
|
| 197 | + if ($identified) { |
|
| 198 | + $activeRoles[] = $v; |
|
| 199 | + } |
|
| 200 | + else { |
|
| 201 | + $inactiveRoles[] = $v; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + else { |
|
| 205 | + $activeRoles[] = $v; |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + public function getRoleConfiguration(){ |
|
| 211 | + return $this->roleConfiguration; |
|
| 212 | + } |
|
| 213 | 213 | } |
@@ -207,7 +207,7 @@ |
||
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function getRoleConfiguration(){ |
|
| 210 | + public function getRoleConfiguration() { |
|
| 211 | 211 | return $this->roleConfiguration; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -207,7 +207,8 @@ |
||
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function getRoleConfiguration(){ |
|
| 210 | + public function getRoleConfiguration() |
|
| 211 | + { |
|
| 211 | 212 | return $this->roleConfiguration; |
| 212 | 213 | } |
| 213 | 214 | } |
@@ -26,89 +26,89 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class AccessDeniedException extends ReadableException |
| 28 | 28 | { |
| 29 | - use NavigationMenuAccessControl; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var SecurityManager |
|
| 33 | - */ |
|
| 34 | - private $securityManager; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * AccessDeniedException constructor. |
|
| 38 | - * |
|
| 39 | - * @param SecurityManager $securityManager |
|
| 40 | - */ |
|
| 41 | - public function __construct(SecurityManager $securityManager = null) |
|
| 42 | - { |
|
| 43 | - $this->securityManager = $securityManager; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function getReadableError() |
|
| 47 | - { |
|
| 48 | - if (!headers_sent()) { |
|
| 49 | - header("HTTP/1.1 403 Forbidden"); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $this->setUpSmarty(); |
|
| 53 | - |
|
| 54 | - // uck. We should still be able to access the database in this situation though. |
|
| 55 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
| 56 | - $currentUser = User::getCurrent($database); |
|
| 57 | - $this->assign('currentUser', $currentUser); |
|
| 58 | - $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
| 59 | - |
|
| 60 | - if($this->securityManager !== null) { |
|
| 61 | - $this->setupNavMenuAccess($currentUser); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - if ($currentUser->isDeclined()) { |
|
| 65 | - $this->assign('htmlTitle', 'Account Declined'); |
|
| 66 | - $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
| 67 | - |
|
| 68 | - return $this->fetchTemplate("exception/account-declined.tpl"); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if ($currentUser->isSuspended()) { |
|
| 72 | - $this->assign('htmlTitle', 'Account Suspended'); |
|
| 73 | - $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
| 74 | - |
|
| 75 | - return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if ($currentUser->isNewUser()) { |
|
| 79 | - $this->assign('htmlTitle', 'Account Pending'); |
|
| 80 | - |
|
| 81 | - return $this->fetchTemplate("exception/account-new.tpl"); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - return $this->fetchTemplate("exception/access-denied.tpl"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param string $action |
|
| 89 | - * @param User $user |
|
| 90 | - * @param PdoDatabase $database |
|
| 91 | - * |
|
| 92 | - * @return null|string |
|
| 93 | - */ |
|
| 94 | - private function getLogEntry($action, User $user, PdoDatabase $database) |
|
| 95 | - { |
|
| 96 | - /** @var Log[] $logs */ |
|
| 97 | - $logs = LogSearchHelper::get($database) |
|
| 98 | - ->byAction($action) |
|
| 99 | - ->byObjectType('User') |
|
| 100 | - ->byObjectId($user->getId()) |
|
| 101 | - ->limit(1) |
|
| 102 | - ->fetch(); |
|
| 103 | - |
|
| 104 | - return $logs[0]->getComment(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @return SecurityManager |
|
| 109 | - */ |
|
| 110 | - protected function getSecurityManager() |
|
| 111 | - { |
|
| 112 | - return $this->securityManager; |
|
| 113 | - } |
|
| 29 | + use NavigationMenuAccessControl; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var SecurityManager |
|
| 33 | + */ |
|
| 34 | + private $securityManager; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * AccessDeniedException constructor. |
|
| 38 | + * |
|
| 39 | + * @param SecurityManager $securityManager |
|
| 40 | + */ |
|
| 41 | + public function __construct(SecurityManager $securityManager = null) |
|
| 42 | + { |
|
| 43 | + $this->securityManager = $securityManager; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function getReadableError() |
|
| 47 | + { |
|
| 48 | + if (!headers_sent()) { |
|
| 49 | + header("HTTP/1.1 403 Forbidden"); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $this->setUpSmarty(); |
|
| 53 | + |
|
| 54 | + // uck. We should still be able to access the database in this situation though. |
|
| 55 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
| 56 | + $currentUser = User::getCurrent($database); |
|
| 57 | + $this->assign('currentUser', $currentUser); |
|
| 58 | + $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
| 59 | + |
|
| 60 | + if($this->securityManager !== null) { |
|
| 61 | + $this->setupNavMenuAccess($currentUser); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + if ($currentUser->isDeclined()) { |
|
| 65 | + $this->assign('htmlTitle', 'Account Declined'); |
|
| 66 | + $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
| 67 | + |
|
| 68 | + return $this->fetchTemplate("exception/account-declined.tpl"); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if ($currentUser->isSuspended()) { |
|
| 72 | + $this->assign('htmlTitle', 'Account Suspended'); |
|
| 73 | + $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
| 74 | + |
|
| 75 | + return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if ($currentUser->isNewUser()) { |
|
| 79 | + $this->assign('htmlTitle', 'Account Pending'); |
|
| 80 | + |
|
| 81 | + return $this->fetchTemplate("exception/account-new.tpl"); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + return $this->fetchTemplate("exception/access-denied.tpl"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param string $action |
|
| 89 | + * @param User $user |
|
| 90 | + * @param PdoDatabase $database |
|
| 91 | + * |
|
| 92 | + * @return null|string |
|
| 93 | + */ |
|
| 94 | + private function getLogEntry($action, User $user, PdoDatabase $database) |
|
| 95 | + { |
|
| 96 | + /** @var Log[] $logs */ |
|
| 97 | + $logs = LogSearchHelper::get($database) |
|
| 98 | + ->byAction($action) |
|
| 99 | + ->byObjectType('User') |
|
| 100 | + ->byObjectId($user->getId()) |
|
| 101 | + ->limit(1) |
|
| 102 | + ->fetch(); |
|
| 103 | + |
|
| 104 | + return $logs[0]->getComment(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @return SecurityManager |
|
| 109 | + */ |
|
| 110 | + protected function getSecurityManager() |
|
| 111 | + { |
|
| 112 | + return $this->securityManager; |
|
| 113 | + } |
|
| 114 | 114 | } |
| 115 | 115 | \ No newline at end of file |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $this->assign('currentUser', $currentUser); |
| 58 | 58 | $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
| 59 | 59 | |
| 60 | - if($this->securityManager !== null) { |
|
| 60 | + if ($this->securityManager !== null) { |
|
| 61 | 61 | $this->setupNavMenuAccess($currentUser); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -15,52 +15,52 @@ |
||
| 15 | 15 | |
| 16 | 16 | class NotIdentifiedException extends ReadableException |
| 17 | 17 | { |
| 18 | - use NavigationMenuAccessControl; |
|
| 19 | - /** |
|
| 20 | - * @var SecurityManager |
|
| 21 | - */ |
|
| 22 | - private $securityManager; |
|
| 18 | + use NavigationMenuAccessControl; |
|
| 19 | + /** |
|
| 20 | + * @var SecurityManager |
|
| 21 | + */ |
|
| 22 | + private $securityManager; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * NotIdentifiedException constructor. |
|
| 26 | - * |
|
| 27 | - * @param SecurityManager $securityManager |
|
| 28 | - */ |
|
| 29 | - public function __construct(SecurityManager $securityManager = null) |
|
| 30 | - { |
|
| 31 | - $this->securityManager = $securityManager; |
|
| 32 | - } |
|
| 24 | + /** |
|
| 25 | + * NotIdentifiedException constructor. |
|
| 26 | + * |
|
| 27 | + * @param SecurityManager $securityManager |
|
| 28 | + */ |
|
| 29 | + public function __construct(SecurityManager $securityManager = null) |
|
| 30 | + { |
|
| 31 | + $this->securityManager = $securityManager; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Returns a readable HTML error message that's displayable to the user using templates. |
|
| 36 | - * @return string |
|
| 37 | - */ |
|
| 38 | - public function getReadableError() |
|
| 39 | - { |
|
| 40 | - if (!headers_sent()) { |
|
| 41 | - header("HTTP/1.1 403 Forbidden"); |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * Returns a readable HTML error message that's displayable to the user using templates. |
|
| 36 | + * @return string |
|
| 37 | + */ |
|
| 38 | + public function getReadableError() |
|
| 39 | + { |
|
| 40 | + if (!headers_sent()) { |
|
| 41 | + header("HTTP/1.1 403 Forbidden"); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - $this->setUpSmarty(); |
|
| 44 | + $this->setUpSmarty(); |
|
| 45 | 45 | |
| 46 | - // uck. We should still be able to access the database in this situation though. |
|
| 47 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
| 48 | - $currentUser = User::getCurrent($database); |
|
| 49 | - $this->assign('currentUser', $currentUser); |
|
| 50 | - $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
| 46 | + // uck. We should still be able to access the database in this situation though. |
|
| 47 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
| 48 | + $currentUser = User::getCurrent($database); |
|
| 49 | + $this->assign('currentUser', $currentUser); |
|
| 50 | + $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
|
| 51 | 51 | |
| 52 | - if($this->securityManager !== null) { |
|
| 53 | - $this->setupNavMenuAccess($currentUser); |
|
| 54 | - } |
|
| 52 | + if($this->securityManager !== null) { |
|
| 53 | + $this->setupNavMenuAccess($currentUser); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return $this->fetchTemplate("exception/not-identified.tpl"); |
|
| 57 | - } |
|
| 56 | + return $this->fetchTemplate("exception/not-identified.tpl"); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return SecurityManager |
|
| 61 | - */ |
|
| 62 | - protected function getSecurityManager() |
|
| 63 | - { |
|
| 64 | - return $this->securityManager; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return SecurityManager |
|
| 61 | + */ |
|
| 62 | + protected function getSecurityManager() |
|
| 63 | + { |
|
| 64 | + return $this->securityManager; |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $this->assign('currentUser', $currentUser); |
| 58 | 58 | $this->assign("loggedIn", (!$currentUser->isCommunityUser())); |
| 59 | 59 | |
| 60 | - if($this->securityManager !== null) { |
|
| 60 | + if ($this->securityManager !== null) { |
|
| 61 | 61 | $this->setupNavMenuAccess($currentUser); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -16,55 +16,55 @@ |
||
| 16 | 16 | |
| 17 | 17 | class MigrateToRoles extends ConsoleTaskBase |
| 18 | 18 | { |
| 19 | - public function execute() |
|
| 20 | - { |
|
| 21 | - $communityUser = User::getCommunity(); |
|
| 19 | + public function execute() |
|
| 20 | + { |
|
| 21 | + $communityUser = User::getCommunity(); |
|
| 22 | 22 | |
| 23 | - $database = $this->getDatabase(); |
|
| 24 | - $statement = $database->query('SELECT id, status, checkuser FROM user;'); |
|
| 25 | - $update = $database->prepare("UPDATE user SET status = 'Active' WHERE id = :id;"); |
|
| 23 | + $database = $this->getDatabase(); |
|
| 24 | + $statement = $database->query('SELECT id, status, checkuser FROM user;'); |
|
| 25 | + $update = $database->prepare("UPDATE user SET status = 'Active' WHERE id = :id;"); |
|
| 26 | 26 | |
| 27 | - $users = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 27 | + $users = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
| 28 | 28 | |
| 29 | - foreach ($users as $user) { |
|
| 30 | - $toAdd = array('user'); |
|
| 29 | + foreach ($users as $user) { |
|
| 30 | + $toAdd = array('user'); |
|
| 31 | 31 | |
| 32 | - if($user['status'] === 'Admin'){ |
|
| 33 | - $toAdd[] = 'admin'; |
|
| 34 | - } |
|
| 32 | + if($user['status'] === 'Admin'){ |
|
| 33 | + $toAdd[] = 'admin'; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - if($user['checkuser'] == 1){ |
|
| 37 | - $toAdd[] = 'checkuser'; |
|
| 38 | - } |
|
| 36 | + if($user['checkuser'] == 1){ |
|
| 37 | + $toAdd[] = 'checkuser'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - foreach ($toAdd as $x) { |
|
| 41 | - $a = new UserRole(); |
|
| 42 | - $a->setUser($user['id']); |
|
| 43 | - $a->setRole($x); |
|
| 44 | - $a->setDatabase($database); |
|
| 45 | - $a->save(); |
|
| 46 | - } |
|
| 40 | + foreach ($toAdd as $x) { |
|
| 41 | + $a = new UserRole(); |
|
| 42 | + $a->setUser($user['id']); |
|
| 43 | + $a->setRole($x); |
|
| 44 | + $a->setDatabase($database); |
|
| 45 | + $a->save(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $logData = serialize(array( |
|
| 49 | - 'added' => $toAdd, |
|
| 50 | - 'removed' => array(), |
|
| 51 | - 'reason' => 'Initial migration' |
|
| 52 | - )); |
|
| 48 | + $logData = serialize(array( |
|
| 49 | + 'added' => $toAdd, |
|
| 50 | + 'removed' => array(), |
|
| 51 | + 'reason' => 'Initial migration' |
|
| 52 | + )); |
|
| 53 | 53 | |
| 54 | - $log = new Log(); |
|
| 55 | - $log->setDatabase($database); |
|
| 56 | - $log->setAction('RoleChange'); |
|
| 57 | - $log->setObjectId($user['id']); |
|
| 58 | - $log->setObjectType('User'); |
|
| 59 | - $log->setUser($communityUser); |
|
| 60 | - $log->setComment($logData); |
|
| 61 | - $log->save(); |
|
| 54 | + $log = new Log(); |
|
| 55 | + $log->setDatabase($database); |
|
| 56 | + $log->setAction('RoleChange'); |
|
| 57 | + $log->setObjectId($user['id']); |
|
| 58 | + $log->setObjectType('User'); |
|
| 59 | + $log->setUser($communityUser); |
|
| 60 | + $log->setComment($logData); |
|
| 61 | + $log->save(); |
|
| 62 | 62 | |
| 63 | - if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 64 | - $update->execute(array('id' => $user['id'])); |
|
| 65 | - } |
|
| 66 | - } |
|
| 63 | + if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 64 | + $update->execute(array('id' => $user['id'])); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $database->exec("UPDATE schemaversion SET version = 25;"); |
|
| 69 | - } |
|
| 68 | + $database->exec("UPDATE schemaversion SET version = 25;"); |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | foreach ($users as $user) { |
| 30 | 30 | $toAdd = array('user'); |
| 31 | 31 | |
| 32 | - if($user['status'] === 'Admin'){ |
|
| 32 | + if ($user['status'] === 'Admin') { |
|
| 33 | 33 | $toAdd[] = 'admin'; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if($user['checkuser'] == 1){ |
|
| 36 | + if ($user['checkuser'] == 1) { |
|
| 37 | 37 | $toAdd[] = 'checkuser'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $log->setComment($logData); |
| 61 | 61 | $log->save(); |
| 62 | 62 | |
| 63 | - if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 63 | + if ($user['status'] === 'Admin' || $user['status'] === 'User') { |
|
| 64 | 64 | $update->execute(array('id' => $user['id'])); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | foreach ($users as $user) { |
| 30 | 30 | $toAdd = array('user'); |
| 31 | 31 | |
| 32 | - if($user['status'] === 'Admin'){ |
|
| 32 | + if($user['status'] === 'Admin') { |
|
| 33 | 33 | $toAdd[] = 'admin'; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if($user['checkuser'] == 1){ |
|
| 36 | + if($user['checkuser'] == 1) { |
|
| 37 | 37 | $toAdd[] = 'checkuser'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $log->setComment($logData); |
| 61 | 61 | $log->save(); |
| 62 | 62 | |
| 63 | - if($user['status'] === 'Admin' || $user['status'] === 'User'){ |
|
| 63 | + if($user['status'] === 'Admin' || $user['status'] === 'User') { |
|
| 64 | 64 | $update->execute(array('id' => $user['id'])); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -15,95 +15,95 @@ |
||
| 15 | 15 | |
| 16 | 16 | class UserRole extends DataObject |
| 17 | 17 | { |
| 18 | - /** @var int */ |
|
| 19 | - private $user; |
|
| 20 | - /** @var string */ |
|
| 21 | - private $role; |
|
| 18 | + /** @var int */ |
|
| 19 | + private $user; |
|
| 20 | + /** @var string */ |
|
| 21 | + private $role; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @param int $userId |
|
| 25 | - * @param PdoDatabase $database |
|
| 26 | - * |
|
| 27 | - * @return UserRole[] |
|
| 28 | - */ |
|
| 29 | - public static function getForUser($userId, PdoDatabase $database) |
|
| 30 | - { |
|
| 31 | - $sql = 'SELECT * FROM userrole WHERE user = :user'; |
|
| 32 | - $statement = $database->prepare($sql); |
|
| 33 | - $statement->bindValue(':user', $userId); |
|
| 23 | + /** |
|
| 24 | + * @param int $userId |
|
| 25 | + * @param PdoDatabase $database |
|
| 26 | + * |
|
| 27 | + * @return UserRole[] |
|
| 28 | + */ |
|
| 29 | + public static function getForUser($userId, PdoDatabase $database) |
|
| 30 | + { |
|
| 31 | + $sql = 'SELECT * FROM userrole WHERE user = :user'; |
|
| 32 | + $statement = $database->prepare($sql); |
|
| 33 | + $statement->bindValue(':user', $userId); |
|
| 34 | 34 | |
| 35 | - $statement->execute(); |
|
| 35 | + $statement->execute(); |
|
| 36 | 36 | |
| 37 | - $result = array(); |
|
| 37 | + $result = array(); |
|
| 38 | 38 | |
| 39 | - /** @var Ban $v */ |
|
| 40 | - foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) { |
|
| 41 | - $v->setDatabase($database); |
|
| 42 | - $result[] = $v; |
|
| 43 | - } |
|
| 39 | + /** @var Ban $v */ |
|
| 40 | + foreach ($statement->fetchAll(PDO::FETCH_CLASS, get_called_class()) as $v) { |
|
| 41 | + $v->setDatabase($database); |
|
| 42 | + $result[] = $v; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $result; |
|
| 46 | - } |
|
| 45 | + return $result; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Saves a data object to the database, either updating or inserting a record. |
|
| 50 | - * |
|
| 51 | - * @throws Exception |
|
| 52 | - */ |
|
| 53 | - public function save() |
|
| 54 | - { |
|
| 55 | - if ($this->isNew()) { |
|
| 56 | - // insert |
|
| 57 | - $statement = $this->dbObject->prepare('INSERT INTO `userrole` (user, role) VALUES (:user, :role);' |
|
| 58 | - ); |
|
| 59 | - $statement->bindValue(":user", $this->user); |
|
| 60 | - $statement->bindValue(":role", $this->role); |
|
| 48 | + /** |
|
| 49 | + * Saves a data object to the database, either updating or inserting a record. |
|
| 50 | + * |
|
| 51 | + * @throws Exception |
|
| 52 | + */ |
|
| 53 | + public function save() |
|
| 54 | + { |
|
| 55 | + if ($this->isNew()) { |
|
| 56 | + // insert |
|
| 57 | + $statement = $this->dbObject->prepare('INSERT INTO `userrole` (user, role) VALUES (:user, :role);' |
|
| 58 | + ); |
|
| 59 | + $statement->bindValue(":user", $this->user); |
|
| 60 | + $statement->bindValue(":role", $this->role); |
|
| 61 | 61 | |
| 62 | - if ($statement->execute()) { |
|
| 63 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 64 | - } |
|
| 65 | - else { |
|
| 66 | - throw new Exception($statement->errorInfo()); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - else { |
|
| 70 | - // update |
|
| 71 | - throw new Exception('Updating roles is not available'); |
|
| 72 | - } |
|
| 73 | - } |
|
| 62 | + if ($statement->execute()) { |
|
| 63 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 64 | + } |
|
| 65 | + else { |
|
| 66 | + throw new Exception($statement->errorInfo()); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + else { |
|
| 70 | + // update |
|
| 71 | + throw new Exception('Updating roles is not available'); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - #region Properties |
|
| 75 | + #region Properties |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @return int |
|
| 79 | - */ |
|
| 80 | - public function getUser() |
|
| 81 | - { |
|
| 82 | - return $this->user; |
|
| 83 | - } |
|
| 77 | + /** |
|
| 78 | + * @return int |
|
| 79 | + */ |
|
| 80 | + public function getUser() |
|
| 81 | + { |
|
| 82 | + return $this->user; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @param int $user |
|
| 87 | - */ |
|
| 88 | - public function setUser($user) |
|
| 89 | - { |
|
| 90 | - $this->user = $user; |
|
| 91 | - } |
|
| 85 | + /** |
|
| 86 | + * @param int $user |
|
| 87 | + */ |
|
| 88 | + public function setUser($user) |
|
| 89 | + { |
|
| 90 | + $this->user = $user; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function getRole() |
|
| 97 | - { |
|
| 98 | - return $this->role; |
|
| 99 | - } |
|
| 93 | + /** |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function getRole() |
|
| 97 | + { |
|
| 98 | + return $this->role; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @param string $role |
|
| 103 | - */ |
|
| 104 | - public function setRole($role) |
|
| 105 | - { |
|
| 106 | - $this->role = $role; |
|
| 107 | - } |
|
| 108 | - #endregion |
|
| 101 | + /** |
|
| 102 | + * @param string $role |
|
| 103 | + */ |
|
| 104 | + public function setRole($role) |
|
| 105 | + { |
|
| 106 | + $this->role = $role; |
|
| 107 | + } |
|
| 108 | + #endregion |
|
| 109 | 109 | } |
@@ -26,455 +26,455 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class IrcNotificationHelper |
| 28 | 28 | { |
| 29 | - /** @var PdoDatabase $notificationsDatabase */ |
|
| 30 | - private $notificationsDatabase; |
|
| 31 | - /** @var PdoDatabase $primaryDatabase */ |
|
| 32 | - private $primaryDatabase; |
|
| 33 | - /** @var bool $notificationsEnabled */ |
|
| 34 | - private $notificationsEnabled; |
|
| 35 | - /** @var int $notificationType */ |
|
| 36 | - private $notificationType; |
|
| 37 | - /** @var User $currentUser */ |
|
| 38 | - private $currentUser; |
|
| 39 | - /** @var string $instanceName */ |
|
| 40 | - private $instanceName; |
|
| 41 | - /** @var string */ |
|
| 42 | - private $baseUrl; |
|
| 43 | - /** @var array */ |
|
| 44 | - private $requestStates; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * IrcNotificationHelper constructor. |
|
| 48 | - * |
|
| 49 | - * @param SiteConfiguration $siteConfiguration |
|
| 50 | - * @param PdoDatabase $primaryDatabase |
|
| 51 | - * @param PdoDatabase $notificationsDatabase |
|
| 52 | - */ |
|
| 53 | - public function __construct( |
|
| 54 | - SiteConfiguration $siteConfiguration, |
|
| 55 | - PdoDatabase $primaryDatabase, |
|
| 56 | - PdoDatabase $notificationsDatabase = null |
|
| 57 | - ) { |
|
| 58 | - $this->primaryDatabase = $primaryDatabase; |
|
| 59 | - |
|
| 60 | - if ($this->notificationsDatabase !== null) { |
|
| 61 | - $this->notificationsDatabase = $notificationsDatabase; |
|
| 62 | - $this->notificationsEnabled = $siteConfiguration->getIrcNotificationsEnabled(); |
|
| 63 | - } |
|
| 64 | - else { |
|
| 65 | - $this->notificationsEnabled = false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $this->notificationType = $siteConfiguration->getIrcNotificationType(); |
|
| 69 | - $this->instanceName = $siteConfiguration->getIrcNotificationsInstance(); |
|
| 70 | - $this->baseUrl = $siteConfiguration->getBaseUrl(); |
|
| 71 | - $this->requestStates = $siteConfiguration->getRequestStates(); |
|
| 72 | - |
|
| 73 | - $this->currentUser = User::getCurrent($primaryDatabase); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Send a notification |
|
| 78 | - * |
|
| 79 | - * @param string $message The text to send |
|
| 80 | - */ |
|
| 81 | - protected function send($message) |
|
| 82 | - { |
|
| 83 | - $instanceName = $this->instanceName; |
|
| 84 | - |
|
| 85 | - if (!$this->notificationsEnabled) { |
|
| 86 | - return; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
|
| 90 | - $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
|
| 91 | - |
|
| 92 | - $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
| 93 | - |
|
| 94 | - try { |
|
| 95 | - $notification = new Notification(); |
|
| 96 | - $notification->setDatabase($this->notificationsDatabase); |
|
| 97 | - $notification->setType($this->notificationType); |
|
| 98 | - $notification->setText($msg); |
|
| 99 | - |
|
| 100 | - $notification->save(); |
|
| 101 | - } |
|
| 102 | - catch (Exception $ex) { |
|
| 103 | - // OK, so we failed to send the notification - that db might be down? |
|
| 104 | - // This is non-critical, so silently fail. |
|
| 105 | - |
|
| 106 | - // Disable notifications for remainder of request. |
|
| 107 | - $this->notificationsEnabled = false; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - #region user management |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * send a new user notification |
|
| 115 | - * |
|
| 116 | - * @param User $user |
|
| 117 | - */ |
|
| 118 | - public function userNew(User $user) |
|
| 119 | - { |
|
| 120 | - $this->send("New user: {$user->getUsername()}"); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * send an approved notification |
|
| 125 | - * |
|
| 126 | - * @param User $user |
|
| 127 | - */ |
|
| 128 | - public function userApproved(User $user) |
|
| 129 | - { |
|
| 130 | - $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * send a promoted notification |
|
| 135 | - * |
|
| 136 | - * @param User $user |
|
| 137 | - */ |
|
| 138 | - public function userPromoted(User $user) |
|
| 139 | - { |
|
| 140 | - $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * send a declined notification |
|
| 145 | - * |
|
| 146 | - * @param User $user |
|
| 147 | - * @param string $reason the reason the user was declined |
|
| 148 | - */ |
|
| 149 | - public function userDeclined(User $user, $reason) |
|
| 150 | - { |
|
| 151 | - $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * send a demotion notification |
|
| 156 | - * |
|
| 157 | - * @param User $user |
|
| 158 | - * @param string $reason the reason the user was demoted |
|
| 159 | - */ |
|
| 160 | - public function userDemoted(User $user, $reason) |
|
| 161 | - { |
|
| 162 | - $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * send a suspended notification |
|
| 167 | - * |
|
| 168 | - * @param User $user |
|
| 169 | - * @param string $reason The reason the user has been suspended |
|
| 170 | - */ |
|
| 171 | - public function userSuspended(User $user, $reason) |
|
| 172 | - { |
|
| 173 | - $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Send a preference change notification |
|
| 178 | - * |
|
| 179 | - * @param User $user |
|
| 180 | - */ |
|
| 181 | - public function userPrefChange(User $user) |
|
| 182 | - { |
|
| 183 | - $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Send a user renamed notification |
|
| 188 | - * |
|
| 189 | - * @param User $user |
|
| 190 | - * @param string $old |
|
| 191 | - */ |
|
| 192 | - public function userRenamed(User $user, $old) |
|
| 193 | - { |
|
| 194 | - $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @param User $user |
|
| 199 | - * @param string $reason |
|
| 200 | - */ |
|
| 201 | - public function userRolesEdited(User $user, $reason) |
|
| 202 | - { |
|
| 203 | - $currentUser = $this->currentUser->getUsername(); |
|
| 204 | - $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - #endregion |
|
| 208 | - |
|
| 209 | - #region Site Notice |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Summary of siteNoticeEdited |
|
| 213 | - */ |
|
| 214 | - public function siteNoticeEdited() |
|
| 215 | - { |
|
| 216 | - $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
| 217 | - } |
|
| 218 | - #endregion |
|
| 219 | - |
|
| 220 | - #region Welcome Templates |
|
| 221 | - /** |
|
| 222 | - * Summary of welcomeTemplateCreated |
|
| 223 | - * |
|
| 224 | - * @param WelcomeTemplate $template |
|
| 225 | - */ |
|
| 226 | - public function welcomeTemplateCreated(WelcomeTemplate $template) |
|
| 227 | - { |
|
| 228 | - $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Summary of welcomeTemplateDeleted |
|
| 233 | - * |
|
| 234 | - * @param int $templateid |
|
| 235 | - */ |
|
| 236 | - public function welcomeTemplateDeleted($templateid) |
|
| 237 | - { |
|
| 238 | - $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Summary of welcomeTemplateEdited |
|
| 243 | - * |
|
| 244 | - * @param WelcomeTemplate $template |
|
| 245 | - */ |
|
| 246 | - public function welcomeTemplateEdited(WelcomeTemplate $template) |
|
| 247 | - { |
|
| 248 | - $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - #endregion |
|
| 252 | - |
|
| 253 | - #region bans |
|
| 254 | - /** |
|
| 255 | - * Summary of banned |
|
| 256 | - * |
|
| 257 | - * @param Ban $ban |
|
| 258 | - */ |
|
| 259 | - public function banned(Ban $ban) |
|
| 260 | - { |
|
| 261 | - if ($ban->getDuration() == -1) { |
|
| 262 | - $duration = "indefinitely"; |
|
| 263 | - } |
|
| 264 | - else { |
|
| 265 | - $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $username = $this->currentUser->getUsername(); |
|
| 269 | - |
|
| 270 | - $this->send("{$ban->getTarget()} banned by {$username} for '{$ban->getReason()}' {$duration}"); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Summary of unbanned |
|
| 275 | - * |
|
| 276 | - * @param Ban $ban |
|
| 277 | - * @param string $unbanreason |
|
| 278 | - */ |
|
| 279 | - public function unbanned(Ban $ban, $unbanreason) |
|
| 280 | - { |
|
| 281 | - $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
| 282 | - ->getUsername() . " (" . $unbanreason . ")"); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - #endregion |
|
| 286 | - |
|
| 287 | - #region request management |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Summary of requestReceived |
|
| 291 | - * |
|
| 292 | - * @param Request $request |
|
| 293 | - */ |
|
| 294 | - public function requestReceived(Request $request) |
|
| 295 | - { |
|
| 296 | - $this->send( |
|
| 297 | - IrcColourCode::DARK_GREY . "[[" |
|
| 298 | - . IrcColourCode::DARK_GREEN . "acc:" |
|
| 299 | - . IrcColourCode::ORANGE . $request->getId() |
|
| 300 | - . IrcColourCode::DARK_GREY . "]]" |
|
| 301 | - . IrcColourCode::RED . " N " |
|
| 302 | - . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
| 303 | - . IrcColourCode::DARK_RED . "* " |
|
| 304 | - . IrcColourCode::DARK_GREEN . $request->getName() |
|
| 305 | - . IrcColourCode::DARK_RED . " * " |
|
| 306 | - . IrcColourCode::RESET |
|
| 307 | - ); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Summary of requestDeferred |
|
| 312 | - * |
|
| 313 | - * @param Request $request |
|
| 314 | - */ |
|
| 315 | - public function requestDeferred(Request $request) |
|
| 316 | - { |
|
| 317 | - $availableRequestStates = $this->requestStates; |
|
| 318 | - |
|
| 319 | - $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
| 320 | - $username = $this->currentUser->getUsername(); |
|
| 321 | - |
|
| 322 | - $this->send("Request {$request->getId()} ({$request->getName()}) deferred to {$deferTo} by {$username}"); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * |
|
| 327 | - * Summary of requestDeferredWithMail |
|
| 328 | - * |
|
| 329 | - * @param Request $request |
|
| 330 | - */ |
|
| 331 | - public function requestDeferredWithMail(Request $request) |
|
| 332 | - { |
|
| 333 | - $availableRequestStates = $this->requestStates; |
|
| 334 | - |
|
| 335 | - $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
| 336 | - $username = $this->currentUser->getUsername(); |
|
| 337 | - $id = $request->getId(); |
|
| 338 | - $name = $request->getName(); |
|
| 339 | - |
|
| 340 | - $this->send("Request {$id} ({$name}) deferred to {$deferTo} with an email by {$username}"); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * Summary of requestClosed |
|
| 345 | - * |
|
| 346 | - * @param Request $request |
|
| 347 | - * @param string $closetype |
|
| 348 | - */ |
|
| 349 | - public function requestClosed(Request $request, $closetype) |
|
| 350 | - { |
|
| 351 | - $username = $this->currentUser->getUsername(); |
|
| 352 | - |
|
| 353 | - $this->send("Request {$request->getId()} ({$request->getName()}) closed ($closetype) by {$username}"); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Summary of sentMail |
|
| 358 | - * |
|
| 359 | - * @param Request $request |
|
| 360 | - */ |
|
| 361 | - public function sentMail(Request $request) |
|
| 362 | - { |
|
| 363 | - $this->send($this->currentUser->getUsername() |
|
| 364 | - . " sent an email related to Request {$request->getId()} ({$request->getName()})"); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - #endregion |
|
| 368 | - |
|
| 369 | - #region reservations |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * Summary of requestReserved |
|
| 373 | - * |
|
| 374 | - * @param Request $request |
|
| 375 | - */ |
|
| 376 | - public function requestReserved(Request $request) |
|
| 377 | - { |
|
| 378 | - $username = $this->currentUser->getUsername(); |
|
| 379 | - |
|
| 380 | - $this->send("Request {$request->getId()} ({$request->getName()}) reserved by {$username}"); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Summary of requestReserveBroken |
|
| 385 | - * |
|
| 386 | - * @param Request $request |
|
| 387 | - */ |
|
| 388 | - public function requestReserveBroken(Request $request) |
|
| 389 | - { |
|
| 390 | - $username = $this->currentUser->getUsername(); |
|
| 391 | - |
|
| 392 | - $this->send("Reservation on request {$request->getId()} ({$request->getName()}) broken by {$username}"); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Summary of requestUnreserved |
|
| 397 | - * |
|
| 398 | - * @param Request $request |
|
| 399 | - */ |
|
| 400 | - public function requestUnreserved(Request $request) |
|
| 401 | - { |
|
| 402 | - $this->send("Request {$request->getId()} ({$request->getName()}) is no longer being handled."); |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Summary of requestReservationSent |
|
| 407 | - * |
|
| 408 | - * @param Request $request |
|
| 409 | - * @param User $target |
|
| 410 | - */ |
|
| 411 | - public function requestReservationSent(Request $request, User $target) |
|
| 412 | - { |
|
| 413 | - $username = $this->currentUser->getUsername(); |
|
| 414 | - |
|
| 415 | - $this->send( |
|
| 416 | - "Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by " |
|
| 417 | - . $username); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - #endregion |
|
| 421 | - |
|
| 422 | - #region comments |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Summary of commentCreated |
|
| 426 | - * |
|
| 427 | - * @param Comment $comment |
|
| 428 | - * @param Request $request |
|
| 429 | - */ |
|
| 430 | - public function commentCreated(Comment $comment, Request $request) |
|
| 431 | - { |
|
| 432 | - $username = $this->currentUser->getUsername(); |
|
| 433 | - $visibility = ($comment->getVisibility() == "admin" ? "private " : ""); |
|
| 434 | - |
|
| 435 | - $this->send("{$username} posted a {$visibility}comment on request {$request->getId()} ({$request->getName()})"); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Summary of commentEdited |
|
| 440 | - * |
|
| 441 | - * @param Comment $comment |
|
| 442 | - * @param Request $request |
|
| 443 | - */ |
|
| 444 | - public function commentEdited(Comment $comment, Request $request) |
|
| 445 | - { |
|
| 446 | - $username = $this->currentUser->getUsername(); |
|
| 447 | - |
|
| 448 | - $this->send(<<<TAG |
|
| 29 | + /** @var PdoDatabase $notificationsDatabase */ |
|
| 30 | + private $notificationsDatabase; |
|
| 31 | + /** @var PdoDatabase $primaryDatabase */ |
|
| 32 | + private $primaryDatabase; |
|
| 33 | + /** @var bool $notificationsEnabled */ |
|
| 34 | + private $notificationsEnabled; |
|
| 35 | + /** @var int $notificationType */ |
|
| 36 | + private $notificationType; |
|
| 37 | + /** @var User $currentUser */ |
|
| 38 | + private $currentUser; |
|
| 39 | + /** @var string $instanceName */ |
|
| 40 | + private $instanceName; |
|
| 41 | + /** @var string */ |
|
| 42 | + private $baseUrl; |
|
| 43 | + /** @var array */ |
|
| 44 | + private $requestStates; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * IrcNotificationHelper constructor. |
|
| 48 | + * |
|
| 49 | + * @param SiteConfiguration $siteConfiguration |
|
| 50 | + * @param PdoDatabase $primaryDatabase |
|
| 51 | + * @param PdoDatabase $notificationsDatabase |
|
| 52 | + */ |
|
| 53 | + public function __construct( |
|
| 54 | + SiteConfiguration $siteConfiguration, |
|
| 55 | + PdoDatabase $primaryDatabase, |
|
| 56 | + PdoDatabase $notificationsDatabase = null |
|
| 57 | + ) { |
|
| 58 | + $this->primaryDatabase = $primaryDatabase; |
|
| 59 | + |
|
| 60 | + if ($this->notificationsDatabase !== null) { |
|
| 61 | + $this->notificationsDatabase = $notificationsDatabase; |
|
| 62 | + $this->notificationsEnabled = $siteConfiguration->getIrcNotificationsEnabled(); |
|
| 63 | + } |
|
| 64 | + else { |
|
| 65 | + $this->notificationsEnabled = false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $this->notificationType = $siteConfiguration->getIrcNotificationType(); |
|
| 69 | + $this->instanceName = $siteConfiguration->getIrcNotificationsInstance(); |
|
| 70 | + $this->baseUrl = $siteConfiguration->getBaseUrl(); |
|
| 71 | + $this->requestStates = $siteConfiguration->getRequestStates(); |
|
| 72 | + |
|
| 73 | + $this->currentUser = User::getCurrent($primaryDatabase); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Send a notification |
|
| 78 | + * |
|
| 79 | + * @param string $message The text to send |
|
| 80 | + */ |
|
| 81 | + protected function send($message) |
|
| 82 | + { |
|
| 83 | + $instanceName = $this->instanceName; |
|
| 84 | + |
|
| 85 | + if (!$this->notificationsEnabled) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
|
| 90 | + $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
|
| 91 | + |
|
| 92 | + $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
| 93 | + |
|
| 94 | + try { |
|
| 95 | + $notification = new Notification(); |
|
| 96 | + $notification->setDatabase($this->notificationsDatabase); |
|
| 97 | + $notification->setType($this->notificationType); |
|
| 98 | + $notification->setText($msg); |
|
| 99 | + |
|
| 100 | + $notification->save(); |
|
| 101 | + } |
|
| 102 | + catch (Exception $ex) { |
|
| 103 | + // OK, so we failed to send the notification - that db might be down? |
|
| 104 | + // This is non-critical, so silently fail. |
|
| 105 | + |
|
| 106 | + // Disable notifications for remainder of request. |
|
| 107 | + $this->notificationsEnabled = false; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + #region user management |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * send a new user notification |
|
| 115 | + * |
|
| 116 | + * @param User $user |
|
| 117 | + */ |
|
| 118 | + public function userNew(User $user) |
|
| 119 | + { |
|
| 120 | + $this->send("New user: {$user->getUsername()}"); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * send an approved notification |
|
| 125 | + * |
|
| 126 | + * @param User $user |
|
| 127 | + */ |
|
| 128 | + public function userApproved(User $user) |
|
| 129 | + { |
|
| 130 | + $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * send a promoted notification |
|
| 135 | + * |
|
| 136 | + * @param User $user |
|
| 137 | + */ |
|
| 138 | + public function userPromoted(User $user) |
|
| 139 | + { |
|
| 140 | + $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * send a declined notification |
|
| 145 | + * |
|
| 146 | + * @param User $user |
|
| 147 | + * @param string $reason the reason the user was declined |
|
| 148 | + */ |
|
| 149 | + public function userDeclined(User $user, $reason) |
|
| 150 | + { |
|
| 151 | + $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * send a demotion notification |
|
| 156 | + * |
|
| 157 | + * @param User $user |
|
| 158 | + * @param string $reason the reason the user was demoted |
|
| 159 | + */ |
|
| 160 | + public function userDemoted(User $user, $reason) |
|
| 161 | + { |
|
| 162 | + $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * send a suspended notification |
|
| 167 | + * |
|
| 168 | + * @param User $user |
|
| 169 | + * @param string $reason The reason the user has been suspended |
|
| 170 | + */ |
|
| 171 | + public function userSuspended(User $user, $reason) |
|
| 172 | + { |
|
| 173 | + $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Send a preference change notification |
|
| 178 | + * |
|
| 179 | + * @param User $user |
|
| 180 | + */ |
|
| 181 | + public function userPrefChange(User $user) |
|
| 182 | + { |
|
| 183 | + $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Send a user renamed notification |
|
| 188 | + * |
|
| 189 | + * @param User $user |
|
| 190 | + * @param string $old |
|
| 191 | + */ |
|
| 192 | + public function userRenamed(User $user, $old) |
|
| 193 | + { |
|
| 194 | + $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @param User $user |
|
| 199 | + * @param string $reason |
|
| 200 | + */ |
|
| 201 | + public function userRolesEdited(User $user, $reason) |
|
| 202 | + { |
|
| 203 | + $currentUser = $this->currentUser->getUsername(); |
|
| 204 | + $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + #endregion |
|
| 208 | + |
|
| 209 | + #region Site Notice |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Summary of siteNoticeEdited |
|
| 213 | + */ |
|
| 214 | + public function siteNoticeEdited() |
|
| 215 | + { |
|
| 216 | + $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
| 217 | + } |
|
| 218 | + #endregion |
|
| 219 | + |
|
| 220 | + #region Welcome Templates |
|
| 221 | + /** |
|
| 222 | + * Summary of welcomeTemplateCreated |
|
| 223 | + * |
|
| 224 | + * @param WelcomeTemplate $template |
|
| 225 | + */ |
|
| 226 | + public function welcomeTemplateCreated(WelcomeTemplate $template) |
|
| 227 | + { |
|
| 228 | + $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Summary of welcomeTemplateDeleted |
|
| 233 | + * |
|
| 234 | + * @param int $templateid |
|
| 235 | + */ |
|
| 236 | + public function welcomeTemplateDeleted($templateid) |
|
| 237 | + { |
|
| 238 | + $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Summary of welcomeTemplateEdited |
|
| 243 | + * |
|
| 244 | + * @param WelcomeTemplate $template |
|
| 245 | + */ |
|
| 246 | + public function welcomeTemplateEdited(WelcomeTemplate $template) |
|
| 247 | + { |
|
| 248 | + $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + #endregion |
|
| 252 | + |
|
| 253 | + #region bans |
|
| 254 | + /** |
|
| 255 | + * Summary of banned |
|
| 256 | + * |
|
| 257 | + * @param Ban $ban |
|
| 258 | + */ |
|
| 259 | + public function banned(Ban $ban) |
|
| 260 | + { |
|
| 261 | + if ($ban->getDuration() == -1) { |
|
| 262 | + $duration = "indefinitely"; |
|
| 263 | + } |
|
| 264 | + else { |
|
| 265 | + $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $username = $this->currentUser->getUsername(); |
|
| 269 | + |
|
| 270 | + $this->send("{$ban->getTarget()} banned by {$username} for '{$ban->getReason()}' {$duration}"); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Summary of unbanned |
|
| 275 | + * |
|
| 276 | + * @param Ban $ban |
|
| 277 | + * @param string $unbanreason |
|
| 278 | + */ |
|
| 279 | + public function unbanned(Ban $ban, $unbanreason) |
|
| 280 | + { |
|
| 281 | + $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
| 282 | + ->getUsername() . " (" . $unbanreason . ")"); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + #endregion |
|
| 286 | + |
|
| 287 | + #region request management |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Summary of requestReceived |
|
| 291 | + * |
|
| 292 | + * @param Request $request |
|
| 293 | + */ |
|
| 294 | + public function requestReceived(Request $request) |
|
| 295 | + { |
|
| 296 | + $this->send( |
|
| 297 | + IrcColourCode::DARK_GREY . "[[" |
|
| 298 | + . IrcColourCode::DARK_GREEN . "acc:" |
|
| 299 | + . IrcColourCode::ORANGE . $request->getId() |
|
| 300 | + . IrcColourCode::DARK_GREY . "]]" |
|
| 301 | + . IrcColourCode::RED . " N " |
|
| 302 | + . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
| 303 | + . IrcColourCode::DARK_RED . "* " |
|
| 304 | + . IrcColourCode::DARK_GREEN . $request->getName() |
|
| 305 | + . IrcColourCode::DARK_RED . " * " |
|
| 306 | + . IrcColourCode::RESET |
|
| 307 | + ); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * Summary of requestDeferred |
|
| 312 | + * |
|
| 313 | + * @param Request $request |
|
| 314 | + */ |
|
| 315 | + public function requestDeferred(Request $request) |
|
| 316 | + { |
|
| 317 | + $availableRequestStates = $this->requestStates; |
|
| 318 | + |
|
| 319 | + $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
| 320 | + $username = $this->currentUser->getUsername(); |
|
| 321 | + |
|
| 322 | + $this->send("Request {$request->getId()} ({$request->getName()}) deferred to {$deferTo} by {$username}"); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * |
|
| 327 | + * Summary of requestDeferredWithMail |
|
| 328 | + * |
|
| 329 | + * @param Request $request |
|
| 330 | + */ |
|
| 331 | + public function requestDeferredWithMail(Request $request) |
|
| 332 | + { |
|
| 333 | + $availableRequestStates = $this->requestStates; |
|
| 334 | + |
|
| 335 | + $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
| 336 | + $username = $this->currentUser->getUsername(); |
|
| 337 | + $id = $request->getId(); |
|
| 338 | + $name = $request->getName(); |
|
| 339 | + |
|
| 340 | + $this->send("Request {$id} ({$name}) deferred to {$deferTo} with an email by {$username}"); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * Summary of requestClosed |
|
| 345 | + * |
|
| 346 | + * @param Request $request |
|
| 347 | + * @param string $closetype |
|
| 348 | + */ |
|
| 349 | + public function requestClosed(Request $request, $closetype) |
|
| 350 | + { |
|
| 351 | + $username = $this->currentUser->getUsername(); |
|
| 352 | + |
|
| 353 | + $this->send("Request {$request->getId()} ({$request->getName()}) closed ($closetype) by {$username}"); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Summary of sentMail |
|
| 358 | + * |
|
| 359 | + * @param Request $request |
|
| 360 | + */ |
|
| 361 | + public function sentMail(Request $request) |
|
| 362 | + { |
|
| 363 | + $this->send($this->currentUser->getUsername() |
|
| 364 | + . " sent an email related to Request {$request->getId()} ({$request->getName()})"); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + #endregion |
|
| 368 | + |
|
| 369 | + #region reservations |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * Summary of requestReserved |
|
| 373 | + * |
|
| 374 | + * @param Request $request |
|
| 375 | + */ |
|
| 376 | + public function requestReserved(Request $request) |
|
| 377 | + { |
|
| 378 | + $username = $this->currentUser->getUsername(); |
|
| 379 | + |
|
| 380 | + $this->send("Request {$request->getId()} ({$request->getName()}) reserved by {$username}"); |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Summary of requestReserveBroken |
|
| 385 | + * |
|
| 386 | + * @param Request $request |
|
| 387 | + */ |
|
| 388 | + public function requestReserveBroken(Request $request) |
|
| 389 | + { |
|
| 390 | + $username = $this->currentUser->getUsername(); |
|
| 391 | + |
|
| 392 | + $this->send("Reservation on request {$request->getId()} ({$request->getName()}) broken by {$username}"); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Summary of requestUnreserved |
|
| 397 | + * |
|
| 398 | + * @param Request $request |
|
| 399 | + */ |
|
| 400 | + public function requestUnreserved(Request $request) |
|
| 401 | + { |
|
| 402 | + $this->send("Request {$request->getId()} ({$request->getName()}) is no longer being handled."); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Summary of requestReservationSent |
|
| 407 | + * |
|
| 408 | + * @param Request $request |
|
| 409 | + * @param User $target |
|
| 410 | + */ |
|
| 411 | + public function requestReservationSent(Request $request, User $target) |
|
| 412 | + { |
|
| 413 | + $username = $this->currentUser->getUsername(); |
|
| 414 | + |
|
| 415 | + $this->send( |
|
| 416 | + "Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by " |
|
| 417 | + . $username); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + #endregion |
|
| 421 | + |
|
| 422 | + #region comments |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Summary of commentCreated |
|
| 426 | + * |
|
| 427 | + * @param Comment $comment |
|
| 428 | + * @param Request $request |
|
| 429 | + */ |
|
| 430 | + public function commentCreated(Comment $comment, Request $request) |
|
| 431 | + { |
|
| 432 | + $username = $this->currentUser->getUsername(); |
|
| 433 | + $visibility = ($comment->getVisibility() == "admin" ? "private " : ""); |
|
| 434 | + |
|
| 435 | + $this->send("{$username} posted a {$visibility}comment on request {$request->getId()} ({$request->getName()})"); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * Summary of commentEdited |
|
| 440 | + * |
|
| 441 | + * @param Comment $comment |
|
| 442 | + * @param Request $request |
|
| 443 | + */ |
|
| 444 | + public function commentEdited(Comment $comment, Request $request) |
|
| 445 | + { |
|
| 446 | + $username = $this->currentUser->getUsername(); |
|
| 447 | + |
|
| 448 | + $this->send(<<<TAG |
|
| 449 | 449 | Comment {$comment->getId()} on request {$request->getId()} ({$request->getName()}) edited by {$username} |
| 450 | 450 | TAG |
| 451 | - ); |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - #endregion |
|
| 455 | - |
|
| 456 | - #region email management (close reasons) |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Summary of emailCreated |
|
| 460 | - * |
|
| 461 | - * @param EmailTemplate $template |
|
| 462 | - */ |
|
| 463 | - public function emailCreated(EmailTemplate $template) |
|
| 464 | - { |
|
| 465 | - $username = $this->currentUser->getUsername(); |
|
| 466 | - $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Summary of emailEdited |
|
| 471 | - * |
|
| 472 | - * @param EmailTemplate $template |
|
| 473 | - */ |
|
| 474 | - public function emailEdited(EmailTemplate $template) |
|
| 475 | - { |
|
| 476 | - $username = $this->currentUser->getUsername(); |
|
| 477 | - $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
| 478 | - } |
|
| 479 | - #endregion |
|
| 451 | + ); |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + #endregion |
|
| 455 | + |
|
| 456 | + #region email management (close reasons) |
|
| 457 | + |
|
| 458 | + /** |
|
| 459 | + * Summary of emailCreated |
|
| 460 | + * |
|
| 461 | + * @param EmailTemplate $template |
|
| 462 | + */ |
|
| 463 | + public function emailCreated(EmailTemplate $template) |
|
| 464 | + { |
|
| 465 | + $username = $this->currentUser->getUsername(); |
|
| 466 | + $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * Summary of emailEdited |
|
| 471 | + * |
|
| 472 | + * @param EmailTemplate $template |
|
| 473 | + */ |
|
| 474 | + public function emailEdited(EmailTemplate $template) |
|
| 475 | + { |
|
| 476 | + $username = $this->currentUser->getUsername(); |
|
| 477 | + $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
| 478 | + } |
|
| 479 | + #endregion |
|
| 480 | 480 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
| 90 | 90 | $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
| 91 | 91 | |
| 92 | - $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
| 92 | + $msg = IrcColourCode::RESET.IrcColourCode::BOLD."[$instanceName]".IrcColourCode::RESET.": $message"; |
|
| 93 | 93 | |
| 94 | 94 | try { |
| 95 | 95 | $notification = new Notification(); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function userApproved(User $user) |
| 129 | 129 | { |
| 130 | - $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
| 130 | + $this->send("{$user->getUsername()} approved by ".$this->currentUser->getUsername()); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function userPromoted(User $user) |
| 139 | 139 | { |
| 140 | - $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
| 140 | + $this->send("{$user->getUsername()} promoted to tool admin by ".$this->currentUser->getUsername()); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function userDeclined(User $user, $reason) |
| 150 | 150 | { |
| 151 | - $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 151 | + $this->send("{$user->getUsername()} declined by ".$this->currentUser->getUsername()." ($reason)"); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function userDemoted(User $user, $reason) |
| 161 | 161 | { |
| 162 | - $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 162 | + $this->send("{$user->getUsername()} demoted by ".$this->currentUser->getUsername()." ($reason)"); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function userSuspended(User $user, $reason) |
| 172 | 172 | { |
| 173 | - $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
| 173 | + $this->send("{$user->getUsername()} suspended by ".$this->currentUser->getUsername()." ($reason)"); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function userPrefChange(User $user) |
| 182 | 182 | { |
| 183 | - $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
| 183 | + $this->send("{$user->getUsername()}'s preferences were changed by ".$this->currentUser->getUsername()); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function userRenamed(User $user, $old) |
| 193 | 193 | { |
| 194 | - $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
| 194 | + $this->send($this->currentUser->getUsername()." renamed $old to {$user->getUsername()}"); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | public function userRolesEdited(User $user, $reason) |
| 202 | 202 | { |
| 203 | 203 | $currentUser = $this->currentUser->getUsername(); |
| 204 | - $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
| 204 | + $this->send("Active roles for {$user->getUsername()} changed by ".$currentUser." ($reason)"); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | #endregion |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function siteNoticeEdited() |
| 215 | 215 | { |
| 216 | - $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
| 216 | + $this->send("Site notice edited by ".$this->currentUser->getUsername()); |
|
| 217 | 217 | } |
| 218 | 218 | #endregion |
| 219 | 219 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | public function welcomeTemplateCreated(WelcomeTemplate $template) |
| 227 | 227 | { |
| 228 | - $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
| 228 | + $this->send("Welcome template {$template->getId()} created by ".$this->currentUser->getUsername()); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function welcomeTemplateDeleted($templateid) |
| 237 | 237 | { |
| 238 | - $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
| 238 | + $this->send("Welcome template {$templateid} deleted by ".$this->currentUser->getUsername()); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function welcomeTemplateEdited(WelcomeTemplate $template) |
| 247 | 247 | { |
| 248 | - $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
| 248 | + $this->send("Welcome template {$template->getId()} edited by ".$this->currentUser->getUsername()); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | #endregion |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $duration = "indefinitely"; |
| 263 | 263 | } |
| 264 | 264 | else { |
| 265 | - $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
| 265 | + $duration = "until ".date("F j, Y, g:i a", $ban->getDuration()); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $username = $this->currentUser->getUsername(); |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function unbanned(Ban $ban, $unbanreason) |
| 280 | 280 | { |
| 281 | - $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
| 282 | - ->getUsername() . " (" . $unbanreason . ")"); |
|
| 281 | + $this->send($ban->getTarget()." unbanned by ".$this->currentUser |
|
| 282 | + ->getUsername()." (".$unbanreason.")"); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | #endregion |
@@ -294,15 +294,15 @@ discard block |
||
| 294 | 294 | public function requestReceived(Request $request) |
| 295 | 295 | { |
| 296 | 296 | $this->send( |
| 297 | - IrcColourCode::DARK_GREY . "[[" |
|
| 298 | - . IrcColourCode::DARK_GREEN . "acc:" |
|
| 299 | - . IrcColourCode::ORANGE . $request->getId() |
|
| 300 | - . IrcColourCode::DARK_GREY . "]]" |
|
| 301 | - . IrcColourCode::RED . " N " |
|
| 302 | - . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
| 303 | - . IrcColourCode::DARK_RED . "* " |
|
| 304 | - . IrcColourCode::DARK_GREEN . $request->getName() |
|
| 305 | - . IrcColourCode::DARK_RED . " * " |
|
| 297 | + IrcColourCode::DARK_GREY."[[" |
|
| 298 | + . IrcColourCode::DARK_GREEN."acc:" |
|
| 299 | + . IrcColourCode::ORANGE.$request->getId() |
|
| 300 | + . IrcColourCode::DARK_GREY."]]" |
|
| 301 | + . IrcColourCode::RED." N " |
|
| 302 | + . IrcColourCode::DARK_BLUE.$this->baseUrl."/internal.php/viewRequest?id={$request->getId()} " |
|
| 303 | + . IrcColourCode::DARK_RED."* " |
|
| 304 | + . IrcColourCode::DARK_GREEN.$request->getName() |
|
| 305 | + . IrcColourCode::DARK_RED." * " |
|
| 306 | 306 | . IrcColourCode::RESET |
| 307 | 307 | ); |
| 308 | 308 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | public function emailCreated(EmailTemplate $template) |
| 464 | 464 | { |
| 465 | 465 | $username = $this->currentUser->getUsername(); |
| 466 | - $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
| 466 | + $this->send("Email {$template->getId()} ({$template->getName()}) created by ".$username); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | public function emailEdited(EmailTemplate $template) |
| 475 | 475 | { |
| 476 | 476 | $username = $this->currentUser->getUsername(); |
| 477 | - $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
| 477 | + $this->send("Email {$template->getId()} ({$template->getName()}) edited by ".$username); |
|
| 478 | 478 | } |
| 479 | 479 | #endregion |
| 480 | 480 | } |