checkSession(); } function add() { if (!empty($this->data)) { $this->data['Alerta']['user_id'] = $this->Session->read('UserId'); if ($this->Alerta->save($this->data)) { $this->redirect('/users/profile'); } } } function edit($id = null) { $owner = $this->Alerta->read(); if ($owner['Alerta']['user_id'] == $this->Session->read('UserId')) { if (empty($this->data)) { $this->Alerta->id = $id; $this->data = $this->Alerta->read(); } else { if ($this->Alerta->save($this->data['Alerta'])) { $this->redirect('/users/profile'); } } } else { $this->flash('Acceso no autorizado','/'); } } function delete($id = null) { $owner = $this->Alerta->read(); if ($owner['Alerta']['user_id'] == $this->Session->read('UserId')) { $this->Alerta->del($id); $this->redirect('/users/profile'); } else { $this->flash('Acceso no autorizado','/'); } } } ?>