diff --git a/e107_plugins/pm/e_url/main.php b/e107_plugins/pm/e_url/main.php
deleted file mode 100644
index 12159a64a..000000000
--- a/e107_plugins/pm/e_url/main.php
+++ /dev/null
@@ -1,15 +0,0 @@
-e107->url->create('pm/'.$action, $params, $options);
+ }
/**
* Send an email to notify of a PM
@@ -344,7 +349,7 @@ class private_message
{
require_once(e_HANDLER.'mail.php');
$subject = LAN_PM_100.SITENAME;
- $pmlink = SITEURLBASE.e_PLUGIN_ABS.'pm/pm.php?show.'.$pmid;
+ $pmlink = $this->url('show', 'id='.$pmid, 'full=1&encode=0');
$txt = LAN_PM_101.SITENAME."\n\n";
$txt .= LAN_PM_102.USERNAME."\n";
$txt .= LAN_PM_103.$pmInfo['pm_subject']."\n";
@@ -368,7 +373,7 @@ class private_message
{
require_once(e_HANDLER.'mail.php');
$subject = LAN_PM_106.$pmInfo['sent_name'];
- $pmlink = SITEURLBASE.e_PLUGIN_ABS."pm/pm.php?show.{$pmInfo['pm_id']}";
+ $pmlink = $this->url('show', 'id='.$pmInfo['pm_id'], 'full=1&encode=0');
$txt = str_replace("{UNAME}", $pmInfo['sent_name'], LAN_PM_107).date('l F dS Y h:i:s A')."\n\n";
$txt .= LAN_PM_108.date('l F dS Y h:i:s A', $pmInfo['pm_sent'])."\n";
$txt .= LAN_PM_103.$pmInfo['pm_subject']."\n";
@@ -698,4 +703,3 @@ class private_message
}
}
}
-?>
\ No newline at end of file
diff --git a/e107_plugins/pm/pm_shortcodes.php b/e107_plugins/pm/pm_shortcodes.php
index 0e3d607bb..749493c1c 100755
--- a/e107_plugins/pm/pm_shortcodes.php
+++ b/e107_plugins/pm/pm_shortcodes.php
@@ -8,10 +8,8 @@
*
* PM plugin - shortcodes
*
- * $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $URL$
+ * $Id$
*/
@@ -223,7 +221,8 @@ class pm_handler_shortcodes
foreach($attachments as $a)
{
list($timestamp, $fromid, $rand, $filename) = explode("_", $a, 4);
- $ret .= "{$filename}
";
+ $url = $this->url('action/get', array('id' => $this->pmInfo['pm_id'], 'index' => $i));
+ $ret .= "{$filename}
";
$i++;
}
$ret = substr($ret, 0, -3);
@@ -345,8 +344,13 @@ class pm_handler_shortcodes
if('link' == $prm[0])
{
$extra = '';
+ // TODO - go with only one route version - view/message ???
if (isset($prm[1])) $extra = '.'.$prm[1];
- $ret = "".$ret."";
+ if($extra == 'inbox') $url = $this->url('message', 'id='.$this->pmInfo['pm_id']);
+ elseif($extra == 'outbox') $url = $this->url('sent', 'id='.$this->pmInfo['pm_id']);
+ else $url = $this->url('show', 'id='.$this->pmInfo['pm_id']);
+
+ $ret = "".$ret."";
}
return $ret;
}
@@ -356,7 +360,7 @@ class pm_handler_shortcodes
{
if('link' == $parm)
{
- return "{$this->pmInfo['user_name']}";
+ return " $this->pmInfo['pm_from'], 'name' => $this->pmInfo['user_name']))."'>{$this->pmInfo['user_name']}";
}
else
{
@@ -394,11 +398,11 @@ class pm_handler_shortcodes
{
if(in_array($this->pmInfo['pm_from'], $this->pmBlocks))
{
- return "
";
+ return "pmInfo['pm_from'])."'>
";
}
else
{
- return "
";
+ return "pmInfo['pm_from'])."'>
";
}
}
@@ -413,7 +417,9 @@ class pm_handler_shortcodes
{
$extra = '.'.($this->pmInfo['pm_from'] == USERID ? 'outbox' : 'inbox');
}
- return "
";
+ if($extra !== 'inbox' && $extra !== 'outbox') return '';
+ $action = $extra == 'outbox' ? 'delete-out' : 'delete-in';
+ return "pmInfo['pm_id'])."'>
";
}
@@ -429,7 +435,7 @@ class pm_handler_shortcodes
{
if('link' == $parm)
{
- return "{$this->pmInfo['user_name']}";
+ return " $this->pmInfo['pm_to'], 'name' => $this->pmInfo['user_name']))."'>{$this->pmInfo['user_name']}";
}
else
{
@@ -453,8 +459,9 @@ class pm_handler_shortcodes
{
if($this->pmInfo['pm_to'] == USERID)
{
+ // pm_id is mapped insisde the config to id key
$ret = "
-
";
@@ -468,7 +475,7 @@ class pm_handler_shortcodes
$pm_outbox = $this->pmManager->pm_getInfo('outbox');
if($pm_outbox['outbox']['filled'] < 100)
{
- $link = $this->e107->url->getUrl('pm','main',array('f' => 'send'));
+ $link = $this->url('new');
return "".PM_SEND_LINK."";
}
return '';
@@ -517,7 +524,7 @@ class pm_handler_shortcodes
}
if('link' == $parm)
{
- return "{$this->pmBlocked['user_name']}";
+ return " $this->pmBlocked['pm_block_from'], 'name' => $this->pmBlocked['user_name']))."'>{$this->pmBlocked['user_name']}";
}
else
{
@@ -535,7 +542,7 @@ class pm_handler_shortcodes
public function sc_pm_blocked_delete()
{
- return "
";
+ return " $this->pmBlocked['pm_block_from']))."'>
";
}
@@ -543,6 +550,15 @@ class pm_handler_shortcodes
{
return "";
}
+
+ /**
+ * Convinient url assembling shortcut
+ */
+ public function url($action, $params = array(), $options = array())
+ {
+ if(strpos($action, '/') === false) $action = 'view/'.$action;
+ $this->e107->url->create('pm/'.$action, $params, $options);
+ }
}
diff --git a/e107_plugins/pm/url/url.php b/e107_plugins/pm/url/url.php
new file mode 100644
index 000000000..94e47a6d4
--- /dev/null
+++ b/e107_plugins/pm/url/url.php
@@ -0,0 +1,158 @@
+ array(
+ 'noSingleEntry' => true, // [optional] default false; disallow this module to be shown via single entry point when this config is used
+ 'legacy' => '{e_PLUGIN}pm/pm.php', // this config won't work in single entry point mod (legacy not used at all), so just set this to default plugin file to notify router it's legacy module
+ 'format' => 'get', // get|path - notify core for the current URL format, if set to 'get' rules will be ignored
+ 'selfCreate' => true, // [optional] default false; use only this->create() method, no core routine URL creating
+ 'defaultRoute' => 'view/inbox', // [optional] default empty; route (no leading module) used when module is found with no additional controller/action information e.g. /news/
+ ),
+
+ // rule set array
+ 'rules' => array()
+ );
+
+ }
+
+ /**
+ * Describe all pm routes.
+ * Routes vs legacy queries:
+ * view/inbox -> ?inbox (default route, resolved on index/index)
+ * view/outbox -> ?outbox
+ * view/message?id=xxx -> ?show.xxx.inbox
+ * view/sent?id=xxx -> ?show.xxx.outbox
+ * view/show?id=xxx -> ?show.xxx (investigate why we have dupps, good time to remove them!)
+ * view/reply?id=xxx -> ?reply.xxx
+ * view/send -> ?send
+ * action/delete-in?id=xx -> ?del.xxx.inbox
+ * action/delete-out?id=xx -> ?del.xxx.outbox
+ * action/delete-blocked?id=xxx -> ?delblocked.xxx
+ * action/block?id=xx -> ?block.xxx
+ * action/unblock?id=xx -> ?unblock.xxx
+ * action/get?id=xxx&index=yyy -> ?get.xxx.yyy
+ */
+ public function create($route, $params = array(), $options = array())
+ {
+ if(is_string($route)) $route = explode('/', $route, 2);
+ if(!varset($route[0]) || 'index' == $route[0]) $route[0] = 'view';
+ if(!varset($route[1])) $route[1] = 'inbox';
+ $base = e107::getInstance()->getFolder('plugins').'pm/';
+
+ //var_dump($options, $route, $params);
+ if($route[0] == 'view')
+ {
+ if(!isset($params['id']) && isset($params['pm_id'])) $params['id'] = $params['pm_id'];
+ switch($route[1])
+ {
+ case 'index':
+ case 'inbox':
+ $this->legacyQueryString = 'inbox';
+ return $base.'pm.php?inbox';
+ break;
+
+ case 'outbox':
+ $this->legacyQueryString = 'outbox';
+ return $base.'pm.php?outbox';
+ break;
+
+ // we could just remove them all and let only 'message' live
+ case 'show':
+ $this->legacyQueryString = 'show.'.$params['id'];
+ return $base.'pm.php?show.'.$params['id'];
+ break;
+
+ case 'message':
+ $this->legacyQueryString = 'show.'.$params['id'].'.inbox';
+ return $base.'pm.php?show.'.$params['id'].'.inbox';
+ break;
+
+ case 'sent':
+ $this->legacyQueryString = 'show.'.$params['id'].'.outbox';
+ return $base.'pm.php?show.'.$params['id'].'.outbox';
+ break;
+
+ case 'reply':
+ $this->legacyQueryString = 'reply.'.$params['id'];
+ return $base.'pm.php?reply.'.$params['id'];
+ break;
+
+ case 'new':
+ $this->legacyQueryString = 'send';
+ return $base.'pm.php?send';
+ break;
+ }
+ }
+ elseif($route[0] == 'action')
+ {
+ if(!isset($params['id']) && isset($params['pm_id'])) $params['id'] = $params['pm_id'];
+ switch($route[1])
+ {
+ case 'delete-in':
+ $this->legacyQueryString = 'del.'.$params['id'].'.inbox';
+ return $base.'pm.php?del.'.$params['id'].'.inbox';
+ break;
+
+ case 'delete-out':
+ $this->legacyQueryString = 'del.'.$params['id'].'.outbox';
+ return $base.'pm.php?del.'.$params['id'].'.outbox';
+ break;
+
+ case 'delete-blocked':
+ $this->legacyQueryString = 'delblocked.'.$params['id'];
+ return $base.'pm.php?delblocked.'.$params['id'];
+ break;
+
+ case 'block':
+ $this->legacyQueryString = 'block.'.$params['id'];
+ return $base.'pm.php?block.'.$params['id'];
+ break;
+
+ case 'unblock':
+ $this->legacyQueryString = 'unblock.'.$params['id'];
+ return $base.'pm.php?unblock.'.$params['id'];
+ break;
+
+ case 'get':
+ $this->legacyQueryString = 'get.'.$params['id'].'.'.$params['index'];
+ return $base.'pm.php?get.'.$params['id'].'.'.$params['index'];
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Admin callback
+ * Language file not loaded as all language data is inside the lan_eurl.php (loaded by default on administration URL page)
+ */
+ public function admin()
+ {
+ // static may be used for performance
+ e107::plugLan('pm', 'url', true);
+ static $admin = array(
+ 'labels' => array(
+ 'name' => PM_LAN_URL_NAME, // Module name
+ 'label' => PM_LAN_URL_DEFAULT_LABEL, // Current profile name
+ 'description' => PM_LAN_URL_DEFAULT_DESCR, //
+ ),
+ 'form' => array(), // Under construction - additional configuration options
+ 'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
+ );
+
+ return $admin;
+ }
+}