Add ability to delete multiple entries, with a select all check image from the setup application

This commit is contained in:
Miles Lott 2003-12-03 04:28:20 +00:00
parent c451623cf9
commit 6eb49e1666
5 changed files with 141 additions and 54 deletions

View File

@ -141,9 +141,7 @@
$jselect = ' onChange="this.form.submit();"'; $jselect = ' onChange="this.form.submit();"';
} }
/* Setup all and none first */ /* Setup all and none first */
$cats_link = "\n" . '<select name="fcat_id' $cats_link = "\n" .'<select name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
. ($multiple?'[]':'') . '"' . $jselect
. ($multiple ? 'multiple size="3"' : '') . ">\n";
if(!$notall) if(!$notall)
{ {
$cats_link .= '<option value=""'; $cats_link .= '<option value=""';
@ -151,7 +149,7 @@
{ {
$cats_link .= ' selected'; $cats_link .= ' selected';
} }
$cats_link .= '>' . lang('all') . '</option>' . "\n"; $cats_link .= '>'.lang("all").'</option>'."\n";
} }
/* Get global and app-specific category listings */ /* Get global and app-specific category listings */
@ -231,6 +229,7 @@
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_header','addressbook_header'); $GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_header','addressbook_header');
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','column','column'); $GLOBALS['phpgw']->template->set_block('addressbook_list_t','column','column');
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','row','row'); $GLOBALS['phpgw']->template->set_block('addressbook_list_t','row','row');
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','delete_block','delete_block');
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer'); $GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
$custom = $this->fields->read_custom_fields(); $custom = $this->fields->read_custom_fields();
@ -420,6 +419,13 @@
/* set basic vars and parse the header */ /* set basic vars and parse the header */
$GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']); $GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
$GLOBALS['phpgw']->template->set_var('lang_actions',lang('Actions')); $GLOBALS['phpgw']->template->set_var('lang_actions',lang('Actions'));
$GLOBALS['phpgw']->template->set_var('check','');
$GLOBALS['phpgw']->template->set_var('select_all','');
if(count($entries))
{
$GLOBALS['phpgw']->template->set_var('check', $GLOBALS['phpgw']->common->image('addressbook','check'));
$GLOBALS['phpgw']->template->set_var('select_all',lang('Select all'));
}
$GLOBALS['phpgw']->template->set_var('searchreturn',$noprefs . ' ' . $searchreturn); $GLOBALS['phpgw']->template->set_var('searchreturn',$noprefs . ' ' . $searchreturn);
$GLOBALS['phpgw']->template->set_var('lang_showing',$lang_showing); $GLOBALS['phpgw']->template->set_var('lang_showing',$lang_showing);
@ -432,6 +438,7 @@
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']); $GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
$GLOBALS['phpgw']->template->set_var('th_font',$GLOBALS['phpgw_info']['theme']['font']); $GLOBALS['phpgw']->template->set_var('th_font',$GLOBALS['phpgw_info']['theme']['font']);
$GLOBALS['phpgw']->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']); $GLOBALS['phpgw']->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete'));
$GLOBALS['phpgw']->template->set_var('lang_add',lang('Add')); $GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
$GLOBALS['phpgw']->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add')); $GLOBALS['phpgw']->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add'));
$GLOBALS['phpgw']->template->set_var('lang_addvcard',lang('AddVCard')); $GLOBALS['phpgw']->template->set_var('lang_addvcard',lang('AddVCard'));
@ -442,6 +449,8 @@
$GLOBALS['phpgw']->template->set_var('import_alt_url',$GLOBALS['phpgw']->link('/addressbook/csv_import.php')); $GLOBALS['phpgw']->template->set_var('import_alt_url',$GLOBALS['phpgw']->link('/addressbook/csv_import.php'));
$GLOBALS['phpgw']->template->set_var('lang_export',lang('Export Contacts')); $GLOBALS['phpgw']->template->set_var('lang_export',lang('Export Contacts'));
$GLOBALS['phpgw']->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export')); $GLOBALS['phpgw']->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'));
$GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
$GLOBALS['phpgw']->template->set_var('column_count',count($columns_to_display));
$GLOBALS['phpgw']->template->set_var('start',$this->start); $GLOBALS['phpgw']->template->set_var('start',$this->start);
$GLOBALS['phpgw']->template->set_var('sort',$this->sort); $GLOBALS['phpgw']->template->set_var('sort',$this->sort);
@ -486,7 +495,9 @@
{ {
if($GLOBALS['phpgw_info']['user']['apps']['email']) if($GLOBALS['phpgw_info']['user']['apps']['email'])
{ {
$ref='<a href="'.$GLOBALS['phpgw']->link("/email/compose.php","to=" . urlencode($coldata)).'" target="_new">'; $ref = '<a href="'
. $GLOBALS['phpgw']->link('/email/compose.php','to=' . urlencode($coldata))
. '" target="_new">';
} }
else else
{ {
@ -502,35 +513,39 @@
$GLOBALS['phpgw']->template->parse('columns','column',True); $GLOBALS['phpgw']->template->parse('columns','column',True);
} }
$actions = '<a href="'. $actions = '<a href="'
$GLOBALS['phpgw']->link('/index.php',array( . $GLOBALS['phpgw']->link('/index.php',array(
'menuaction' => 'addressbook.uiaddressbook.view', 'menuaction' => 'addressbook.uiaddressbook.view',
'ab_id' => $entries[$i]['id'] 'ab_id' => $entries[$i]['id']
)).'"><img src="'. ))
$GLOBALS['phpgw']->common->image('addressbook','view'). . '"><img src="'
'" border="0" title="'.lang('View').'"></a> '; . $GLOBALS['phpgw']->common->image('addressbook','view')
. '" border="0" title="'.lang('View').'"></a> ';
if($this->bo->check_perms($entries[$i],PHPGW_ACL_EDIT)) if($this->bo->check_perms($entries[$i],PHPGW_ACL_EDIT))
{ {
$actions .= '<a href="' . $actions .= '<a href="'
$GLOBALS['phpgw']->link('/index.php',array( . $GLOBALS['phpgw']->link('/index.php',array(
'menuaction' => 'addressbook.uiaddressbook.edit', 'menuaction' => 'addressbook.uiaddressbook.edit',
'ab_id' => $entries[$i]['id'] 'ab_id' => $entries[$i]['id']
)).'"><img src="'. ))
$GLOBALS['phpgw']->common->image('addressbook','edit'). . '"><img src="'
'" border="0" title="'.lang('Edit').'"></a> '; . $GLOBALS['phpgw']->common->image('addressbook','edit')
. '" border="0" title="' . lang('Edit') . '"></a> ';
} }
if($this->bo->check_perms($entries[$i],PHPGW_ACL_DELETE)) if($this->bo->check_perms($entries[$i],PHPGW_ACL_DELETE))
{ {
$actions .= '<a href="' . $actions .= '<a href="'
$GLOBALS['phpgw']->link('/index.php',array( . $GLOBALS['phpgw']->link('/index.php',array(
'menuaction' => 'addressbook.uiaddressbook.delete', 'menuaction' => 'addressbook.uiaddressbook.delete',
'ab_id' => $entries[$i]['id'] 'ab_id' => $entries[$i]['id']
)).'"><img src="'. ))
$GLOBALS['phpgw']->common->image('addressbook','delete'). . '"><img src="'
'" border="0" title="'.lang('Delete').'"></a>'; . $GLOBALS['phpgw']->common->image('addressbook','delete')
. '" border="0" title="'.lang('Delete').'"></a>';
} }
$actions .= '<input type="checkbox" name="select[' . $entries[$i]['id'] . ']">';
$GLOBALS['phpgw']->template->set_var('actions',$actions); $GLOBALS['phpgw']->template->set_var('actions',$actions);
$GLOBALS['phpgw']->template->parse('rows','row',True); $GLOBALS['phpgw']->template->parse('rows','row',True);
@ -538,6 +553,10 @@
reset($columns_to_display); reset($columns_to_display);
} }
if(count($entries))
{
$GLOBALS['phpgw']->template->fp('delete_button','delete_block');
}
$GLOBALS['phpgw']->template->pparse('out','addressbook_footer'); $GLOBALS['phpgw']->template->pparse('out','addressbook_footer');
$this->save_sessiondata(); $this->save_sessiondata();
/* $GLOBALS['phpgw']->common->phpgw_footer(); */ /* $GLOBALS['phpgw']->common->phpgw_footer(); */
@ -726,22 +745,45 @@
{ {
$ab_id = $_POST['entry']['ab_id'] ? $_POST['entry']['ab_id'] : $_POST['ab_id']; $ab_id = $_POST['entry']['ab_id'] ? $_POST['entry']['ab_id'] : $_POST['ab_id'];
$confirm = $_GET['confirm'] ? $_GET['confirm'] :$_POST['confirm']; $confirm = $_GET['confirm'] ? $_GET['confirm'] :$_POST['confirm'];
$select = $_POST['select'];
if(@is_array($select))
{
/* The original values are sent as select[number] = on */
$select = array_keys($select);
}
elseif(is_string($select))
{
/* This is imploded below and sent along with the form if the answer is yes */
$select = explode(',',$select);
}
if(!$ab_id) if(!$ab_id)
{ {
$ab_id = $_GET['ab_id']; // else plain Link in delete does not work $ab_id = $_GET['ab_id']; // else plain Link in delete does not work
} }
if(!$ab_id || $_POST['no']) if((!$ab_id && !$select) || $_POST['no'])
{ {
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
} }
$check = $this->bo->read_entry(array('id' => $ab_id, 'fields' => array('owner' => 'owner','tid' => 'tid'))); if(!@is_array($select))
{
$select[] = $ab_id;
}
foreach($select as $null => $_id)
{
if(!(int)$_id)
{
continue;
}
$check = $this->bo->read_entry(array('id' => $_id, 'fields' => array('owner' => 'owner','tid' => 'tid')));
if(!(($this->bo->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id'])) if(!(($this->bo->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['phpgw_info']['user']['account_id']))
{ {
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')); Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->common->phpgw_exit(); $GLOBALS['phpgw']->common->phpgw_exit();
} }
}
$GLOBALS['phpgw']->template->set_file(array('delete' => 'delete.tpl')); $GLOBALS['phpgw']->template->set_file(array('delete' => 'delete.tpl'));
@ -751,17 +793,31 @@
$GLOBALS['phpgw']->common->phpgw_header(); $GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
if(count($select) == 1)
{
$GLOBALS['phpgw']->template->set_var('lang_sure',lang('Are you sure you want to delete this entry ?')); $GLOBALS['phpgw']->template->set_var('lang_sure',lang('Are you sure you want to delete this entry ?'));
$GLOBALS['phpgw']->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->template->set_var('lang_no',lang('NO'));
$GLOBALS['phpgw']->template->set_var('yes_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete&ab_id=' . $ab_id . '&confirm=true'));
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('YES'));
$GLOBALS['phpgw']->template->pparse('out','delete');
} }
else else
{ {
$this->bo->delete_entry(array('id' => $ab_id)); $GLOBALS['phpgw']->template->set_var('lang_sure',lang('Are you sure you want to delete these entries ?'));
}
$GLOBALS['phpgw']->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$GLOBALS['phpgw']->template->set_var('lang_no',lang('NO'));
$GLOBALS['phpgw']->template->set_var('yes_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete&ab_id=' . $ab_id . '&confirm=true'));
$GLOBALS['phpgw']->template->set_var('select',implode(',',$select));
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('YES'));
$GLOBALS['phpgw']->template->pparse('out','delete');
}
else
{
if(!@is_array($select))
{
$select[] = $ab_id;
}
foreach($select as $null => $_id)
{
$this->bo->delete_entry(array('id' => $_id));
}
@Header('Location: ' . $GLOBALS['phpgw']->link('/addressbook/index.php','menuaction=addressbook.uiaddressbook.index')); @Header('Location: ' . $GLOBALS['phpgw']->link('/addressbook/index.php','menuaction=addressbook.uiaddressbook.index'));
} }
} }
@ -925,7 +981,7 @@
{ {
if($contactscat) if($contactscat)
{ {
$catinfo = $this->cat->return_single((int)$contactscat); $catinfo = $this->cat->return_single(intval($contactscat));
$catname .= $catinfo[0]['name'] . '; '; $catname .= $catinfo[0]['name'] . '; ';
} }
} }
@ -937,7 +993,7 @@
else else
{ {
$fields[0]['cat_id'] = ereg_replace(',','',$fields[0]['cat_id']); $fields[0]['cat_id'] = ereg_replace(',','',$fields[0]['cat_id']);
$catinfo = $this->cat->return_single((int)$fields[0]['cat_id']); $catinfo = $this->cat->return_single(intval($fields[0]['cat_id']));
$catname = $catinfo[0]['name']; $catname = $catinfo[0]['name'];
if(!$this->cat_id) if(!$this->cat_id)
{ {
@ -1020,7 +1076,7 @@
{ {
$prefs = $_POST['prefs']; $prefs = $_POST['prefs'];
$other = $_POST['other']; $other = $_POST['other'];
$fcat_id = (int)$_POST['fcat_id']; $fcat_id = intval($_POST['fcat_id']);
$custom = $this->fields->read_custom_fields(); $custom = $this->fields->read_custom_fields();
$customfields = array(); $customfields = array();
@ -1423,7 +1479,7 @@
} }
} }
if($format != 'view') if($format != "view")
{ {
/* Preferred phone number radio buttons */ /* Preferred phone number radio buttons */
$pref[0] = '<font size="-2">'; $pref[0] = '<font size="-2">';
@ -1437,7 +1493,7 @@
} }
$str[$name] .= '>'; $str[$name] .= '>';
$str[$name] = $pref[0].$str[$name].$pref[1]; $str[$name] = $pref[0].$str[$name].$pref[1];
$GLOBALS['phpgw']->template->set_var('pref_' . $name,$str[$name]); $GLOBALS['phpgw']->template->set_var("pref_".$name,$str[$name]);
} }
if(strlen($bday) > 2) if(strlen($bday) > 2)
@ -1572,12 +1628,12 @@
} }
$birthday = $GLOBALS['phpgw']->common->dateformatorder($bday_year,$bday_month,$bday_day) $birthday = $GLOBALS['phpgw']->common->dateformatorder($bday_year,$bday_month,$bday_day)
. '<font face="' . $theme['font'] . '" size="-2">' . lang('(e.g. 1969)') . '</font>'; . '<font face="'.$theme["font"].'" size="-2">'.lang('(e.g. 1969)').'</font>';
if($format == 'edit') if($format == 'edit')
{ {
$create .= '<tr bgcolor="' . $GLOBALS['phpgw_info']['theme']['th_bg'] . '"><td colspan="2"><font size="-1">' . lang('Created by') . ':</font></td>' $create .= '<tr bgcolor="' . $GLOBALS['phpgw_info']['theme']['th_bg'] . '"><td colspan="2"><font size="-1">' . lang("Created by") . ':</font></td>'
. '<td colspan="3"><font size="-1">' . '<td colspan="3"><font size="-1">'
. $GLOBALS['phpgw']->common->grab_owner_name($fields['owner']); . $GLOBALS['phpgw']->common->grab_owner_name($fields["owner"]);
} }
else else
{ {

View File

@ -5,5 +5,6 @@
<form action="{yes_link}" method="POST"> <form action="{yes_link}" method="POST">
<input type="submit" name="yes" value="{lang_yes}"> &nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" name="yes" value="{lang_yes}"> &nbsp; &nbsp; &nbsp; &nbsp;
<input type="submit" name="no" value="{lang_no}"> <input type="submit" name="no" value="{lang_no}">
<input type="hidden" name="select" value="{select}">
</form> </form>
</center> </center>

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

View File

@ -1,11 +1,33 @@
<!-- BEGIN addressbook_header --> <!-- BEGIN addressbook_header -->
<script>
function check_all(which)
{
for (i=0; i<document.addr_index.elements.length; i++)
{
if (document.addr_index.elements[i].type == "checkbox" && document.addr_index.elements[i].name.substring(0,which.length) == which)
{
if (document.addr_index.elements[i].checked)
{
document.addr_index.elements[i].checked = false;
}
else
{
document.addr_index.elements[i].checked = true;
}
}
}
}
</script>
<center> <center>
{lang_showing} {lang_showing}
<br>{searchreturn} <br>{searchreturn}
{search_filter} {search_filter}
<table width="95%" border="0" cellspacing="1" cellpadding="3"> <table width="95%" border="0" cellspacing="1" cellpadding="3">
<form name="addr_index" action="{action_url}" method="POST">
<tr bgcolor="{th_bg}">{cols} <tr bgcolor="{th_bg}">{cols}
<td width="5%" height="21"><font face="Arial, Helvetica, sans-serif" size="-1">{lang_actions}</font></td> <td width="5%" height="21"><font face="Arial, Helvetica, sans-serif" size="-1">{lang_actions}</font>
&nbsp;<a href="javascript:check_all('select')"><img src="{check}" border="0" height="16" width="21" alt="{select_all}"></a></td>
</tr> </tr>
<!-- END addressbook_header --> <!-- END addressbook_header -->
@ -19,7 +41,14 @@
</tr> </tr>
<!-- END row --> <!-- END row -->
<!-- BEGIN addressbook_footer --> <!-- BEGIN delete_block -->
<tr bgcolor="{row_tr_color}"><td colspan="{column_count}">&nbsp;</td>
<td align="right"><input type="submit" name="Delete" value="{lang_delete}"></td>
</tr>
<!-- END delete_block -->
<!-- BEGIN addressbook_footer -->{delete_button}
</form>
</table> </table>
<table width="95%" border="0" cellspacing="0" cellpadding="4"> <table width="95%" border="0" cellspacing="0" cellpadding="4">
<tr bgcolor="{th_bg}"> <tr bgcolor="{th_bg}">

View File

@ -29,6 +29,7 @@ antigua and barbuda common en ANTIGUA AND BARBUDA
apply common en Apply apply common en Apply
april common en April april common en April
are you sure you want to delete this entry ? common en Are you sure you want to delete this entry ? are you sure you want to delete this entry ? common en Are you sure you want to delete this entry ?
are you sure you want to delete these entries ? common en Are you sure you want to delete these entries ?
argentina common en ARGENTINA argentina common en ARGENTINA
armenia common en ARMENIA armenia common en ARMENIA
aruba common en ARUBA aruba common en ARUBA