Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]
| Date | Directory [filter] | File(s) [view] | Author [filter] |
| 16 Aug 2002 15:49:19 | postnuke_official/html/includes | pnMod.php,1.77,1.78 pnAPI.php,1.154,1.155 | Mike |
| module aliases | |||
Update of /home/cvsroot/postnuke_official/html/includes
In directory ns7.hostnuke.net:/tmp/cvs-serv7832
Modified Files:
pnMod.php pnAPI.php
Log Message:
module aliases
Index: pnMod.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/includes/pnMod.php,v
retrieving revision 1.77
retrieving revision 1.78
diff -C2 -d -r1.77 -r1.78
*** pnMod.php 10 Aug 2002 17:40:37 -0000 1.77
--- pnMod.php 16 Aug 2002 15:49:17 -0000 1.78
***************
*** 1206,1208 ****
--- 1206,1326 ----
}
+ /**
+ * check if a module name is an alias for some other module
+ * (only used for short URL support at the moment)
+ *
+ * @access private
+ * @param modname name of the module
+ * @returns mixed
+ * @return string containing the module name, or null if database error
+ * @raise BAD_PARAM
+ */
+ function pnModGetAlias($modname)
+ {
+ if (empty($modname)) {
+ $msg = pnML('Invalid module name');
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+ new SystemException($msg));
+ return;
+ }
+
+ $aliases = pnConfigGetVar('System.ModuleAliases');
+
+ if (isset($aliases) && !empty($aliases[$modname])) {
+ return $aliases[$modname];
+ } else {
+ return $modname;
+ }
+ }
+
+ /**
+ * define a module name as an alias for some other module
+ * (only used for short URL support at the moment)
+ *
+ * @access public
+ * @param modname name of the 'fake' module you want to define
+ * @param alias name of the 'real' module you want to assign it to
+ * @returns bool
+ * @return true on success, false on failure
+ * @raise BAD_PARAM
+ */
+ function pnModSetAlias($modname,$alias)
+ {
+ if (empty($modname) || empty($alias)) {
+ $msg = pnML('Invalid module name or alias');
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+ new SystemException($msg));
+ return false;
+ }
+
+ // Check if the module name we want to define is already in use
+ $modid = pnModGetIDFromName($modname);
+ if (isset($modid)) {
+ $msg = pnML('Module name #(1) is already in use',
+ pnVarPrepForDisplay($modname));
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+ new SystemException($msg));
+ return false;
+ }
+ if (pnExceptionMajor() != PN_NO_EXCEPTION) {
+ // Ignore exceptions here!
+ pnExceptionFree();
+ }
+
+ // Check if the alias we want to set it to *does* exist
+ $modid = pnModGetIDFromName($alias);
+ if (!isset($modid)) {
+ $msg = pnML('Alias #(1) is unknown',
+ pnVarPrepForDisplay($alias));
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+ new SystemException($msg));
+ return false;
+ }
+
+ // Get the list of current aliases
+ $aliases = pnConfigGetVar('System.ModuleAliases');
+
+ if (!isset($aliases)) {
+ $aliases = array();
+ }
+
+ // TODO: what if 2 modules want to use the same aliases ?
+ $aliases[$modname] = $alias;
+ pnConfigSetVar('System.ModuleAliases', $aliases);
+
+ return true;
+ }
+
+ /**
+ * remove an alias for a module name
+ * (only used for short URL support at the moment)
+ *
+ * @access public
+ * @param modname name of the 'fake' module you want to remove
+ * @param alias name of the 'real' module it was assigned to (= verification)
+ * @returns bool
+ * @return true on success, false on failure
+ * @raise BAD_PARAM
+ */
+ function pnModDelAlias($modname, $alias)
+ {
+ if (empty($modname) || empty($alias)) {
+ $msg = pnML('Invalid module name or alias');
+ pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+ new SystemException($msg));
+ return false;
+ }
+
+ $aliases = pnConfigGetVar('System.ModuleAliases');
+
+ // Make sure we only delete it *if* it was assigned to the right alias
+ if (isset($aliases) && !empty($aliases[$modname]) &&
+ $aliases[$modname] == $alias) {
+ unset($aliases[$modname]);
+ pnConfigSetVar('System.ModuleAliases',$aliases);
+ }
+
+ return true;
+ }
+
?>
Index: pnAPI.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/includes/pnAPI.php,v
retrieving revision 1.154
retrieving revision 1.155
diff -C2 -d -r1.154 -r1.155
*** pnAPI.php 10 Aug 2002 17:55:40 -0000 1.154
--- pnAPI.php 16 Aug 2002 15:49:17 -0000 1.155
***************
*** 1021,1024 ****
--- 1021,1027 ----
$type = 'user';
}
+ // Check if this is an alias for some other module
+ $modname = pnModGetAlias($modname);
+ // Call the appropriate decode_shorturl function
if (pnConfigGetVar('System.UseShortURLsIfPossible') &&
pnModGetVar($modname, 'SupportShortURLs') &&
View Statistics - Next Notice - Previous Notice
| Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |