4,251
社区成员
发帖
与我相关
我的任务
分享
function delete_report($items = null)
{
if(!isset($this->data['id']))
{
$this->redirect(array('controller' => 'reports', 'action' => 'index'));
exit;
}
if(empty($items)) $items = $this->data['id'];
if(!is_array($items)) $items = array($items);
$result = $this->Report->find('all', array('order' => 'Report.id DESC', 'conditions' => array('Report.id' => $items)));
if(isset($this->data['confirmed']) && strcmp($this->data['confirmed'], 'true') == 0)
{
foreach($result as $r)
{
$id = $r['Report']['id'];
if($id == 1) continue;
$this->Report->delete($id);
}
$this->flash("Delete report(s) successfully.", "/reports/index"); //TODO
}
else
{
$this->set('results', $result);
}
}
}