示例#1
0
 function Uninstall()
 {
     $result = FALSE;
     if ($this->serial) {
         // Checks if the module exists in modules table
         //
         $modquery =& $this->ampdb->Execute('SELECT * FROM modules WHERE id=' . (int) $this->serial);
         if ($modquery->NumRows() == 1) {
             $moddata = $modquery->Fields();
             // Checks if the module is Ampoliros itself
             //
             if ($moddata['modid'] != 'ampoliros') {
                 // Checks if the structure file still exists
                 //
                 if (file_exists(MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE)) {
                     $this->modname = $moddata['modid'];
                     // Checks if there are depengind modules
                     //
                     $moddeps = new ModuleDep($this->ampdb);
                     $pendingdeps = $moddeps->CheckDependingModules($moddata['modid']);
                     // If dependencies are ok, go on
                     //
                     if ($pendingdeps == FALSE) {
                         if ($moddata['onlyextension'] != $this->ampdb->fmttrue) {
                             $this->DisableToAllSites($moddata['modid']);
                         }
                         $this->HandleStructure(MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE, Module::INSTALL_MODE_UNINSTALL, TMP_PATH . 'modinst/');
                         // Removes module archive and directory
                         //
                         if (file_exists(MODULE_PATH . $moddata['modfile'])) {
                             @unlink(MODULE_PATH . $moddata['modfile']);
                         }
                         RecRemoveDir(MODULE_PATH . $moddata['modid']);
                         // Module rows in modules table
                         //
                         $this->ampdb->Execute('DELETE FROM modules WHERE id=' . (int) $this->serial);
                         // Remove cached items
                         //
                         Carthag::import('com.solarix.ampoliros.datatransfer.cache.CacheGarbageCollector');
                         $cache_gc = new CacheGarbageCollector();
                         $cache_gc->RemoveModuleItems($moddata['modid']);
                         // Remove dependencies
                         //
                         $moddeps->RemallDep($this->serial);
                         $this->serial = 0;
                         $result = true;
                         if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_MODULE_OPERATION') == '1') {
                             Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
                             $amp_security = new SecurityLayer();
                             $amp_security->SendAlert('Module ' . $moddata['modid'] . ' has been removed');
                             unset($amp_security);
                         }
                     } else {
                         $this->unmetdeps = $pendingdeps;
                     }
                     if ($result == TRUE) {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('Ampoliros', 'Uninstalled module ' . $this->modname, LOGGER_NOTICE);
                     }
                 } else {
                     import('com.solarix.ampoliros.io.log.Logger');
                     $log = new Logger(AMP_LOG);
                     $log->LogEvent('ampoliros.modules_library.modules_class.uninstall', 'Structure file ' . MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE . ' for module ' . $moddata['modid'] . ' was not found', LOGGER_ERROR);
                 }
             } else {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger(AMP_LOG);
                 $log->LogEvent('ampoliros.modules_library.modules_class.uninstall', 'Cannot uninstall Ampoliros', LOGGER_ERROR);
             }
         } else {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.modules_library.modules_class.uninstall', 'A module with serial ' . $this->serial . ' was not found in modules table', LOGGER_ERROR);
         }
         $modquery->Free();
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.modules_library.modules_class.uninstall', 'Empty module serial', LOGGER_ERROR);
     }
     return $result;
 }
示例#2
0
function main_dependencies($eventData)
{
    global $env, $hui_mainframe, $amp_locale, $hui_titlebar;
    $query =& $env['ampdb']->execute('SELECT modid ' . 'FROM modules ' . 'WHERE id=' . $eventData['modid'] . ' ');
    $module_data = $query->Fields();
    $hui_vgroup = new HuiVertGroup('vgroup');
    $hui_hgroup1 = new HuiHorizGroup('hgroup1');
    $hui_hgroup2 = new HuiHorizGroup('hgroup2');
    $temp_deps = new ModuleDep($env['ampdb']);
    $module_deps = array();
    $module_suggs = array();
    $depending_mods = array();
    $suggesting_mods = array();
    $enabled_sites = array();
    $module_deps_array = $temp_deps->DependsOn($module_data['modid']);
    if (is_array($module_deps_array)) {
        while (list($key, $val) = each($module_deps_array)) {
            if ($val['deptype'] == DEPTYPE_DEP) {
                $module_deps[$val['moddep']] = $val['moddep'] . ' ' . $val['version'];
            } else {
                $module_suggs[$val['moddep']] = $val['moddep'] . ' ' . $val['version'];
            }
        }
    }
    $depending_mods_array = $temp_deps->CheckDependingModules($module_data['modid'], DEPTYPE_DEP);
    if (is_array($depending_mods_array)) {
        while (list($key, $val) = each($depending_mods_array)) {
            $depending_mods[$val] = $val;
        }
    }
    $suggesting_mods_array = $temp_deps->CheckDependingModules($module_data['modid'], DEPTYPE_SUGG);
    if (is_array($suggesting_mods_array)) {
        while (list($key, $val) = each($suggesting_mods_array)) {
            $suggesting_mods[$val] = $val;
        }
    }
    $enabled_sites_array = $temp_deps->CheckEnabledSites($eventData['modid']);
    if (is_array($enabled_sites_array)) {
        asort($enabled_sites_array);
        while (list($key, $val) = each($enabled_sites_array)) {
            $enabled_sites[$val] = $val;
        }
    }
    $xml_def = '<grid><name>deps</name><children>
    
      <vertframe row="0" col="0">
        <name>deps</name>
        <children>
          <label>
            <name>deps</name>
              <args>
                <label>' . $amp_locale->GetStr('moddeps_label') . '</label>
              </args>
            </label>
            <listbox>
              <name>deps</name>
              <args>
                <disp>pass</disp>
                <readonly>true</readonly>
                <elements type="array">' . huixml_encode($module_deps) . '</elements>
                <size>5</size>
              </args>
            </listbox>
          </children>
        </vertframe>
    
      <vertframe row="0" col="1"><name>suggs</name><children>
        <label><name>suggs</name><args><label>' . $amp_locale->GetStr('modsuggs_label') . '</label></args></label>
        <listbox><name>suggs</name><args><disp>pass</disp><readonly>true</readonly><elements type="array">' . huixml_encode($module_suggs) . '</elements><size>5</size></args></listbox>
      </children></vertframe>';
    if (strcmp($module_data['modid'], 'ampoliros')) {
        $xml_def .= '  <vertframe row="1" col="0"><name>depending</name><children>
            <label><name>depending</name><args><label>' . sprintf($amp_locale->GetStr('dependingmods_label'), $module_data['modid']) . '</label></args></label>
            <listbox><name>depending</name><args><disp>pass</disp><readonly>true</readonly><elements type="array">' . huixml_encode($depending_mods) . '</elements><size>5</size></args></listbox>
          </children></vertframe>
        
          <vertframe row="1" col="1"><name>suggesting</name><children>
            <label><name>suggesting</name><args><label>' . sprintf($amp_locale->GetStr('suggestingmods_label'), $module_data['modid']) . '</label></args></label>
            <listbox><name>suggesting</name><args><disp>pass</disp><readonly>true</readonly><elements type="array">' . huixml_encode($suggesting_mods) . '</elements><size>5</size></args></listbox>
          </children></vertframe>
        
          <vertframe row="2" col="0"><name>enabled</name><children>
            <label><name>enabled</name><args><label>' . $amp_locale->GetStr('enabledsites_label') . '</label></args></label>
            <listbox><name>enabled</name><args><disp>pass</disp><readonly>true</readonly><elements type="array">' . huixml_encode($enabled_sites) . '</elements><size>5</size></args></listbox>
          </children></vertframe>';
    }
    $xml_def .= '</children></grid>';
    $hui_mainframe->AddChild(new HuiXml('deps', array('definition' => $xml_def)));
    $hui_titlebar->mTitle .= ' - ' . $module_data['modid'] . ' - ' . $amp_locale->GetStr('moduledeps_title');
}