/** Initialise the index pages * @access public * @return void */ public function indexAction() { $content = new Content(); $this->view->contents = $content->getFrontContent('research'); $research = new ResearchProjects(); $this->view->research = $research->getCounts(); }
/** get an individual project */ public function projectAction() { if ($this->_getParam('id', false)) { $projects = new ResearchProjects(); $this->view->projects = $projects->getProjectDetails($this->_getParam('id')); } else { throw new Exception($this->_missingParameter); } }
/** Edit a research project * @access public * @return void * @uses ResearchForm * @throws Pas_Exception_Param */ public function editAction() { if ($this->getParam('id', false)) { $form = new ResearchForm(); $form->submit->setLabel('Submit changes to project'); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($this->_request->getPost())) { $where = $this->_research->getAdapter()->quoteInto('id = ?', $this->getParam('id')); $this->_research->update($form->getValues(), $where); $this->getFlash()->addMessage('Research project details updated.'); $this->redirect(self::REDIRECT); } else { $form->populate($form->getValues()); } } else { $form->populate($this->_research->fetchRow('id=' . $this->_request->getParam('id'))->toArray()); } } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }
/** Upgrade a user's account to research status */ public function upgradeAction() { if ($this->_getParam('id', false)) { $id = $this->_getParam('id'); $form = new AcceptUpgradeForm(); $form->role->removeMultiOption('admin'); $this->view->form = $form; if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) { if ($form->isValid($form->getValues())) { $approvalData = array('status' => 'approved', 'message' => $form->getValue('message'), 'createdBy' => $this->getIdentityForForms(), 'created' => $this->getTimeForForms()); if ($form->getValue('already') != 1 && $form->getValue('insert') == 1) { $researchData = array('title' => $form->getValue('title'), 'investigator' => $form->getValue('fullname'), 'description' => $form->getValue('researchOutline'), 'level' => $form->getValue('level'), 'createdBy' => $this->getIdentityForForms(), 'created' => $this->getTimeForForms(), 'startDate' => $form->getValue('startDate'), 'valid' => 1, 'endDate' => $form->getValue('endDate')); $research = new ResearchProjects(); $research->insert($researchData); } $userData = array('higherLevel' => '0', 'updatedBy' => $this->getIdentityForForms(), 'created' => $this->getTimeForForms(), 'researchOutline' => $form->getValue('researchOutline')); $users = new Users(); $where = array(); $where[] = $users->getAdapter()->quoteInto('id = ?', $id); $users->update($userData, $where); $approvals = new ApproveReject(); $approvals->insert($approvalData); $to = array(array('email' => $form->getValue('email'), 'name' => $form->getValue('fullname'))); $this->_helper->mailer($form->getValues(), 'upgradeAccount', $to); $this->_flashMessenger->addMessage('Account upgraded and project data entered'); $this->_redirect('/admin/users/upgrades'); } else { $form->populate($form->getValues()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $users = new Users(); $user = $users->fetchRow('id =' . $id); if (count($user)) { $form->populate($user->toArray()); } else { throw new Pas_Exception_Param('No user account found with that id'); } } } } else { throw new Pas_Exception_Param($this->_missingParameter); } }
public function deleteprojectAction() { if ($this->_getParam('id', false)) { $projects = new ResearchProjects(); $where = $projects->getAdapter()->quoteInto('id = ?', (int) $this->_getParam('id')); $projects->delete($where); } else { throw new Exception('There is no research project ID specified', 500); } }
/** Delete a project * @access public * @return mixed * @throws Pas_Exception_Param */ public function deleteprojectAction() { if ($this->getParam('id', false)) { $projects = new ResearchProjects(); $where = $projects->getAdapter()->quoteInto('id = ?', (int) $this->getParam('id')); $projects->delete($where); } else { throw new Pas_Exception_Param($this->_missingParameter, 404); } }