function add() {
$this->autoRender = false;
if (!empty($this->data)) {
$usr_id = $this->data['Comment']['user_id'];
$this->data['Comment']['sub_id'] = 1;
$this->Comment->create();
if ($this->Comment->save($this->data)) {
$this->Session->setFlash(__('The Comment has been saved', true));
$this->redirect(array('controller' => 'users', 'action'=>'view/'.$usr_id));
} else {
$this->Session->setFlash(__('The Comment could not be saved. Please, try again.', true));
$this->redirect(array('controller' => 'users', 'action'=>'view/'.$usr_id));
}
}
}
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Comment', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Comment->save($this->data)) {
$this->Session->setFlash(__('The Comment has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Comment could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Comment->read(null, $id);
}
$users = $this->Comment->User->find('list');
$user2s = $this->Comment->User2->find('list');
$this->set(compact('users','user2s'));
}