Esempio n. 1
0
 public function disable($domainid)
 {
     $result = false;
     $hook = new \Innomatic\Process\Hook($this->rootda, 'innomatic', 'application.disable');
     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();
                         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();
                         $pendingdeps = $appdeps->checkDomainDependingApplications($this->appname, $domaindata['domainid'], false);
                         $modenabled = $appdeps->isEnabled($this->appname, $domaindata['domainid']);
                         // If dependencies are ok, go on
                         //
                         if ($pendingdeps == false and $modenabled == true) {
                             $result = $this->HandleStructure($this->container->getHome() . 'core/applications/' . $appdata['appid'] . '/application.xml', Application::INSTALL_MODE_DISABLE, $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('DELETE FROM applications_enabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . $this->rootda->formatText($domainid));
                             $this->rootda->execute('DELETE FROM applications_options_disabled WHERE applicationid=' . (int) $this->serial . ' AND domainid=' . (int) $domainid);
                             if ($this->container->getConfig()->Value('SecurityAlertOnApplicationDomainOperation') == '1') {
                                 $innomaticSecurity = new \Innomatic\Security\SecurityManager();
                                 $innomaticSecurity->sendAlert('Application ' . $appdata['appid'] . ' has been disabled from domain ' . $domaindata['domainid']);
                                 unset($innomaticSecurity);
                             }
                             if ($hook->callHooks('applicationdisabled', $this, array('domainserial' => $domainid, 'modserial' => $this->serial)) != \Innomatic\Process\Hook::RESULT_OK) {
                                 $result = false;
                             }
                         } elseif ($modenabled == false) {
                         } else {
                             $this->unmetdeps = $pendingdeps;
                         }
                         //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.disable', '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.disable', 'Tried to disable application ' . $appdata['appid'] . ', but it is an extension only application', \Innomatic\Logging\Logger::ERROR);
                 }
             } else {
                 $log = $this->container->getLogger();
                 $log->logEvent('innomatic.applications.applications.disable', '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.disable', 'Empty application serial', \Innomatic\Logging\Logger::ERROR);
         }
     }
     return $result;
 }