/** 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); } }