function main_applicationversions($eventData)
{
    global $gLocale, $gXmlDefinition, $gPageTitle, $gToolbars;
    $acRemote = new \Innomatic\Application\AppCentralRemoteServer($eventData['id']);
    $availReps = $acRemote->ListAvailableRepositories(isset($eventData['refresh']) ? true : false);
    $availMods = $acRemote->ListAvailableApplications($eventData['repid'], isset($eventData['refresh']) ? true : false);
    $appVersions = $acRemote->ListAvailableApplicationVersions($eventData['repid'], $eventData['applicationid'], isset($eventData['refresh']) ? true : false);
    $xAccount = new WebServicesAccount($acRemote->mAccountId);
    $headers[0]['label'] = $gLocale->getStr('version.header');
    $headers[1]['label'] = $gLocale->getStr('dependencies.header');
    $headers[2]['label'] = $gLocale->getStr('installed_version.header');
    $gXmlDefinition = '<vertgroup><name>applications</name>
  <children>
    <label><name>title</name>
      <args>
        <bold>true</bold>
        <label type="encoded">' . urlencode($xAccount->mName . ' - ' . $availReps[$eventData['repid']]['name'] . ' - ' . $availMods[$eventData['applicationid']]['appid']) . '</label>
      </args>
    </label>
    <table><name>applications</name>
      <args>
        <headers type="array">' . WuiXml::encode($headers) . '</headers>
        <rowsperpage>10</rowsperpage>
        <pagesactionfunction>repapplications_list_action_builder</pagesactionfunction>
        <pagenumber>' . (isset($eventData['pagenumber']) ? $eventData['pagenumber'] : '') . '</pagenumber>
        <sessionobjectusername>' . $eventData['id'] . '-' . $eventData['repid'] . '-' . $eventData['applicationid'] . '</sessionobjectusername>
      </args>
      <children>';
    $row = 0;
    $appQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT appversion ' . 'FROM applications ' . 'WHERE appid=' . \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->formatText($availMods[$eventData['applicationid']]['appid']));
    while (list($version, $data) = each($appVersions)) {
        if (strlen($data['dependencies'])) {
            $appDeps = new \Innomatic\Application\ApplicationDependencies();
            $depCheck = $appDeps->checkApplicationDependencies(0, '', $appDeps->explodeDependencies($data['dependencies']));
        } else {
            $depCheck = false;
        }
        if ($appQuery->getNumberRows()) {
            $currentVersion = $appQuery->getFields('appversion');
        } else {
            $currentVersion = $gLocale->getStr('none_version.label');
        }
        if ($depCheck == false) {
            $appInstallable = true;
            $missingDeps = '';
            if ($appQuery->getNumberRows()) {
                switch (\Innomatic\Application\ApplicationDependencies::compareVersionNumbers($version, $currentVersion)) {
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_EQUAL:
                        $label = $gLocale->getStr('reinstall_application.button');
                        $icon = 'cycle';
                        break;
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_MORE:
                        $label = $gLocale->getStr('update_application.button');
                        $icon = 'up';
                        break;
                    case \Innomatic\Application\ApplicationDependencies::VERSIONCOMPARE_LESS:
                        $label = $gLocale->getStr('downgrade_application.button');
                        $icon = 'down';
                        break;
                }
            } else {
                $label = $gLocale->getStr('install_application.button');
                $icon = 'folder';
            }
        } else {
            $appInstallable = false;
            $missingDeps = '<br><strong>' . $gLocale->getStr('missing_deps.label') . '</strong>';
            while (list(, $dep) = each($depCheck)) {
                $missingDeps .= '<br>' . $dep;
            }
        }
        $toolbars = '';
        if ($appInstallable) {
            $toolbars .= '<button>
                    <args>
              <label>' . WuiXml::cdata($label) . '</label>
        <themeimage>' . $icon . '</themeimage>
        <horiz>true</horiz>
        <action>' . WuiXml::cdata(\Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'repositoryapplications', array('id' => $eventData['id'], 'repid' => $eventData['repid'])), array('action', 'installapplication', array('id' => $eventData['id'], 'repid' => $eventData['repid'], 'applicationid' => $eventData['applicationid'], 'version' => $version))))) . '</action>
                  </args>
                </button>';
        }
        $gXmlDefinition .= '<label row="' . $row . '" col="0"><name>version</name>
  <args>
    <label type="encoded">' . urlencode($version) . '</label>
  </args>
</label>

<label row="' . $row . '" col="1"><name>dependencies</name>
  <args>
    <label type="encoded">' . urlencode(str_replace(',', '<br>', $data['dependencies']) . (strlen($data['suggestions']) ? '<br><br><strong>' . $gLocale->getStr('suggestions.label') . '</strong><br>' . str_replace(',', '<br>', $data['suggestions']) . '<br>' : '') . $missingDeps) . '</label>
  </args>
</label>

<label row="' . $row . '" col="2"><name>current</name>
  <args>
    <label type="encoded">' . urlencode($currentVersion) . '</label>
  </args>
</label>

<horizgroup row="' . $row . '" col="3"><name>tb</name>
    <children>' . $toolbars . '</children>
</horizgroup>';
        $row++;
    }
    $gXmlDefinition .= '      </children>
    </table>
  </children>
</vertgroup>';
    $gToolbars['reptools'] = array('refresh' => array('label' => $gLocale->getStr('refresh.button'), 'themeimage' => 'cycle', 'horiz' => 'true', 'action' => \Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'applicationversions', array('id' => $eventData['id'], 'repid' => $eventData['repid'], 'applicationid' => $eventData['applicationid'], 'refresh' => '1'))))));
    $gPageTitle .= ' - ' . $gLocale->getStr('applicationversions.title');
}
Example #2
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;
 }