/** * Default task * * @return void */ public function displayTask() { // If authenticator is specified, call the plugin display method, // otherwise (or if method does not exist) use default $authenticator = Request::getVar('authenticator', '', 'method'); Plugin::import('authentication'); $plugins = Plugin::byType('authentication'); foreach ($plugins as $plugin) { $className = 'plg' . $plugin->type . $plugin->name; $params = json_decode($plugin->params); if (class_exists($className) && isset($params->admin_login) && $params->admin_login) { $myplugin = new $className($this, (array) $plugin); if ($plugin->name != $authenticator) { continue; } if (method_exists($className, 'display')) { $this->view->return = Request::getVar('return', null, 'method', 'base64'); $result = $myplugin->display($this->view, null); return $result; } } } // Special treatment is required for this plugin, as this view may be called // after a session timeout. We must reset the view and layout prior to display // otherwise an error will occur. Request::setVar('view', 'login'); Request::setVar('tmpl', 'login'); //Request::setVar('layout', 'default'); // See if we have any messages available by cookie $handler = new Handler(new Cookie(1)); if ($handler->any()) { foreach ($handler->messages() as $message) { Notify::{$message['type']}($message['message']); } } $this->view->setLayout('default')->display(); }
/** * Test __toString * * @covers \Hubzero\Notification\Handler::__toString * @return void **/ public function testToString() { $handler = new Handler(new Memory()); foreach ($this->data as $item) { $handler->message($item['message'], $item['type'], $item['domain']); } $messages = (string) $handler; $this->assertTrue(is_string($messages)); $this->assertJson($messages); }
/** * Test that messages added with error() are * assigned the appropriate type. * * @return void **/ public function testError() { $handler = new Handler(new Memory()); $handler->error('Lorem ipsum dol.'); $m = $handler->messages(); $message = array_pop($m); $this->assertTrue(is_array($message), 'Individual messages should be of type array'); $this->assertEquals($message['type'], 'error'); }