$mod_dir = basename(dirname(__FILE__)); require WB_PATH . '/modules/' . $mod_dir . '/info.php'; // include module.functions.php include_once WB_PATH . '/framework/module.functions.php'; // load outputfilter-functions require_once dirname(__FILE__) . "/functions.php"; opf_io_mkdir(__OPF_UPLOAD_DIRNAME); opf_io_mkdir(WB_PATH . MEDIA_DIRECTORY . '/opf_plugins'); opf_io_unlink($mod_dir . '/debug_config.php'); opf_io_unlink($mod_dir . '/config_init.php'); opf_io_unlink($mod_dir . '/precheck.php'); if (file_exists(WB_PATH . '/modules/practical_module_functions/pmf.php')) { // load Practical Module Functions include_once WB_PATH . '/modules/practical_module_functions/pmf.php'; $opf = pmf_init(0, basename(dirname(__FILE__))); // unregister this module since we do not use pmf anymore pmf_mod_unregister($opf, basename(dirname(__FILE__))); } opf_db_run_query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_outputfilter_dashboard_settings`"); opf_io_rmdir(dirname(__FILE__) . '/naturaldocs_txt'); // install or upgrade example plugins $install_file = '/plugin_install.php'; $info_file = 'plugin_info.php'; $install_dir = dirname(__FILE__) . '/plugins/'; $plugins = array('cachecontrol', 'correct_date_format'); foreach ($plugins as $plugin_dir) { // run install-script if (file_exists($install_dir . $plugin_dir . $install_file)) { require $install_dir . $plugin_dir . $install_file; } }
function opf_unregister_filter($name) { if (!function_exists('opf_unregister_call_uninstall')) { function opf_unregister_call_uninstall($file) { include $file; } } static $old_name = FALSE; $now = time(); $name = opf_check_name($name); if (!$name) { return FALSE; } if ($old_name == $name) { return FALSE; } // prevent usage of opf_unregister_filter() in plugin_uninstall.php $old_name = $name; // check whether $name is in DB if (opf_is_registered($name)) { $pos = opf_get_position($name); $type = opf_get_type($name); // delete plugin-dir if present if ($plugin_dir = opf_db_query_vars("SELECT `plugin` FROM `" . TABLE_PREFIX . "mod_outputfilter_dashboard` WHERE `name`='%s'", $name)) { if ($plugin_dir && file_exists(WB_PATH . '/modules/outputfilter_dashboard/plugins/' . $plugin_dir)) { // uninstall.php present? include it if (file_exists(WB_PATH . '/modules/outputfilter_dashboard/plugins/' . $plugin_dir . '/plugin_uninstall.php')) { opf_unregister_call_uninstall(WB_PATH . '/modules/outputfilter_dashboard/plugins/' . $plugin_dir . '/plugin_uninstall.php'); } opf_io_rmdir(WB_PATH . '/modules/outputfilter_dashboard/plugins/' . $plugin_dir); } } $res = opf_db_run_query("DELETE FROM `" . TABLE_PREFIX . "mod_outputfilter_dashboard` WHERE `name`='%s'", $name); if ($res) { if (opf_db_run_query("UPDATE `" . TABLE_PREFIX . "mod_outputfilter_dashboard` SET `position`=`position`-1\n WHERE `type`='%s' AND `position`>%d", $type, $pos)) { return TRUE; } } } return FALSE; }
function opf_switch_position($type, $pos1, $pos2) { $pos1 = (int) $pos1; $pos2 = (int) $pos2; if (abs($pos1 - $pos2) != 1) { return FALSE; } $name1 = opf_db_query_vars("SELECT `name`" . " FROM `" . TABLE_PREFIX . "mod_outputfilter_dashboard`" . " WHERE `type`='%s'" . " AND `position`=%d", $type, $pos1); $name2 = opf_db_query_vars("SELECT `name`" . " FROM `" . TABLE_PREFIX . "mod_outputfilter_dashboard`" . " WHERE `type`='%s'" . " AND `position`=%d", $type, $pos2); if ($name1 === FALSE || $name2 === FALSE) { return FALSE; } $res1 = opf_db_run_query("UPDATE `" . TABLE_PREFIX . "mod_outputfilter_dashboard`" . " SET `position`=%d" . " WHERE `name`='%s'", $pos2, $name1); $res2 = opf_db_run_query("UPDATE `" . TABLE_PREFIX . "mod_outputfilter_dashboard`" . " SET `position`=%d" . " WHERE `name`='%s'", $pos1, $name2); if ($res1 && $res2) { return TRUE; } return FALSE; }
} // obtain module directory $mod_dir = basename(dirname(__FILE__)); require WB_PATH . '/modules/' . $mod_dir . '/info.php'; // include module.functions.php include_once WB_PATH . '/framework/module.functions.php'; // include the module language file depending on the backend language of the current user if (!(include get_module_language_file($mod_dir))) { return; } // load outputfilter-functions require_once dirname(__FILE__) . '/functions.php'; // create media-dir opf_io_mkdir(WB_PATH . MEDIA_DIRECTORY . '/opf_plugins'); opf_db_run_query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_outputfilter_dashboard`"); opf_db_run_query("CREATE TABLE `" . TABLE_PREFIX . "mod_outputfilter_dashboard` (\n `id` INT NOT NULL AUTO_INCREMENT,\n `userfunc` TINYINT NOT NULL DEFAULT '0',\n `position` INT NOT NULL DEFAULT '0',\n `active` TINYINT NOT NULL DEFAULT '1',\n `allowedit` TINYINT NOT NULL DEFAULT '0',\n `allowedittarget` TINYINT NOT NULL DEFAULT '0',\n `name` VARCHAR(249) NOT NULL,\n `func` TEXT NOT NULL,\n `type` VARCHAR(255) NOT NULL,\n `file` VARCHAR(255) NOT NULL,\n `csspath` VARCHAR(255) NOT NULL,\n `funcname` VARCHAR(255) NOT NULL,\n `configurl` VARCHAR( 255 ) NOT NULL,\n `plugin` VARCHAR( 255 ) NOT NULL,\n `helppath` TEXT NOT NULL,\n `modules` TEXT NOT NULL,\n `desc` LONGTEXT NOT NULL,\n `pages` TEXT NOT NULL,\n `pages_parent` TEXT NOT NULL,\n `additional_values` LONGTEXT NOT NULL,\n `additional_fields` TEXT NOT NULL,\n `additional_fields_languages` TEXT NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE (`name`),\n INDEX (`type`)\n) ENGINE = MYISAM"); opf_io_rmdir(dirname(__FILE__) . '/naturaldocs_txt'); // install example plugins $install_file = '/plugin_install.php'; $info_file = 'plugin_info.php'; $install_dir = dirname(__FILE__) . '/plugins/'; $plugins = array('cachecontrol', 'correct_date_format'); foreach ($plugins as $plugin_dir) { // run install-script if (file_exists($install_dir . $plugin_dir . $install_file)) { require $install_dir . $plugin_dir . $install_file; } } // run install scripts of already present module filters foreach (preg_grep('/\\/install.php/', opf_io_filelist(WB_PATH . '/modules')) as $installer) { if (strpos($installer, 'outputfilter_dashboard') === FALSE) {
// Sanitize variables $action = $admin->add_slashes($_POST['action']); if ($action == "updatePosition") { $i = array(); $i_keys = array(); foreach (opf_get_types() as $type => $typename) { $i[$type] = 1; $i_keys[] = $type; } foreach ($aRows as $recID) { $id = $admin->checkIDKEY($recID, 0, 'key', true); $filter = opf_get_data($id); $type = $filter['type']; // now we sanitize array $qstring = "UPDATE `" . TABLE_PREFIX . "mod_outputfilter_dashboard`" . " SET `position` = '" . $i[$type] . "'" . " WHERE `id` = " . intval($id) . " "; if (!opf_db_run_query($qstring)) { $aJsonRespond['success'] = false; $aJsonRespond['message'] = 'db query failed: ' . opf_db_get_error(); $aJsonRespond['icon'] = 'cancel.gif'; exit(json_encode($aJsonRespond)); } $i[$type]++; } } else { $aJsonRespond['message'] = 'wrong arguments "$action"'; exit(json_encode($aJsonRespond)); } $aJsonRespond['icon'] = 'dialog-close.gif'; $aJsonRespond['message'] = 'seems everything is fine'; $aJsonRespond['success'] = true; exit(json_encode($aJsonRespond));