This is cake php 1.3
I have a method in appcontroller called setLog(). I'm trying to use this Method as common for all controllers. but when call this in another controller (Committee Controller ) it says
Call to undefined method CommitteesController::setLog()
I need to know how to call this function correctly.
AppController
App::import('Controller', 'ActionLogs');
class AppController extends Controller {
public function setLog($action,$remark,$status){
$logs = new ActionLogsController;
$logs->constructClasses();
$data = ['action'=>$action,'user'=>$this->Auth->user('id'),'remark'=>$remark,'status'=>$status];
$logs->add($data);
}
}
Committees Controller
function add() {
if (!empty($this->data)) {
$this->Committee->create();
if ($this->Committee->save($this->data)) {
//create a log for success
$this->setLog('add new committee',json_encode($this->data),1);
$this->Session->setFlash(__('The committee has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The committee could not be saved. Please, try again.', true));
//create a log for failed
$this->setLog('add new committee',json_encode($this->data),0);
}
}
$committeeTypes = $this->Committee->CommitteeType->find('list');
$cond = array('group_id' => 2,'is_active' => '1');
$cond2 = array('group_id' => 4,'is_active' => '1');
$secretaryUserids = $this->Committee->SecretaryUserid->find('list', array('conditions' => $cond));
$assistantSecretaryUserids = $this->Committee->AssistantSecretaryUserid->find('list', array('conditions' => $cond2));
$this->set(compact('committeeTypes', 'secretaryUserids', 'assistantSecretaryUserids'));
}