protected function beforeDelete(&$obj) { $profile_fields_handler = icms_getModuleHandler('field', basename(dirname(dirname(__FILE__))), 'profile'); $fields_count = $profile_fields_handler->getCount(icms_buildCriteria(array('catid' => $obj->getVar('catid')))); if ($fields_count == 0) { return true; } $obj->setErrors(sprintf(_AM_PROFILE_CATEGORY_NOTDELETED_FIELDS, $fields_count)); return false; }
/** * Shows the form to edit the top posters * * @param array $options The block options * @return string $form The edit top posters form HTML string */ function b_system_topposters_edit($options) { $inputtag = "<input type='text' name='options[]' value='". (int) $options[0] . "' />"; $form = sprintf(_MB_SYSTEM_DISPLAY, $inputtag); $form .= "<br />" . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'"; if ($options[1] == 1) { $form .= " checked='checked'"; } $form .= " /> " . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; if ($options[1] == 0) { $form .= " checked='checked'"; } $form .= " /> " . _NO . ""; $form .= "<br />" . _MB_SYSTEM_NODISPGR . "<br /><select id='options[]' name='options[]' multiple='multiple'>"; $ranks = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array('rank_special' => '1'))); $size = count($options); foreach ($ranks as $k => $v) { $sel = ""; for ($i = 2; $i < $size; $i++) { if ($k == $options[$i]) { $sel = " selected='selected'"; } } $form .= "<option value='$k'$sel>$v</option>"; } $form .= "</select>"; return $form; }
/** * Returns a {@link icms_form_Element} for editing the value of this field * * @param icms_member_user_Object $user {@link icms_member_user_Object} object to edit the value of * @param mod_profile_Profile $profile {@link mod_profile_Profile} object to edit the value of * * @return icms_form_Element */ public function getEditElement($user, $profile) { $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); if ($value === null) { $value = $this->getVar('field_default'); } $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = unserialize($this->getVar('field_options', 'n')); if ($this->getVar('field_type') != "image" && is_array($options)) { asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } switch ($this->getVar('field_type')) { case "autotext": $element = new icms_form_elements_Label($caption, $value); break; case "textarea": $element = new icms_form_elements_Textarea($caption, $name, $value, 4, 30); break; case "dhtml": $element = new icms_form_elements_Dhtmltextarea($caption, $name, $value, 10, 30); break; case "select": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOptionArray($options); break; case "select_multi": $element = new icms_form_elements_Select($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case "radio": $element = new icms_form_elements_Radio($caption, $name, $value); $element->addOptionArray($options); break; case "checkbox": $element = new icms_form_elements_Checkbox($caption, $name, $value); $element->addOptionArray($options); break; case "yesno": $element = new icms_form_elements_Radioyn($caption, $name, $value); break; case "group": $element = new icms_form_elements_select_Group($caption, $name, true, $value); break; case "group_multi": $element = new icms_form_elements_select_Group($caption, $name, true, $value, 5, true); break; case "language": $element = new icms_form_elements_select_Lang($caption, $name, $value); break; case "date": $element = new icms_form_elements_Date($caption, $name, 15, $value); break; case "longdate": $element = new icms_form_elements_Date($caption, $name, 15, str_replace("-", "/", $value)); break; case "datetime": $element = new icms_form_elements_Datetime($caption, $name, 15, $value); break; case "timezone": $element = new icms_form_elements_select_Timezone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case "rank": $element = new icms_form_elements_Select($caption, $name, $value); $ranks = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array("rank_special" => 1))); $element->addOption(0, "--------------"); $element->addOptionArray($ranks); break; case "theme": $element = new icms_form_elements_Select($caption, $name, $value); $element->addOption("0", _MD_PROFILE_SITEDEFAULT); $handle = opendir(ICMS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(ICMS_THEME_PATH . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') { if (file_exists(ICMS_THEME_PATH . '/' . $file . '/theme.html') && in_array($file, $GLOBALS['icmsConfig']['theme_set_allowed'])) { $dirlist[$file] = $file; } } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $element->addOptionArray($dirlist); } break; case "image": $element = new icms_form_elements_File($caption, $name, $options['maxsize'] * 1024); if ($value != "") { $this->assignVar('field_description', ""); $element->setDescription($this->getOutputValue($user, $profile)); } break; case "openid": if ($icmsConfigAuth['auth_openid'] != 1) { break; } $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case "textbox": default: $element = new icms_form_elements_Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; } if ($this->getVar('field_description') != '') { $element->setDescription($this->getVar('field_description')); } return $element; }
/** * Gets list of all user ranks in the database * @deprecated Use SystemUserrankHandler->getList * @todo Remove in version 1.4 * * @return array $ret list of user ranks */ public static function getUserRankList() { icms_core_Debug::setDeprecated('SystemUserrankHandler->getList', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); return icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array("rank_special" => 1))); }
/** * Automatic update of the system module * * @param object $module reference to the module object * @param int $oldversion The old version of the database * @param int $dbVersion The database version * @return mixed */ function xoops_module_update_system(&$module, $oldversion = NULL, $dbVersion = NULL) { global $icmsConfig, $xoTheme; $from_112 = $abortUpdate = FALSE; $oldversion = $module->getVar('version'); if ($oldversion < 120) { $result = icms::$xoopsDB->query("SELECT t1.tpl_id FROM " . icms::$xoopsDB->prefix('tplfile') . " t1, " . icms::$xoopsDB->prefix('tplfile') . " t2 WHERE t1.tpl_module = t2.tpl_module AND t1.tpl_tplset=t2.tpl_tplset AND t1.tpl_file = t2.tpl_file AND t1.tpl_id > t2.tpl_id"); $tplids = array(); while (list($tplid) = icms::$xoopsDB->fetchRow($result)) { $tplids[] = $tplid; } if (count($tplids) > 0) { $tplfile_handler = icms::handler('icms_view_template_file'); $duplicate_files = $tplfile_handler->getObjects(new icms_db_criteria_Item('tpl_id', "(" . implode(',', $tplids) . ")", "IN")); if (count($duplicate_files) > 0) { foreach (array_keys($duplicate_files) as $i) { $tplfile_handler->delete($duplicate_files[$i]); } } } } $icmsDatabaseUpdater = icms_db_legacy_Factory::getDatabaseUpdater(); //$dbVersion = $module->getDBVersion(); //$oldversion = $module->getVar('version'); ob_start(); $dbVersion = $module->getDBVersion(); echo sprintf(_DATABASEUPDATER_CURRENTVER, icms_conv_nr2local($dbVersion)) . '<br />'; echo "<code>" . sprintf(_DATABASEUPDATER_UPDATE_TO, icms_conv_nr2local(ICMS_SYSTEM_DBVERSION)) . "<br />"; /* * DEVELOPER, PLEASE NOTE !!! * * Everytime we add a new upgrade block here, the dbversion of the System Module will get * incremented. It is very important to modify the ICMS_SYSTEM_DBVERSION accordingly * in htdocs/include/version.php * * When we start a new major release, move all the previous version's upgrade scripts to * a separate file, to minimize file size and memory usage */ $CleanWritingFolders = FALSE; if ($dbVersion < 40) { include 'update-112-to-122.php'; } /* Begin upgrade to version 1.3 */ if (!$abortUpdate) { $newDbVersion = 41; } if ($dbVersion < $newDbVersion) { /* Add new tables and data for the help suggestions and quick search */ $table = new icms_db_legacy_updater_Table('autosearch_cat'); if (!$table->exists()) { $table->setStructure("`cid` int(11) NOT NULL auto_increment,\n\t\t\t\t `cat_name` varchar(255) NOT NULL,\n\t\t\t\t `cat_url` text NOT NULL,\n\t\t\t\t PRIMARY KEY (`cid`)"); if (!$table->createTable()) { $abortUpdate = TRUE; $newDbVersion = 40; } if (!$abortUpdate) { icms_loadLanguageFile('system', 'admin'); $search_cats = array("NULL, '" . _MD_AM_ADSENSES . "', '/modules/system/admin.php?fct=adsense'", "NULL, '" . _MD_AM_AUTOTASKS . "', '/modules/system/admin.php?fct=autotasks'", "NULL, '" . _MD_AM_AVATARS . "', '/modules/system/admin.php?fct=avatars'", "NULL, '" . _MD_AM_BANS . "', '/modules/system/admin.php?fct=banners'", "NULL, '" . _MD_AM_BKPOSAD . "', '/modules/system/admin.php?fct=blockspadmin'", "NULL, '" . _MD_AM_BKAD . "', '/modules/system/admin.php?fct=blocksadmin'", "NULL, '" . _MD_AM_COMMENTS . "', '/modules/system/admin.php?fct=comments'", "NULL, '" . _MD_AM_CUSTOMTAGS . "', '/modules/system/admin.php?fct=customtag'", "NULL, '" . _MD_AM_USER . "', '/modules/system/admin.php?fct=users'", "NULL, '" . _MD_AM_FINDUSER . "', '/modules/system/admin.php?fct=finduser'", "NULL, '" . _MD_AM_ADGS . "', '/modules/system/admin.php?fct=groups'", "NULL, '" . _MD_AM_IMAGES . "', '/modules/system/admin.php?fct=images'", "NULL, '" . _MD_AM_MLUS . "', '/modules/system/admin.php?fct=mailusers'", "NULL, '" . _MD_AM_MIMETYPES . "', '/modules/system/admin.php?fct=mimetype'", "NULL, '" . _MD_AM_MDAD . "', '/modules/system/admin.php?fct=modulesadmin'", "NULL, '" . _MD_AM_PREF . "', '/modules/system/admin.php?fct=preferences'", "NULL, '" . _MD_AM_RATINGS . "', '/modules/system/admin.php?fct=rating'", "NULL, '" . _MD_AM_SMLS . "', '/modules/system/admin.php?fct=smilies'", "NULL, '" . _MD_AM_PAGES . "', '/modules/system/admin.php?fct=pages'", "NULL, '" . _MD_AM_TPLSETS . "', '/modules/system/admin.php?fct=tplsets'", "NULL, '" . _MD_AM_RANK . "', '/modules/system/admin.php?fct=userrank'", "NULL, '" . _MD_AM_VERSION . "', '/modules/system/admin.php?fct=version'"); foreach ($search_cats as $cat) { $table->setData($cat); } $table->addData(); } unset($table); } $table = new icms_db_legacy_updater_Table('autosearch_list'); if (!$table->exists() && !$abortUpdate) { $table->setStructure("`id` int(11) NOT NULL auto_increment,\n\t\t\t\t `cat_id` int(11) NOT NULL,\n\t\t\t\t `name` varchar(255) NOT NULL,\n\t\t\t\t `img` varchar(255) NOT NULL,\n\t\t\t\t `desc` text NOT NULL,\n\t\t\t\t `url` text NOT NULL,\n\t\t\t\t PRIMARY KEY (`id`)"); if (!$table->createTable()) { $abortUpdate = TRUE; $newDbVersion = 40; } if (!$abortUpdate) { icms_loadLanguageFile('system', 'admin'); icms_loadLanguageFile('system', 'preferences', TRUE); $search_items = array("NULL, 1, '" . _MD_AM_ADSENSES . "', '/modules/system/admin/adsense/images/adsense_small.png', '" . _MD_AM_ADSENSES_DSC . "', '/modules/system/admin.php?fct=adsense'", "NULL, 2, '" . _MD_AM_AUTOTASKS . "', '/modules/system/admin/autotasks/images/autotasks_small.png', '" . _MD_AM_AUTOTASKS_DSC . "', '/modules/system/admin.php?fct=autotasks'", "NULL, 3, '" . _MD_AM_AVATARS . "', '/modules/system/admin/avatars/images/avatars_small.png', '" . _MD_AM_AVATARS_DSC . "', '/modules/system/admin.php?fct=avatars'", "NULL, 4, '" . _MD_AM_BANS . "', '/modules/system/admin/banners/images/banners_small.png', '" . _MD_AM_BANS_DSC . "', '/modules/system/admin.php?fct=banners'", "NULL, 5, '" . _MD_AM_BKPOSAD . "', '/modules/system/admin/blockspadmin/images/blockspadmin_small.png', '" . _MD_AM_BKPOSAD_DSC . "', '/modules/system/admin.php?fct=blockspadmin'", "NULL, 6, '" . _MD_AM_BKAD . "', '/modules/system/admin/blocksadmin/images/blocksadmin_small.png', '" . _MD_AM_BKAD_DSC . "', '/modules/system/admin.php?fct=blocksadmin'", "NULL, 7, '" . _MD_AM_COMMENTS . "', '/modules/system/admin/comments/images/comments_small.png', '" . _MD_AM_COMMENTS_DSC . "', '/modules/system/admin.php?fct=comments'", "NULL, 8, '" . _MD_AM_CUSTOMTAGS . "', '/modules/system/admin/customtag/images/customtag_small.png', '" . _MD_AM_CUSTOMTAGS_DSC . "', '/modules/system/admin.php?fct=customtag'", "NULL, 9, '" . _MD_AM_USER . "', '/modules/system/admin/users/images/users_small.png', '" . _MD_AM_USER_DSC . "', '/modules/system/admin.php?fct=users'", "NULL, 10, '" . _MD_AM_FINDUSER . "', '/modules/system/admin/findusers/images/findusers_small.png', '" . _MD_AM_FINDUSER_DSC . "', '/modules/system/admin.php?fct=findusers'", "NULL, 11, '" . _MD_AM_ADGS . "', '/modules/system/admin/groups/images/groups_small.png', '" . _MD_AM_ADGS_DSC . "', '/modules/system/admin.php?fct=groups'", "NULL, 12, '" . _MD_AM_IMAGES . "', '/modules/system/admin/images/images/images_small.png', '" . _MD_AM_IMAGES_DSC . "', '/modules/system/admin.php?fct=images'", "NULL, 13, '" . _MD_AM_MLUS . "', '/modules/system/admin/mailusers/images/mailusers_small.png', '" . _MD_AM_MLUS_DSC . "', '/modules/system/admin.php?fct=mailusers'", "NULL, 14, '" . _MD_AM_MIMETYPES . "', '/modules/system/admin/mimetype/images/mimetype_small.png', '" . _MD_AM_MIMETYPES_DSC . "', '/modules/system/admin.php?fct=mimetype'", "NULL, 15, '" . _MD_AM_MDAD . "', '/modules/system/admin/modulesadmin/images/modulesadmin_small.png', '" . _MD_AM_MDAD_DSC . "', '/modules/system/admin.php?fct=modulesadmin'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_AUTHENTICATION . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_AUTHENTICATION_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=7'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_AUTOTASKS . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_AUTOTASKS_PREF_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=13'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_CAPTCHA . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_CAPTCHA_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=11'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_GENERAL . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_GENERAL_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=1'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_PURIFIER . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_PURIFIER_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=14'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_MAILER . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_MAILER_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=6'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_METAFOOTER . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_METAFOOTER_DSC . "', '/modules/system/admin/preferences/images/preferences_small.png'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_MULTILANGUAGE . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_MULTILANGUAGE_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=8'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_PERSON . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_PERSON_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=10'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_PLUGINS . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_PLUGINS_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=12'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_SEARCH . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_SEARCH_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=5'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_USERSETTINGS . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_USERSETTINGS_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=2'", "NULL, 16, '" . _MD_AM_PREF . " - " . _MD_AM_CENSOR . "', '/modules/system/admin/preferences/images/preferences_small.png', '" . _MD_AM_CENSOR_DSC . "', '/modules/system/admin.php?fct=preferences&op=show&confcat_id=4'", "NULL, 17, '" . _MD_AM_RATINGS . "', '/modules/system/admin/rating/images/rating_small.png', '" . _MD_AM_RATINGS_DSC . "', '/modules/system/admin.php?fct=rating'", "NULL, 18, '" . _MD_AM_SMLS . "', '/modules/system/admin/smilies/images/smilies_small.png', '" . _MD_AM_SMLS_DSC . "', '/modules/system/admin.php?fct=smilies'", "NULL, 19, '" . _MD_AM_PAGES . "', '/modules/system/admin/pages/images/pages_small.png', '" . _MD_AM_PAGES_DSC . "', '/modules/system/admin.php?fct=pages'", "NULL, 20, '" . _MD_AM_TPLSETS . "', '/modules/system/admin/tplsets/images/tplsets_small.png', '" . _MD_AM_TPLSETS_DSC . "', '/modules/system/admin.php?fct=tplsets'", "NULL, 21, '" . _MD_AM_RANK . "', '/modules/system/admin/userrank/images/userrank_small.png', '" . _MD_AM_RANK_DSC . "', '/modules/system/admin.php?fct=userrank'", "NULL, 22, '" . _MD_AM_VRSN . "', '/modules/system/admin/version/images/version_small.png', '" . _MD_AM_VRSN_DSC . "', '/modules/system/admin.php?fct=version'"); foreach ($search_items as $item) { $table->setData($item); } $table->addData(); } unset($table); } /* Optimize old tables and fix data structures */ $table = new icms_db_legacy_updater_Table('config'); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX conf_mod_cat_id, ADD INDEX mod_cat_order(conf_modid, conf_catid, conf_order)", 'Successfully altered the indexes on table config', ''); unset($table); $table = new icms_db_legacy_updater_Table('group_permission'); $table->addAlteredField('gperm_modid', "SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0'", 'gperm_modid'); $table->alterTable(); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX itemid, DROP INDEX groupid, DROP INDEX gperm_modid", 'Successfully dropped the indexes on table group_permission', ''); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` ADD INDEX name_mod_group (gperm_name(10), gperm_modid, gperm_groupid)", 'Successfully added the indexes on table group_permission', ''); unset($table); $table = new icms_db_legacy_updater_Table('modules'); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX hasmain, DROP INDEX hasadmin, DROP INDEX hassearch, DROP INDEX hasnotification, DROP INDEX name, DROP INDEX dirname", 'Successfully dropped the indexes on table modules', ''); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` ADD INDEX dirname (dirname(5)), ADD INDEX active_main_weight (isactive, hasmain, weight)", 'Successfully added the indexes on table modules', ''); unset($table); $table = new icms_db_legacy_updater_Table('users'); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX email, DROP INDEX uiduname, DROP INDEX unamepass", 'Successfully dropped the indexes on table users', ''); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX login_name, ADD UNIQUE INDEX login_name (login_name)", 'Successfully added the indexes on table users', ''); unset($table); $table = new icms_db_legacy_updater_Table('priv_msgs'); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX to_userid", 'Successfully dropped the indexes on table priv_msgs', ''); unset($table); $table = new icms_db_legacy_updater_Table('ranks'); $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` DROP INDEX rank_min", 'Successfully dropped the indexes on table ranks', ''); unset($table); /* Corrects an error from db version 4 */ $table = new icms_db_legacy_updater_Table('users'); if ($table->fieldExists('pass')) { $table->addAlteredField('pass', "varchar(255) NOT NULL default ''", 'pass'); $table->alterTable(); } unset($table); /* change IP address to varchar(64) in session to accomodate IPv6 addresses */ $table = new icms_db_legacy_updater_Table('session'); if ($table->fieldExists('sess_ip')) { $table->addAlteredField('sess_ip', "varchar(64) NOT NULL default ''", 'sess_ip'); $table->alterTable(); } unset($table); /* add modname and ipf to modules table */ $table = new icms_db_legacy_updater_Table("modules"); $alter = FALSE; if (!$table->fieldExists("modname")) { $table->addNewField("modname", "varchar(25) NOT NULL default ''"); $alter = TRUE; } if (!$table->fieldExists("ipf")) { $table->addNewField("ipf", "tinyint(1) unsigned NOT NULL default '0'"); $alter = TRUE; } if ($alter) { $table->addNewFields(); } unset($table, $alter); $module_handler = icms::handler('icms_module'); $modules = $module_handler->getObjects(); foreach ($modules as $module) { if ($module->getInfo("modname") !== FALSE) { $module->setVar("modname", $module->getInfo("modname")); } if ($module->getInfo("object_items") !== FALSE) { $module->setVar("ipf", 1); } $module_handler->insert($module); } unset($module_handler, $modules); /* add slot for adsense and rename fields */ $table = new icms_db_legacy_updater_Table('system_adsense'); if (!$table->fieldExists("slot")) { $table->addNewField("slot", "varchar(12) NOT NULL default ''"); $table->addNewFields(); } if ($table->fieldExists("border_color")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE border_color color_border varchar(6) NOT NULL default ''"); } if ($table->fieldExists("background_color")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE background_color color_background varchar(6) NOT NULL default ''"); } if ($table->fieldExists("link_color")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE link_color color_link varchar(6) NOT NULL default ''"); } if ($table->fieldExists("url_color")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE url_color color_url varchar(6) NOT NULL default ''"); } if ($table->fieldExists("text_color")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE text_color color_text varchar(6) NOT NULL default ''"); } unset($table); /* rename content field for customtag */ $table = new icms_db_legacy_updater_Table("system_customtag"); if ($table->fieldExists("content")) { $icmsDatabaseUpdater->runQuery("ALTER TABLE `" . $table->name() . "` CHANGE content customtag_content text NOT NULL"); } unset($table); /* rename gperm_name from view to view_customtag for system module */ $table = new icms_db_legacy_updater_Table("group_permission"); $icmsDatabaseUpdater->runQuery("UPDATE `" . $table->name() . "` SET gperm_name = 'view_customtag' WHERE gperm_name = 'view' AND gperm_modid = 1", "", ""); unset($table); /* reset default source editor if jsvi is used */ $configs = icms::$config->getConfigs(icms_buildCriteria(array("conf_name" => "sourceeditor_default"))); if (count($configs) == 1 && $configs[0]->getVar("conf_value") == "jsvi") { $configs[0]->setVar("conf_value", "editarea"); icms::$config->insertConfig($configs[0]); } unset($configs); /* New HTML Purifier options - * purifier_HTML_FlashAllowFullScreen, after purifier_HTML_AttrNameUseCDATA * purifier_Output_FlashCompat, after purifier_HTML_FlashAllowFullScreen * purifier_Filter_AllowCustom, after purifier_Filter_YouTube * purifier_Core_NormalizeNewlines, after purifier_Core_RemoveInvalidImg */ $table = new icms_db_legacy_updater_Table("config"); // retrieve the value of the position before the config to be inserted. $configs = icms::$config->getConfigs(icms_buildCriteria(array("conf_name" => "purifier_HTML_AttrNameUseCDATA"))); $p = $configs[0]->getVar('conf_order') + 1; //move all the other options down $icmsDatabaseUpdater->runQuery("UPDATE `" . $table->name() . "` SET conf_order = conf_order + 2 WHERE conf_order >= " . $p . " AND conf_catid = " . ICMS_CONF_PURIFIER, "", ""); $icmsDatabaseUpdater->insertConfig(ICMS_CONF_PURIFIER, 'purifier_HTML_FlashAllowFullScreen', '_MD_AM_PURIFIER_HTML_FLASHFULLSCRN', '0', '_MD_AM_PURIFIER_HTML_FLASHFULLSCRNDSC', 'yesno', 'int', $p); $icmsDatabaseUpdater->insertConfig(ICMS_CONF_PURIFIER, 'purifier_Output_FlashCompat', '_MD_AM_PURIFIER_OUTPUT_FLASHCOMPAT', '0', '_MD_AM_PURIFIER_OUTPUT_FLASHCOMPATDSC', 'yesno', 'int', $p++); // retrieve the value of the position before the config to be inserted. $configs = icms::$config->getConfigs(icms_buildCriteria(array("conf_name" => "purifier_Filter_YouTube"))); $p = $configs[0]->getVar('conf_order') + 1; //move all the other options down $icmsDatabaseUpdater->runQuery("UPDATE `" . $table->name() . "` SET conf_order = conf_order + 1 WHERE conf_order >= " . $p . " AND conf_catid = " . ICMS_CONF_PURIFIER, "", ""); $icmsDatabaseUpdater->insertConfig(ICMS_CONF_PURIFIER, 'purifier_Filter_AllowCustom', '_MD_AM_PURIFIER_FILTER_ALLOWCUSTOM', '0', '_MD_AM_PURIFIER_FILTER_ALLOWCUSTOMDSC', 'yesno', 'int', $p); // retrieve the value of the position before the config to be inserted. $configs = icms::$config->getConfigs(icms_buildCriteria(array("conf_name" => "purifier_Core_RemoveInvalidImg"))); $p = $configs[0]->getVar('conf_order') + 1; //move all the other options down $icmsDatabaseUpdater->runQuery("UPDATE `" . $table->name() . "` SET conf_order = conf_order + 1 WHERE conf_order >= " . $p . " AND conf_catid = " . ICMS_CONF_PURIFIER, "", ""); $icmsDatabaseUpdater->insertConfig(ICMS_CONF_PURIFIER, 'purifier_Core_NormalizeNewlines', '_MD_AM_PURIFIER_CORE_NORMALNEWLINES', '1', '_MD_AM_PURIFIER_CORE_NORMALNEWLINESDSC', 'yesno', 'int', $p); unset($table); /* Finish up this portion of the db update */ if (!$abortUpdate) { $icmsDatabaseUpdater->updateModuleDBVersion($newDbVersion, 'system'); echo sprintf(_DATABASEUPDATER_UPDATE_OK, icms_conv_nr2local($newDbVersion)) . '<br />'; } } /* 1.3 beta|rc|final release */ /* * This portion of the upgrade must remain as the last section of code to execute * Place all release upgrade steps above this point */ echo "</code>"; if ($abortUpdate) { icms_core_Message::error(sprintf(_DATABASEUPDATER_UPDATE_ERR, icms_conv_nr2local($newDbVersion)), _DATABASEUPDATER_UPDATE_DB, TRUE); } if ($from_112 && !$abortUpdate) { /** * @todo create a language constant for this text */ echo _DATABASEUPDATER_MSG_FROM_112; echo '<script>setTimeout("window.location.href=\'' . ICMS_MODULES_URL . '/system/admin.php?fct=modulesadmin&op=install&module=content&from_112=1\'",20000);</script>'; } $feedback = ob_get_clean(); if (method_exists($module, "setMessage")) { $module->messages = $module->setMessage($feedback); } else { echo $feedback; } $icmsDatabaseUpdater->updateModuleDBVersion($newDbVersion, 'system'); return icms_core_Filesystem::cleanFolders(array('templates_c' => ICMS_COMPILE_PATH . "/", 'cache' => ICMS_CACHE_PATH . "/"), $CleanWritingFolders); }
/** * Validates username, email address and password entries during registration * Username is validated for uniqueness and length * password is validated for length and strictness * email is validated as a proper email address pattern * * @param string $uname User display name entered by the user * @param string $login_name Username entered by the user * @param string $email Email address entered by the user * @param string $pass Password entered by the user * @param string $vpass Password verification entered by the user * @param int $uid user id (only applicable if the user already exists) * @global array $icmsConfigUser user configuration * @return string of errors encountered while validating the user information, will be blank if successful */ public function userCheck($login_name, $uname, $email, $pass, $vpass, $uid = 0) { global $icmsConfigUser; // initializations $member_handler = icms::handler('icms_member'); $thisUser = $uid > 0 ? $thisUser = $member_handler->getUser($uid) : FALSE; $icmsStopSpammers = new icms_core_StopSpammer(); $stop = ''; switch ($icmsConfigUser['uname_test_level']) { case 0: // strict $restriction = '/[^a-zA-Z0-9\\_\\-]/'; break; case 1: // medium $restriction = '/[^a-zA-Z0-9\\_\\-\\<\\>\\,\\.\\$\\%\\#\\@\\!\\\'\\"]/'; break; case 2: // loose $restriction = '/[\\000-\\040]/'; break; } // check email if (is_object($thisUser) && $thisUser->getVar('email', 'e') != $email && $email !== FALSE || !is_object($thisUser)) { if (!icms_core_DataFilter::checkVar($email, 'email', 0, 1)) { $stop .= _US_INVALIDMAIL . '<br />'; } $count = $this->getCount(icms_buildCriteria(array('email' => addslashes($email)))); if ($count > 0) { $stop .= _US_EMAILTAKEN . '<br />'; } } // check login_name $login_name = icms_core_DataFilter::icms_trim($login_name); if (is_object($thisUser) && $thisUser->getVar('login_name', 'e') != $login_name && $login_name !== FALSE || !is_object($thisUser)) { if (empty($login_name) || preg_match($restriction, $login_name)) { $stop .= _US_INVALIDNICKNAME . '<br />'; } if (strlen($login_name) > $icmsConfigUser['maxuname']) { $stop .= sprintf(_US_NICKNAMETOOLONG, $icmsConfigUser['maxuname']) . '<br />'; } if (strlen($login_name) < $icmsConfigUser['minuname']) { $stop .= sprintf(_US_NICKNAMETOOSHORT, $icmsConfigUser['minuname']) . '<br />'; } foreach ($icmsConfigUser['bad_unames'] as $bu) { if (!empty($bu) && preg_match('/' . $bu . '/i', $login_name)) { $stop .= _US_NAMERESERVED . '<br />'; break; } } if (strrpos($login_name, ' ') > 0) { $stop .= _US_NICKNAMENOSPACES . '<br />'; } $count = $this->getCount(icms_buildCriteria(array('login_name' => addslashes($login_name)))); if ($count > 0) { $stop .= _US_LOGINNAMETAKEN . '<br />'; } } // check uname if (is_object($thisUser) && $thisUser->getVar('uname', 'e') != $uname && $uname !== FALSE || !is_object($thisUser)) { $count = $this->getCount(icms_buildCriteria(array('uname' => addslashes($uname)))); if ($count > 0) { $stop .= _US_NICKNAMETAKEN . '<br />'; } } // check password if ($pass !== FALSE) { if (!isset($pass) || $pass == '' || !isset($vpass) || $vpass == '') { $stop .= _US_ENTERPWD . '<br />'; } if (isset($pass) && $pass != $vpass) { $stop .= _US_PASSNOTSAME . '<br />'; } elseif ($pass != '' && strlen($pass) < $icmsConfigUser['minpass']) { $stop .= sprintf(_US_PWDTOOSHORT, $icmsConfigUser['minpass']) . '<br />'; } if (isset($pass) && isset($login_name) && ($pass == $login_name || $pass == icms_core_DataFilter::utf8_strrev($login_name, TRUE) || strripos($pass, $login_name) === TRUE)) { $stop .= _US_BADPWD . '<br />'; } } // check other things if ($icmsStopSpammers->badIP($_SERVER['REMOTE_ADDR'])) { $stop .= _US_INVALIDIP . '<br />'; } return $stop; }
public function &getConfigPerUser($uid, $new = false) { static $buffer = array(); if (!isset($buffer[$uid])) { $configs = $this->getObjects(icms_buildCriteria(array('config_uid' => $uid))); if (is_array($configs) && count($configs) > 0 && is_object($configs[0])) { $buffer[$uid] = $configs[0]; } elseif ($new) { return $this->get(0); } } return $buffer[$uid]; }
* functions for image. * * @copyright http://www.impresscms.org/ The ImpressCMS Project * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) * @package core * @since XOOPS * @version $Id: image.php 20607 2010-12-21 19:05:12Z phoenyx $ */ $image_id = isset($_GET["id"]) ? (int) $_GET["id"] : 0; if (empty($image_id)) { header("Content-type: image/gif"); readfile(ICMS_UPLOAD_PATH . "/blank.gif"); exit; } include "mainfile.php"; icms::$logger->disableLogger(); $criteria = icms_buildCriteria(array("i.image_display" => 1, "i.image_id" => $image_id)); $images = icms::handler("icms_image")->getObjects($criteria, FALSE, TRUE); if (count($images) == 1 && $images[0]->getVar("image_body") !== NULL) { header("Content-type: " . $images[0]->getVar("image_mimetype")); header("Cache-control: max-age=31536000"); header("Expires: " . gmdate("D, d M Y H:i:s", time() + 31536000) . "GMT"); header("Content-disposition: filename=" . $images[0]->getVar("image_name")); header("Content-Length: " . strlen($images[0]->getVar("image_body"))); header("Last-Modified: " . gmdate("D, d M Y H:i:s", $images[0]->getVar("image_created")) . "GMT"); echo $images[0]->getVar("image_body"); } else { header("Content-type: image/gif"); readfile(ICMS_UPLOAD_PATH . "/blank.gif"); exit; }
$sig_cbox->addOption(1, _US_SHOWSIG); $sig_tray->addElement($sig_cbox); $umode_select = new icms_form_elements_Select(_US_CDISPLAYMODE, "umode", $umode_value); $umode_select->addOptionArray(array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED)); $uorder_select = new icms_form_elements_Select(_US_CSORTORDER, "uorder", $uorder_value); $uorder_select->addOptionArray(array("0" => _OLDESTFIRST, "1" => _NEWESTFIRST)); // RMV-NOTIFY icms_loadLanguageFile('core', 'notification'); include_once ICMS_ROOT_PATH . '/include/notification_constants.php'; $notify_method_select = new icms_form_elements_Select(_NOT_NOTIFYMETHOD, 'notify_method', $notify_method_value); $notify_method_select->addOptionArray(array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL)); $notify_mode_select = new icms_form_elements_Select(_NOT_NOTIFYMODE, 'notify_mode', $notify_mode_value); $notify_mode_select->addOptionArray(array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN)); $bio_tarea = new icms_form_elements_Textarea(_US_EXTRAINFO, "bio", $bio_value); $rank_select = new icms_form_elements_Select(_AM_RANK, "rank", $rank_value); $ranklist = icms_getModuleHandler("userrank", "system")->getList(icms_buildCriteria(array('rank_special' => '1'))); if (count($ranklist) > 0) { $rank_select->addOption(0, "--------------"); $rank_select->addOptionArray($ranklist); } else { $rank_select->addOption(0, _AM_NSRID); } global $icmsConfigUser; $pwd_text = new icms_form_elements_Password(_AM_PASSWORD, "password", 10, 255, '', false, $icmsConfigUser['pass_level'] ? 'password_adv' : ''); $pwd_text2 = new icms_form_elements_Password(_AM_RETYPEPD, "pass2", 10, 255); $mailok_radio = new icms_form_elements_Radioyn(_US_MAILOK, 'user_mailok', (int) $mailok_value); $language = new icms_form_elements_select_Lang(_US_SELECT_LANG, 'language', $language_value); // Groups administration addition XOOPS 2.0.9: Mith $gperm_handler = icms::handler('icms_member_groupperm'); //If user has admin rights on groups if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, icms::$user->getGroups(), 1)) {
$rtn[$i]['uid'] = $visitor['uid_visitor']; $rtn[$i]['uname'] = $visitorUser->getVar('uname'); $rtn[$i]['time'] = $visitor['visit_time']; $i++; } $icmsTpl->assign('visitors', $rtn); unset($visitors); // Dynamic User Profiles $field_handler = icms_getModuleHandler('field', basename(dirname(__FILE__)), 'profile'); $icmsTpl->assign('fields', $field_handler->getProfileFields($thisUser)); unset($field_handler); // getting user contributions if (icms::$module->config['profile_search'] && $permissions['profile_usercontributions']) { $groups = is_object(icms::$user) ? icms::$user->getGroups() : ICMS_GROUP_ANONYMOUS; $module_handler = icms::handler('icms_module'); $mids = array_keys($module_handler->getList(icms_buildCriteria(array('hassearch' => 1, 'isactive' => 1)))); foreach ($mids as $mid) { if (icms::handler('icms_member_groupperm')->checkRight('module_read', $mid, $groups)) { $module = $module_handler->get($mid); $results = $module->search('', '', 5, 0, $thisUser->getVar('uid')); $count = count($results); if (is_array($results) && $count > 0) { for ($i = 0; $i < $count; $i++) { if (isset($results[$i]['image']) && $results[$i]['image'] != '') { $results[$i]['image'] = 'modules/' . $module->getVar('dirname') . '/' . $results[$i]['image']; } else { $results[$i]['image'] = 'images/icons/posticon2.gif'; } if (!preg_match("/^http[s]*:\\/\\//i", $results[$i]['link'])) { $results[$i]['link'] = ICMS_URL . "/modules/" . $module->getVar('dirname') . "/" . $results[$i]['link']; }
public function mergeTribes($tribes_id, $merge_tribes_id) { // make sure not to join one tribe with itself if ($tribes_id == $merge_tribes_id) { redirect_header(PROFILE_ADMIN_URL . 'tribes.php?op=merge&tribes_id=' . $tribes_id, 3, _AM_PROFILE_TRIBES_MERGE_ERR_SAME); } // make sure both tribes exist $tribesObj = $this->get($tribes_id); $merge_tribesObj = $this->get($merge_tribes_id); if ($tribesObj->isNew() || $merge_tribesObj->isNew()) { redirect_header(PROFILE_ADMIN_URL . 'tribes.php', 3, _AM_PROFILE_TRIBES_MERGE_ERR_ID); } $profile_tribetopic_handler = icms_getModuleHandler('tribetopic', basename(dirname(dirname(__FILE__))), 'profile'); $profile_tribepost_handler = icms_getModuleHandler('tribepost', basename(dirname(dirname(__FILE__))), 'profile'); $profile_tribeuser_handler = icms_getModuleHandler('tribeuser', basename(dirname(dirname(__FILE__))), 'profile'); // move the discussions $profile_tribetopic_handler->updateAll('tribes_id', $merge_tribes_id, icms_buildCriteria(array('tribes_id' => $tribes_id))); $profile_tribepost_handler->updateAll('tribes_id', $merge_tribes_id, icms_buildCriteria(array('tribes_id' => $tribes_id))); // get all members of the old tribe and add the owner as a "member" $tribeusers = $profile_tribeuser_handler->getObjects(icms_buildCriteria(array('tribe_id' => $tribes_id))); $tribeuserObj = $profile_tribeuser_handler->get(0); $tribeuserObj->setVar('tribe_id', $tribes_id); $tribeuserObj->setVar('user_id', $tribesObj->getVar('uid_owner')); $tribeusers[] = $tribeuserObj; unset($tribeuserObj); // move all users foreach ($tribeusers as $tribeuserObj) { $merge_tribeusers = $profile_tribeuser_handler->getCount(icms_buildCriteria(array('user_id' => $tribeuserObj->getVar('user_id'), 'tribe_id' => $merge_tribes_id))); // we only have to add this user as a user of the new tribe if he isn't already a user and if he isn't the owner if ($merge_tribeusers == 0 && $tribeuserObj->getVar('user_id') != $merge_tribesObj->getVar('uid_owner')) { $merge_tribeuserObj = $profile_tribeuser_handler->get(0); if ($merge_tribesObj->getVar('security') == PROFILE_TRIBES_SECURITY_APPROVAL) { $merge_tribeuserObj->setVar('approved', 0); } elseif ($merge_tribesObj->getVar('security') == PROFILE_TRIBES_SECURITY_INVITATION) { $merge_tribeuserObj->setVar('accepted', 0); } $merge_tribeuserObj->setVar('tribe_id', $merge_tribesObj->getVar('tribes_id')); $merge_tribeuserObj->setVar('user_id', $tribeuserObj->getVar('user_id')); $merge_tribeuserObj->store(); } if (!$tribeuserObj->getVar('tribeuser_id') == 0) { $tribeuserObj->delete(); } } // deleting the old tribe $tribesObj->delete(); }
/** * Logic for uninstalling a module * * @todo add installation_notify(), send status * * @param unknown_type $dirname * @return string Result messages for uninstallation */ function xoops_module_uninstall($dirname) { global $icmsConfig, $icmsAdminTpl; $reservedTables = array( 'avatar', 'avatar_users_link', 'block_module_link', 'xoopscomments', 'config', 'configcategory', 'configoption', 'image', 'imagebody', 'imagecategory', 'imgset', 'imgset_tplset_link', 'imgsetimg', 'groups', 'groups_users_link', 'group_permission', 'online', 'bannerclient', 'banner', 'bannerfinish', 'priv_msgs', 'ranks', 'session', 'smiles', 'users', 'newblocks', 'modules', 'tplfile', 'tplset', 'tplsource', 'xoopsnotifications', 'banner', 'bannerclient', 'bannerfinish'); $db =& icms_db_Factory::instance(); $module_handler = icms::handler('icms_module'); $module =& $module_handler->getByDirname($dirname); $module->registerClassPath(); $icmsAdminTpl->template_clear_module_cache($module->getVar('mid')); if ($module->getVar('dirname') == 'system') { return "<p>" . sprintf(_MD_AM_FAILUNINS, "<strong>" . $module->getVar('name') . "</strong>") . " " . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_SYSNO . "</p>"; } elseif ($module->getVar('dirname') == $icmsConfig['startpage']) { return "<p>" . sprintf(_MD_AM_FAILUNINS, "<strong>" . $module->getVar('name') . "</strong>") . " " . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_STRTNO . "</p>"; } else { $msgs = array(); $member_handler = icms::handler('icms_member'); $grps = $member_handler->getGroupList(); foreach ($grps as $k => $v) { $stararr = explode('-', $icmsConfig['startpage'][$k]); if (count($stararr) > 0) { if ($module->getVar('mid') == $stararr[0]) { return "<p>" . sprintf(_MD_AM_FAILDEACT, "<strong>" . $module->getVar('name') . "</strong>") . " " . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_STRTNO . "</p>"; } } } if (in_array($module->getVar('dirname'), $icmsConfig ['startpage'])) { return "<p>" . sprintf(_MD_AM_FAILDEACT, "<strong>" . $module->getVar('name') . "</strong>") . " " . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_STRTNO . "</p>"; } $page_handler = icms::handler('icms_data_page'); $criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('page_moduleid', $module->getVar('mid'))); $pages = $page_handler->getCount($criteria); if ($pages > 0) { $pages = $page_handler->getObjects($criteria); $msgs[] = _MD_AM_SYMLINKS_DELETE; foreach ($pages as $page) { if (!$page_handler->delete($page)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_SYMLINK_DELETE_FAIL . '</span>', $page->getVar('page_title'), '<strong>'. $page->getVar('page_id') . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_SYMLINK_DELETED, '<strong>' . $page->getVar('page_title') . '</strong>', '<strong>' . $page->getVar('page_id') . '</strong>'); } } } if (!$module_handler->delete($module)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_DELETE_FAIL . '</span>', $module->getVar('name')); } else { // delete template files $tplfile_handler = icms::handler('icms_view_template_file'); $templates =& $tplfile_handler->find(NULL, 'module', $module->getVar('mid')); $tcount = count($templates); if ($tcount > 0) { $msgs[] = _MD_AM_TEMPLATES_DELETE; for ($i = 0; $i < $tcount; $i++) { if (!$tplfile_handler->delete($templates[$i])) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_TEMPLATE_DELETE_FAIL . '</span>', $templates[$i]->getVar('tpl_file') , '<strong>' . icms_conv_nr2local($templates[$i]->getVar('tpl_id')) . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_TEMPLATE_DELETED, '<strong>' . icms_conv_nr2local($templates[$i]->getVar('tpl_file')) . '</strong>', '<strong>' . icms_conv_nr2local($templates[$i]->getVar('tpl_id')) . '</strong>' ); } } } unset($templates); // delete blocks and block template files $icms_block_handler = icms::handler('icms_view_block'); $block_arr =& $icms_block_handler->getByModule($module->getVar('mid')); if (is_array($block_arr)) { $bcount = count($block_arr); $msgs[] = _MD_AM_BLOCKS_DELETE; for ($i = 0; $i < $bcount; $i++) { if (!$icms_block_handler->delete($block_arr[$i])) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_BLOCK_DELETE_FAIL . '</span>', '<strong>' . $block_arr[$i]->getVar('name') . '</strong>', '<strong>' . icms_conv_nr2local($block_arr[$i]->getVar('bid')) . '</strong>' ); } else { $msgs[] = sprintf(' ' . _MD_AM_BLOCK_DELETED, '<strong>' . $block_arr[$i]->getVar('name') . '</strong>', '<strong>' . icms_conv_nr2local($block_arr[$i]->getVar('bid')) . '</strong>' ); } if ($block_arr[$i]->getVar('template') != '') { $templates =& $tplfile_handler->find(NULL, 'block', $block_arr[$i]->getVar('bid')); $btcount = count($templates); if ($btcount > 0) { for ($j = 0; $j < $btcount; $j++) { if (!$tplfile_handler->delete($templates[$j])) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_BLOCK_TMPLT_DELETE_FAILED . '</span>', $templates[$j]->getVar('tpl_file'), '<strong>' . icms_conv_nr2local($templates[$j]->getVar('tpl_id')) . '</strong>' ); } else { $msgs[] = sprintf(' ' . _MD_AM_BLOCK_TMPLT_DELETED, '<strong>' . $templates[$j]->getVar('tpl_file') . '</strong>', '<strong>' . icms_conv_nr2local($templates[$j]->getVar('tpl_id')) . '</strong>' ); } } } unset($templates); } } } // delete tables used by this module $modtables = $module->getInfo('tables'); if ($modtables !== FALSE && is_array($modtables)) { $msgs[] = _MD_AM_MOD_TABLES_DELETE; foreach ($modtables as $table) { // prevent deletion of reserved core tables! if (!in_array($table, $reservedTables)) { $sql = 'DROP TABLE ' . $db->prefix($table); if (!$db->query($sql)) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_MOD_TABLE_DELETE_FAIL . '</span>', '<strong>'. $db->prefix($table) . '<strong> . ' ); } else { $msgs[] = sprintf(' ' . _MD_AM_MOD_TABLE_DELETED, '<strong>' . $db->prefix($table) . '</strong>' ); } } else { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_MOD_TABLE_DELETE_NOTALLOWED . '</span>', '<strong>' . $db->prefix($table) . '</strong>' ); } } } // delete comments if any if ($module->getVar('hascomments') != 0) { $msgs[] = _MD_AM_COMMENTS_DELETE; $comment_handler = icms::handler('icms_data_comment'); if (!$comment_handler->deleteByModule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">' . _MD_AM_COMMENT_DELETE_FAIL . '</span>'; } else { $msgs[] = ' ' . _MD_AM_COMMENT_DELETED; } } // delete notifications if any if ($module->getVar('hasnotification') != 0) { $msgs[] = _MD_AM_NOTIFICATIONS_DELETE; if (!xoops_notification_deletebymodule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">' . _MD_AM_NOTIFICATION_DELETE_FAIL .'</span>'; } else { $msgs[] = ' ' . _MD_AM_NOTIFICATION_DELETED; } } // delete permissions if any $msgs[] = _MD_AM_GROUPPERM_DELETE; $gperm_handler = icms::handler('icms_member_groupperm'); if (!$gperm_handler->deleteByModule($module->getVar('mid'))) { $msgs[] = ' <span style="color:#ff0000;">' . _MD_AM_GROUPPERM_DELETE_FAIL . '</span>'; } else { $msgs[] = ' ' . _MD_AM_GROUPPERM_DELETED; } // delete module config options if any if ($module->getVar('hasconfig') != 0 || $module->getVar('hascomments') != 0) { $config_handler = icms::handler('icms_config'); $configs =& $config_handler->getConfigs(new icms_db_criteria_Item('conf_modid', $module->getVar('mid'))); $confcount = count($configs); if ($confcount > 0) { $msgs[] = _MD_AM_CONFIGOPTIONS_DELETE; for ($i = 0; $i < $confcount; $i++) { if (!$config_handler->deleteConfig($configs[$i])) { $msgs[] = sprintf(' <span style="color:#ff0000;">' . _MD_AM_CONFIGOPTION_DELETE_FAIL .'</span>', '<strong>' . icms_conv_nr2local($configs[$i]->getvar('conf_id')) . '</strong>'); } else { $msgs[] = sprintf(' ' . _MD_AM_CONFIGOPTION_DELETED, '<strong>' . icms_conv_nr2local($configs[$i]->getVar('conf_id')) . '</strong>'); } } } } // delete autotasks $atasks = $module->getInfo('autotasks'); if (isset($atasks) && is_array($atasks) && (count($atasks) > 0)) { $msgs[] = _MD_AM_AUTOTASKS_DELETE; $atasks_handler = &icms_getModuleHandler('autotasks', 'system'); $criteria = new icms_db_criteria_Compo(); $criteria->add(new icms_db_criteria_Item('sat_type', 'addon/' . $module->getInfo('dirname'))); $atasks_handler->deleteAll($criteria); unset($atasks_handler, $criteria, $taskData); } unset($atasks); // delete urllinks $urllink_handler = icms::handler('icms_data_urllink'); $urllink_handler->deleteAll(icms_buildCriteria(array("mid" => $module->getVar("mid")))); // delete files $file_handler = icms::handler('icms_data_file'); $file_handler->deleteAll(icms_buildCriteria(array("mid" => $module->getVar("mid")))); // execute module specific install script if any $uninstall_script = $module->getInfo('onUninstall'); $ModName = ($module->getInfo('modname') != '') ? trim($module->getInfo('modname')) : $dirname; if (FALSE !== $uninstall_script && trim($uninstall_script) != '') { include_once ICMS_MODULES_PATH . '/' . $dirname . '/' . trim($uninstall_script); if (function_exists('xoops_module_uninstall_' . $ModName)) { $func = 'xoops_module_uninstall_' . $ModName; if (!$func($module)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = $module->messages; $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } elseif (function_exists('icms_module_uninstall_' . $ModName)) { $func = 'icms_module_uninstall_' . $ModName; if (!$func($module)) { $msgs[] = sprintf(_MD_AM_FAIL_EXEC, '<strong>' . $func . '</strong>'); } else { $msgs[] = $module->messages; $msgs[] = sprintf(_MD_AM_FUNCT_EXEC, '<strong>' . $func . '</strong>'); } } } $msgs[] = '</code><p>' . sprintf(_MD_AM_OKUNINS, "<strong>" . $module->getVar('name') . "</strong>") . '</p>'; } $ret = '<code>' . implode('<br />', $msgs); return $ret; } }