public function executeDelete() { $job = JobPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($job); $job_information = JobInformationPeer::retrieveByPk($this->getRequestParameter('job_information_id')); $this->forward404Unless($job_information); $ref_error = 0; foreach ($job->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $job->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('job/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('job/delete', '_ERR_DELETE_ (' . $job->toString() . ' - id:' . $job->getId() . ')'); } else { $job->delete(); $job_information->delete(); } return $this->forward('job_information', 'list'); }
public function executeDelete() { $group = $this->getContext()->getUser()->getAttribute('group', null, 'bo'); if ($group != 'root') { $this->forward('default', 'index'); } $job = JobPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($job); $ref_error = 0; foreach ($job->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $job->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('job/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('job/delete', '_ERR_DELETE_ (' . $job->toString() . ' - id:' . $job->getId() . ')'); } else { $job->delete(); } return $this->forward('job', 'list'); }