/** * Sets up initial settings for the smileys mod or upgrades * the settings from old versions. * @return modinfo - Updated module information. */ function phorum_mod_smileys_initsettings() { $PHORUM = $GLOBALS["PHORUM"]; global $MOD_SMILEY_DEFAULT_PREFIX; global $MOD_SMILEY_DEFAULT_SMILEYS; $modinfo = isset($PHORUM["mod_smileys"]) ? $PHORUM["mod_smileys"] : array(); // Keep track if we need to store settings in the database. $do_db_update = false; // Set default for the image prefix path. if (!isset($modinfo['prefix'])) { $modinfo['prefix'] = $MOD_SMILEY_DEFAULT_PREFIX; // So phorum_mod_smileys_available() sees it right away. $GLOBALS["PHORUM"]["mod_smileys"]["prefix"] = $MOD_SMILEY_DEFAULT_PREFIX; $do_db_update = true; } // Set a default list of smileys or upgrade from existing smiley mod. if (!isset($modinfo['smileys'])) { $modinfo['smileys'] = array(); // Check if we have smileys from the previous version of the // smiley mod. These were stored at the same level as the // settings. $upgrade_list = array(); if (isset($PHORUM["mod_smileys"])) { foreach ($PHORUM["mod_smileys"] as $id => $smiley) { if (is_numeric($id)) { $upgrade_list[$id] = $smiley; } } } // We have an existing list of smileys to upgrade. Move the // smileys to their new location. if (count($upgrade_list)) { foreach ($upgrade_list as $id => $smiley) { unset($modinfo[$id]); $modinfo["smileys"][$id] = $smiley; } $do_db_update = true; } else { foreach ($MOD_SMILEY_DEFAULT_SMILEYS as $search => $data) { list($smiley, $alt) = preg_split('/\\s+/', $data, 2); $modinfo["smileys"][] = array("search" => $search, "alt" => $alt, "smiley" => $smiley, "uses" => 2); } $do_db_update = true; } } // Store the changed settings in the database. Errors are // silently ignored here, to keep them away from end-users. if ($do_db_update) { list($modinfo, $message) = phorum_mod_smileys_store($modinfo); $GLOBALS["PHORUM"]["mod_smileys"] = $modinfo; return $modinfo; } }
$do_db_update = true; $okmsg = "The smiley has been deleted successfully"; } // ACTION: Startup editing a smiley from the list. if (isset($_GET["edit"])) { $smiley_id = $_GET["smiley_id"]; } } // --------------------------------------------------------------------------- // Do database updates. // --------------------------------------------------------------------------- // Changes have been made to the smileys configuration. // Store these changes in the database. if (empty($error) && $do_db_update) { $PHORUM['mod_smileys']['cache_key'] = isset($PHORUM['mod_smileys']['cache_key']) ? $PHORUM['mod_smileys']['cache_key'] + 1 : 0; list($modinfo, $message) = phorum_mod_smileys_store($PHORUM["mod_smileys"]); if ($modinfo == NULL) { $error = $message; } else { if (empty($okmsg)) { $okmsg = $message; } $PHORUM["mod_smileys"] = $modinfo; // Back to the startscreen unset($_POST); $smiley_id = 'NEW'; } } // --------------------------------------------------------------------------- // Display the settings page // ---------------------------------------------------------------------------