function getHandler($name = "file", $path = false, $create = false, $mode = null) { $handler = null; XoopsFile::load($name); $class = "Xoops" . ucfirst($name) . "Handler"; if (class_exists($class)) { $handler = new $class($path, $create, $mode); } else { trigger_error("Class '{$class}' not exist", E_USER_WARNING); } return $handler; }
/** * Constructor * * @param string $path Path to file * @param boolean $create Create file if it does not exist (if true) * @param integer $mode Mode to apply to the folder holding the file * * @access public */ public function __construct($path, $create = false, $mode = 0755) { $this->folder = XoopsFile::getHandler('folder', dirname($path), $create, $mode); if (!is_dir($path)) { $this->name = basename($path); } else { return false; } if (!$this->exists()) { if ($create === true) { if ($this->safe($path) && $this->create() === false) { return false; } } else { return false; } } return true; }
/** * @param $module * @param null $oldversion * @return bool */ function xoops_module_update_pm(XoopsModule $module, $oldversion = null) { global $xoopsDB; if ($oldversion <= 100) { // Check pm table version $sql = 'SHOW COLUMNS FROM ' . $xoopsDB->prefix('priv_msgs'); if (!($result = $xoopsDB->queryF($sql))) { return false; } // Migrate from existent pm module if (($rows = $xoopsDB->getRowsNum($result)) == 12) { return true; } elseif ($rows == 8) { return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.upgrade.sql'); } else { return false; } } if ($oldversion < 110) { // remove old html template files $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/'; $template_list = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($template_list as $k => $v) { $fileinfo = new SplFileInfo($templateDirectory . $v); if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') { @unlink($templateDirectory . $v); } } xoops_load('xoopsfile'); //remove /images directory $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/'; $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); $folderHandler->delete($imagesDirectory); //delete .html entries from the tpl table $sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; $xoopsDB->queryF($sql); } return true; }
function xoops_module_update_pm(&$module, $oldversion = null) { if ($oldversion <= 100) { global $xoopsDB; // Check pm table version $sql = "SHOW COLUMNS FROM " . $xoopsDB->prefix("priv_msgs"); if (!($result = $xoopsDB->queryF($sql))) { return false; } // Migrate from existent pm module if (($rows = $xoopsDB->getRowsNum($result)) == 12) { return true; } elseif ($rows == 8) { return $xoopsDB->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/sql/mysql.upgrade.sql"); } else { return false; } } if ($oldversion < 110) { // remove old html template files $templateDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/"; $template_list = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($template_list as $k => $v) { $fileinfo = new SplFileInfo($templateDirectory . $v); if ($fileinfo->getExtension() == 'html' && $fileinfo->getFilename() != 'index.html') { @unlink($templateDirectory . $v); } } // Load class XoopsFile xoops_load('xoopsfile'); //remove /images directory $imagesDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/images/"; $folderHandler = XoopsFile::getHandler("folder", $imagesDirectory); $folderHandler->delete($imagesDirectory); } return true; }
/** * XoopsFile::getHandler() * * @param string $name * @param mixed $path * @param mixed $create * @param mixed $mode * @return */ public static function getHandler($name = 'file', $path = false, $create = false, $mode = null) { $handler = null; XoopsFile::load($name); $class = 'Xoops' . ucfirst($name) . 'Handler'; if (class_exists($class)) { $handler = new $class($path, $create, $mode); } else { trigger_error('Class ' . $class . ' not exist in File ' . __FILE__ . ' at Line ' . __LINE__, E_USER_WARNING); } return $handler; }
/** * @param $data * * @return bool */ public function writeConfig($data) { if ($this->createPath($this->configPath)) { $path_file = $this->configPath . $this->configFile . $this->configFileExt; XoopsLoad::load('XoopsFile'); $file = XoopsFile::getHandler('file', $path_file); return $file->write('return ' . var_export($data, true) . ';'); } }
if (!$uploader->upload()) { $err[] =& $uploader->getErrors(); } } if (isset($err)) { foreach ($err as $line) { echo $line; } } redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_UPLOAD_FILE); break; case 'filemanager_add_dir_save': $path = system_CleanVars($_REQUEST, 'path', XOOPS_ROOT_PATH . '/', 'string'); xoops_load('XoopsFile'); XoopsFile::load('folder'); $folder = XoopsFile::getHandler('folder'); if ($folder->create($path . $_REQUEST['dir_name'], 0777)) { $indexFile = XOOPS_ROOT_PATH . '/modules/system/index.html'; copy($indexFile, $path . $_REQUEST['dir_name'] . '/index.html'); redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_DIR_SUCCESS); } else { redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_DIR_ERROR); } break; case 'filemanager_add_file_save': $path = system_CleanVars($_REQUEST, 'path', XOOPS_ROOT_PATH . '/', 'string'); if ($path == '') { $path = XOOPS_ROOT_PATH . '/'; } $open = fopen($path . $_REQUEST['file_name'], 'w+'); fclose($open);
break; // Edit File // Edit File case 'tpls_edit_file': $path_file = XOOPS_ROOT_PATH . '/themes' . trim($_REQUEST['path_file']); //Button restore if (file_exists($path_file . '.back')) { $restore = '<button class="ui-corner-all tooltip" type="button" onclick="tpls_restore(\'' . $path_file . '\')" value="' . _AM_SYSTEM_TEMPLATES_RESTORE . '" title="' . _AM_SYSTEM_TEMPLATES_RESTORE . '"> <img src="' . system_AdminIcons('revert.png') . '" alt="' . _AM_SYSTEM_TEMPLATES_RESTORE . '" /> </button>'; } else { $restore = ''; } xoops_load('XoopsFile'); XoopsFile::load('file'); $file = XoopsFile::getHandler('file', $path_file); $content = $file->read(); if (empty($content)) { echo _AM_SYSTEM_TEMPLATES_EMPTY_FILE; } $ext = preg_replace('/^.*\\./', '', $_REQUEST['path_file']); echo '<form name="back" action="admin.php?fct=tplsets&op=tpls_save" method="POST"> <table border="0"> <tr> <td> <div class="xo-btn-actions"> <div class="xo-buttons"> <button class="ui-corner-all tooltip" type="submit" value="' . _AM_SYSTEM_TEMPLATES_SAVE . '" title="' . _AM_SYSTEM_TEMPLATES_SAVE . '"> <img src="' . system_AdminIcons('save.png') . '" alt="' . _AM_SYSTEM_TEMPLATES_SAVE . '" /> </button> ' . $restore . '
function xoops_module_update_profile(&$module, $oldversion = null) { if ($oldversion < 162) { $GLOBALS['xoopsDB']->queryF("UPDATE `" . $GLOBALS['xoopsDB']->prefix("profile_field") . " SET field_valuetype=2 WHERE field_name=umode"); } if ($oldversion < 100) { // Drop old category table $sql = "DROP TABLE " . $GLOBALS['xoopsDB']->prefix("profile_category"); $GLOBALS['xoopsDB']->queryF($sql); // Drop old field-category link table $sql = "DROP TABLE " . $GLOBALS['xoopsDB']->prefix("profile_fieldcategory"); $GLOBALS['xoopsDB']->queryF($sql); // Create new tables for new profile module $GLOBALS['xoopsDB']->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/sql/mysql.sql"); include_once dirname(__FILE__) . "/install.php"; xoops_module_install_profile($module); $goupperm_handler =& xoops_getHandler("groupperm"); $field_handler =& xoops_getModuleHandler('field', $module->getVar('dirname', 'n')); $skip_fields = $field_handler->getUserVars(); $skip_fields[] = 'newemail'; $skip_fields[] = 'pm_link'; $sql = "SELECT * FROM `" . $GLOBALS['xoopsDB']->prefix("user_profile_field") . "` WHERE `field_name` NOT IN ('" . implode("', '", $skip_fields) . "')"; $result = $GLOBALS['xoopsDB']->query($sql); $fields = array(); while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $fields[] = $myrow['field_name']; $object =& $field_handler->create(); $object->setVars($myrow, true); $object->setVar('cat_id', 1); if (!empty($myrow['field_register'])) { $object->setVar('step_id', 2); } if (!empty($myrow['field_options'])) { $object->setVar('field_options', unserialize($myrow['field_options'])); } $field_handler->insert($object, true); $gperm_itemid = $object->getVar('field_id'); $sql = "UPDATE " . $GLOBALS['xoopsDB']->prefix("group_permission") . " SET gperm_itemid = " . $gperm_itemid . " WHERE gperm_itemid = " . $myrow['fieldid'] . " AND gperm_modid = " . $module->getVar('mid') . " AND gperm_name IN ('profile_edit', 'profile_search')"; $GLOBALS['xoopsDB']->queryF($sql); $groups_visible = $goupperm_handler->getGroupIds("profile_visible", $myrow['fieldid'], $module->getVar('mid')); $groups_show = $goupperm_handler->getGroupIds("profile_show", $myrow['fieldid'], $module->getVar('mid')); foreach ($groups_visible as $ugid) { foreach ($groups_show as $pgid) { $sql = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("profile_visibility") . " (field_id, user_group, profile_group) " . " VALUES " . " ({$gperm_itemid}, {$ugid}, {$pgid})"; $GLOBALS['xoopsDB']->queryF($sql); } } //profile_install_setPermissions($object->getVar('field_id'), $module->getVar('mid'), $canedit, $visible); unset($object); } // Copy data from profile table foreach ($fields as $field) { $GLOBALS['xoopsDB']->queryF("UPDATE `" . $GLOBALS['xoopsDB']->prefix("profile_profile") . "` u, `" . $GLOBALS['xoopsDB']->prefix("user_profile") . "` p SET u.{$field} = p.{$field} WHERE u.profile_id=p.profileid"); } // Drop old profile table $sql = "DROP TABLE " . $GLOBALS['xoopsDB']->prefix("user_profile"); $GLOBALS['xoopsDB']->queryF($sql); // Drop old field module $sql = "DROP TABLE " . $GLOBALS['xoopsDB']->prefix("user_profile_field"); $GLOBALS['xoopsDB']->queryF($sql); // Remove not used items $sql = "DELETE FROM " . $GLOBALS['xoopsDB']->prefix("group_permission") . " WHERE `gperm_modid` = " . $module->getVar('mid') . " AND `gperm_name` IN ('profile_show', 'profile_visible')"; $GLOBALS['xoopsDB']->queryF($sql); } if ($oldversion < 162) { $GLOBALS['xoopsDB']->queryF("UPDATE `" . $GLOBALS['xoopsDB']->prefix("profile_field") . "` SET `field_valuetype`=1 WHERE `field_name`='umode'"); } if ($oldversion < 186) { // delete old html template files $templateDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/"; $template_list = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($template_list as $k => $v) { $fileinfo = new SplFileInfo($templateDirectory . $v); if ($fileinfo->getExtension() == 'html' && $fileinfo->getFilename() != 'index.html') { @unlink($templateDirectory . $v); } } // Load class XoopsFile xoops_load('xoopsfile'); //delete /images directory $imagesDirectory = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/images/"; $folderHandler = XoopsFile::getHandler("folder", $imagesDirectory); $folderHandler->delete($imagesDirectory); //delete /templates/style.css file $cssFile = XOOPS_ROOT_PATH . "/modules/" . $module->getVar('dirname', 'n') . "/templates/style.css"; $folderHandler = XoopsFile::getHandler("file", $cssFile); $folderHandler->delete($cssFile); } $profile_handler =& xoops_getModuleHandler("profile", $module->getVar('dirname', 'n')); $profile_handler->cleanOrphan($GLOBALS['xoopsDB']->prefix("users"), "uid", "profile_id"); $field_handler =& xoops_getModuleHandler('field', $module->getVar('dirname', 'n')); $user_fields = $field_handler->getUserVars(); $criteria = new Criteria("field_name", "('" . implode("', '", $user_fields) . "')", "IN"); $field_handler->updateAll("field_config", 0, $criteria); return true; }
break; case 'tar': case 'gz': PclTarExtract($path_file, $path); break; } break; //Confirm delete file //Confirm delete file case 'filemanager_confirm_delete_file': echo '<div class="confirmMsg">' . sprintf(_AM_SYSTEM_FILEMANAGER_SUREDEL, $_REQUEST['file']) . '<br /><br /><div class="buttons"><a href="#" class="ui-corner-all" onclick="filemanager_delete_file(\'' . $_REQUEST['path_file'] . '\', \'' . $_REQUEST['path'] . '\');">' . _AM_SYSTEM_FILEMANAGER_DELETE . '</a> <a href="#" class="ui-corner-all" onclick="$(\'#confirm_delete\').hide();filemanager_load_tree(); filemanager_display_file(\'\', 0)">' . _AM_SYSTEM_FILEMANAGER_CANCEL . '</a></div></div>'; break; //Delete one file //Delete one file case 'filemanager_delete_file': $file = XoopsFile::getHandler('file', $_REQUEST['path_file']); if (!$file->delete()) { echo $xoops->alert('error', _AM_SYSTEM_FILEMANAGER_ERROR); } else { echo $xoops->alert('info', _AM_SYSTEM_FILEMANAGER_DELETE_FILE); } break; case 'filemanager_upload': if ($_REQUEST['path'] != '') { $path = trim($_REQUEST['path']); } else { $path = XOOPS_ROOT_PATH . '/'; } $form = new Xoops\Form\ThemeForm('', 'upload_form', 'admin.php?fct=filemanager', "post", true); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new Xoops\Form\File(_AM_SYSTEM_FILEMANAGER_UPLOAD_CHOOSE, 'upload_file'), false);
/** * Initialize the Cache Engine * * Called automatically by the cache frontend * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array()); * * @param array $setting array of setting for the engine * @return boolean True if the engine has been successfully initialized, false if not * @access public */ function init($settings = array()) { parent::init($settings); $defaults = array('path' => XOOPS_VAR_PATH . '/caches/xoops_cache', 'extension' => '.php', 'prefix' => 'xoops_', 'lock' => false, 'serialize' => false, 'duration' => 31556926); $this->settings = array_merge($defaults, $this->settings); if (!isset($this->file)) { XoopsLoad::load('XoopsFile'); $this->file = XoopsFile::getHandler('file', $this->settings['path'] . '/index.html', true); } $this->settings['path'] = $this->file->folder->cd($this->settings['path']); if (empty($this->settings['path'])) { return false; } return $this->active(); }
/** * XoopsCaptcha::writeConfig() * * @param string $filename * @param array $config * * @return array */ function writeConfig($filename = 'config', $config) { $path_file = $this->configPath . $filename . '.php'; $file = XoopsFile::getHandler('file', $path_file); return $file->write('return ' . var_export($config, true) . ';'); }
/** * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license http://www.fsf.org/copyleft/gpl.html GNU public license * @author trabis <*****@*****.**> * @version $Id: onupdate.php 10374 2012-12-12 23:39:48Z trabis $ * * @param $module * @param null $oldversion * * @return */ function xoops_module_update_publisher(XoopsModule $module, $oldversion = null) { global $xoopsDB; if ($oldversion < 102) { // delete old html template files $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/'); $templateList = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($templateList as $k => $v) { $fileInfo = new SplFileInfo($templateDirectory . $v); if ($fileInfo->getExtension() === 'html' && $fileInfo->getFilename() !== 'index.html') { if (file_exists($templateDirectory . $v)) { unlink($templateDirectory . $v); } } } // delete old block html template files $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks/'); $templateList = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($templateList as $k => $v) { $fileInfo = new SplFileInfo($templateDirectory . $v); if ($fileInfo->getExtension() === 'html' && $fileInfo->getFilename() !== 'index.html') { if (file_exists($templateDirectory . $v)) { unlink($templateDirectory . $v); } } } //delete old files: $oldFiles = array('/class/request.php', '/class/registry.php', '/include/constants.php', '/ajaxrating.txt'); foreach (array_keys($oldFiles) as $i) { unlink($GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . $oldFiles[$i])); } //delete .html entries from the tpl table $sql = "DELETE FROM " . $xoopsDB->prefix("tplfile") . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; $xoopsDB->queryF($sql); // Load class XoopsFile xoops_load('XoopsFile'); //delete /images directory $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/'); $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); $folderHandler->delete($imagesDirectory); //delete /css directory $cssDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/css/'); $folderHandler = XoopsFile::getHandler('folder', $cssDirectory); $folderHandler->delete($cssDirectory); //delete /js directory $jsDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/js/'); $folderHandler = XoopsFile::getHandler('folder', $jsDirectory); $folderHandler->delete($jsDirectory); //delete /tcpdf directory $tcpdfDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/tcpdf/'); $folderHandler = XoopsFile::getHandler('folder', $tcpdfDirectory); $folderHandler->delete($tcpdfDirectory); //delete /templates/style.css file // $cssFile = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/style.css'); // $folderHandler = XoopsFile::getHandler('file', $cssFile); // $folderHandler->delete($cssFile); //create upload directories, if needed $moduleDirName = $module->getVar('dirname'); include $GLOBALS['xoops']->path('modules/' . $moduleDirName . '/include/config.php'); foreach (array_keys($uploadFolders) as $i) { PublisherUtilities::createFolder($uploadFolders[$i]); } //copy blank.png files, if needed $file = PUBLISHER_ROOT_PATH . '/assets/images/blank.png'; foreach (array_keys($copyFiles) as $i) { $dest = $copyFiles[$i] . '/blank.png'; PublisherUtilities::copyFile($file, $dest); } } $gpermHandler =& xoops_getHandler('groupperm'); return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); }
/** * @param $module * @param null $oldversion * @return bool */ function xoops_module_update_profile(XoopsModule $module, $oldversion = null) { if ($oldversion < 162) { $GLOBALS['xoopsDB']->queryF('UPDATE `' . $GLOBALS['xoopsDB']->prefix('profile_field') . ' SET field_valuetype=2 WHERE field_name=umode'); } if ($oldversion < 100) { // Drop old category table $sql = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('profile_category'); $GLOBALS['xoopsDB']->queryF($sql); // Drop old field-category link table $sql = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('profile_fieldcategory'); $GLOBALS['xoopsDB']->queryF($sql); // Create new tables for new profile module $GLOBALS['xoopsDB']->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/sql/mysql.sql'); include_once __DIR__ . '/install.php'; xoops_module_install_profile($module); $goupperm_handler = xoops_getHandler('groupperm'); $field_handler = xoops_getModuleHandler('field', $module->getVar('dirname', 'n')); $skip_fields = $field_handler->getUserVars(); $skip_fields[] = 'newemail'; $skip_fields[] = 'pm_link'; $sql = 'SELECT * FROM `' . $GLOBALS['xoopsDB']->prefix('user_profile_field') . "` WHERE `field_name` NOT IN ('" . implode("', '", $skip_fields) . "')"; $result = $GLOBALS['xoopsDB']->query($sql); $fields = array(); while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $fields[] = $myrow['field_name']; $object = $field_handler->create(); $object->setVars($myrow, true); $object->setVar('cat_id', 1); if (!empty($myrow['field_register'])) { $object->setVar('step_id', 2); } if (!empty($myrow['field_options'])) { $object->setVar('field_options', unserialize($myrow['field_options'])); } $field_handler->insert($object, true); $gperm_itemid = $object->getVar('field_id'); $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('group_permission') . ' SET gperm_itemid = ' . $gperm_itemid . ' WHERE gperm_itemid = ' . $myrow['fieldid'] . ' AND gperm_modid = ' . $module->getVar('mid') . " AND gperm_name IN ('profile_edit', 'profile_search')"; $GLOBALS['xoopsDB']->queryF($sql); $groups_visible = $goupperm_handler->getGroupIds('profile_visible', $myrow['fieldid'], $module->getVar('mid')); $groups_show = $goupperm_handler->getGroupIds('profile_show', $myrow['fieldid'], $module->getVar('mid')); foreach ($groups_visible as $ugid) { foreach ($groups_show as $pgid) { $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('profile_visibility') . ' (field_id, user_group, profile_group) ' . ' VALUES ' . " ({$gperm_itemid}, {$ugid}, {$pgid})"; $GLOBALS['xoopsDB']->queryF($sql); } } //profile_install_setPermissions($object->getVar('field_id'), $module->getVar('mid'), $canedit, $visible); unset($object); } // Copy data from profile table foreach ($fields as $field) { $GLOBALS['xoopsDB']->queryF('UPDATE `' . $GLOBALS['xoopsDB']->prefix('profile_profile') . '` u, `' . $GLOBALS['xoopsDB']->prefix('user_profile') . "` p SET u.{$field} = p.{$field} WHERE u.profile_id=p.profileid"); } // Drop old profile table $sql = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('user_profile'); $GLOBALS['xoopsDB']->queryF($sql); // Drop old field module $sql = 'DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('user_profile_field'); $GLOBALS['xoopsDB']->queryF($sql); // Remove not used items $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('group_permission') . ' WHERE `gperm_modid` = ' . $module->getVar('mid') . " AND `gperm_name` IN ('profile_show', 'profile_visible')"; $GLOBALS['xoopsDB']->queryF($sql); } if ($oldversion < 162) { $GLOBALS['xoopsDB']->queryF('UPDATE `' . $GLOBALS['xoopsDB']->prefix('profile_field') . "` SET `field_valuetype`=1 WHERE `field_name`='umode'"); } if ($oldversion < 186) { // delete old html template files $templateDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/'; $template_list = array_diff(scandir($templateDirectory), array('..', '.')); foreach ($template_list as $k => $v) { $fileinfo = new SplFileInfo($templateDirectory . $v); if ($fileinfo->getExtension() === 'html' && $fileinfo->getFilename() !== 'index.html') { @unlink($templateDirectory . $v); } } xoops_load('xoopsfile'); //delete /images directory $imagesDirectory = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/images/'; $folderHandler = XoopsFile::getHandler('folder', $imagesDirectory); $folderHandler->delete($imagesDirectory); //delete /templates/style.css file $cssFile = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname', 'n') . '/templates/style.css'; $folderHandler = XoopsFile::getHandler('file', $cssFile); $folderHandler->delete($cssFile); //delete .html entries from the tpl table $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; $GLOBALS['xoopsDB']->queryF($sql); } $profile_handler = xoops_getModuleHandler('profile', $module->getVar('dirname', 'n')); $profile_handler->cleanOrphan($GLOBALS['xoopsDB']->prefix('users'), 'uid', 'profile_id'); $field_handler = xoops_getModuleHandler('field', $module->getVar('dirname', 'n')); $user_fields = $field_handler->getUserVars(); $criteria = new Criteria('field_name', "('" . implode("', '", $user_fields) . "')", 'IN'); $field_handler->updateAll('field_config', 0, $criteria); return true; }