[2] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare API - Accounts manager - User Interface functions * |
---|
| 4 | * Written or modified by RalfBecker@outdoor-training.de * |
---|
| 5 | * The original version of the acount-selection popup was written and * |
---|
| 6 | * (c) 2003 by Bettina Gille [ceb@phpgroupware.org] * |
---|
| 7 | * -------------------------------------------------------------------------* |
---|
| 8 | * This library is part of the eGroupWare API * |
---|
| 9 | * http://www.egroupware.org * |
---|
| 10 | * ------------------------------------------------------------------------ * |
---|
| 11 | * This library is free software; you can redistribute it and/or modify it * |
---|
| 12 | * under the terms of the GNU Lesser General Public License as published by * |
---|
| 13 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
| 14 | * or any later version. * |
---|
| 15 | * This library is distributed in the hope that it will be useful, but * |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
| 18 | * See the GNU Lesser General Public License for more details. * |
---|
| 19 | * You should have received a copy of the GNU Lesser General Public License * |
---|
| 20 | * along with this library; if not, write to the Free Software Foundation, * |
---|
| 21 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
| 22 | \**************************************************************************/ |
---|
| 23 | |
---|
| 24 | include_once(PHPGW_API_INC . '/class.accounts.inc.php'); |
---|
| 25 | |
---|
| 26 | /** |
---|
| 27 | * User Interface for account and/or group selection |
---|
| 28 | */ |
---|
| 29 | |
---|
| 30 | class uiaccountsel extends accounts |
---|
| 31 | { |
---|
| 32 | var $public_functions = array( |
---|
| 33 | 'popup' => True, |
---|
| 34 | ); |
---|
| 35 | |
---|
| 36 | function uiaccountsel($account_id = '', $account_type='') |
---|
| 37 | { |
---|
| 38 | $this->accounts($account_id,$account_type); // call constructor of extended class |
---|
| 39 | |
---|
| 40 | $this->account_selection = $GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection']; |
---|
| 41 | |
---|
| 42 | if (!is_object($GLOBALS['phpgw']->html)) |
---|
| 43 | { |
---|
| 44 | $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html'); |
---|
| 45 | } |
---|
| 46 | $this->html = $GLOBALS['phpgw']->html; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * Create an account-selection for a certain range of users |
---|
| 51 | * |
---|
| 52 | * @param $name string name of the form-element |
---|
| 53 | * @param $element_id string id of the form-element, this need to be unique for the whole window !!! |
---|
| 54 | * @param $selected array/int user-id or array of user-id's which are already selected |
---|
| 55 | * @param $use string 'accounts', 'groups', 'owngroups', 'both' or app-name for all accounts with run-rights. |
---|
| 56 | * If an '+' is appended to the app-name, one can also select groups with run-rights for that app. |
---|
| 57 | * @param $lines int number of lines for multiselection or 0 for a single selection |
---|
| 58 | * (in that case accounts should be an int or contain only 1 user-id) |
---|
| 59 | * @param $not int/array user-id or array of user-id's not to display in selection, default False = display all |
---|
| 60 | * @param $options additional options (e.g. style) |
---|
| 61 | * @param $onchange javascript to execute if the selection changes, eg. to reload the page |
---|
| 62 | * @param $select array/bool/string array with id's as keys or values. If the id is in the key and the value is a string, |
---|
| 63 | * it gets appended to the user-name. Or false if the selectable values for the selectbox are determined by use. |
---|
| 64 | * Or a string which gets added as first Option with value=0, eg. lang('all') |
---|
| 65 | * @return the necessary html |
---|
| 66 | */ |
---|
| 67 | function selection($name,$element_id,$selected,$use='accounts',$lines=1,$not=False,$options='',$onchange='',$select=False) |
---|
| 68 | { |
---|
| 69 | //echo "<p>uiaccountsel::selection('$name',".print_r($selected,True).",'$use',$lines,$not,'$options','$onchange',".print_r($select,True).")</p>\n"; |
---|
| 70 | if (!is_array($selected)) |
---|
| 71 | { |
---|
| 72 | $selected = $selected ? explode(',',$selected) : array(); |
---|
| 73 | } |
---|
| 74 | $account_sel = $this->account_selection; |
---|
| 75 | $app = False; |
---|
| 76 | switch($use) |
---|
| 77 | { |
---|
| 78 | default: |
---|
| 79 | if (substr($use,-1) == '+') |
---|
| 80 | { |
---|
| 81 | $app = substr($use,0,-1); |
---|
| 82 | $use = 'both'; |
---|
| 83 | } |
---|
| 84 | else |
---|
| 85 | { |
---|
| 86 | $app = $use; |
---|
| 87 | $use = 'accounts'; |
---|
| 88 | } |
---|
| 89 | break; |
---|
| 90 | case 'accounts': |
---|
| 91 | case 'both': |
---|
| 92 | break; |
---|
| 93 | case 'groups': |
---|
| 94 | case 'owngroups': |
---|
| 95 | $account_sel = 'selectbox'; // groups always use only the selectbox |
---|
| 96 | break; |
---|
| 97 | } |
---|
| 98 | $extra_label = is_string($select) && !empty($select) ? $select : False; |
---|
| 99 | switch($account_sel) |
---|
| 100 | { |
---|
| 101 | case 'popup': |
---|
| 102 | $select = $selected; |
---|
| 103 | break; |
---|
| 104 | case 'primary_group': |
---|
| 105 | $select = count($selected) && !isset($selected[0]) ? array_keys($selected) : $selected; |
---|
| 106 | $members = $this->member($GLOBALS['phpgw']->accounts->data['account_primary_group']); |
---|
| 107 | if (is_array($members)) |
---|
| 108 | { |
---|
| 109 | foreach($members as $member) |
---|
| 110 | { |
---|
| 111 | if (!in_array($member['account_id'],$select)) |
---|
| 112 | { |
---|
| 113 | $select[] = $member['account_id']; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | break; |
---|
| 118 | case 'selectbox': |
---|
| 119 | default: |
---|
| 120 | if (!is_array($select)) |
---|
| 121 | { |
---|
| 122 | $select = $GLOBALS['phpgw']->accounts->search(array( |
---|
| 123 | 'type' => $use, |
---|
| 124 | 'app' => $app, |
---|
| 125 | )); |
---|
| 126 | } |
---|
| 127 | break; |
---|
| 128 | } |
---|
| 129 | $already_selected = $users = $groups = array(); |
---|
| 130 | $use_keys = count($select) && !isset($select[0]); // id's are the keys |
---|
| 131 | foreach($select as $key => $val) |
---|
| 132 | { |
---|
| 133 | $id = $use_keys ? $key : (is_array($val) ? $val['account_id'] : $val); |
---|
| 134 | |
---|
| 135 | if ($not && ($id == $not || is_array($not) && in_array($id,$not))) |
---|
| 136 | { |
---|
| 137 | continue; // dont display that one |
---|
| 138 | } |
---|
| 139 | if (in_array($id,$selected)) // show already selected accounts first |
---|
| 140 | { |
---|
| 141 | $already_selected[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 142 | } |
---|
| 143 | elseif ($this->get_type($id) == 'u') |
---|
| 144 | { |
---|
| 145 | $users[$id] = !is_array($val) ? $GLOBALS['phpgw']->common->grab_owner_name($id) : |
---|
| 146 | $GLOBALS['phpgw']->common->display_fullname( |
---|
| 147 | $val['account_lid'],$val['account_firstname'],$val['account_lastname']); |
---|
| 148 | } |
---|
| 149 | else |
---|
| 150 | { |
---|
| 151 | $groups[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | // sort users and groups alphabeticaly and put the groups behind the users |
---|
| 155 | uasort($already_selected,strcasecmp); |
---|
| 156 | uasort($users,strcasecmp); |
---|
| 157 | uasort($groups,strcasecmp); |
---|
| 158 | $select = $already_selected + $users + $groups; |
---|
| 159 | |
---|
| 160 | if (count($selected) && !isset($selected[0])) // id's are the keys |
---|
| 161 | { |
---|
| 162 | foreach($selected as $id => $val) |
---|
| 163 | { |
---|
| 164 | if (is_string($val) && isset($users[$id])) // add string to option-label |
---|
| 165 | { |
---|
| 166 | $users[$id] .= " ($val)"; |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | $selected = array_keys($selected); |
---|
| 170 | } |
---|
| 171 | // add necessary popup trigers |
---|
| 172 | $link = $GLOBALS['phpgw']->link('/index.php',array( |
---|
| 173 | 'menuaction' => 'phpgwapi.uiaccountsel.popup', |
---|
| 174 | 'app' => $app, |
---|
| 175 | 'use' => $use, |
---|
| 176 | 'element_id' => $element_id, |
---|
| 177 | 'single' => !$lines, // single selection, closes after the first selection |
---|
| 178 | )); |
---|
| 179 | $popup_options = 'width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes'; |
---|
| 180 | $app = $GLOBALS['phpgw_info']['flags']['currentapp']; |
---|
| 181 | $single = (int) !$lines; |
---|
| 182 | if (!$lines && $use != 'groups' && $use != 'owngroups') |
---|
| 183 | { |
---|
| 184 | $options .= ' onchange="if (this.value==\'popup\') '."window.open('$link','uiaccountsel','$popup_options');". |
---|
| 185 | ($onchange ? " else { $onchange }" : '' ).'" onclick="if (this.value==\'popup\') '."window.open('$link','uiaccountsel','$popup_options');\""; |
---|
| 186 | $select['popup'] = lang('Search').' ...'; |
---|
| 187 | $need_js_popup = True; |
---|
| 188 | } |
---|
| 189 | elseif ($onchange) |
---|
| 190 | { |
---|
| 191 | $options .= ' onchange="'.$onchange.'"'; |
---|
| 192 | } |
---|
| 193 | if ($extra_label) |
---|
| 194 | { |
---|
| 195 | $select = array($extra_label) + $select; |
---|
| 196 | } |
---|
| 197 | //echo "<p>html::select('$name',".print_r($selected,True).",".print_r($select,True).",True,'$options')</p>\n"; |
---|
| 198 | $html = $this->html->select($name,$selected,$select,True,$options.' id="'.$element_id.'"',$lines); |
---|
| 199 | |
---|
| 200 | if ($lines > 1 && ($this->account_selection == 'popup' || $this->account_selection == 'primary_group')) |
---|
| 201 | { |
---|
| 202 | $html .= '<a href="'.$link.'" target="uiaccountsel" onclick="'."window.open(this,this.target,'$popup_options'); return false;".'">'. |
---|
| 203 | $this->html->image('phpgwapi','users',lang('search or select accounts')).'</a>'; |
---|
| 204 | $need_js_popup = True; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | if($need_js_popup && !$GLOBALS['phpgw_info']['flags']['uiaccountsel']['addOption_installed']) |
---|
| 208 | { |
---|
| 209 | $html .= '<script language="JavaScript"> |
---|
| 210 | function addOption(id,label,value) |
---|
| 211 | { |
---|
| 212 | selectBox = document.getElementById(id); |
---|
| 213 | for (i=0; i < selectBox.length; i++) { |
---|
| 214 | '.// check existing entries if they're already there and only select them in that case |
---|
| 215 | ' if (selectBox.options[i].value == value) { |
---|
| 216 | selectBox.options[i].selected = true; |
---|
| 217 | break; |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | if (i >= selectBox.length) { |
---|
| 221 | selectBox.options[selectBox.length] = new Option(label,value,false,true); |
---|
| 222 | } |
---|
| 223 | if (selectBox.onchange) selectBox.onchange(); |
---|
| 224 | } |
---|
| 225 | </script>'; |
---|
| 226 | $GLOBALS['phpgw_info']['flags']['uiaccountsel']['addOption_installed'] = True; |
---|
| 227 | } |
---|
| 228 | return $html; |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | function popup() |
---|
| 232 | { |
---|
| 233 | global $query; // nextmatch requires that !!! |
---|
| 234 | |
---|
| 235 | $app = get_var('app',array('POST','GET')); |
---|
| 236 | $use = get_var('use',array('POST','GET')); |
---|
| 237 | $group_id = get_var('group_id',array('POST','GET'),$GLOBALS['phpgw']->accounts->data['account_primary_group']); |
---|
| 238 | $element_id = get_var('element_id',array('POST','GET')); |
---|
| 239 | $single = get_var('single',array('POST','GET')); |
---|
| 240 | |
---|
| 241 | $query = get_var('query',array('POST','GET')); |
---|
| 242 | $query_type = get_var('query_type',array('POST','GET')); |
---|
| 243 | |
---|
| 244 | $start = (int) get_var('start',array('POST'),0); |
---|
| 245 | $order = get_var('order',array('POST','GET'),'account_lid'); |
---|
| 246 | $sort = get_var('sort',array('POST','GET'),'ASC'); |
---|
| 247 | |
---|
| 248 | //echo "<p>uiaccountsel::popup(): app='$app', use='$use', single='$single', group_id='$group_id', element_id='$element_id', start='$start', order='$order', sort='$sort'</p>\n"; |
---|
| 249 | |
---|
| 250 | $this->nextmatchs = CreateObject('phpgwapi.nextmatchs'); |
---|
| 251 | |
---|
| 252 | $GLOBALS['phpgw']->template->set_root($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi')); |
---|
| 253 | |
---|
| 254 | $GLOBALS['phpgw']->template->set_file(array('accounts_list_t' => 'uiaccountsel.tpl')); |
---|
| 255 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','letter_search','letter_search_cells'); |
---|
| 256 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','group_cal','cal'); |
---|
| 257 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','group_other','other'); |
---|
| 258 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','group_all','all'); |
---|
| 259 | |
---|
| 260 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','bla_intro','ibla'); |
---|
| 261 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','other_intro','iother'); |
---|
| 262 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','all_intro','iall'); |
---|
| 263 | |
---|
| 264 | $GLOBALS['phpgw']->template->set_block('accounts_list_t','accounts_list','list'); |
---|
| 265 | |
---|
| 266 | $GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']); |
---|
| 267 | $GLOBALS['phpgw']->template->set_var('lang_search',lang('search')); |
---|
| 268 | $GLOBALS['phpgw']->template->set_var('lang_groups',lang('user groups')); |
---|
| 269 | $GLOBALS['phpgw']->template->set_var('lang_accounts',lang('user accounts')); |
---|
| 270 | |
---|
| 271 | $GLOBALS['phpgw']->template->set_var('img',$GLOBALS['phpgw']->common->image('phpgwapi','select')); |
---|
| 272 | $GLOBALS['phpgw']->template->set_var('lang_select_user',lang('Select user')); |
---|
| 273 | $GLOBALS['phpgw']->template->set_var('lang_select_group',lang('Select group')); |
---|
| 274 | |
---|
| 275 | if ($app) // split the groups in the ones with run-rights and without |
---|
| 276 | { |
---|
| 277 | if ($use == 'both') // groups with run-rights too, eg. calendar |
---|
| 278 | { |
---|
| 279 | $GLOBALS['phpgw']->template->fp('ibla','bla_intro',True); |
---|
| 280 | } |
---|
| 281 | else |
---|
| 282 | { |
---|
| 283 | $GLOBALS['phpgw']->template->fp('iother','other_intro',True); |
---|
| 284 | } |
---|
| 285 | $GLOBALS['phpgw']->template->fp('iall','all_intro',True); |
---|
| 286 | } |
---|
| 287 | else // use all groups and account, eg. admin |
---|
| 288 | { |
---|
| 289 | $GLOBALS['phpgw']->template->set_var('lang_perm',lang('group name')); |
---|
| 290 | $GLOBALS['phpgw']->template->fp('iother','other_intro',True); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | if (!$single) |
---|
| 294 | { |
---|
| 295 | if (!is_object($GLOBALS['phpgw']->js)) |
---|
| 296 | { |
---|
| 297 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
| 298 | } |
---|
| 299 | $GLOBALS['phpgw']->js->set_onload("copyOptions('$element_id');"); |
---|
| 300 | } |
---|
| 301 | $GLOBALS['phpgw_info']['flags']['app_header'] = lang('search or select accounts'); |
---|
| 302 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 303 | |
---|
| 304 | $GLOBALS['phpgw']->template->set_var('lang_perm',lang('Groups with permission for %1',lang($app))); |
---|
| 305 | $GLOBALS['phpgw']->template->set_var('lang_nonperm',lang('Groups without permission for %1',lang($app))); |
---|
| 306 | |
---|
| 307 | $link_data = array |
---|
| 308 | ( |
---|
| 309 | 'menuaction' => 'phpgwapi.uiaccountsel.popup', |
---|
| 310 | 'app' => $app, |
---|
| 311 | 'use' => $use, |
---|
| 312 | 'group_id' => $group_id, |
---|
| 313 | 'element_id' => $element_id, |
---|
| 314 | 'single' => $single, |
---|
| 315 | 'query_type' => $query_type, |
---|
| 316 | 'query' => $query, |
---|
| 317 | ); |
---|
| 318 | |
---|
| 319 | // -------------- list header variable template-declaration ------------------------ |
---|
| 320 | $GLOBALS['phpgw']->template->set_var('sort_lid',$this->nextmatchs->show_sort_order($sort,'account_lid',$order,'/index.php',lang('LoginID'),$link_data)); |
---|
| 321 | $GLOBALS['phpgw']->template->set_var('sort_firstname',$this->nextmatchs->show_sort_order($sort,'account_firstname',$order,'/index.php',lang('Firstname'),$link_data)); |
---|
| 322 | $GLOBALS['phpgw']->template->set_var('sort_lastname',$this->nextmatchs->show_sort_order($sort,'account_lastname',$order,'/index.php',lang('Lastname'),$link_data)); |
---|
| 323 | |
---|
| 324 | // ------------------------- end header declaration -------------------------------- |
---|
| 325 | |
---|
| 326 | $link_data['sort'] = $sort; |
---|
| 327 | $link_data['order'] = $order; |
---|
| 328 | |
---|
| 329 | $GLOBALS['phpgw']->template->set_var('lang_list_members',lang('List members')); |
---|
| 330 | $GLOBALS['phpgw']->template->set_var('lang_firstname',lang('firstname')); |
---|
| 331 | $GLOBALS['phpgw']->template->set_var('lang_lastname',lang('lastname')); |
---|
| 332 | |
---|
| 333 | if ($app) |
---|
| 334 | { |
---|
| 335 | $app_groups = $this->split_accounts($app,'groups'); |
---|
| 336 | } |
---|
| 337 | $all_groups = $this->search(array( |
---|
| 338 | 'type' => 'groups', |
---|
| 339 | )); |
---|
| 340 | foreach($all_groups as $group) |
---|
| 341 | { |
---|
| 342 | $link_data['group_id'] = $group['account_id']; |
---|
| 343 | |
---|
| 344 | $GLOBALS['phpgw']->template->set_var('onclick',"addOption('$element_id','". |
---|
| 345 | $GLOBALS['phpgw']->common->grab_owner_name($group['account_id'])."','$group[account_id]')". |
---|
| 346 | ($single ? '; window.close()' : '')); |
---|
| 347 | |
---|
| 348 | if (!$app || in_array($group['account_id'],$app_groups)) |
---|
| 349 | { |
---|
| 350 | $GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color($tr_color,True)); |
---|
| 351 | $GLOBALS['phpgw']->template->set_var('link_user_group',$GLOBALS['phpgw']->link('/index.php',$link_data)); |
---|
| 352 | $GLOBALS['phpgw']->template->set_var('name_user_group',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id'])); |
---|
| 353 | |
---|
| 354 | if($use == 'both') // allow selection of groups |
---|
| 355 | { |
---|
| 356 | $GLOBALS['phpgw']->template->fp('cal','group_cal',True); |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | $GLOBALS['phpgw']->template->fp('other','group_other',True); |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | else |
---|
| 364 | { |
---|
| 365 | $GLOBALS['phpgw']->template->set_var('link_all_group',$GLOBALS['phpgw']->link('/index.php',$link_data)); |
---|
| 366 | $GLOBALS['phpgw']->template->set_var('name_all_group',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id'])); |
---|
| 367 | $GLOBALS['phpgw']->template->set_var('accountid',$group['account_id']); |
---|
| 368 | $GLOBALS['phpgw']->template->fp('all','group_all',True); |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | $link_data['group_id'] = $group_id; // reset it |
---|
| 372 | |
---|
| 373 | // --------------------------------- nextmatch --------------------------- |
---|
| 374 | $users = $this->search(array( |
---|
| 375 | 'type' => $group_id ? $group_id : $use, |
---|
| 376 | 'app' => $app, |
---|
| 377 | 'start' => $start, |
---|
| 378 | 'order' => $order, |
---|
| 379 | 'sort' => $sort, |
---|
| 380 | 'query' => $query, |
---|
| 381 | 'query_type' => $query_type, |
---|
| 382 | )); |
---|
| 383 | |
---|
| 384 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 385 | 'left' => $this->nextmatchs->left('/index.php',$start,$this->total,$link_data+array('query'=>$query)), |
---|
| 386 | 'right' => $this->nextmatchs->right('/index.php',$start,$this->total,$link_data+array('query'=>$query)), |
---|
| 387 | 'lang_showing' => ($group_id ? $GLOBALS['phpgw']->common->grab_owner_name($group_id).': ' : ''). |
---|
| 388 | ($query ? lang("Search %1 '%2'",lang($this->query_types[$query_type]),$query).': ' : '') |
---|
| 389 | .$this->nextmatchs->show_hits($this->total,$start), |
---|
| 390 | )); |
---|
| 391 | |
---|
| 392 | // -------------------------- end nextmatch ------------------------------------ |
---|
| 393 | |
---|
| 394 | $GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data)); |
---|
| 395 | $GLOBALS['phpgw']->template->set_var('prev_query', $query); |
---|
| 396 | $GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query' => $query, 'search_obj' => 1))); |
---|
| 397 | $GLOBALS['phpgw']->template->set_var('lang_firstname', lang("firstname")); |
---|
| 398 | $GLOBALS['phpgw']->template->set_var('lang_lastname', lang("lastname")); |
---|
| 399 | |
---|
| 400 | foreach($users as $user) |
---|
| 401 | { |
---|
| 402 | $GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color($tr_color,True)); |
---|
| 403 | |
---|
| 404 | // ---------------- template declaration for list records -------------------------- |
---|
| 405 | |
---|
| 406 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 407 | 'lid' => $user['account_lid'], |
---|
| 408 | 'firstname' => $user['account_firstname'] ? $user['account_firstname'] : ' ', |
---|
| 409 | 'lastname' => $user['account_lastname'] ? $user['account_lastname'] : ' ', |
---|
| 410 | 'onclick' => "addOption('$element_id','". |
---|
| 411 | $GLOBALS['phpgw']->common->grab_owner_name($user['account_id'])."','$user[account_id]')". |
---|
| 412 | ($single ? '; window.close()' : ''), |
---|
| 413 | )); |
---|
| 414 | $GLOBALS['phpgw']->template->fp('list','accounts_list',True); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | $GLOBALS['phpgw']->template->set_var('accountsel_icon',$this->html->image('phpgwapi','users-big')); |
---|
| 418 | $GLOBALS['phpgw']->template->set_var('query_type',is_array($this->query_types) ? $this->html->select('query_type',$query_type,$this->query_types) : ''); |
---|
| 419 | |
---|
| 420 | $link_data['query_type'] = 'start'; |
---|
| 421 | $letters = lang('alphabet'); |
---|
| 422 | $letters = explode(',',substr($letters,-1) != '*' ? $letters : 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z'); |
---|
| 423 | foreach($letters as $letter) |
---|
| 424 | { |
---|
| 425 | $link_data['query'] = $letter; |
---|
| 426 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 427 | 'letter' => $letter, |
---|
| 428 | 'link' => $GLOBALS['phpgw']->link('/index.php',$link_data), |
---|
| 429 | 'class' => $query == $letter && $query_type == 'start' ? 'letter_box_active' : 'letter_box', |
---|
| 430 | )); |
---|
| 431 | $GLOBALS['phpgw']->template->fp('letter_search_cells','letter_search',True); |
---|
| 432 | } |
---|
| 433 | unset($link_data['query']); |
---|
| 434 | unset($link_data['query_type']); |
---|
| 435 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 436 | 'letter' => lang('all'), |
---|
| 437 | 'link' => $GLOBALS['phpgw']->link('/index.php',$link_data), |
---|
| 438 | 'class' => $query_type != 'start' || !in_array($query,$letters) ? 'letter_box_active' : 'letter_box', |
---|
| 439 | )); |
---|
| 440 | $GLOBALS['phpgw']->template->fp('letter_search_cells','letter_search',True); |
---|
| 441 | |
---|
| 442 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 443 | 'lang_selection' => lang('selection'), |
---|
| 444 | 'lang_close' => lang('close'), |
---|
| 445 | )); |
---|
| 446 | |
---|
| 447 | if (!$single) |
---|
| 448 | { |
---|
| 449 | $GLOBALS['phpgw']->template->set_var(array( |
---|
| 450 | 'selection' => $this->html->select('selected',False,array(),True,' id="uiaccountsel_popup_selection" style="width: 100%;"',13), |
---|
| 451 | 'remove' => $this->html->submit_button('remove','remove', |
---|
| 452 | "removeSelectedOptions('$element_id'); return false;",True,' title="'.lang('Remove selected accounts').'"','delete'), |
---|
| 453 | )); |
---|
| 454 | } |
---|
| 455 | $GLOBALS['phpgw']->template->pfp('out','accounts_list_t',True); |
---|
| 456 | |
---|
| 457 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 458 | } |
---|
| 459 | } |
---|