1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-14 01:22:13 +02:00

Fixes for Private Messaging via the admin area.

This commit is contained in:
Cameron 2015-02-16 02:22:47 -08:00
parent 02766efff5
commit 9501745c07
5 changed files with 126 additions and 61 deletions

View File

@ -39,7 +39,7 @@ class eurl_admin extends e_admin_dispatcher
'main/config' => array('caption'=> LAN_EURL_MENU_CONFIG, 'perm' => 'L'),
'main/alias' => array('caption'=> LAN_EURL_MENU_ALIASES, 'perm' => 'L'),
'main/settings' => array('caption'=> LAN_EURL_MENU_SETTINGS, 'perm' => 'L'),
'main/simple' => array('caption'=> LAN_EURL_MENU_REDIRECTS, 'perm' => 'L'), //TODO LAN
'main/simple' => array('caption'=> LAN_EURL_MENU_REDIRECTS, 'perm' => 'L'),
// 'main/help' => array('caption'=> LAN_EURL_MENU_HELP, 'perm' => 'L'),
);
@ -666,7 +666,7 @@ class eurl_admin_form_ui extends e_admin_form_ui
[Miro] Solution comes from the module itself, not related with URL assembling in anyway (as per latest Skype discussion)
*/
// FIXME TODO XXX
// Global On/Off Switch Example
// [Miro] there is no reason of switch, everything could go through single entry point at any time, without a need of .htaccess (path info)

View File

@ -95,7 +95,10 @@ class generic_ui extends e_admin_ui
}
}
public function afterDelete($data)
{
// $sql2->db_Delete('banlist', "banlist_ip='{$banIP}'");
}
}

View File

@ -696,9 +696,9 @@ class admin_shortcodes
$countDisp = '';
}
$inboxUrl = e_PLUGIN.'pm/admin_config.php?'.'searchquery=&iframe=1&filter_options=bool__pm_to__'.USERID;
$outboxUrl = e_PLUGIN.'pm/admin_config.php?'.'searchquery=&iframe=1&filter_options=bool__pm_from__'.USERID;
$composeUrl = e_PLUGIN.'pm/admin_config.php?'.'mode=main&iframe=1&action=create';
$inboxUrl = e_PLUGIN.'pm/admin_config.php?mode=inbox&action=list&iframe=1';
$outboxUrl = e_PLUGIN.'pm/admin_config.php?mode=outbox&action=list&iframe=1';
$composeUrl = e_PLUGIN.'pm/admin_config.php?mode=outbox&action=create&iframe=1';
$text = '<ul class="nav navbar-nav nav-pills">
<li class="dropdown">

View File

@ -1136,7 +1136,7 @@ class e_user_provider
}
public function init()
{
if(!e107::getPref('social_login_active', false))

View File

@ -16,7 +16,13 @@ class pm_admin extends e_admin_dispatcher
protected $modes = array(
'main' => array(
'inbox' => array(
'controller' => 'private_msg_ui',
'path' => null,
'ui' => 'private_msg_form_ui',
'uipath' => null
),
'outbox' => array(
'controller' => 'private_msg_ui',
'path' => null,
'ui' => 'private_msg_form_ui',
@ -35,8 +41,9 @@ class pm_admin extends e_admin_dispatcher
protected $adminMenu = array(
'main/list' => array('caption'=> "Inbox", 'perm' => 'P'),
'main/create' => array('caption'=> "Compose", 'perm' => 'P'),
'inbox/list' => array('caption'=> "Inbox", 'perm' => 'P'),
'outbox/list' => array('caption'=> "Outbox", 'perm' => 'P'),
'outbox/create' => array('caption'=> "Compose", 'perm' => 'P'),
// 'block/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
// 'block/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
@ -66,17 +73,17 @@ class private_msg_ui extends e_admin_ui
protected $pluginName = 'pm';
protected $table = 'private_msg';
protected $pid = 'pm_id';
protected $perPage = 5;
protected $listQry = 'SELECT p.*, u.user_name FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_from ';
protected $listOrder = "pm_sent DESC";
protected $perPage = 7;
protected $listQry = '';
protected $listOrder = "p.pm_id DESC";
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'pm_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'pm_from' => array ( 'title' => 'From', 'type' => 'user', 'noedit'=>true, 'data' => 'int', 'filter'=>true, 'width' => '5%%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'pm_to' => array ( 'title' => 'To', 'type' => 'user', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'pm_from' => array ( 'title' => 'From', 'type' => 'method', 'noedit'=>true, 'data' => 'int', 'filter'=>true, 'width' => '5%%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'pm_to' => array ( 'title' => 'To', 'type' => 'user', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'pm_sent' => array ( 'title' => LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => '15%', 'help' => '', 'readParms' => '', 'writeParms' => 'auto=1&readonly=1', 'class' => 'center', 'thclass' => 'center', ),
'pm_subject' => array ( 'title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => '15%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'pm_text' => array ( 'title' => 'Message', 'type' => 'bbarea', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => 'expand=1&truncate=50', 'writeParms' => 'size=medium', 'class' => 'left', 'thclass' => 'left', ),
'pm_subject' => array ( 'title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => '15%', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xlarge'), 'class' => 'left', 'thclass' => 'left', ),
'pm_text' => array ( 'title' => 'Message', 'type' => 'bbarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => 'expand=1&truncate=50', 'writeParms' => 'rows=5&size=block&cols=80', 'class' => 'left', 'thclass' => 'left', ),
'pm_read' => array ( 'title' => 'Read', 'type' => 'boolean', 'noedit'=>1, 'data' => 'int', 'batch'=>true, 'filter'=>true, 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'pm_sent_del' => array ( 'title' => 'Del', 'type' => 'boolean', 'noedit'=>true, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
@ -84,65 +91,79 @@ class private_msg_ui extends e_admin_ui
'pm_attachments' => array ( 'title' => 'Attachments', 'type' => 'text', 'noedit'=>true, 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'pm_option' => array ( 'title' => 'Option', 'type' => 'text', 'noedit'=>true, 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'pm_size' => array ( 'title' => 'Size', 'type' => 'boolean', 'noedit'=>true, 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'options' => array ( 'title' => 'Options', 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
'options' => array ( 'title' => LAN_OPTIONS, 'type' => 'method', 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
);
protected $fieldpref = array('pm_id', 'pm_from', 'pm_to', 'pm_sent', 'pm_read', 'pm_subject', 'pm_text');
// optional
public function init()
{
// $this->listQry = "SELECT p.*,u.user_name FROM #private_msg AS p LEFT JOIN #user AS u ON p.pm_from = u.user_id ";
// $this->listQry = "SELECT p.*,u.user_name FROM #private_msg AS p LEFT JOIN #user AS u ON p.pm_from = u.user_id ";
if($this->getMode() == 'inbox')
{
$this->listQry = 'SELECT p.*, u.user_name, f.user_name AS fromuser FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_to
LEFT JOIN #user as f on f.user_id = p.pm_from WHERE p.pm_to = '.USERID;
$this->fields['pm_to']['nolist'] = true;
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
}
if($this->getMode() == 'outbox')
{
$this->listQry = 'SELECT p.*, u.user_name, f.user_name AS fromuser FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_to
LEFT JOIN #user as f on f.user_id = p.pm_from WHERE p.pm_from = '.USERID;
$this->fields['pm_from']['nolist'] = true;
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
}
if($this->getAction() == 'create')
{
$this->fields['pm_to']['writeParms']['default'] = 99999999;
$this->fields['pm_to']['writeParms']['required'] = 1;
$this->fields['pm_subject']['writeParms']['required'] = 1;
if(!empty($_GET['to']))
{
$this->fields['pm_to']['writeParms']['default'] = intval($_GET['to']);
$this->addTitle('Reply');
}
if(!empty($_GET['subject']))
{
$this->fields['pm_subject']['writeParms']['default'] = "Re: ". base64_decode($_GET['subject']);
}
}
if(vartrue($_GET['iframe']))
{
define('e_IFRAME', true);
}
// Prevent snooping of other people's messages. ;-) //XXX Not working Yet. FIXME!
if(varset($_GET['filter_options']))
{
list($tmp,$field,$id) = explode("__",$_GET['filter_options']);
if($field == 'pm_to') // Inbox
{
$this->listQry = "SELECT p.*, u.user_name FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_from ";
$this->fields['pm_to']['nolist'] = true;
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
}
if($field == 'pm_from') // Outbox
{
$this->listQry = "SELECT p.*, u.user_name FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_to ";
$this->fields['pm_from']['nolist'] = true;
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
}
// echo "FIELD = ".$field;
// $this->getDispatcher()->setRequest('filter_options')
if($field == 'pm_to' && $id != USERID)
{
$_GET['filter_options'] = 'batch__pm_to__'.USERID;
}
if($field == 'pm_from' && $id != USERID)
{
echo "<h3>HI THERE</h3>";
$_GET['filter_options'] = 'batch__pm_from__'.USERID;
}
}
}
}
public function beforeCreate($new_data)
{
if(empty($new_data['pm_to']))
{
e107::getMessage()->addError('Please enter a recipient in the "To" field.');
return false;
}
$new_data['pm_size'] = strlen($new_data['pm_text']);
$new_data['pm_from'] = USERID;
return $new_data;
}
/*
protected = array(
'pref_type' => array('title'=> 'type', 'type'=>'text', 'data' => 'string', 'validate' => true),
@ -170,6 +191,47 @@ class private_msg_ui extends e_admin_ui
class private_msg_form_ui extends e_admin_form_ui
{
function options($parms, $value, $id, $attributes)
{
// return $this->renderValue('options',$value,$att,$id);;
$tp = e107::getParser();
$mode = $this->getController()->getMode();
if($mode == 'inbox')
{
$text = "";
$pmData = $this->getController()->getListModel()->getData();
if($pmData['pm_from'] != USERID)
{
$link = e_SELF."?";
$link .= (!empty($_GET['iframe'])) ? 'mode=inbox&iframe=1' : 'mode=outbox';
$link .= "&action=create&to=".intval($pmData['pm_from'])."&subject=".base64_encode($pmData['pm_subject']);
$text .= "<a href='".$link."' class='btn' title='Reply'>".$tp->toGlyph('fa-reply', array('size'=>'1x'))."</a>";
}
// $text .= $this->renderValue('options',$value,$attr,$id);
return $text;
}
}
function pm_from($curVal, $mode)
{
if($mode == 'read')
{
$pmData = $this->getController()->getListModel()->getData();
}
return $pmData['fromuser'];
}
}
/*