diff --git a/phpgwapi/addressbook.php b/phpgwapi/addressbook.php
index 090bc479ef..6f35b59070 100644
--- a/phpgwapi/addressbook.php
+++ b/phpgwapi/addressbook.php
@@ -44,15 +44,17 @@
'bcc' => lang('Bcc'),
'lang_email' => lang('Select work email address'),
'lang_hemail' => lang('Select home email address'),
+ 'lang_to_title' => lang('Select all %1 %2 for %3')
));
-
$start = intval(get_var('start',array('POST','GET'),0));
$filter = get_var('filter',array('POST','GET'),'none');
$cat_id = intval(get_var('cat_id',array('POST','GET'),0));
$query = get_var('query',array('POST','GET'));
$sort = get_var('sort',array('POST','GET'));
$order = get_var('order',array('POST','GET'));
+ list($all) = @each($_POST['all']);
+ $inserted = $_GET['inserted'];
$common_vars = array(
'filter' => $filter,
@@ -63,9 +65,10 @@
);
$link = '/phpgwapi/addressbook.php';
- $GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link($link,$common_vars+array(
+ $full_link = $GLOBALS['phpgw']->link($link,$common_vars+array(
'start' => $start,
- )));
+ ));
+ $GLOBALS['phpgw']->template->set_var('form_action',$full_link);
$qfilter = 'tid=n';
switch($filter)
@@ -110,8 +113,21 @@
'email_home' => 'email_home'
);
- $entries = $contacts->read($start,$offset,$cols,$query,$qfilter,$sort,$order,$account_id);
-
+ if ($all)
+ {
+ $qfilter .= ',email'.($all[0] == 'h' ? '_home' : '')."=!''";
+ $entries = $contacts->read(0,0,$cols,$query,$qfilter,$sort,$order,$account_id);
+ //echo "
".print_r($entries,True)."
\n";
+ if (!$entries)
+ {
+ $all = False;
+ $inserted = 0;
+ }
+ }
+ if (!$all)
+ {
+ $entries = $contacts->read($start,$offset,$cols,$query,$qfilter,$sort,$order,$account_id);
+ }
//------------------------------------------- nextmatch --------------------------------------------
$GLOBALS['phpgw']->template->set_var('left',$GLOBALS['phpgw']->nextmatchs->left(
$link,$start,$contacts->total_records,'&'.explode('&',$common_vars)));
@@ -140,6 +156,22 @@
}
// --------------------------------------- end nextmatch ------------------------------------------
+ foreach(array(
+ 'work' => lang('work email'),
+ 'home' => lang('home email')
+ ) as $type => $lang_type)
+ {
+ foreach(array(
+ 'to' => lang('To'),
+ 'cc' => lang('Cc'),
+ 'bcc'=> lang('Bcc')) as $target => $lang_target)
+ {
+ $GLOBALS['phpgw']->template->set_var('title_'.$type.'_'.$target,
+ lang('Insert all %1 addresses of the %2 contacts in %3',$lang_type,
+ $contacts->total_records,$lang_target));
+ }
+ }
+
// ------------------- list header variable template-declaration -----------------------
$GLOBALS['phpgw']->template->set_var('cats_list',$cats->formated_list('select','all',$cat_id,'True'));
@@ -158,23 +190,25 @@
));
// --------------------------- end header declaration ----------------------------------
- for ($i=0;$itemplate->set_var('tr_class',
$GLOBALS['phpgw']->nextmatchs->alternate_row_color('',True));
- $firstname = $entries[$i]['n_given'];
+ $firstname = $entry['n_given'];
if (!$firstname)
{
$firstname = ' ';
}
- $lastname = $entries[$i]['n_family'];
+ $lastname = $entry['n_family'];
if (!$lastname)
{
$lastname = ' ';
}
// thanks to dave.hall@mbox.com.au for adding company
- $company = $entries[$i]['org_name'];
+ $company = $entry['org_name'];
if (!$company)
{
$company = ' ';
@@ -200,50 +234,81 @@
if (($personal_part == '') ||
($include_personal == False))
{
- $id = $entries[$i]['id'];
- $email = $entries[$i]['email'];
- $hemail = $entries[$i]['email_home'];
+ $id = $entry['id'];
+ $email = $entry['email'];
+ $hemail = $entry['email_home'];
}
else
{
- $id = $entries[$i]['id'];
- if ((isset($entries[$i]['email'])) &&
- (trim($entries[$i]['email']) != ''))
+ $id = $entry['id'];
+ if ((isset($entry['email'])) &&
+ (trim($entry['email']) != ''))
{
- $email = '"'.$personal_part.'" <'.$entries[$i]['email'].'>';
+ $email = '"'.$personal_part.'" <'.$entry['email'].'>';
}
else
{
- $email = $entries[$i]['email'];
+ $email = $entry['email'];
}
- if ((isset($entries[$i]['email_home'])) &&
- (trim($entries[$i]['email_home']) != ''))
+ if ((isset($entry['email_home'])) &&
+ (trim($entry['email_home']) != ''))
{
- $hemail = '"'.$personal_part.'" <'.$entries[$i]['email_home'].'>';
+ $hemail = '"'.$personal_part.'" <'.$entry['email_home'].'>';
}
else
{
- $hemail = $entries[$i]['email_home'];
+ $hemail = $entry['email_home'];
}
}
-
- // --------------------- template declaration for list records --------------------------
- $GLOBALS['phpgw']->template->set_var(array(
- 'firstname' => $firstname,
- 'lastname' => $lastname,
- 'company' => $company
- ));
+ if ($all)
+ {
+ $all_emails[] = $all[0] == 'h' ? $hemail : $email;
+ }
+ else
+ {
+ $email = htmlspecialchars($email);
+ $hemail = htmlspecialchars($hemail);
- $GLOBALS['phpgw']->template->set_var('id',$id);
- $GLOBALS['phpgw']->template->set_var('email',$email);
- $GLOBALS['phpgw']->template->set_var('hemail',$hemail);
+ // --------------------- template declaration for list records --------------------------
+ $GLOBALS['phpgw']->template->set_var(array(
+ 'firstname' => $firstname,
+ 'lastname' => $lastname,
+ 'company' => $company
+ ));
- $GLOBALS['phpgw']->template->parse('list','addressbook_list',True);
+ $GLOBALS['phpgw']->template->set_var('id',$id);
+ $GLOBALS['phpgw']->template->set_var('email',$email);
+ $GLOBALS['phpgw']->template->set_var('hemail',$hemail);
+
+ $GLOBALS['phpgw']->template->parse('list','addressbook_list',True);
+ }
}
// --------------------------- end record declaration ---------------------------
- $GLOBALS['phpgw']->template->parse('out','addressbook_list_t',True);
- $GLOBALS['phpgw']->template->p('out');
-
+ if ($all && count($all_emails))
+ {
+ $full_link .= '&inserted='.count($all_emails);
+ $target = substr($all,1);
+ echo "
+