public function enable($domainid) { $result = false; $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'application.enable'); if ($hook->callHooks('calltime', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) == \Innomatic\Process\Hook::RESULT_OK) { if ($this->serial) { // Checks if the application exists in applications table // $modquery = $this->rootda->execute('SELECT * FROM applications WHERE id=' . (int) $this->serial); if ($modquery->getNumberRows() == 1) { $appdata = $modquery->getFields(); if ($appdata['onlyextension'] != $this->rootda->fmttrue) { // Checks if the structure file still exists // if (file_exists($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml')) { $this->appname = $appdata['appid']; $domainquery = $this->rootda->execute('SELECT * FROM domains WHERE id=' . $this->rootda->formatText((int) $domainid)); $domaindata = $domainquery->getFields(); // Connects to the tenant database if Innomatic has been installed in ASP edition. if ($this->container->getEdition() == \Innomatic\Core\InnomaticContainer::EDITION_MULTITENANT) { $args['dbtype'] = $domaindata['dataaccesstype']; $args['dbname'] = $domaindata['domaindaname']; $args['dbhost'] = $domaindata['dataaccesshost']; $args['dbport'] = $domaindata['dataaccessport']; $args['dbuser'] = $domaindata['dataaccessuser']; $args['dbpass'] = $domaindata['dataaccesspassword']; $args['dblog'] = $this->container->getHome() . 'core/domains/' . $domaindata['domainid'] . '/log/dataaccess.log'; $dasnString = $args['dbtype'] . '://' . $args['dbuser'] . ':' . $args['dbpass'] . '@' . $args['dbhost'] . ':' . $args['dbport'] . '/' . $args['dbname'] . '?' . 'logfile=' . $args['dblog']; $this->domainda = \Innomatic\Dataaccess\DataAccessFactory::getDataAccess(new \Innomatic\Dataaccess\DataAccessSourceName($dasnString)); $this->domainda->connect(); } else { $this->domainda = $this->rootda; } // Dependencies check // $this->unmetdeps = array(); $this->unmetsuggs = array(); $appdeps = new ApplicationDependencies(); $modenabled = $appdeps->IsEnabled($this->appname, $domaindata['domainid']); $unmetdeps = $appdeps->checkDomainApplicationDependencies($this->appname, $domaindata['domainid'], ApplicationDependencies::TYPE_DEPENDENCY); $unmetsuggs = $appdeps->checkDomainApplicationDependencies($this->appname, $domaindata['domainid'], ApplicationDependencies::TYPE_SUGGESTION); // Suggestions check // if (is_array($unmetsuggs)) { $this->unmetsuggs = $unmetsuggs; } // If dependencies are ok, go on // if ($unmetdeps == false and !$modenabled) { $result = $this->HandleStructure($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml', Application::INSTALL_MODE_ENABLE, $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/', $domainid); $modquery = $this->rootda->execute('SELECT id FROM applications WHERE appid=' . $this->rootda->formatText($this->appname)); $this->rootda->execute('INSERT INTO applications_enabled VALUES (' . $this->serial . ',' . $this->rootda->formatText($domainid) . ',' . $this->rootda->formatDate(time()) . ',' . $this->rootda->formatDate(time()) . ',' . $this->rootda->formatText($this->rootda->fmttrue) . ')'); if (\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getConfig()->Value('SecurityAlertOnApplicationDomainOperation') == '1') { $innomaticSecurity = new \Innomatic\Security\SecurityManager(); $innomaticSecurity->SendAlert('Application ' . $appdata['appid'] . ' has been enabled to domain ' . $domaindata['domainid']); unset($innomaticSecurity); } if ($hook->callHooks('applicationenabled', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) != \Innomatic\Process\Hook::RESULT_OK) { $result = false; } } else { $this->unmetdeps = $unmetdeps; } //if ( $result == true ) $this->mLog->logEvent( // 'Innomatic', // 'Uninstalled application '.$this->appname, // \Innomatic\Logging\Logger::NOTICE //); $domainquery->free(); } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.enable', 'Structure file ' . $this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml' . ' for application ' . $appdata['appid'] . ' was not found', \Innomatic\Logging\Logger::ERROR); } } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.enable', 'Tried to enable application ' . $appdata['appid'] . ', but it is an extension only application', \Innomatic\Logging\Logger::ERROR); } } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.enable', 'A application with serial ' . $this->serial . ' was not found in applications table', \Innomatic\Logging\Logger::ERROR); } $modquery->free(); } else { $log = $this->container->getLogger(); $log->logEvent('innomatic.applications.applications.enable', 'Empty application serial', \Innomatic\Logging\Logger::ERROR); } } return $result; }