mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
userpicker() functioning correctly with jquery
This commit is contained in:
@@ -208,12 +208,11 @@ class e_form
|
||||
|
||||
if(vartrue($options['typeahead']))
|
||||
{
|
||||
$options['data-provide'] ="typeahead";
|
||||
if(vartrue($options['typeahead']) == 'users')
|
||||
{
|
||||
$options['data-source'] = e_BASE."user.php";
|
||||
$options['class'] .= " e-typeahead";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$options = $this->format_options('text', $name, $options);
|
||||
@@ -643,6 +642,14 @@ class e_form
|
||||
{
|
||||
if(!is_array($options)) parse_str($options, $options);
|
||||
|
||||
//TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ?
|
||||
|
||||
return $this->text($name_fld,$default_name,20, "typeahead=users&readonly=".vartrue($options['readonly']))
|
||||
.$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
$label_fld = str_replace('_', '-', $name_fld).'-upicker-lable';
|
||||
|
||||
//'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).'
|
||||
@@ -657,9 +664,9 @@ class e_form
|
||||
<div class="e-autocomplete"></div>
|
||||
</div>
|
||||
';
|
||||
// FIXME - switch to external JS, jQuery support
|
||||
|
||||
e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2);
|
||||
//TODO - external JS
|
||||
|
||||
e107::getJs()->footerInline("
|
||||
//autocomplete fields
|
||||
\$\$('input[name={$name_fld}]').each(function(el) {
|
||||
@@ -695,7 +702,7 @@ class e_form
|
||||
});
|
||||
");
|
||||
return $ret;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -1045,6 +1052,7 @@ class e_form
|
||||
$name = (strpos($name, '[') === false) ? $name.'[]' : $name;
|
||||
if(!is_array($selected)) $selected = explode(",",$selected);
|
||||
}
|
||||
|
||||
$text = $this->select_open($name, $options)."\n";
|
||||
|
||||
if(isset($options['default']))
|
||||
|
@@ -137,7 +137,11 @@ class pm_extended extends private_message
|
||||
$tpl_file = THEME.'pm_template.php';
|
||||
include_once(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
|
||||
$enc = (check_class($this->pmPrefs['attach_class']) ? "enctype='multipart/form-data'" : '');
|
||||
setScVar('pm_handler_shortcodes','pmInfo', $pm_info);
|
||||
// setScVar('pm_handler_shortcodes','pmInfo', $pm_info);
|
||||
|
||||
$sc = e107::getScBatch('pm',TRUE);
|
||||
$sc->setVars($pm_info);
|
||||
|
||||
$text = "<form {$enc} method='post' action='".e_SELF."' id='dataform'>
|
||||
<div><input type='hidden' name='numsent' value='{$pm_outbox['outbox']['total']}' />".
|
||||
$this->e107->tp->parseTemplate($PM_SEND_PM, TRUE).
|
||||
@@ -155,35 +159,39 @@ class pm_extended extends private_message
|
||||
|
||||
function show_inbox($start = 0)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
$tpl_file = THEME.'pm_template.php';
|
||||
include(is_readable($tpl_file) ? $tpl_file : e_PLUGIN.'pm/pm_template.php');
|
||||
|
||||
$pm_blocks = $this->block_get();
|
||||
$pmlist = $this->pm_get_inbox(USERID, $start, $this->pmPrefs['perpage']);
|
||||
|
||||
// setScVar('pm_handler_shortcodes', 'pmNextPrev', array('start' => $start, 'total' => $pmlist['total_messages']));
|
||||
|
||||
$sc = e107::getScBatch('pm',TRUE);
|
||||
$sc->pmNextPrev = array('start' => $start, 'total' => $pmlist['total_messages']);
|
||||
|
||||
$txt = "<form method='post' action='".e_SELF."?".e_QUERY."'>";
|
||||
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_HEADER, true);
|
||||
$txt .= $tp->parseTemplate($PM_INBOX_HEADER, true);
|
||||
|
||||
if($pmlist['total_messages'])
|
||||
{
|
||||
foreach($pmlist['messages'] as $rec)
|
||||
{
|
||||
if(trim($rec['pm_subject']) == '') { $rec['pm_subject'] = '['.LAN_PM_61.']'; }
|
||||
// setScVar('pm_handler_shortcodes','pmInfo', $rec);
|
||||
$sc->setVars($rec);
|
||||
|
||||
|
||||
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_TABLE, true);
|
||||
$txt .= $tp->parseTemplate($PM_INBOX_TABLE, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_EMPTY, true);
|
||||
$txt .= $tp->parseTemplate($PM_INBOX_EMPTY, true);
|
||||
}
|
||||
$txt .= $this->e107->tp->parseTemplate($PM_INBOX_FOOTER, true);
|
||||
|
||||
$txt .= $tp->parseTemplate($PM_INBOX_FOOTER, true);
|
||||
$txt .= "</form>";
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
@@ -324,6 +332,9 @@ class pm_extended extends private_message
|
||||
*/
|
||||
function post_pm()
|
||||
{
|
||||
print_a($_POST);
|
||||
|
||||
|
||||
if(!check_class($this->pmPrefs['pm_class']))
|
||||
{
|
||||
return LAN_PM_12;
|
||||
|
@@ -112,6 +112,7 @@ class pm_shortcodes extends e_shortcode
|
||||
else
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
//TODO Use $frm->userpicker();
|
||||
return $frm->text('pm_to','',10,'typeahead=users');
|
||||
|
||||
$ret = $us->select_form($type, 'pm_to', '', $this->pmPrefs['pm_class']);
|
||||
|
@@ -13,6 +13,29 @@ $(document).ready(function()
|
||||
// $(".e-spinner").spinner(); //FIXME breaks tooltips
|
||||
|
||||
|
||||
$('.e-typeahead').each(function() {
|
||||
|
||||
var id = $(this).attr("id");
|
||||
var name = '#' + id.replace('-usersearch', '');
|
||||
var newval = $(this).attr("data-value");
|
||||
$(this).typeahead({
|
||||
source: $(this).attr("data-source"),
|
||||
updater: function(text, type){
|
||||
if(type == 'value')
|
||||
{
|
||||
$(name).val(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//check all
|
||||
$("#check-all").click(function(event){
|
||||
var val = $(this).val(), selector = '.field-spacer';
|
||||
|
5
user.php
5
user.php
@@ -26,11 +26,12 @@ if(e_AJAX_REQUEST)
|
||||
if(vartrue($_GET['q']))
|
||||
{
|
||||
$q = filter_var($_GET['q'], FILTER_SANITIZE_STRING);
|
||||
if($sql->select("user", "user_name", "user_name LIKE '". $q."%' ORDER BY user_name LIMIT 15"))
|
||||
if($sql->select("user", "user_id,user_name", "user_name LIKE '". $q."%' ORDER BY user_name LIMIT 15"))
|
||||
{
|
||||
while($row = $sql->db_Fetch())
|
||||
{
|
||||
$data[] = $row['user_name'];
|
||||
$id = $row['user_id'];
|
||||
$data[$id] = $row['user_name'];
|
||||
}
|
||||
|
||||
if(count($data))
|
||||
|
Reference in New Issue
Block a user