+function contacts_batch_actions(&$a){
+ $contacts_id = $_POST['contact_batch'];
+ if (!is_array($contacts_id)) return;
+
+ $orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
+ implode(",", $contacts_id),
+ intval(local_user())
+ );
+
+ $count_actions=0;
+ foreach($orig_records as $orig_record) {
+ $contact_id = $orig_record['id'];
+ if (x($_POST, 'contacts_batch_update')) {
+ _contact_update($contact_id);
+ $count_actions++;
+ }
+ if (x($_POST, 'contacts_batch_block')) {
+ $r = _contact_block($contact_id, $orig_record);
+ if ($r) $count_actions++;
+ }
+ if (x($_POST, 'contacts_batch_ignore')) {
+ $r = _contact_ignore($contact_id, $orig_record);
+ if ($r) $count_actions++;
+ }
+ if (x($_POST, 'contacts_batch_archive')) {
+ $r = _contact_archive($contact_id, $orig_record);
+ if ($r) $count_actions++;
+ }
+ if (x($_POST, 'contacts_batch_drop')) {
+ _contact_drop($contact_id, $orig_record);
+ $count_actions++;
+ }
+ }
+ if ($count_actions>0) {
+ info ( sprintf( tt("%d contact edited.", "%d contacts edited", $count_actions), $count_actions) );
+ }
+
+ if(x($_SESSION,'return_url'))
+ goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
+ else
+ goaway($a->get_baseurl(true) . '/contacts');
+
+}
+
+