Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public function removeUser()
 {
     import('com.solarix.ampoliros.util.Hook');
     $hook = new Hook($this->mrAmpDb, 'ampoliros', 'site.user.remove');
     if ($hook->CallHooks('calltime', $this, array('siteserial' => $this->siteserial, 'userid' => $this->userid)) == HOOK_RESULT_OK) {
         if ($this->userid != 0) {
             $result = $this->mrAmpDb->Execute('DELETE FROM users ' . 'WHERE siteid=' . (int) $this->siteserial . ' ' . 'AND id=' . (int) $this->userid);
             // Remove user dir
             $site_query =& $GLOBALS['gEnv']['root']['db']->Execute('SELECT siteid ' . 'FROM sites ' . 'WHERE id=' . (int) $this->siteserial);
             OpenLibrary('misc.library');
             if (SITESTUFF_PATH . $site_query->Fields('siteid') . '/users/' . $this->username != SITESTUFF_PATH . $site_query->Fields('siteid') . '/users/') {
                 RecRemoveDir(SITESTUFF_PATH . $site_query->Fields('siteid') . '/users/' . $this->username, 0755);
             }
             // Remove cached items
             Carthag::import('com.solarix.ampoliros.datatransfer.cache.CacheGarbageCollector');
             $cache_gc = new CacheGarbageCollector();
             $cache_gc->RemoveUserItems((int) $this->userid);
             //$this->htp->remuser( $this->username );
             if ($hook->CallHooks('userremoved', $this, array('siteserial' => $this->siteserial, 'userid' => $this->userid)) != HOOK_RESULT_OK) {
                 $result = false;
             }
             $this->userid = 0;
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 public function remove()
 {
     $result = false;
     $hook = new Hook($this->ampdb, 'ampoliros', 'site.remove');
     if ($hook->CallHooks('calltime', $this, '') == HOOK_RESULT_OK) {
         $query = $this->ampdb->Execute('SELECT * ' . 'FROM sites ' . 'WHERE id=' . (int) $this->siteserial);
         $data = $query->Fields();
         // Disables all modules
         //
         $this->DisableAllModules($this->siteserial);
         $args['dbname'] = $data['sitedbname'];
         $args['dbhost'] = $data['sitedbhost'];
         $args['dbport'] = $data['sitedbport'];
         $args['dbuser'] = $data['sitedbuser'];
         $args['dbpass'] = $data['sitedbpass'];
         $args['dbtype'] = $data['sitedbtype'];
         $args['dblog'] = $data['sitedblog'];
         $this->sitedb->Close();
         $this->sitedb->DropDB($args);
         // Remove cached items
         //
         Carthag::import('com.solarix.ampoliros.datatransfer.cache.CacheGarbageCollector');
         $cache_gc = new CacheGarbageCollector();
         $cache_gc->RemoveSiteItems((int) $data['id']);
         // Removes site users
         //
         $this->RemoveAllUsers();
         // Removes site from amp database
         //
         $this->ampdb->Execute('DELETE FROM sites ' . 'WHERE id=' . (int) $data['id']);
         $this->ampdb->Execute('DELETE FROM disabledsubmodules ' . 'WHERE siteid=' . $this->siteserial);
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent($data['siteid'], 'Removed site ' . $data['siteid'], LOGGER_NOTICE);
         if (!empty($data['siteid'])) {
             RecRemoveDir(SITESTUFF_PATH . $data['siteid']);
         }
         if ($hook->CallHooks('siteremoved', $this, '') == HOOK_RESULT_OK) {
             $result = true;
         }
         global $gEnv;
         if ($gEnv['core']['config']->Value('ALERT_ON_SITE_OPERATION') == '1') {
             Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
             $amp_security = new SecurityLayer();
             $amp_security->SendAlert('Site ' . $data['siteid'] . ' has been removed');
             unset($amp_security);
         }
     }
     return $result;
 }