PageRenderTime 41ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/source/innomatic/core/classes/innomatic/core/InnomaticContainer.php

https://bitbucket.org/innoteam/innomatic
PHP | 1571 lines | 1204 code | 170 blank | 197 comment | 113 complexity | 94d66aedc685157599c9c2daf01899c4 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, LGPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Innomatic
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.
  9. *
  10. * @copyright 1999-2012 Innoteam S.r.l.
  11. * @license http://www.innomatic.org/license/ BSD License
  12. * @link http://www.innomatic.org
  13. * @since Class available since Release 5.0
  14. */
  15. require_once('innomatic/util/Singleton.php');
  16. require_once('innomatic/webapp/WebAppContainer.php');
  17. /**
  18. * Innomatic base container class.
  19. *
  20. * This class takes care of bootstrapping and shutting down the whole container,
  21. * the root, the domains and the Web Services interface.
  22. *
  23. * It holds the container current state, mode and interface.
  24. *
  25. * This class provided a custom PHP error handler for the container
  26. * applications.
  27. *
  28. * @copyright 1999-2012 Innoteam S.r.l.
  29. * @license http://www.innomatic.org/license/ BSD License
  30. * @version Release: @package_version@
  31. * @link http://www.innomatic.org
  32. * @since Class available since Release 5.0
  33. * @package Core
  34. */
  35. class InnomaticContainer extends Singleton
  36. {
  37. private $_home;
  38. /**
  39. * Complete path of the Innomatic configuration file.
  40. * @var string
  41. */
  42. private $_configurationFile;
  43. /**
  44. *
  45. * @var boolean
  46. */
  47. private $_bootstrapped = false;
  48. private $_rootStarted = false;
  49. private $_domainStarted = false;
  50. private $_pid;
  51. private $_state;
  52. private $_mode = InnomaticContainer::MODE_BASE;
  53. private $_interface = InnomaticContainer::INTERFACE_UNKNOWN;
  54. private $_edition = InnomaticContainer::EDITION_SAAS;
  55. private $_rootDb;
  56. /**
  57. * Root language
  58. *
  59. * @var string
  60. */
  61. private $_language;
  62. /**
  63. * Root country.
  64. *
  65. * @var string
  66. */
  67. private $_country;
  68. private $_config;
  69. private $_logger;
  70. /**
  71. * Stores the result object of a maintenance routine.
  72. *
  73. * @var mixed
  74. */
  75. private $_maintenanceResult;
  76. private $_loadTimer;
  77. private $_dbLoadTimer;
  78. private $_platformName;
  79. private $_platformGroup;
  80. private $_lockOverride = false;
  81. private $_baseUrl;
  82. private $_externalBaseUrl;
  83. private $_currentWebServicesProfile;
  84. private $_currentWebServicesUser;
  85. private $_currentWebServicesMethods = array();
  86. private $_currentDomain;
  87. private $_currentUser;
  88. // Innomatic platform/instance state
  89. const STATE_SETUP = 1;
  90. const STATE_DEVELOPMENT = 2;
  91. const STATE_DEBUG = 3;
  92. const STATE_PRODUCTION = 4;
  93. const STATE_UPGRADE = 5;
  94. const STATE_MAINTENANCE = 6;
  95. // Output interface types
  96. const INTERFACE_UNKNOWN = 1;
  97. const INTERFACE_CONSOLE = 2;
  98. const INTERFACE_WEB = 3;
  99. const INTERFACE_WEBSERVICES = 4;
  100. const INTERFACE_GUI = 5;
  101. const INTERFACE_EXTERNAL = 6;
  102. // Mode types
  103. const MODE_BASE = 1;
  104. const MODE_ROOT = 2;
  105. const MODE_DOMAIN = 3;
  106. // Edition types
  107. const EDITION_SAAS = 1;
  108. const EDITION_ENTERPRISE = 2;
  109. // Deprecated
  110. const EDITION_ASP = 1;
  111. // Password result codes
  112. const SETROOTPASSWORD_NEW_PASSWORD_IS_EMPTY = -1;
  113. const SETROOTPASSWORD_UNABLE_TO_WRITE_NEW_PASSWORD = -2;
  114. const SETROOTPASSWORD_OLD_PASSWORD_IS_WRONG = -3;
  115. /**
  116. * Bootstraps the Innomatic container.
  117. *
  118. * @param string $home Complete path of the directory containing the
  119. * Innomatic webapp.
  120. * @param string $configuration Complete path of the Innomatic
  121. * configuration file.
  122. */
  123. public function bootstrap($home, $configuration)
  124. {
  125. if ($this->_bootstrapped) {
  126. return;
  127. }
  128. $this->_home = $home;
  129. // Reads the configuration
  130. $this->_configurationFile = $configuration;
  131. require_once('innomatic/core/InnomaticSettings.php');
  132. $this->_config = new InnomaticSettings($configuration);
  133. // *********************************************************************
  134. // Environment
  135. // *********************************************************************
  136. // PHP
  137. $timelimit = $this->_config->Value('PHPExecutionTimeLimit');
  138. if (!strlen($timelimit)) {
  139. $timelimit = 0;
  140. }
  141. set_time_limit($timelimit);
  142. ignore_user_abort(TRUE);
  143. //set_magic_quotes_runtime(0);
  144. // Adds global override classes folder to the include path.
  145. set_include_path(
  146. $this->_home . 'core/overrides/classes/'
  147. . PATH_SEPARATOR . get_include_path()
  148. );
  149. // *********************************************************************
  150. // Innomatic state, mode, interface and edition
  151. // *********************************************************************
  152. // Waits until system is in upgrade phase
  153. if ($this->_lockOverride == false) {
  154. while (file_exists(
  155. $this->_home . 'core/temp/upgrading_system_lock'
  156. )) {
  157. $this->_state = InnomaticContainer::STATE_UPGRADE;
  158. clearstatcache();
  159. sleep(1);
  160. }
  161. }
  162. // Checks if system is in setup phase and sets the state
  163. if (file_exists($this->_home . 'core/temp/setup_lock')) {
  164. $this->_state = InnomaticContainer::STATE_SETUP;
  165. if (extension_loaded('APD')) {
  166. apd_set_session_trace(35);
  167. }
  168. } else {
  169. switch ($this->_config->Value('PlatformState')) {
  170. case 'debug':
  171. $this->_state = InnomaticContainer::STATE_DEBUG;
  172. if (extension_loaded('APD')) {
  173. apd_set_session_trace(35);
  174. }
  175. break;
  176. case 'development':
  177. $this->_state = InnomaticContainer::STATE_DEVELOPMENT;
  178. break;
  179. case 'production':
  180. $this->_state = InnomaticContainer::STATE_PRODUCTION;
  181. break;
  182. default:
  183. $this->_state = InnomaticContainer::STATE_PRODUCTION;
  184. }
  185. }
  186. // Interface
  187. //$this->interface = InnomaticContainer::INTERFACE_UNKNOWN;
  188. // Mode
  189. //$this->mode = InnomaticContainer::MODE_ROOT;
  190. // Edition
  191. if ($this->_config->Value('PlatformEdition') == 'enterprise') {
  192. $this->_edition = InnomaticContainer::EDITION_ENTERPRISE;
  193. }
  194. // *********************************************************************
  195. // Pid and shutdown function
  196. // *********************************************************************
  197. if ($this->_state != InnomaticContainer::STATE_SETUP) {
  198. $this->_pid = md5(microtime());
  199. if (!file_exists($this->_home . 'core/temp/pids/')) {
  200. @mkdir($this->_home . 'core/temp/pids/');
  201. }
  202. touch($this->_home . 'core/temp/pids/' . $this->_pid, time());
  203. register_shutdown_function(array($this, 'shutdown'));
  204. }
  205. // *********************************************************************
  206. // Innomatic platform name
  207. // *********************************************************************
  208. $this->_platformName = $this->_config->Value('PlatformName');
  209. $this->_platformGroup = $this->_config->Value('PlatformGroup');
  210. // *********************************************************************
  211. // Innomatic error handler
  212. // *********************************************************************
  213. set_error_handler(array($this, 'errorHandler'));
  214. // *********************************************************************
  215. // Innomatic root
  216. // *********************************************************************
  217. $this->_country = $this->_config->Value('RootCountry');
  218. $this->_language = $this->_config->Value('RootLanguage');
  219. require_once('innomatic/dataaccess/DataAccessFactory.php');
  220. if ($this->_state != InnomaticContainer::STATE_SETUP) {
  221. // Innomatic central database
  222. //
  223. require_once('innomatic/dataaccess/DataAccessSourceName.php');
  224. $dasnString = $this->_config->Value('RootDatabaseType') . '://'
  225. . $this->_config->Value('RootDatabaseUser') . ':'
  226. . $this->_config->Value('RootDatabasePassword') . '@'
  227. . $this->_config->Value('RootDatabaseHost') . ':'
  228. . $this->_config->Value('RootDatabasePort') . '/'
  229. . $this->_config->Value('RootDatabaseName') . '?'
  230. . 'logfile='
  231. . InnomaticContainer::instance('innomaticcontainer')->getHome()
  232. . 'core/log/innomatic_root_db.log';
  233. $this->_rootDb = DataAccessFactory::getDataAccess(
  234. new DataAccessSourceName($dasnString)
  235. );
  236. if (!$this->_rootDb->Connect()) {
  237. $this->abort('Database not connected');
  238. }
  239. }
  240. // *********************************************************************
  241. // Run time state and interface defined data
  242. // *********************************************************************
  243. // Debugger
  244. if ($this->_state == InnomaticContainer::STATE_DEBUG) {
  245. require_once('innomatic/debug/LoadTime.php');
  246. $this->_loadTimer = new LoadTime(
  247. LoadTime::LOADTIME_MODE_CONTINUOUS
  248. );
  249. $this->_loadTimer->Mark('start');
  250. $this->_dbLoadTimer = new LoadTime(
  251. LoadTime::LOADTIME_MODE_STARTSTOP
  252. );
  253. }
  254. // Security
  255. $securityReportsInterval = $this->_config->Value(
  256. 'SecurityReportsInterval'
  257. );
  258. if ($securityReportsInterval > 0) {
  259. $lastSecurityReport = $this->_config->Value(
  260. 'SecurityLastReportTime'
  261. );
  262. if (
  263. !$lastSecurityReport
  264. or $lastSecurityReport < (time() - (
  265. $securityReportsInterval * 3600 * 24
  266. ))
  267. ) {
  268. require_once('innomatic/security/SecurityManager.php');
  269. $innomaticSecurity = new SecurityManager();
  270. $innomaticSecurity->SendReport();
  271. unset($innomaticSecurity);
  272. }
  273. }
  274. unset($securityReportsInterval);
  275. // Maintenance
  276. $maintenanceInterval = $this->_config->Value('MaintenanceInterval');
  277. if (
  278. $this->_state != InnomaticContainer::STATE_MAINTENANCE
  279. and $maintenanceInterval > 0
  280. ) {
  281. $lastMaintenance = $this->_config->Value(
  282. 'MaintenanceLastExecutionTime'
  283. );
  284. if (
  285. !$lastMaintenance
  286. or $lastMaintenance < (time() - (
  287. $maintenanceInterval * 3600 * 24
  288. ))
  289. ) {
  290. require_once('innomatic/maintenance/MaintenanceHandler.php');
  291. $innomaticMaintenance = new MaintenanceHandler();
  292. $innomaticMaintenance->DoMaintenance();
  293. $innomaticMaintenance->SendReport();
  294. unset($innomaticMaintenance);
  295. }
  296. }
  297. unset($maintenanceInterval);
  298. // *********************************************************************
  299. // Auto exec routines
  300. // *********************************************************************
  301. // Application reupdate check
  302. if (file_exists($this->_home . 'core/temp/appinst/reupdate')) {
  303. require_once('innomatic/application/Application.php');
  304. $tmpmod = new Application($this->_rootDb, '');
  305. $tmpmod->Install($this->_home . 'core/temp/appinst/reupdate');
  306. clearstatcache();
  307. if (file_exists($this->_home . 'core/temp/appinst/reupdate')) {
  308. unlink($this->_home . 'core/temp/appinst/reupdate');
  309. }
  310. }
  311. // Startup hook
  312. if ($this->_state != InnomaticContainer::STATE_SETUP) {
  313. require_once('innomatic/process/Hook.php');
  314. $hook = new Hook($this->_rootDb, 'innomatic', 'instance');
  315. $null = '';
  316. switch ($hook->CallHooks('startup', $null, '')) {
  317. case Hook::RESULT_ABORT :
  318. $this->abort('Bootstrap aborted');
  319. break;
  320. }
  321. }
  322. // Bootstrap end
  323. $this->_bootstrapped = true;
  324. }
  325. /**
  326. * Starts the root mode.
  327. * @param string $userId Root username (currently not used, defaults to
  328. * "root").
  329. */
  330. public function startRoot($userId = 'root')
  331. {
  332. $this->setMode(InnomaticContainer::MODE_ROOT);
  333. if ($this->_rootStarted) {
  334. return;
  335. }
  336. $this->_rootStarted = true;
  337. }
  338. public function startDomain($domainId, $userId = '')
  339. {
  340. $result = false;
  341. $this->setMode(InnomaticContainer::MODE_DOMAIN);
  342. if (is_object($this->_currentDomain) or $this->_domainStarted) {
  343. // A domain has been already started
  344. return false;
  345. }
  346. require_once('innomatic/domain/Domain.php');
  347. $this->_currentDomain = new Domain($this->_rootDb, $domainId, null);
  348. if ($this->_currentDomain->isValid()) {
  349. // Check if domain is active
  350. //
  351. if (
  352. $this->getInterface() != InnomaticContainer::INTERFACE_WEB
  353. and $this->_currentDomain->domaindata['domainactive']
  354. == $this->_rootDb->fmtfalse
  355. ) {
  356. $this->abort('Domain disabled');
  357. }
  358. if (!$this->_currentDomain->getDataAccess()->isConnected()) {
  359. $adloc = new LocaleCatalog(
  360. 'innomatic::authentication',
  361. $this->_language
  362. );
  363. InnomaticContainer::instance('innomaticcontainer')->abort(
  364. $adloc->getStr('nodb')
  365. );
  366. }
  367. // Adds override classes folder to the include path.
  368. set_include_path(
  369. $this->_home . 'core/domains/'
  370. . $this->_currentDomain->getDomainId()
  371. . '/overrides/classes/'
  372. . PATH_SEPARATOR . get_include_path()
  373. );
  374. // User
  375. //
  376. // TODO check in Enterprise edition if the admin@domainid part is ok
  377. // $admin_username = 'admin'
  378. // .(InnomaticContainer::instance(
  379. // 'innomaticcontainer'
  380. // )->getEdition() == InnomaticContainer::EDITION_SAAS ? '@'.$domain
  381. // : '');
  382. require_once('innomatic/domain/user/User.php');
  383. $this->_currentUser = new User(
  384. $this->_currentDomain->domainserial,
  385. User::getUserIdByUsername(
  386. strlen($userId) ? $userId : 'admin@' . $domainId
  387. )
  388. );
  389. $result = true;
  390. }
  391. $this->_domainStarted = $result;
  392. return $result;
  393. }
  394. public function stopDomain()
  395. {
  396. if ($this->_domainStarted) {
  397. if (InnomaticContainer::instance('innomaticcontainer')->getEdition() == InnomaticContainer::EDITION_SAAS) {
  398. $this->_currentDomain->getDataAccess()->close();
  399. }
  400. // TODO implement
  401. // Removes override classes folder from the include path
  402. set_include_path(
  403. str_replace(
  404. $this->_home . 'core/domains/'
  405. . $this->_currentDomain->getDomainId()
  406. . '/overrides/classes/' . PATH_SEPARATOR,
  407. '', get_include_path()
  408. )
  409. );
  410. $this->_domainStarted = false;
  411. $this->_currentDomain = null;
  412. $this->setMode(InnomaticContainer::MODE_ROOT);
  413. }
  414. }
  415. // TODO to be implemented
  416. public function startWebServices()
  417. {
  418. }
  419. public function startMaintenance()
  420. {
  421. $this->setState(InnomaticContainer::STATE_MAINTENANCE);
  422. $this->setInterface(InnomaticContainer::INTERFACE_CONSOLE);
  423. require_once('innomatic/maintenance/MaintenanceHandler.php');
  424. require_once('innomatic/process/Hook.php');
  425. $hook = new Hook($this->_rootDb, 'innomatic', 'instance');
  426. $null = null;
  427. switch ($hook->CallHooks('maintenance', $null, '')) {
  428. case Hook::RESULT_ABORT:
  429. InnomaticContainer::instance('innomaticcontainer')->abort(
  430. 'Maintenance aborted'
  431. );
  432. break;
  433. }
  434. $innomaticMnt = new MaintenanceHandler();
  435. $this->_maintenanceResult = $innomaticMnt->DoMaintenance();
  436. $innomaticMnt->SendReport($this->_maintenanceResult);
  437. }
  438. /**
  439. * Halts Innomatic Container.
  440. *
  441. * This must be called by applications in place of exit(), in order to exit
  442. * in a clean mode.
  443. *
  444. * @param string $status
  445. */
  446. public function halt($status = '')
  447. {
  448. $rootContainer = RootContainer::instance('rootcontainer');
  449. $rootContainer->stop();
  450. exit($status);
  451. }
  452. public function shutdown()
  453. {
  454. if ($this->_state != InnomaticContainer::STATE_SETUP) {
  455. require_once('innomatic/process/Hook.php');
  456. if (is_object($this->_rootDb)) {
  457. $hook = new Hook($this->_rootDb, 'innomatic', 'instance');
  458. $null = '';
  459. switch ($hook->CallHooks('shutdown', $null, '')) {
  460. case Hook::RESULT_ABORT:
  461. $this->abort('Shutdown aborted');
  462. break;
  463. }
  464. }
  465. }
  466. switch ($this->_state) {
  467. case InnomaticContainer::STATE_DEBUG:
  468. if (
  469. is_object($this->_loadTimer)
  470. and RootContainer::instance('rootcontainer')->isClean()
  471. == true
  472. ) {
  473. $this->_loadTimer->Mark('end');
  474. $log = $this->getLogger();
  475. $log->logEvent(
  476. 'innomatic',
  477. 'Profiler total time: '
  478. . $this->_loadTimer->getTotalTime(),
  479. Logger::DEBUG
  480. );
  481. $fh = @fopen(
  482. $this->_home . 'core/temp/pids/' . $this->_pid,
  483. 'w'
  484. );
  485. if ($fh) {
  486. require_once('innomatic/debug/InnomaticDump.php');
  487. $dump = InnomaticDump::instance('innomaticdump');
  488. $dump->snapshot();
  489. @fwrite($fh, serialize($dump));
  490. @fclose($fh);
  491. }
  492. }
  493. break;
  494. }
  495. if (!RootContainer::instance('rootcontainer')->isClean()) {
  496. if (is_object($this->_loadTimer)) {
  497. $this->_loadTimer->Mark('end');
  498. $log = $this->getLogger();
  499. $log->logEvent(
  500. 'innomatic',
  501. 'Profiler total time: '
  502. . $this->_loadTimer->getTotalTime(),
  503. Logger::DEBUG
  504. );
  505. }
  506. $fh = @fopen(
  507. $this->_home . 'core/temp/pids/' . $this->_pid . '_coredump',
  508. 'w'
  509. );
  510. if ($fh) {
  511. require_once('innomatic/debug/InnomaticDump.php');
  512. $dump = InnomaticDump::instance('innomaticdump');
  513. $dump->snapshot();
  514. @fwrite($fh, serialize($dump));
  515. @fclose($fh);
  516. }
  517. }
  518. if (
  519. !RootContainer::instance('rootcontainer')->isClean()
  520. or (
  521. $this->_state != InnomaticContainer::STATE_DEBUG
  522. and file_exists(
  523. $this->_home . 'core/temp/pids/' . $this->_pid
  524. )
  525. )
  526. ) {
  527. @unlink($this->_home . 'core/temp/pids/' . $this->_pid);
  528. }
  529. exit();
  530. }
  531. public function abort($text, $forceInterface = '')
  532. {
  533. require_once('innomatic/wui/Wui.php');
  534. if (strlen($forceInterface)) {
  535. $interface = $forceInterface;
  536. } else {
  537. $interface = $this->_interface;
  538. }
  539. if ($interface == InnomaticContainer::INTERFACE_EXTERNAL) {
  540. /*
  541. if (
  542. isset(
  543. $GLOBALS['gEnv']['runtime']
  544. ['external_interface_error_handler'])
  545. and function_exists(
  546. $GLOBALS['gEnv']['runtime']['external_interface_error_handler'])) {
  547. $func = $GLOBALS['gEnv']['runtime']
  548. ['external_interface_error_handler'];
  549. $func ($text);
  550. } else {
  551. */
  552. $interface = InnomaticContainer::INTERFACE_WEB;
  553. $this->_interface = InnomaticContainer::INTERFACE_WEB;
  554. //}
  555. }
  556. switch ($interface) {
  557. case InnomaticContainer::INTERFACE_GUI :
  558. // break was intentionally omitted
  559. case InnomaticContainer::INTERFACE_UNKNOWN :
  560. // break was intentionally omitted
  561. case InnomaticContainer::INTERFACE_WEBSERVICES :
  562. // break was intentionally omitted
  563. case InnomaticContainer::INTERFACE_EXTERNAL :
  564. break;
  565. case InnomaticContainer::INTERFACE_CONSOLE :
  566. echo "\n".$text."\n";
  567. break;
  568. case InnomaticContainer::INTERFACE_WEB :
  569. $tmpWui = Wui::instance('wui');
  570. $tmpWui->loadWidget('empty');
  571. //$tmp_elem = new WuiEmpty('empty');
  572. $dieImage = Wui::instance('wui')->getTheme()->mStyle['biglogo'];
  573. ?>
  574. <html>
  575. <head>
  576. <basefont face="Verdana" />
  577. <title>Innomatic</title>
  578. <link rel="stylesheet" type="text/css"
  579. href="<?php echo Wui::instance('wui')->getTheme()->mStyle['css'];
  580. ?>">
  581. </head>
  582. <body bgcolor="white">
  583. <table border="0" cellspacing="0" cellpadding="0" align="center"
  584. width="200" height="100%">
  585. <tr>
  586. <td height="50%">
  587. </tr>
  588. <tr>
  589. <td align="center" valign="middle"><a
  590. href="<?php echo InnomaticContainer::instance(
  591. 'innomaticcontainer'
  592. )->getExternalBaseUrl();
  593. ?>"
  594. target="_top"><img src="<?php echo $dieImage;
  595. ?>"
  596. alt="Innomatic" border="0"></a></td>
  597. </tr>
  598. <tr>
  599. <td>&nbsp;</td>
  600. </tr>
  601. <tr>
  602. <td align="center"><?php echo $text;
  603. ?></td>
  604. </tr>
  605. <tr>
  606. <td height="50%">
  607. </tr>
  608. </table>
  609. </body>
  610. </html>
  611. <?php break;
  612. }
  613. $this->halt();
  614. }
  615. public function errorHandler(
  616. $errorType,
  617. $errorMessage,
  618. $errorFile,
  619. $errorLine,
  620. $errorContext
  621. )
  622. {
  623. $logError[E_ERROR]['log'] = true;
  624. $logError[E_ERROR]['die'] = true;
  625. $logError[E_WARNING]['log'] = false;
  626. $logError[E_WARNING]['die'] = false;
  627. $logError[E_PARSE]['log'] = true;
  628. $logError[E_PARSE]['die'] = false;
  629. $logError[E_NOTICE]['log'] = false;
  630. $logError[E_NOTICE]['die'] = false;
  631. $logError[E_CORE_ERROR]['log'] = true;
  632. $logError[E_CORE_ERROR]['die'] = true;
  633. $logError[E_CORE_WARNING]['log'] = false;
  634. $logError[E_CORE_WARNING]['die'] = false;
  635. $logError[E_COMPILE_ERROR]['log'] = true;
  636. $logError[E_COMPILE_ERROR]['die'] = true;
  637. $logError[E_COMPILE_WARNING]['log'] = false;
  638. $logError[E_COMPILE_WARNING]['die'] = false;
  639. $logError[E_USER_ERROR]['log'] = true;
  640. $logError[E_USER_ERROR]['die'] = true;
  641. $logError[E_USER_WARNING]['log'] = false;
  642. $logError[E_USER_WARNING]['die'] = false;
  643. $logError[E_USER_NOTICE]['log'] = false;
  644. $logError[E_USER_NOTICE]['die'] = false;
  645. if (InnomaticContainer::instance('innomaticcontainer')->getState() != InnomaticContainer::STATE_SETUP) {
  646. $phpLog = InnomaticContainer::instance(
  647. 'innomaticcontainer'
  648. )->getHome() . 'core/log/php.log';
  649. } else {
  650. $phpLog = InnomaticContainer::instance(
  651. 'innomaticcontainer'
  652. )->getHome() . 'core/log/innomatic.log';
  653. }
  654. switch ($this->_state) {
  655. case InnomaticContainer::STATE_DEBUG :
  656. $logError[E_NOTICE]['log'] = true;
  657. $logError[E_USER_NOTICE]['log'] = true;
  658. $logError[E_WARNING]['log'] = true;
  659. $logError[E_CORE_WARNING]['log'] = true;
  660. $logError[E_COMPILE_WARNING]['die'] = true;
  661. $logError[E_USER_WARNING]['log'] = true;
  662. break;
  663. case InnomaticContainer::STATE_SETUP :
  664. case InnomaticContainer::STATE_DEVELOPMENT :
  665. /* For debug purposes in setup procedure add these commands:
  666. $log_err[E_NOTICE]['log'] = true;
  667. $log_err[E_USER_NOTICE]['log'] = true;
  668. */
  669. $logError[E_WARNING]['log'] = true;
  670. $logError[E_CORE_WARNING]['log'] = true;
  671. $logError[E_COMPILE_WARNING]['die'] = true;
  672. $logError[E_USER_WARNING]['log'] = true;
  673. break;
  674. case InnomaticContainer::STATE_PRODUCTION :
  675. case InnomaticContainer::STATE_UPGRADE :
  676. break;
  677. }
  678. switch ($errorType) {
  679. case E_ERROR:
  680. if ($logError[E_ERROR]['log']) {
  681. require_once('innomatic/logging/Logger.php');
  682. $log = new Logger($phpLog);
  683. $log->logEvent(
  684. 'Innomatic error handler',
  685. 'PHP generated an ERROR at line '
  686. . $errorLine
  687. . ' of file '
  688. . $errorFile
  689. . '. The error message was: '
  690. . $errorMessage,
  691. Logger::FAILURE
  692. );
  693. }
  694. if ($logError[E_ERROR]['die']) {
  695. $this->abort(
  696. 'A fatal error occured at line '
  697. . $errorLine
  698. . ' of file '
  699. . $errorFile
  700. . '. The error message was: '
  701. . $errorMessage
  702. );
  703. }
  704. break;
  705. case E_WARNING:
  706. if ($logError[E_WARNING]['log']) {
  707. require_once('innomatic/logging/Logger.php');
  708. $log = new Logger($phpLog);
  709. $log->logEvent(
  710. 'Innomatic error handler',
  711. 'PHP generated a WARNING at line '
  712. . $errorLine
  713. . ' of file '
  714. . $errorFile
  715. . '. The error message was: '
  716. . $errorMessage,
  717. Logger::WARNING
  718. );
  719. }
  720. if ($logError[E_WARNING]['die']) {
  721. $this->abort(
  722. 'A warning occured at line '
  723. . $errorLine
  724. . ' of file '
  725. . $errorFile
  726. . '. The error message was: '
  727. . $errorMessage
  728. );
  729. }
  730. break;
  731. case E_PARSE :
  732. if ($logError[E_PARSE]['log']) {
  733. require_once('innomatic/logging/Logger.php');
  734. $log = new Logger($phpLog);
  735. $log->logEvent(
  736. 'Innomatic error handler',
  737. 'PHP generated a PARSE error at line '
  738. .$errorLine
  739. .' of file '
  740. .$errorFile
  741. .'. The error message was: '
  742. .$errorMessage,
  743. Logger::ERROR
  744. );
  745. }
  746. if ($logError[E_PARSE]['die'])
  747. $this->abort(
  748. 'A parse error occured at line '
  749. .$errorLine
  750. .' of file '
  751. .$errorFile
  752. .'. The error message was: '
  753. .$errorMessage
  754. );
  755. break;
  756. case E_NOTICE :
  757. if ($logError[E_NOTICE]['log']) {
  758. require_once('innomatic/logging/Logger.php');
  759. $log = new Logger($phpLog);
  760. $log->logEvent(
  761. 'Innomatic error handler',
  762. 'PHP generated a notice at line '
  763. .$errorLine
  764. .' of file '
  765. .$errorFile
  766. .'. The error message was: '
  767. .$errorMessage,
  768. Logger::NOTICE
  769. );
  770. }
  771. if ($logError[E_NOTICE]['die'])
  772. $this->abort(
  773. 'A notice occured at line '
  774. .$errorLine
  775. .' of file '
  776. .$errorFile
  777. .'. The error message was: '
  778. .$errorMessage
  779. );
  780. break;
  781. case E_CORE_ERROR :
  782. if ($logError[E_CORE_ERROR]['log']) {
  783. require_once('innomatic/logging/Logger.php');
  784. $log = new Logger($phpLog);
  785. $log->logEvent(
  786. 'Innomatic error handler',
  787. 'PHP generated a CORE ERROR at line '
  788. .$errorLine
  789. .' of file '
  790. .$errorFile
  791. .'. The error message was: '
  792. .$errorMessage,
  793. Logger::ERROR
  794. );
  795. }
  796. if ($logError[E_CORE_ERROR]['die'])
  797. $this->abort(
  798. 'A core error occured at line '
  799. .$errorLine
  800. .' of file '
  801. .$errorFile
  802. .'. The error message was: '
  803. .$errorMessage
  804. );
  805. break;
  806. case E_CORE_WARNING :
  807. if ($logError[E_CORE_WARNING]['log']) {
  808. require_once('innomatic/logging/Logger.php');
  809. $log = new Logger($phpLog);
  810. $log->logEvent(
  811. 'Innomatic error handler',
  812. 'PHP generated a CORE WARNING at line '
  813. .$errorLine
  814. .' of file '
  815. .$errorFile
  816. .'. The error message was: '
  817. .$errorMessage,
  818. Logger::ERROR
  819. );
  820. }
  821. if ($logError[E_CORE_WARNING]['die'])
  822. $this->abort(
  823. 'A core warning occured at line '
  824. .$errorLine
  825. .' of file '
  826. .$errorFile
  827. .'. The error message was: '
  828. .$errorMessage
  829. );
  830. break;
  831. case E_COMPILE_ERROR :
  832. if ($logError[E_COMPILE_ERROR]['log']) {
  833. require_once('innomatic/logging/Logger.php');
  834. $log = new Logger($phpLog);
  835. $log->logEvent(
  836. 'Innomatic error handler',
  837. 'PHP generated a COMPILE ERROR at line '
  838. .$errorLine
  839. .' of file '
  840. .$errorFile
  841. .'. The error message was: '
  842. .$errorMessage,
  843. Logger::ERROR
  844. );
  845. }
  846. if ($logError[E_COMPILE_ERROR]['die'])
  847. $this->abort(
  848. 'A compile error occured at line '
  849. .$errorLine
  850. .' of file '
  851. .$errorFile
  852. .'. The error message was: '
  853. .$errorMessage
  854. );
  855. break;
  856. case E_COMPILE_WARNING :
  857. if ($logError[E_COMPILE_WARNING]['log']) {
  858. require_once('innomatic/logging/Logger.php');
  859. $log = new Logger($phpLog);
  860. $log->logEvent(
  861. 'Innomatic error handler',
  862. 'PHP generated a COMPILE WARNING at line '
  863. .$errorLine
  864. .' of file '
  865. .$errorFile
  866. .'. The error message was: '
  867. .$errorMessage,
  868. Logger::ERROR
  869. );
  870. }
  871. if ($logError[E_COMPILE_WARNING]['die'])
  872. $this->abort(
  873. 'A compile warning occured at line '
  874. .$errorLine
  875. .' of file '
  876. .$errorFile
  877. .'. The error message was: '
  878. .$errorMessage
  879. );
  880. break;
  881. case E_USER_ERROR :
  882. if ($logError[E_USER_ERROR]['log']) {
  883. require_once('innomatic/logging/Logger.php');
  884. $log = new Logger($phpLog);
  885. $log->logEvent(
  886. 'Innomatic error handler',
  887. 'PHP generated an USER ERROR at line '
  888. .$errorLine
  889. .' of file '
  890. .$errorFile
  891. .'. The error message was: '
  892. .$errorMessage,
  893. Logger::ERROR
  894. );
  895. }
  896. if ($logError[E_USER_ERROR]['die'])
  897. $this->abort(
  898. 'An user error occured at line '
  899. .$errorLine
  900. .' of file '
  901. .$errorFile
  902. .'. The error message was: '
  903. .$errorMessage
  904. );
  905. break;
  906. case E_USER_WARNING :
  907. if ($logError[E_USER_WARNING]['log']) {
  908. require_once('innomatic/logging/Logger.php');
  909. $log = new Logger($phpLog);
  910. $log->logEvent(
  911. 'Innomatic error handler',
  912. 'PHP generated an USER WARNING at line '
  913. .$errorLine
  914. .' of file '
  915. .$errorFile
  916. .'. The error message was: '
  917. .$errorMessage,
  918. Logger::ERROR
  919. );
  920. }
  921. if ($logError[E_USER_WARNING]['die'])
  922. $this->abort(
  923. 'An user warning occured at line '
  924. .$errorLine
  925. .' of file '
  926. .$errorFile
  927. .'. The error message was: '
  928. .$errorMessage
  929. );
  930. break;
  931. case E_USER_NOTICE :
  932. if ($logError[E_USER_NOTICE]['log']) {
  933. require_once('innomatic/logging/Logger.php');
  934. $log = new Logger($phpLog);
  935. $log->logEvent(
  936. 'Innomatic error handler',
  937. 'PHP generated an USER NOTICE at line '
  938. .$errorLine
  939. .' of file '
  940. .$errorFile
  941. .'. The error message was: '
  942. .$errorMessage,
  943. Logger::ERROR
  944. );
  945. }
  946. if ($logError[E_USER_NOTICE]['die'])
  947. $this->abort(
  948. 'An user notice occured at line '
  949. .$errorLine
  950. .' of file '
  951. .$errorFile
  952. .'. The error message was: '
  953. .$errorMessage
  954. );
  955. break;
  956. default :
  957. break;
  958. }
  959. }
  960. // Accessors
  961. public function getHome()
  962. {
  963. return $this->_home;
  964. }
  965. public function getConfigurationFile()
  966. {
  967. return $this->_configurationFile;
  968. }
  969. public function getDataAccess()
  970. {
  971. return $this->_rootDb;
  972. }
  973. public function getLanguage()
  974. {
  975. return $this->_language;
  976. }
  977. public function getCountry()
  978. {
  979. return $this->_country;
  980. }
  981. public function getConfig()
  982. {
  983. return $this->_config;
  984. }
  985. public function getLogger()
  986. {
  987. // Initialized the logger if not started
  988. if (!is_object($this->_logger)) {
  989. require_once('innomatic/logging/Logger.php');
  990. $this->_logger = new Logger(
  991. $this->_home . 'core/log/innomatic.log'
  992. );
  993. }
  994. return $this->_logger;
  995. }
  996. public function getPid()
  997. {
  998. return $this->_pid;
  999. }
  1000. public function getState()
  1001. {
  1002. return $this->_state;
  1003. }
  1004. public function setState($state)
  1005. {
  1006. switch ($state) {
  1007. case InnomaticContainer::STATE_SETUP:
  1008. // break was intentionally omitted
  1009. case InnomaticContainer::STATE_DEVELOPMENT:
  1010. // break was intentionally omitted
  1011. case InnomaticContainer::STATE_DEBUG:
  1012. // break was intentionally omitted
  1013. case InnomaticContainer::STATE_PRODUCTION:
  1014. // break was intentionally omitted
  1015. case InnomaticContainer::STATE_UPGRADE:
  1016. // break was intentionally omitted
  1017. case InnomaticContainer::STATE_MAINTENANCE:
  1018. $this->_state = $state;
  1019. break;
  1020. }
  1021. }
  1022. public function getMode()
  1023. {
  1024. return $this->_mode;
  1025. }
  1026. public function setMode($mode)
  1027. {
  1028. // Mode Base cannot be set
  1029. switch ($mode) {
  1030. case InnomaticContainer::MODE_ROOT:
  1031. // break was intentionally omitted
  1032. case InnomaticContainer::MODE_DOMAIN:
  1033. $this->_mode = $mode;
  1034. break;
  1035. }
  1036. }
  1037. public function getInterface()
  1038. {
  1039. return $this->_interface;
  1040. }
  1041. public function setInterface($interface)
  1042. {
  1043. switch ($interface) {
  1044. case InnomaticContainer::INTERFACE_UNKNOWN:
  1045. // break was intentionally omitted
  1046. case InnomaticContainer::INTERFACE_CONSOLE:
  1047. // break was intentionally omitted
  1048. case InnomaticContainer::INTERFACE_WEB:
  1049. // break was intentionally omitted
  1050. case InnomaticContainer::INTERFACE_WEBSERVICES:
  1051. // break was intentionally omitted
  1052. case InnomaticContainer::INTERFACE_GUI:
  1053. // break was intentionally omitted
  1054. case InnomaticContainer::INTERFACE_EXTERNAL:
  1055. $this->_interface = $interface;
  1056. break;
  1057. }
  1058. }
  1059. public function getEdition()
  1060. {
  1061. return $this->_edition;
  1062. }
  1063. public function getPlatformName()
  1064. {
  1065. return $this->_platformName;
  1066. }
  1067. public function getPlatformGroup()
  1068. {
  1069. return $this->_platformGroup;
  1070. }
  1071. public function &getMaintenanceResult()
  1072. {
  1073. return $this->_maintenanceResult;
  1074. }
  1075. public function getLoadTimer()
  1076. {
  1077. return $this->_loadTimer;
  1078. }
  1079. public function getDbLoadTimer()
  1080. {
  1081. return $this->_dbLoadTimer;
  1082. }
  1083. public function getLockOverride()
  1084. {
  1085. return $this->_lockOverride;
  1086. }
  1087. public function setLockOverride($status)
  1088. {
  1089. $this->_lockOverride = $status;
  1090. }
  1091. public function unlock()
  1092. {
  1093. // Erases all semaphores.
  1094. $handle = opendir(
  1095. InnomaticContainer::instance('innomaticcontainer')->getHome()
  1096. . 'core/temp/semaphores'
  1097. );
  1098. if ($handle) {
  1099. while (($file = readdir($handle)) !== false) {
  1100. if ($file != '.' and $file != '..') {
  1101. @unlink(
  1102. InnomaticContainer::instance(
  1103. 'innomaticcontainer'
  1104. )->getHome()
  1105. . 'core/temp/semaphores/' . $file
  1106. );
  1107. }
  1108. }
  1109. closedir($handle);
  1110. }
  1111. // Erases system upgrading lock if it exists.
  1112. if (
  1113. file_exists(
  1114. InnomaticContainer::instance('innomaticcontainer')->getHome()
  1115. . 'core/temp/upgrading_system_lock'
  1116. )
  1117. ) {
  1118. if (
  1119. @unlink(
  1120. InnomaticContainer::instance(
  1121. 'innomaticcontainer'
  1122. )->getHome()
  1123. . 'core/temp/upgrading_system_lock'
  1124. )
  1125. ) {
  1126. require_once('innomatic/logging/Logger.php');
  1127. $tmpLog = InnomaticContainer::instance(
  1128. 'innomaticcontainer'
  1129. )->getLogger();
  1130. $tmpLog->logEvent(
  1131. 'Innomatic',
  1132. 'Innomatic has been unlocked.',
  1133. Logger::NOTICE
  1134. );
  1135. $message = 'System unlocked.';
  1136. } else {
  1137. $message = 'Unable to unlock system.';
  1138. }
  1139. } else {
  1140. $message = 'System was not locked.';
  1141. }
  1142. $this->abort($message);
  1143. }
  1144. public function setBaseUrl($url)
  1145. {
  1146. $this->_baseUrl = $url;
  1147. }
  1148. public function getBaseUrl($addController = true, $addHostname = false)
  1149. {
  1150. if ($addHostname) {
  1151. $port = WebAppContainer::instance(
  1152. 'webappcontainer'
  1153. )->getProcessor()->getRequest()->getServerPort();
  1154. if (!strlen($port) or $port == 80) {
  1155. $port = '';
  1156. } else {
  1157. $port = ':' . $port;
  1158. }
  1159. }
  1160. return (
  1161. $addHostname ? WebAppContainer::instance(
  1162. 'webappcontainer'
  1163. )->getProcessor()->getRequest()->getScheme()
  1164. . '://' . WebAppContainer::instance(
  1165. 'webappcontainer'
  1166. )->getProcessor()->getRequest()->getServerName().$port : ''
  1167. )
  1168. . ( $addController ? $this->_baseUrl : (
  1169. WebAppContainer::instance(
  1170. 'webappcontainer'
  1171. )->getProcessor()->getRequest()->isUrlRewriteOn() ? $this->_baseUrl
  1172. : substr($this->_baseUrl, 0, -10)
  1173. ));
  1174. }
  1175. /**
  1176. * Gets the Innomatic webapp base URL, similar to the Domain webapp URL
  1177. * field. Since the innomatic webapp lacks the Domain webapp URL field and
  1178. * the getBaseUrl() method determines the URL assuming that the active
  1179. * webapp is innomatic itself, this method has been added in order to
  1180. * obtain the innomatic webapp public URL.
  1181. *
  1182. * The base URL is automatically discovered during Innomatic setup and is
  1183. * stored inside innomatic.ini configuration file in InnomaticBaseUrl key.
  1184. *
  1185. * @return string
  1186. */
  1187. public function getExternalBaseUrl()
  1188. {
  1189. // If already set, returns it.
  1190. if (!empty($this->_externalBaseUrl)) {
  1191. return $this->_externalBaseUrl;
  1192. }
  1193. // Not already set, so reads it from the configuration file.
  1194. $this->_externalBaseUrl = $this->_config->value('InnomaticBaseUrl');
  1195. // Should be empty only during setup phase.
  1196. if (empty($this->_externalBaseUrl)) {
  1197. $this->_externalBaseUrl = WebAppContainer::instance(
  1198. 'webappcontainer'
  1199. )->getProcessor()->getRequest()->getRequestURL();
  1200. // Checks if the URL contains the setup layout frames names
  1201. // and strips them away.
  1202. switch(substr($this->_externalBaseUrl, -5)) {
  1203. case '/main':
  1204. // break was intentionally omitted
  1205. case '/logo':
  1206. // break was intentionally omitted
  1207. case '/menu':
  1208. $this->_externalBaseUrl = substr(
  1209. $this->_externalBaseUrl, 0, -4
  1210. );
  1211. break;
  1212. }
  1213. }
  1214. return $this->_externalBaseUrl;
  1215. }
  1216. public static function setRootPassword($oldPassword, $newPassword)
  1217. {
  1218. $result = false;
  1219. $fh = @fopen(
  1220. InnomaticContainer::instance('innomaticcontainer')->getHome()
  1221. . 'core/conf/rootpasswd.ini',
  1222. 'r'
  1223. );
  1224. if ($fh) {
  1225. $cpassword = fgets($fh, 4096);
  1226. fclose($fh);
  1227. }
  1228. if (md5($oldPassword) == $cpassword) {
  1229. if (strlen($newPassword)) {
  1230. $fh = @fopen(
  1231. InnomaticContainer::instance(
  1232. 'innomaticcontainer'
  1233. )->getHome()
  1234. . 'core/conf/rootpasswd.ini',
  1235. 'w'
  1236. );
  1237. if ($fh) {
  1238. require_once('innomatic/logging/Logger.php');
  1239. $log = InnomaticContainer::instance(
  1240. 'innomaticcontainer'
  1241. )->getLogger();
  1242. fputs($fh, md5($newPassword));
  1243. fclose($fh);
  1244. $result = true;
  1245. $log->logEvent(
  1246. 'Innomatic',
  1247. 'Changed Innomatic root password',
  1248. Logger::NOTICE
  1249. );
  1250. } else {
  1251. $result = InnomaticContainer::SETROOTPASSWORD_UNABLE_TO_WRITE_NEW_PASSWORD;
  1252. }
  1253. } else {
  1254. $result = InnomaticContainer::SETROOTPASSWORD_NEW_PASSWORD_IS_EMPTY;
  1255. }
  1256. } else {
  1257. $result = InnomaticContainer::SETROOTPASSWORD_OLD_PASSWORD_IS_WRONG;
  1258. }
  1259. return $result;
  1260. }
  1261. public static function getRootWuiMenuDefinition($localeLang)
  1262. {
  1263. require_once('innomatic/locale/LocaleCatalog.php');
  1264. require_once('innomatic/wui/dispatch/WuiEventsCall.php');
  1265. $shLoc = new LocaleCatalog('innomatic::sharedmenu', $localeLang);
  1266. $result =
  1267. '.|' . $shLoc->getStr('domains.menu') . "\n".
  1268. '..|' . $shLoc->getStr('domainslist.menu') . '|'
  1269. . WuiEventsCall::buildEventsCallString(
  1270. 'domains', array( array('view', 'default'))
  1271. ) . "\n".
  1272. '..|' . $shLoc->getStr('newdomain.menu') . '|'
  1273. . WuiEventsCall::buildEventsCallString(
  1274. 'domains', array( array('view', 'newdomain'))
  1275. ) . "\n".
  1276. '.|' . $shLoc->getStr('applications.menu') . "\n".
  1277. '..|' . $shLoc->getStr('applicationslist.menu') . '|'
  1278. . WuiEventsCall::buildEventsCallString(
  1279. 'applications', array( array('view', 'default'))
  1280. ) . "\n".
  1281. '..|' . $shLoc->getStr('appcentral.menu') . '|'
  1282. . WuiEventsCall::buildEventsCallString(
  1283. 'applications', array( array('view', 'appcentral'))
  1284. ) . "\n".
  1285. '..|' . $shLoc->getStr('keyring.menu') . '|'
  1286. . WuiEventsCall::buildEventsCallString(
  1287. 'applications', array( array('view', 'keyring'))
  1288. ) . "\n".
  1289. '.|' . $shLoc->getStr('webservices.menu') . "\n".
  1290. '..|' . $shLoc->getStr('webservicesprofiles.menu') . '|'
  1291. . WuiEventsCall::buildEventsCallString(
  1292. 'webservices', array( array('view', 'default'))
  1293. ) . "\n".
  1294. '..|' . $shLoc->getStr('newwebservicesprofile.menu') . '|'
  1295. . WuiEventsCall::buildEventsCallString(
  1296. 'webservices', array( array('view', 'newprofile'))
  1297. ) . "\n".
  1298. '..|' . $shLoc->getStr('webservicesusers.menu') . '|'
  1299. . WuiEventsCall::buildEventsCallString(
  1300. 'webservices', array( array('view', 'users'))
  1301. ) . "\n".
  1302. '..|' . $shLoc->getStr('newwebservicesuser.menu') . '|'
  1303. . WuiEventsCall::buildEventsCallString(
  1304. 'webservices', array( array('view', 'newuser'))
  1305. ) . "\n".
  1306. '..|' . $shLoc->getStr('webservicesaccounts.menu') . '|'
  1307. . WuiEventsCall::buildEventsCallString(
  1308. 'webservices', array( array('view', 'accounts'))
  1309. ) . "\n".
  1310. '..|' . $shLoc->getStr('newwebservicesaccount.menu') . '|'
  1311. . WuiEventsCall::buildEventsCallString(
  1312. 'webservices', array( array('view', 'newaccount'))
  1313. ) . "\n".
  1314. '.|' . $shLoc->getStr('settings.menu') . "\n".
  1315. '..|' . $shLoc->getStr('interface.menu') . '|'
  1316. . WuiEventsCall::buildEventsCallString(
  1317. 'interface', array( array('view', 'default'))
  1318. ) . "\n".
  1319. '..|' . $shLoc->getStr('network.menu') . '|'
  1320. . WuiEventsCall::buildEventsCallString(
  1321. 'interface', array( array('view', 'name'))
  1322. ) . "\n".
  1323. '..|' . $shLoc->getStr('locale.menu') . '|'
  1324. . WuiEventsCall::buildEventsCallString(
  1325. 'interface', array( array('view', 'localization'))
  1326. ) . "\n".
  1327. '..|' . $shLoc->getStr('password.menu') . '|'
  1328. . WuiEventsCall::buildEventsCallString(
  1329. 'security', array( array('view', 'change_password'))
  1330. ) . "\n".
  1331. '..|' . $shLoc->getStr('securitysettings.menu') . '|'
  1332. . WuiEventsCall::buildEventsCallString(
  1333. 'security', array( array('view', 'settings'))
  1334. ) . "\n".
  1335. '..|' . $shLoc->getStr('maintenancesettings.menu') . '|'
  1336. . WuiEventsCall::buildEventsCallString(
  1337. 'maintenance', array( array('view', 'default'))
  1338. ) . "\n".
  1339. '.|' . $shLoc->getStr('tools.menu') . "\n".
  1340. '..|' . $shLoc->getStr('securitycheck.menu') . '|'
  1341. . WuiEventsCall::buildEventsCallString(
  1342. 'security', array( array('view', 'default'))
  1343. ) . "\n".
  1344. '..|' . $shLoc->getStr('maintenance.menu') . '|'
  1345. . WuiEventsCall::buildEventsCallString(
  1346. 'maintenance', array( array('view', 'default'))
  1347. ) . "\n".
  1348. '.|' . $shLoc->getStr('help.menu') . "\n".
  1349. '..|' . $shLoc->getStr('about.menu') . '|'
  1350. . WuiEventsCall::buildEventsCallString(
  1351. 'applications', array( array('view', 'about'))
  1352. ) . "\n";
  1353. return $result;
  1354. }
  1355. // Web services methods
  1356. public function setWebServicesUser($user)
  1357. {
  1358. $this->_currentWebServicesUser = $user;
  1359. }
  1360. public function getWebServicesUser()
  1361. {
  1362. return $this->_currentWebServicesUser;
  1363. }
  1364. public function setWebServicesProfile($profile)
  1365. {
  1366. $this->_currentWebServicesProfile = $profile;
  1367. }
  1368. public function getWebServicesProfile()
  1369. {
  1370. return $this->_currentWebServicesProfile;
  1371. }
  1372. public function setWebServicesMethods($methods)
  1373. {
  1374. $this->_currentWebServicesMethods = $methods;
  1375. }
  1376. public function getWebServicesMethods()
  1377. {
  1378. return $this->_currentWebServicesMethods;
  1379. }
  1380. // Domain / User methods
  1381. public function getCurrentDomain()
  1382. {
  1383. return $this->_currentDomain;
  1384. }
  1385. public function getCurrentUser()
  1386. {
  1387. return $this->_currentUser;
  1388. }
  1389. public function isBootstrapped()
  1390. {
  1391. return $this->_bootstrapped;
  1392. }
  1393. public function isDomainStarted()
  1394. {
  1395. return $this->_domainStarted;
  1396. }
  1397. public function isRootStarted()
  1398. {
  1399. return $this->_rootStarted;
  1400. }
  1401. }