Xataface 2.0
Xataface Application Framework
actions/delete_selected.php
Go to the documentation of this file.
00001 <?php
00008 class dataface_actions_delete_selected {
00009         function handle(&$params){
00010                 if ( !$_POST ) return PEAR::raiseError("This method is only available via POST");
00011                 $app =& Dataface_Application::getInstance();
00012                 $query =& $app->getQuery();
00013                 $records = df_get_selected_records($query);
00014                 
00015                 $updated = 0;
00016                 $errs = array();
00017                 foreach ($records as $rec){
00018                         if ( !$rec->checkPermission('delete') ){
00019                                 $errs[] = Dataface_Error::permissionDenied("You do not have permission to delete '".$rec->getTitle()."' because you do not have the 'delete' permission.");
00020                                 continue;
00021                         }
00022                         $res = $rec->delete(true /*secure*/);
00023                         if ( PEAR::isError($res) ) $errs[] = $res->getMessage();
00024                         else $updated++;
00025                         
00026                 }
00027                 
00028                 if ( $errs ){
00029                         $_SESSION['--msg'] = 'Errors Occurred:<br/> '.implode('<br/> ', $errs);
00030                 } else {
00031                         $_SESSION['--msg'] = "No errors occurred";
00032                 }
00033                 
00034                 $url = $app->url('-action=list');
00035                 if ( @$_POST['--redirect'] ) $url = base64_decode($_POST['--redirect']);
00036                 $url .= '&--msg='.urlencode($updated.' records were deleted.');
00037                 $app->redirect($url);
00038         }
00039 }
 All Data Structures Namespaces Files Functions Variables Enumerations