Page 1 of 1

approve a row in a table

PostPosted: Mon Feb 13, 2012 9:35 am
by samhans
hai,
my problem is with the selected row operations. i have done according to the tutorial but error popped up while listing the table.

might be there is some error.

can anyone just give me step by step instructions . starting from table
thanks in advance

Re: approve a row in a table

PostPosted: Mon Feb 13, 2012 9:15 pm
by samhans
sir,

i have pasted the exact code but on going to approve_demand.php in my actions folder i am getting unexpected ',' in line no 13. parse error .
is i am missing something.

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 11:22 am
by shannah
Post the code... and let me know which line is line 13.

-Steve

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 11:33 am
by samhans
<?php
class actions_approve_demand{
function handle(&$params){
// First get the selected records
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$records =& df_get_selected_records($query);

$updated = 0; // Count the number of records we update
$errs = array(); // Log the errors we encounter

foreach ($records as $rec){
if ( !$rec->checkPermission('edit'), array('field'=>'approved')) ){
$errs[] = Dataface_Error::permissionDenied(
"You do not have permission to approve '".
$rec->getTitle().
"' because you do not have the 'edit' permission.");
continue;
}
$rec->setValue('approved', 1);

$res = $rec->save(true /*secure*/);
if ( PEAR::isError($res) ) $errs[] = $res->getMessage();
else $updated++;

}

if ( $errs ){
// Errors occurred. Let's let the user know.
// The $_SESSION['--msg'] content will be displayed to the user as a message
// in the next page request.
$_SESSION['--msg'] = 'Errors Occurred:<br/> '.implode('<br/> ', $errs);
} else {
$_SESSION['--msg'] = "No errors occurred";
}


$url = $app->url('-action=list'); // A default URL in case no redirect was supplied
if ( @$_POST['--redirect'] ) $url = base64_decode($_POST['--redirect']);
$url .= '&--msg='.urlencode($updated.' records were deleted.');

// Redirect back to the previous page
header('Location: '.$url);
exit;
}

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 11:40 am
by samhans
hai Steve,
waiting for your reply. just posted the code.
actually i want to make a demand and issue system. where there is a demand table. and approve column . while seeing the select record action documentation i have done.
the approve menu comes in with selected tab. but when i select a record and click on approve error pops up saying parse error unexpected ','at line 13 .
i have checked the code and found nothing.
just pasted the exact code for your reply.

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 11:51 am
by shannah
As the parser says. You problem is on line 13:
Code: Select all
if ( !$rec->checkPermission('edit'), array('field'=>'approved')) ){


It should be

Code: Select all
if ( !$rec->checkPermission('edit', array('field'=>'approved')) ){


-Steve

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 12:23 pm
by samhans
Steve i will check a come back to you.

Re: approve a row in a table

PostPosted: Tue Feb 14, 2012 11:21 pm
by samhans
hai steve
lots of problem, when i have done what you have suggested to line 13. now its come a line 16 unexpected t_variable.

steve , please review the entire code. i cant find any soluton.

please give me a fresh code of approving a record. :?:

thanks in advance

Re: approve a row in a table

PostPosted: Wed Feb 15, 2012 9:48 am
by shannah
Where did you get this code? Any time you copy and paste code, you may need to do some debugging. The parser tells you what line the problem is on, you should be able to then eye-ball what the problem is on that line.

Re: approve a row in a table

PostPosted: Wed Feb 15, 2012 10:07 am
by samhans
hai Steve,
i.have taken the code from your tutorial . i have modified it according to make my need. but stuck on every syntax. the error is persistently coming. when i ratified one line.. other error comes. can you give me a sample example for creating this approve action . it will be of immense help.