-----Original Message-----
From: address@hidden
[mailto:address@hidden
On Behalf Of Dave Hall
Sent: Monday, June 14, 2004 11:49 AM
To: phpgw-users
Subject: Re: [Phpgroupware-users] New participant select option
Hi Don,
I am working on getting a prioritised list of features for the
HEAD version of calendar. I am happy to look at including
something like this. A nicely formatted patch always helps
motivate me ;)
Cheers
Dave
On Mon, 2004-06-14 at 19:39, Don Graver (dgraver) wrote:
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']['accoun
t_
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>'."nn";
$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=">>"
ONCLICK="moveSelectedOptions(this.form['excluded_participants'],this.f
or
m.elements[findIncludeParticipantsIndex()],true,this.form['move
pattern1'
].value)"><BR><BR>
<INPUT TYPE="button" NAME="right" VALUE="All >>"
ONCLICK="moveAllOptions(this.form['excluded_participants'],this.form.e
le
ments[findIncludeParticipantsIndex()],true,this.form['movepattern1'].v
al
ue)"><BR><BR>
<INPUT TYPE="button" NAME="left" VALUE="<<"
ONCLICK="moveSelectedOptions(this.form.elements[findIncludeParticipant
sI
ndex()],this.form['excluded_participants'],true,this['form'].movepatte
rn
1.value)"><BR><BR>
<INPUT TYPE="button" NAME="left" VALUE="All <<"
ONCLICK="moveAllOptions(this.form.elements[findIncludeParticipantsInde
x(
)],this.form['excluded_participants'],true,this.form['movepattern1'].v
al
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[findIncludeParticipantsInd
ex
()]);
}
Hope this helps some people...as my users are quite happy with the
selection process now.
Don