phpgroupware-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-users] New participant select option


From: Don Graver \(dgraver\)
Subject: [Phpgroupware-users] New participant select option
Date: Mon, 14 Jun 2004 10:39:10 +0100

I asked this question a few weeks ago about how to better select
participants than from a straight select box, and I think I have come up
with a good solution.  I use the javascript code from
http://www.mattkruse.com/javascript/selectbox/.  Once select box
contains all the users, and the other contains all those that are being
invited.  Below is some sample things of what I had to do to get it to
work...nothing major.  



>From class.uicalendar.inc.php:
<snip>
switch($GLOBALS['phpgw_info']['user']['preferences']['common']['account_
selection']) {

...<snip>...                       

default:
foreach($users as $id => $user_array)
{
if($id != intval($event['owner']))
{
//Added by DG
//Used for better participant selection, separates included from
excluded participants

if ($event['participants'][$id]){
$include_participants .= '    <option value="' .
$id.$event['participants'][$id] . '" SELECTED>('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";
}else{
$exclude_participants .= '    <option value="' .
$id.$event['participants'][$id] . '">('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";
}
//End edit by DG

$str .= '    <option value="' . $id.$event['participants'][$id] .
'"'.($event['participants'][$id]?'
selected':'').'>('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";

//Added by DG
//Used for better participant selection
$str2 .= '    <option value="' . $id.$event['participants'][$id] .
'"'.($event['participants'][$id]?'
selected':'').'>('.$user_array['type'].')
'.$user_array['name'].'</option>'."\n";
//End edit by DG
}
}
$var['participants'] = array
(
'field' => lang('Participants'),
'data'  => "\n".'   <select name="participants[]" multiple
size="7">'."\n".$str.'   </select>'
);

//Added by DG
//Used for better participant selection, overrides variable set above

$var['participants']['data']='<SCRIPT LANGUAGE="JavaScript"
src="/channels-de/calendar/inc/selectbox2.js"></SCRIPT>'."\n\n";
$var['participants']['data'].=<<<EOF
(In some browsers, you can double-click the options.)
<p>
<TABLE BORDER=0>
<TR>
<TD>
<b>Exclude</b><br>
<SELECT NAME="excluded_participants" MULTIPLE SIZE=10 >
$exclude_participants
</SELECT>
</TD>
<TD VALIGN=MIDDLE ALIGN=CENTER>
<INPUT TYPE="button" NAME="right" VALUE="&gt;&gt;"
ONCLICK="moveSelectedOptions(this.form['excluded_participants'],this.for
m.elements[findIncludeParticipantsIndex()],true,this.form['movepattern1'
].value)"><BR><BR>
<INPUT TYPE="button" NAME="right" VALUE="All &gt;&gt;"
ONCLICK="moveAllOptions(this.form['excluded_participants'],this.form.ele
ments[findIncludeParticipantsIndex()],true,this.form['movepattern1'].val
ue)"><BR><BR>
<INPUT TYPE="button" NAME="left" VALUE="&lt;&lt;"
ONCLICK="moveSelectedOptions(this.form.elements[findIncludeParticipantsI
ndex()],this.form['excluded_participants'],true,this['form'].movepattern
1.value)"><BR><BR>
<INPUT TYPE="button" NAME="left" VALUE="All &lt;&lt;"
ONCLICK="moveAllOptions(this.form.elements[findIncludeParticipantsIndex(
)],this.form['excluded_participants'],true,this.form['movepattern1'].val
ue)">
</TD>
<TD>
<b>Include</b><br>

<SELECT NAME="participants[]"  SIZE=10 multiple >
$include_participants
</SELECT>
</TD>
</TR>
<TR>
<TD COLSPAN="3">
Do not allow moving of options matching pattern:<BR><INPUT TYPE="text"
NAME="movepattern1" VALUE="">
<!--<input type="button" name="test" onclick="selectAllParticipants()"
value="test">-->
</TD>
</TR>
</TABLE>
EOF;
//End edit by DG
break;

<snip>...


I also had to add the following javascript functions to the selectbox.js
file to get it to work, as well as add an onsubmit to the form in
class.uicalender.inc.php to call selectAllParticipants() so that the
participants would be highlighted within the selectbox prior to
submission.  Here are the added js functions:

>From selectbox2.js...

//Added by DG 
function findIncludeParticipantsIndex(){ 
var toIndex='not found'; 
for (var i=0; i < document.forms.length; i++) {  
  for (var k=0; k< document.forms[i].elements.length; k++) {  
    if (document.forms[i].elements[k].name == 'excluded_participants'){ 
      toIndex= k + 5; 
      break;
  } 
} 
return toIndex; 
} 
 
function selectAllParticipants(){ 
 
selectAllOptions(document.forms[3].elements[findIncludeParticipantsIndex
()]); 
} 



Hope this helps some people...as my users are quite happy with the
selection process now.

Don




reply via email to

[Prev in Thread] Current Thread [Next in Thread]