public function init() { if (Security::isAdmin()) { Filter::register('set_plugin_has_updates', array($this, 'siteTransientUpdatePlugins')); Hook::register('set_plugin_has_updates', array($this, 'transientUpdatePlugins')); if (isset($_GET['plugin']) && $_GET['plugin'] == $this->application->getName()) { Hook::register('install_plugins_pre_plugin-information', array($this, 'versionInformation')); } $this->application->onInitUpdate(); $oldVersion = AoiSoraSettings::getApplicationVersion($this->application->getName()); if ($this->application->installed() && version_compare($oldVersion, $this->version, '<')) { AoiSoraSettings::addApplication($this->application->getName(), $this->application->getInstallDirectory(), $this->version); $this->application->update(); } if ($this->update_site && isset($_REQUEST['action']) && 'upgrade-plugin' == $_REQUEST['action'] && isset($_REQUEST['plugin']) && urldecode($_REQUEST['plugin']) == $this->application->getInstallName()) { Filter::register('http_request_args', array($this, 'addUpdateUrl'), 10); } } }
/** * Performs the security check, verify nonce and if user can perform action. * * @param BaseController $controller * @param $data * @param string $action * * @return bool */ public function perform($controller, $data, $action = '') { $s = Security::create(); if ($this->nonce_base) { $nonce = array_key_exists_v('_asnonce', $controller->values); if ($nonce) { $verified_nonce = $s->verifyNonce($nonce, $this->nonce_base); if (!$verified_nonce) { return false; } } else { return false; } } if ($s->currentUserIsLoggedIn()) { if (!$this->useraction || $s->currentUserCan($this->useraction)) { return true; } } $controller->getRenderer()->RenderText('You cannot perform this action'); return false; }