mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
PM - URL support, old URL config removed
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
// $Id$
|
||||
function url_pm_main($parms)
|
||||
{
|
||||
switch($parms['f'])
|
||||
{
|
||||
case 'box':
|
||||
return e_PLUGIN_ABS."pm/pm.php?{$parms['box']}";
|
||||
break;
|
||||
|
||||
case 'send':
|
||||
return e_PLUGIN_ABS."pm/pm.php?send";
|
||||
break;
|
||||
}
|
||||
}
|
@@ -2,16 +2,14 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* PM plugin - base class API
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_class.php,v $
|
||||
* $Revision$
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
@@ -328,7 +326,14 @@ class private_message
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -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 .= "<a href='".e_SELF."?get.{$this->pmInfo['pm_id']}.{$i}'>{$filename}</a><br />";
|
||||
$url = $this->url('action/get', array('id' => $this->pmInfo['pm_id'], 'index' => $i));
|
||||
$ret .= "<a href='".$url."'>{$filename}</a><br />";
|
||||
$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 = "<a href='".e_PLUGIN_ABS."pm/pm.php?show.{$this->pmInfo['pm_id']}{$extra}'>".$ret."</a>";
|
||||
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 = "<a href='".$ret."'>".$ret."</a>";
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -356,7 +360,7 @@ class pm_handler_shortcodes
|
||||
{
|
||||
if('link' == $parm)
|
||||
{
|
||||
return "<a href='".e_HTTP."user.php?id.{$this->pmInfo['pm_from']}'>{$this->pmInfo['user_name']}</a>";
|
||||
return "<a href='".$this->e107->url->create('user/profile/view', array('id' => $this->pmInfo['pm_from'], 'name' => $this->pmInfo['user_name']))."'>{$this->pmInfo['user_name']}</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -394,11 +398,11 @@ class pm_handler_shortcodes
|
||||
{
|
||||
if(in_array($this->pmInfo['pm_from'], $this->pmBlocks))
|
||||
{
|
||||
return "<a href='".e_PLUGIN_ABS."pm/pm.php?unblock.{$this->pmInfo['pm_from']}'><img src='".e_PLUGIN_ABS."pm/images/mail_unblock.png' title='".LAN_PM_51."' alt='".LAN_PM_51."' class='icon S16' /></a>";
|
||||
return "<a href='".$this->url('action/unblock', 'id='.$this->pmInfo['pm_from'])."'><img src='".e_PLUGIN_ABS."pm/images/mail_unblock.png' title='".LAN_PM_51."' alt='".LAN_PM_51."' class='icon S16' /></a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<a href='".e_PLUGIN_ABS."pm/pm.php?block.{$this->pmInfo['pm_from']}'><img src='".e_PLUGIN_ABS."pm/images/mail_block.png' title='".LAN_PM_50."' alt='".LAN_PM_50."' class='icon S16' /></a>";
|
||||
return "<a href='".$this->url('action/block', 'id='.$this->pmInfo['pm_from'])."'><img src='".e_PLUGIN_ABS."pm/images/mail_block.png' title='".LAN_PM_50."' alt='".LAN_PM_50."' class='icon S16' /></a>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +417,9 @@ class pm_handler_shortcodes
|
||||
{
|
||||
$extra = '.'.($this->pmInfo['pm_from'] == USERID ? 'outbox' : 'inbox');
|
||||
}
|
||||
return "<a href='".e_PLUGIN_ABS."pm/pm.php?del.{$this->pmInfo['pm_id']}{$extra}'><img src='".e_PLUGIN_ABS."pm/images/mail_delete.png' title='".LAN_PM_52."' alt='".LAN_PM_52."' class='icon S16' /></a>";
|
||||
if($extra !== 'inbox' && $extra !== 'outbox') return '';
|
||||
$action = $extra == 'outbox' ? 'delete-out' : 'delete-in';
|
||||
return "<a href='".$this->url('action/'.$action, 'id='.$this->pmInfo['pm_id'])."'><img src='".e_PLUGIN_ABS."pm/images/mail_delete.png' title='".LAN_PM_52."' alt='".LAN_PM_52."' class='icon S16' /></a>";
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +435,7 @@ class pm_handler_shortcodes
|
||||
{
|
||||
if('link' == $parm)
|
||||
{
|
||||
return "<a href='".e_HTTP."user.php?id.{$this->pmInfo['pm_to']}'>{$this->pmInfo['user_name']}</a>";
|
||||
return "<a href='".$this->e107->url->create('user/profile/view', array('id' => $this->pmInfo['pm_to'], 'name' => $this->pmInfo['user_name']))."'>{$this->pmInfo['user_name']}</a>";
|
||||
}
|
||||
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 = "
|
||||
<form method='post' action='".e_SELF."?reply.{$this->pmInfo['pm_id']}'>
|
||||
<form method='post' action='".$this->url('reply', $this->pmInfo)."'>
|
||||
<input type='checkbox' name='quote' /> ".LAN_PM_54."  <input class='button' type='submit' name='reply' value='".LAN_PM_55."' />
|
||||
</form>
|
||||
";
|
||||
@@ -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 "<a href='{$link}'>".PM_SEND_LINK."</a>";
|
||||
}
|
||||
return '';
|
||||
@@ -517,7 +524,7 @@ class pm_handler_shortcodes
|
||||
}
|
||||
if('link' == $parm)
|
||||
{
|
||||
return "<a href='".e_HTTP."user.php?id.{$this->pmBlocked['pm_block_from']}'>{$this->pmBlocked['user_name']}</a>";
|
||||
return "<a href='".$this->e107->url->create('user/profile/view', array('id' => $this->pmBlocked['pm_block_from'], 'name' => $this->pmBlocked['user_name']))."'>{$this->pmBlocked['user_name']}</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -535,7 +542,7 @@ class pm_handler_shortcodes
|
||||
|
||||
public function sc_pm_blocked_delete()
|
||||
{
|
||||
return "<a href='".e_PLUGIN_ABS."pm/pm.php?delblocked.{$this->pmBlocked['pm_block_from']}'><img src='".e_PLUGIN_ABS."pm/images/mail_delete.png' title='".LAN_PM_52."' alt='".LAN_PM_52."' class='icon S16' /></a>";
|
||||
return "<a href='".$this->url('action/delete-blocked', array('id' => $this->pmBlocked['pm_block_from']))."'><img src='".e_PLUGIN_ABS."pm/images/mail_delete.png' title='".LAN_PM_52."' alt='".LAN_PM_52."' class='icon S16' /></a>";
|
||||
}
|
||||
|
||||
|
||||
@@ -543,6 +550,15 @@ class pm_handler_shortcodes
|
||||
{
|
||||
return "<input type='submit' name='pm_delete_blocked_selected' class='button' value='".LAN_PM_53."' />";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
158
e107_plugins/pm/url/url.php
Normal file
158
e107_plugins/pm/url/url.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id$
|
||||
*
|
||||
* PM Default URL configuration
|
||||
* TODO - SEF URL configuration
|
||||
*/
|
||||
class plugin_pm_url extends eUrlConfig
|
||||
{
|
||||
public function config()
|
||||
{
|
||||
return array(
|
||||
|
||||
'config' => 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user