/** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void * * @since 4.0 */ public function register(Container $container) { $container->share('JApplicationAdministrator', function (Container $container) { $app = new \JApplicationAdministrator(null, null, null, $container); // The session service provider needs JFactory::$application, set it if still null if (JFactory::$application === null) { JFactory::$application = $app; } $app->setDispatcher($container->get('Joomla\\Event\\DispatcherInterface')); $app->setLogger(JLog::createDelegatedLogger()); $app->setSession($container->get('Joomla\\Session\\SessionInterface')); return $app; }, true); $container->share('JApplicationSite', function (Container $container) { $app = new \JApplicationSite(null, null, null, $container); // The session service provider needs JFactory::$application, set it if still null if (JFactory::$application === null) { JFactory::$application = $app; } $app->setDispatcher($container->get('Joomla\\Event\\DispatcherInterface')); $app->setLogger(JLog::createDelegatedLogger()); $app->setSession($container->get('Joomla\\Session\\SessionInterface')); return $app; }, true); }
/** * Tests the findOption() method simulating the option at a special value. */ public function testFindOptionCanLoginAdminOptionSet() { $user = $this->getMock('JUser', array('get', 'authorise')); $user->expects($this->once())->method('get')->with($this->equalTo('guest'))->willReturn(false); $user->expects($this->once())->method('authorise')->with($this->equalTo('core.login.admin'))->willReturn(false); $this->class->loadIdentity($user); $this->class->input->set('option', 'foo'); $this->assertEquals('com_login', $this->class->findOption()); $this->assertEquals('com_login', JFactory::$application->input->get('option')); }
/** * This method should handle any login logic and report back to the subject * * @param array $options Array holding options (remember, return, entry_url, action, user, responseType) * * @return boolean True on success */ public function onUserAfterLogin($options) { if (!$this->app->isAdmin() or !JComponentHelper::isEnabled("com_identityproof")) { return true; } // Get the number of days after the system have to remove records. $days = $this->params->get("days", 14); if (!empty($days)) { $today = new JDate(); $today->modify("- " . (int) $days . " days"); $date = $today->format("Y-m-d"); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select("a.filename")->from($db->quoteName("#__identityproof_files", "a"))->where("a.record_date <= " . $db->quote($date)); $db->setQuery($query); $results = $db->loadColumn(); if (!empty($results)) { $params = JComponentHelper::getParams("com_identityproof"); /** @var $params Joomla\Registry\Registry */ // Remove old key files jimport("joomla.filesystem.file"); foreach ($results as $filename) { $file = JPath::clean($params->get("files_path") . DIRECTORY_SEPARATOR . $filename); if (JFile::exists($file)) { JFile::delete($file); } } // Remove old records. $query = $db->getQuery(true); $query->delete($db->quoteName("#__identityproof_files"))->where($db->quoteName("record_date") . " <= " . $db->quote($date)); $db->setQuery($query); $db->execute(); } } return true; }
/** * Tests the JApplicationCms::isSite method. * * @return void * * @since 3.2 */ public function testIsSite() { $this->assertFalse($this->class->isSite()); }
/** * Tests the JApplicationCms::isSite method. * * @return void * * @since 3.2 */ public function testIsSite() { $this->assertThat($this->class->isSite(), $this->isFalse(), 'JApplicationAdministrator is not a site app'); }
/** * Tests the JApplicationCms::isClient method. * * @return void * * @since __DEPLOY_VERSION__ */ public function testIsClient() { $this->assertTrue($this->class->isClient('administrator')); $this->assertFalse($this->class->isClient('site')); }