Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
delete_selected.php
Go to the documentation of this file.
1 <?php
9  function handle(&$params){
10  if ( !$_POST ) return PEAR::raiseError("This method is only available via POST");
12  $query =& $app->getQuery();
13  $records = df_get_selected_records($query);
14 
15  $updated = 0;
16  $errs = array();
17  foreach ($records as $rec){
18  if ( !$rec->checkPermission('delete') ){
19  $errs[] = Dataface_Error::permissionDenied("You do not have permission to delete '".$rec->getTitle()."' because you do not have the 'delete' permission.");
20  continue;
21  }
22  $res = $rec->delete(true /*secure*/);
23  if ( PEAR::isError($res) ) $errs[] = $res->getMessage();
24  else $updated++;
25 
26  }
27 
28  if ( $errs ){
29  $_SESSION['--msg'] = 'Errors Occurred:<br/> '.implode('<br/> ', $errs);
30  } else {
31  $_SESSION['--msg'] = "No errors occurred";
32  }
33 
34  $url = $app->url('-action=list');
35  if ( @$_POST['--redirect'] ) $url = base64_decode($_POST['--redirect']);
36  $url .= '&--msg='.urlencode($updated.' records were deleted.');
37  $app->redirect($url);
38  }
39 }