GetSmarty(); $db = $gCms->GetDb(); //Messagestring (success) for module operations $modulemessage=""; include_once("header.php"); if ($access) { if ($action == "chmod" ) { $result = chmod_r( $config['root_path'].DIRECTORY_SEPARATOR. 'modules'.DIRECTORY_SEPARATOR.$module, 0777 ); if( !$result ) { echo $themeObject->ShowErrors(lang('cantchmodfiles')); } else { audit('','Core','Changed permissions on '.$module.' directory'); redirect($thisurl); } } if ($action == "exportxml") { // get our xml $message = ''; $files = 0; $old_display_errors = ini_set('display_errors',0); $modops = $gCms->GetModuleOperations(); $orig_lang = CmsNlsOperations::get_current_language(); CmsNlsOperations::set_language('en_US'); $object = $modops->get_module_instance($module,'',TRUE); $xmltxt = $modops->CreateXMLPackage($object,$message,$files); CmsNlsOperations::set_language($orig_lang); if( $files == 0 ) { echo "

".lang('errornofilesexported')."

"; if( $old_display_errors !== FALSE ) { ini_set('display_errors',$old_display_errors); } } else { $xmlname = $object->GetName().'-'.$object->GetVersion().'.xml'; audit('','Core','Exported '.$object->GetName().' to '.$xmlname); // and send the file ob_end_clean(); header('Content-Description: File Transfer'); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename='.$xmlname); // header('Content-Type: text/xml'); echo $xmltxt; exit(); } } if ($action == "importxml" ) { $fieldName = "browse_xml"; if (!isset ($_FILES[$fieldName]) || !isset ($_FILES) || !is_array ($_FILES[$fieldName]) || !$_FILES[$fieldName]['name']) { echo $themeObject->ShowErrors(lang('noxmlfileuploaded')); } else { // normalize the file variable $file = $_FILES[$fieldName]; if( !isset($file['tmp_name']) || trim($file['tmp_name']) == '' ) { echo $themeObject->ShowErrors(lang('noxmlfileuploaded').' (empty tmp_name)'); } // and parse it $modops = $gCms->GetModuleOperations(); $result = $modops->ExpandXMLPackage( $file['tmp_name'], true, true ); $error = ''; if( is_array($result) ) { if( isset($result['mincmsversion']) ) { if( version_compare($result['mincmsversion'],$CMS_VERSION) > 0 ) { $error = lang('error_module_mincmsversion'); } } if( !$error && isset($result['requires']) && is_array($result['requires']) ) { // check dependencies. foreach( $result['requires'] as $rec ) { if( !$modops->get_module_instance($rec['name'],$rec['version']) ) { $error = lang('missingdependency').' '.$rec['name'].' v'.$rec['version']; break; } } } } if( $error ) { echo $themeObject->ShowErrors($error); } else { $result = $modops->ExpandXMLPackage( $file['tmp_name'], true ); if( !$result ) { echo $themeObject->ShowErrors($modops->GetLastError()); } else if( $autoinstallupgrade == 0 ) { // no auto install or upgrade audit('','Core','Expanded XML Package '.$file['name']); redirect($thisurl); } } } } if ($action == "install") { $modops = $gCms->GetModuleOperations(); $result = $modops->InstallModule($module,false); if( $result[0] == false ) { echo '
'; echo ''; echo $result[1]; echo "
"; echo '

« '.lang('back').'

'; include_once("footer.php"); exit; } else { $content = cms_utils::get_module($module)->InstallPostMessage(); if( $content != FALSE ) { //Redirect right away so that the installed module shows in the menu redirect($thisurl.'&action=showpostinstall&module='.$module); } // all is good, but no postinstall message redirect($thisurl); } } if ($action == 'showpostinstall') { // this is probably dead code now $modinstance = cms_utils::get_module($module); if( is_object($modinstance) ) { if ($modinstance->InstallPostMessage() != FALSE) { @ob_start(); echo $modinstance->InstallPostMessage(); $content = @ob_get_contents(); @ob_end_clean(); echo $themeObject->ShowMessage($content); } } } if ($action == 'remove') { $result = recursive_delete( $config['root_path'].DIRECTORY_SEPARATOR. 'modules'.DIRECTORY_SEPARATOR.$module ); if( !$result ) { echo '
'; echo ''; echo lang('cantremovefiles'); echo "
"; echo '

« '.lang('back').'

'; include_once("footer.php"); } else { // put mention into the admin log audit('','Module: '.$module, 'Deleted'); redirect($thisurl); } } if ($action == 'upgrade') { $modops = $gCms->GetModuleOperations(); $result = $modops->UpgradeModule( $module ); if( !$result ) { @ob_start(); echo $modops->GetLastError(); $content = @ob_get_contents(); @ob_end_clean(); echo $themeObject->ShowErrors(lang('moduleupgradeerror')); } redirect($thisurl); } if ($action == "uninstall") { $modinstance = ModuleOperations::get_instance()->get_module_instance($module,'',TRUE); if( is_object($modinstance) ) { $modops = $gCms->GetModuleOperations(); // get the postinstall message, so we have it if successful $postuninstall = $modinstance->UninstallPostMessage(); $result = $modops->UninstallModule($module); if ($result) { // show the uninstallpost if necessary... if ($postuninstall != FALSE) { // Redirect right away so that the uninstalled module is removed from the menu redirect($thisurl.'&action=showpostuninstall&module='.$module); } redirect($thisurl); } else { echo $themeObject->ShowErrors($modops->GetLastError()); } } } if ($action == 'showpostuninstall') { // this is probably dead code now $modinstance = ModuleOperations::get_instance()->get_module_instance($module); if (is_object($modinstance)) { if ($modinstance->UninstallPostMessage() != FALSE) { @ob_start(); echo $modinstance->UninstallPostMessage(); $content = @ob_get_contents(); @ob_end_clean(); echo $themeObject->ShowMessage($content); } } } if ($action == "settrue") { $query = "UPDATE ".cms_db_prefix()."modules SET active = ? WHERE module_name = ?"; $db->Execute($query, array(1,$module)); audit('','Core','Activated module '.$module); cmsms()->clear_cached_files(); redirect($thisurl); } if ($action == "setfalse") { $query = "UPDATE ".cms_db_prefix()."modules SET active = ? WHERE module_name = ?"; $db->Execute($query, array(0,$module)); audit('','Core','Deactivated module '.$module); cmsms()->clear_cached_files(); redirect($thisurl); } } // if access if ($action == "showmoduleabout") { $modinstance = ModuleOperations::get_instance()->get_module_instance($module,'',TRUE); if( is_object($modinstance) ) { echo '
'; echo ''; echo $modinstance->GetAbout(); echo "
"; } echo '

« '.lang('back').'

'; } else if ($action == "showmodulehelp") { $modinstance = ModuleOperations::get_instance()->get_module_instance($module,'',TRUE); if( is_object($modinstance) ) { $orig_lang = CmsNlsOperations::get_current_language(); $modulehelp_yourlang = lang('modulehelp_yourlang'); if( isset($_GET['lang']) && $orig_lang != 'en_US' ) { CmsNlsOperations::set_language(trim($_GET['lang'])); } echo '
'; // Commented out because of bug #914 and had to use code extra below // echo $themeObject->ShowHeader(lang('modulehelp', array($module)), '', lang('wikihelp', $module), 'wiki'); $header = ''; echo $header; // this is ugly hacky stuff to ajust the language temporarily. $mod_old_lang = $modinstance->curlang; $modinstance->params = array(array('name'=>'lang','default'=>'en_US','optional'=>true)); if( isset($_GET['lang']) ) { $modinstance->curlang = trim($_GET['lang']); } echo @$modinstance->GetHelpPage(); $modinstance->params = array(array('name'=>'lang','default'=>'en_US','optional'=>true)); $modinstance->curlang = $mod_old_lang; echo "
"; CmsNlsOperations::set_language($orig_lang); } echo '

« '.lang('back').'

'; } else if ($action == 'missingdeps') { echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; $modinstance = $modops->get_module_instance($module,'',true); if( is_object($modinstance) ) { if (count($modinstance->GetDependencies()) > 0) #Check for any deps { $curclass = 'row1'; #Now check to see if we can satisfy any deps debug_buffer($modinstance->GetDependencies(), 'deps in module'); foreach ($modinstance->GetDependencies() as $onedepkey=>$onedepvalue) { echo ''; ($curclass=="row1"?$curclass="row2":$curclass="row1"); } } } echo ''; echo '
'.lang('name').''.lang('minimumversion').''.lang('installed').'
'.$onedepkey.''.$onedepvalue.''; $havedep = false; $newmod = cms_utils::get_module($onedepkey); if( is_object($newmod) && version_compare($newmod->GetVersion(),$onedepvalue) > -1 ) { $havedep = true; } echo lang(($havedep?'true':'false')); echo '
'; echo '
'; echo '

« '.lang('back').'

'; } else { if ($access) { $modops->LoadModules(TRUE); $allmodules = $modops->GetAllModuleNames(); if (count($allmodules) > 0) { $query = "SELECT * from ".cms_db_prefix()."modules ORDER BY module_name"; $result = $db->Execute($query); while ($result && $row = $result->FetchRow()) { $dbm[$row['module_name']]['Status'] = $row['status']; $dbm[$row['module_name']]['Version'] = $row['version']; $dbm[$row['module_name']]['Active'] = ($row['active'] == 1?true:false); } ?>
0) { echo '"; unset($_SESSION['modules_messages']); } ?> ShowHeader('modules').'
'; ?> DisplayImage('icons/system/true.gif', lang('true'),'','','systemicon'); $image_false = $themeObject->DisplayImage('icons/system/false.gif', lang('false'),'','','systemicon'); foreach($allmodules as $key) { $modinstance = $modops->get_module_instance($key,'',true); if( !is_object($modinstance) ) continue; // interesting. $is_sysmodule = $modops->IsSystemModule($key); $namecol = $key; $versioncol = " "; $statuscol = array(); $statusspans = false; $actioncol = array(); $activecol = " "; $helpcol = " "; $aboutcol = " "; $xmlcol = " "; $cachablecol = ' '; $xmlcol = ''.lang('xml').''; //Is there help? if (@$modinstance->GetHelp() != '') { $namecol = "".$key.""; } // check these modules permissions to see if we can uninstall this thing $permsok = is_directory_writable( $config['root_path'].DIRECTORY_SEPARATOR. 'modules'.DIRECTORY_SEPARATOR.$key ); $maxverok = version_compare($modinstance->MaximumCMSVersion(), $CMS_VERSION); $maxverok = ($maxverok >= 0 )?1:0; // Make sure it's a valid module for this version of CMSMS if (version_compare($modinstance->MinimumCMSVersion(), $CMS_VERSION) == 1) { // Fix undefined index error if module is not already installed. $statuscol[] = ''.lang('minimumversionrequired').': '.$modinstance->MinimumCMSVersion().''; $xmlcol = " "; $statusspans = true; } else if( $maxverok == 0 ) { // maximum cms version exceeded $xmlcol = " "; $statuscol[] = ''.lang('maximumversionsupported').' = '.$modinstance->MaximumCMSVersion().""; } if (!isset($dbm[$key])) #Not installed, lets put up the install button { $brokendeps = 0; $xmlcol = " "; $dependencies = $modinstance->GetDependencies(); if (count($dependencies) > 0) #Check for any deps { // Now check to see if we can satisfy any deps foreach ($dependencies as $onedepkey=>$onedepvalue) { $depmod = cms_utils::get_module($onedepkey); if( !is_object($depmod) || version_compare($depmod->GetVersion(),$onedepvalue) < 0 ) $brokendeps++; } } $versioncol = $modinstance->GetVersion(); $statuscol[] = lang('notinstalled'); if ($brokendeps > 0) { $actioncol[] = ''.lang('missingdependency').''; } else if( $maxverok == 1) { $actioncol[] = "".lang('install').""; $xmlcol = ' '; } if( !$is_sysmodule ) { if( $permsok ) { $actioncol[] .= "".lang('remove').""; } else { $actioncol[] = "".lang('changepermissions').""; } } } else if (version_compare($modinstance->GetVersion(), $dbm[$key]['Version']) == 1) // Check for an upgrade { $xmlcol = " "; $versioncol = $dbm[$key]['Version']; $statuscol[] = ''.lang('needupgrade').''; $activecol = ($dbm[$key]['Active']==true?"".$image_true."":"".$image_false.""); if( $maxverok == 1 && $dbm[$key]['Active'] == true) { $actioncol[] = "".lang('upgrade').""; } } else // Must be installed { $versioncol = $dbm[$key]['Version']; $statuscol[] = lang('installed'); $cachablecol = $modinstance->AllowSmartyCaching()?lang('yes'):lang('no'); //$actioncol = " "; // Can't be removed if it has a dependency... if (!$modinstance->CheckForDependents()) { $activecol = ($dbm[$key]['Active']==true?"".$image_true."":"".$image_false.""); $actioncol[] = "UninstallPreMessage() !== FALSE? cms_utf8entities($modinstance->UninstallPreMessage()):lang('uninstallconfirm').' '.$key)."');\">".lang('uninstall').""; } else { // HAS DEPENDENTS =============== $result = $db->Execute("SELECT child_module from ".cms_db_prefix()."module_deps WHERE parent_module='$key'"); $dependentof = array();; while ($result && $row = $result->FetchRow()) { $dependentof[$row['child_module']] = ""; } $str = implode(array_keys($dependentof),", "); //$activecol = ($dbm[$key]['Active']==true?$image_true:"".$image_false.""); $statuscol[] = lang('hasdependents')." ($str)"; // END HAS DEPENDENTS =========== } if( !$permsok ) { $statuscol[] = lang('cantremove'); $actioncol[] = "".lang('changepermissions').""; } } //Is there help? if (@$modinstance->GetHelp() != '') { $helpcol = "".lang('help').""; } //About is constructed from other details now $aboutcol = "".lang('about').""; // row output echo "\n"; echo ""; echo ""; if( $statusspans === true) { echo '"; } else { echo ""; echo ''; echo ''; } echo ""; echo ""; echo ""; echo ""; echo "\n"; ($curclass=="row1"?$curclass="row2":$curclass="row1"); } ?>
$namecol$versioncol'.implode('
',$statuscol)."
".implode('
',$statuscol)."
'.$activecol.''.implode('
',$actioncol).'
$cachablecol$helpcol$aboutcol$xmlcol
ShowErrors(lang('modulesnotwritable')); } else { ?>

:

 

'; } } //end if access else { //now print the menssage echo "
".lang('needpermissionto', array('Modify Modules'))."
"; } echo '

« '.lang('back').'

'; } include_once("footer.php"); # vim:ts=4 sw=4 noet ?>