diff --git a/application/config/internal.php b/application/config/internal.php index 1199306a56d..2d4961da2ca 100644 --- a/application/config/internal.php +++ b/application/config/internal.php @@ -14,6 +14,8 @@ @date_default_timezone_set(@date_default_timezone_get()); $internalConfig = array( 'basePath' => __DIR__ . '/../', + + 'theme' => 'default', 'runtimePath' => dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'runtime', 'name' => 'LimeSurvey', 'defaultController' => 'surveys', diff --git a/application/controllers/DevController.php b/application/controllers/DevController.php new file mode 100644 index 00000000000..4cbd9ed07c0 --- /dev/null +++ b/application/controllers/DevController.php @@ -0,0 +1,17 @@ +pluginManager->scanPlugins(), true); + +// $plugins = \ls\pluginmanager\PluginConfig::findAll(true); + +// App()->pluginManager->subscribe("test", function($event) { var_dump($event); }); + + $this->renderText('
' . $result . ''); + } +} \ No newline at end of file diff --git a/application/controllers/PluginsController.php b/application/controllers/PluginsController.php index 708fc5d572e..7706537e183 100644 --- a/application/controllers/PluginsController.php +++ b/application/controllers/PluginsController.php @@ -9,17 +9,17 @@ class PluginsController extends LSYii_Controller * Stored dynamic properties set and unset via __get and __set. * @var array of mixed. */ - protected $properties = array(); - - public function __get($property) - { - return $this->properties[$property]; - } - - public function __set($property, $value) - { - $this->properties[$property] = $value; - } +// protected $properties = array(); +// +// public function __get($property) +// { +// return $this->properties[$property]; +// } +// +// public function __set($property, $value) +// { +// $this->properties[$property] = $value; +// } public function _init() { diff --git a/application/controllers/UsersController.php b/application/controllers/UsersController.php new file mode 100644 index 00000000000..ed94d145731 --- /dev/null +++ b/application/controllers/UsersController.php @@ -0,0 +1,29 @@ + 'login'], + ['allow' , 'actions' => 'logout', 'users' => '@'], + ], parent::accessRules()); + } + + public function actionLogin() { + // Get all active auth plugins. + $event = new PluginEvent('newLoginForm'); + $event->dispatch(); + $loginForms = $event->get('forms'); + return $this->render('login', ['loginForms' => $loginForms]); + } + +} + +?> diff --git a/application/core/LSWebUser.php b/application/core/LSWebUser.php index 67d52af91b3..5c13912f1e3 100644 --- a/application/core/LSWebUser.php +++ b/application/core/LSWebUser.php @@ -1,5 +1,5 @@ set('forms.' . $this->name, [ + 'serverkey' => array( + 'type' => 'string', + 'label' => 'Key to use for username e.g. PHP_AUTH_USER, LOGON_USER, REMOTE_USER. See phpinfo in global settings.', + 'default' => 'REMOTE_USER', + ) ]); + return; $sUserName=''; $sPassword=''; if (Yii::app()->getConfig("demoMode") === true && Yii::app()->getConfig("demoModePrefill") === true) @@ -63,6 +70,8 @@ public function eventNewLoginForm(PluginEvent $event) public function eventNewUserSession(PluginEvent $event) { + + // Do nothing if this user is not Authdb type $identity = $event->get('identity'); if ($identity->plugin != __CLASS__) { diff --git a/application/core/plugins/Authwebserver/AuthWebServer.php b/application/core/plugins/Authwebserver/AuthWebServer.php index 35c6360c1fd..fec871e6a8e 100644 --- a/application/core/plugins/Authwebserver/AuthWebServer.php +++ b/application/core/plugins/Authwebserver/AuthWebServer.php @@ -29,6 +29,16 @@ public function init() { } + public function eventNewLoginForm(PluginEvent $event) + { + $event->set('forms.' . $this->name, [ + 'serverkey' => array( + 'type' => 'string', + 'label' => 'Key to use for username e.g. PHP_AUTH_USER, LOGON_USER, REMOTE_USER. See phpinfo in global settings.', + 'default' => 'REMOTE_USER', + ) ]); + return; + } public function eventBeforeLogin(PluginEvent $event) { // normal login through webserver authentication @@ -66,10 +76,10 @@ public function eventBeforeLogin(PluginEvent $event) } } - public function eventNewUserSession() + public function eventNewUserSession(PluginEvent $event) { // Do nothing if this user is not Authwebserver type - $identity = $this->getEvent()->get('identity'); + $identity = $event->get('identity'); if ($identity->plugin != 'Authwebserver') { return; diff --git a/application/core/plugins/Authwebserver/limesurvey.json b/application/core/plugins/Authwebserver/limesurvey.json index 17cb6142e92..5447a38f025 100644 --- a/application/core/plugins/Authwebserver/limesurvey.json +++ b/application/core/plugins/Authwebserver/limesurvey.json @@ -11,7 +11,8 @@ }, "events" : [ "beforeLogin", - "newUserSession" + "newUserSession", + "newLoginForm" ], "apiVersion" : "1.0" } \ No newline at end of file diff --git a/application/helpers/Hash.php b/application/helpers/Hash.php deleted file mode 100644 index a921217c0ec..00000000000 --- a/application/helpers/Hash.php +++ /dev/null @@ -1,993 +0,0 @@ -`, `<`, `>=`, `<=` Value comparison. - * - `=/.../` Regular expression pattern match. - * - * Given a set of User array data, from a `$User->find('all')` call: - * - * - `1.User.name` Get the name of the user at index 1. - * - `{n}.User.name` Get the name of every user in the set of users. - * - `{n}.User[id]` Get the name of every user with an id key. - * - `{n}.User[id>=2]` Get the name of every user with an id key greater than or equal to 2. - * - `{n}.User[username=/^paul/]` Get User elements with username matching `^paul`. - * - * @param array $data The data to extract from. - * @param string $path The path to extract. - * @return array An array of the extracted values. Returns an empty array - * if there are no matches. - */ - public static function extract(array $data, $path) { - if (empty($path)) { - return $data; - } - - // Simple paths. - if (!preg_match('/[{\[]/', $path)) { - return (array)self::get($data, $path); - } - - if (strpos($path, '[') === false) { - $tokens = explode('.', $path); - } else { - $tokens = String::tokenize($path, '.', '[', ']'); - } - - $_key = '__set_item__'; - - $context = array($_key => array($data)); - - foreach ($tokens as $token) { - $next = array(); - - $conditions = false; - $position = strpos($token, '['); - if ($position !== false) { - $conditions = substr($token, $position); - $token = substr($token, 0, $position); - } - - foreach ($context[$_key] as $item) { - foreach ((array)$item as $k => $v) { - if (self::_matchToken($k, $token)) { - $next[] = $v; - } - } - } - - // Filter for attributes. - if ($conditions) { - $filter = array(); - foreach ($next as $item) { - if (self::_matches($item, $conditions)) { - $filter[] = $item; - } - } - $next = $filter; - } - $context = array($_key => $next); - - } - return $context[$_key]; - } - -/** - * Check a key against a token. - * - * @param string $key The key in the array being searched. - * @param string $token The token being matched. - * @return boolean - */ - protected static function _matchToken($key, $token) { - if ($token === '{n}') { - return is_numeric($key); - } - if ($token === '{s}') { - return is_string($key); - } - if (is_numeric($token)) { - return ($key == $token); - } - return ($key === $token); - } - -/** - * Checks whether or not $data matches the attribute patterns - * - * @param array $data Array of data to match. - * @param string $selector The patterns to match. - * @return boolean Fitness of expression. - */ - protected static function _matches(array $data, $selector) { - preg_match_all( - '/(\[ (?