/** * Initializes any data for the page * @returns boolean. True on sucess. False on failture */ protected function initPage() { if (!parent::initPage()) { //parent loads needed objects and checks for view access return false; } if (empty($this->type)) { if ($this->isPost()) { //type should not be empty return false; } $task = "can_view_database_lists"; $msg = "You don't have permission to view database lists"; } else { $task = "can_view_database_list_{$this->type}|can_view_all_database_lists "; $msg = "You don't have permission to edit the list `{$this->type}`"; } if (!$this->permissionParser->hasPermission("task({$task})")) { $this->userMessage($msg, 'notice'); return false; } return true; }
/** * Initializes any data for the page * @returns boolean. True on sucess. False on failture */ protected function initPage() { if ($this->person_position instanceof iHRIS_PersonPosition) { $this->person_position->populate(); $this->setObject($this->person_position, I2CE_PageForm::EDIT_PARENT); } $this->person = $this->factory->createContainer("person" . '|' . $this->person_id); if ($this->person instanceof iHRIS_Person) { $this->person->populate(); } if ($this->factory->exists($this->getForm())) { $this->setObject($this->factory->createContainer($this->getForm() . '|' . $this->id), I2CE_PageForm::EDIT_PRIMARY, 'new_salary'); $this->getPrimary()->populate(); } if (strlen($this->last_id) > 0) { $this->getPrimary()->last = $this->last_id; } if ($this->last instanceof iHRIS_Salary) { $this->template->setForm($this->last, 'current_salary'); } if ($this->person instanceof iHRIS_Person) { $this->template->setForm($this->person); } if (!$this->hasPermission('task(person_can_edit_child_form_salary)')) { $this->userMessage("You do not have access to edit the salary", 'notice', false); return false; } if (!parent::initPage()) { return false; } if ($this->isPost()) { if ($this->last instanceof iHRIS_Salary) { $this->last->end_date = $this->getPrimary()->start_date; } else { //you are trying to change an existing salary if (!$this->hasPermission('task(person_can_change_child_form_salary)')) { $this->userMessage("You do not have access to edit the salary", 'notice', false); return false; } } } if ($this->last instanceof iHRIS_Salary) { if ($this->person_position instanceof iHRIS_PersonPosition) { $end_date = $this->person_position->getField('end_date'); if ($end_date->isValid()) { $this->getPrimary()->end_date = $end_date; } } } return true; }