-// sites
-if (empty( $sites ) ) {
- plc_warning('This user is not affiliated with a site !!');
- }
-$can_manage_sites = $local_peer && plc_is_admin() || $is_my_account;
-$headers=array();
-$headers['Login_base']="string";
-$headers['Name']="string";
-if ($can_manage_sites)
- $headers['Remove']="string";
-$table_options = array('notes_area'=>false,'search_area'=>false, 'pagesize_area'=>false);
-plc_table_start ("person_sites",$headers,0,$table_options);
-foreach( $sites as $site ) {
- $site_name= $site['name'];
- $site_id= $site['site_id'];
- $login_base=$site['login_base'];
- plc_table_row_start();
- plc_table_cell ($login_base);
- plc_table_cell (l_site_t($site_id,$site_name));
- if ($can_manage_sites)
- plc_table_cell (plc_form_checkbox_text('site_ids[]',$site_id));
- plc_table_row_end ();
-}
-// footers : the remove and add buttons
-$footers=array();
-if ($can_manage_sites) {
- // remove selected sites
- $remove_sites_area = plc_form_submit_text("remove-person-from-sites","Remove Sites");
-
- // add a site : the button
- $add_site_right_area=plc_form_submit_text("add-person-to-site","Add in site");
- // get list of local sites that the person is not in
- $person_site_ids=array_map("get_site_id",$sites);
- $relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids), $site_columns);
-
- // xxx cannot use onchange=submit() - would need to somehow pass action name
- $selector=array();
- foreach ($relevant_sites as $site)
- $selector[]= array('display'=>$site['name'],"value"=>$site['site_id']);
- $add_site_left_area=plc_form_select_text("site_id",$selector,"Choose a site to add");
- $add_site_area = $add_site_left_area . $add_site_right_area;
- if ($sites)
- $footers[]="<td colspan=3 style='text-align:right'> $remove_sites_area </td>";
- // add a new site
- $footers []="<td colspan=3 style='text-align:right'> $add_site_area </td>";
+ if (empty( $sites ) ) {
+ plc_warning('This user is not affiliated with a site !!');
+ }
+ $can_manage_sites = $local_peer && plc_is_admin() || $is_my_account;
+ $headers=array();
+ $headers['Login_base']="string";
+ $headers['Name']="string";
+ if ($can_manage_sites) $headers[plc_delete_icon()]="none";
+ $table_options = array('notes_area'=>false,'search_area'=>false, 'pagesize_area'=>false);
+ $table=new PlekitTable ("person_sites",$headers,0,$table_options);
+ $table->start();
+ foreach( $sites as $site ) {
+ $site_name= $site['name'];
+ $site_id= $site['site_id'];
+ $login_base=$site['login_base'];
+ $table->row_start();
+ $table->cell ($login_base);
+ $table->cell (l_site_t($site_id,$site_name));
+ if ($can_manage_sites)
+ $table->cell ($form->checkbox_html('site_ids[]',$site_id));
+ $table->row_end ();
+ }
+ if ($can_manage_sites) {
+ $table->tfoot_start();
+
+ if ($sites) {
+ $table->row_start();
+ $table->cell($form->submit_html("remove-person-from-sites","Remove Sites"),
+ array('hfill'=>true,'align'=>'right'));
+ $table->row_end();
+ }
+
+ if (plc_is_admin())
+ {
+ // NOTE: only admins can add users to different sites.
+ $table->row_start();
+ // get list of local sites that the person is not in
+ function get_site_id ($site) { return $site['site_id'];}
+ $person_site_ids=array_map("get_site_id",$sites);
+ $relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids, '-SORT'=>'name'), $site_columns);
+ // xxx cannot use onchange=submit() - would need to somehow pass action name
+ function site_selector($site) { return array('display'=>$site['name'],"value"=>$site['site_id']); }
+ $selectors = array_map ("site_selector",$relevant_sites);
+ $table->cell ($form->select_html("site_id",$selectors,array('label'=>"Choose a site to add")).
+ $form->submit_html("add-person-to-site","Add in site"),
+ array('hfill'=>true,'align'=>'right'));
+ $table->row_end();
+ }
+ }
+ $table->end();
+ $toggle->end();