/** * Rejects a participant. * @param int $id id of the participant * @param array $formParams * @return array $response */ public function reject($id, array $formParams = array()) { // create the form object $form = new Daiquiri_Form_Confirm(array('submit' => 'Reject the participant')); // valiadate the form if POST if (!empty($formParams)) { if ($form->isValid($formParams)) { // get the rejected status $participantStatusModel = new Meetings_Model_ParticipantStatus(); $status_id = $participantStatusModel->getResource()->fetchId(array('where' => array('`status` = "rejected"'))); // get the user credentials $participant = $this->getResource()->updateRow($id, array('status_id' => $status_id)); return array('status' => 'ok'); } else { return $this->getModelHelper('CRUD')->validationErrorResponse($form); } } return array('form' => $form, 'status' => 'form'); }
/** * Rejects a contribution. * @param int $id id of the contribution * @param array $formParams * @return array $response */ public function reject($id, array $formParams = array()) { // create the form object $form = new Daiquiri_Form_Confirm(array('submit' => 'Reject the contribution')); // valiadate the form if POST if (!empty($formParams)) { if ($form->isValid($formParams)) { // get the user credentials $this->getResource()->updateRow($id, array('accepted' => 0)); return array('status' => 'ok'); } else { return $this->getModelHelper('CRUD')->validationErrorResponse($form); } } return array('form' => $form, 'status' => 'form'); }
/** * Sets the status of a given user from 'disabled' to 'active'. * @param int $userId id of the user * @param array $formParams * @return array $response */ public function reenable($userId, array $formParams = array()) { // create the form object $form = new Daiquiri_Form_Confirm(array('submit' => 'Reenable user')); // valiadate the form if POST if (!empty($formParams)) { if ($form->isValid($formParams)) { // get the user credentials $user = $this->getResource()->fetchRow($userId); // update the use if ($user['status'] === 'active') { $form->setDescription('User status is already "active"'); return $this->getModelHelper('CRUD')->validationErrorResponse($form); } else { // get the new status id $statusId = Daiquiri_Auth::getInstance()->getStatusId('active'); // activate user in database $this->getResource()->updateRow($userId, array('status_id' => $statusId)); // send a notification mail if (Daiquiri_Config::getInstance()->auth->notification->updateUser) { $user = $this->getResource()->fetchRow($userId); $this->getModelHelper('mail')->send('auth.updateUser', array('to' => Daiquiri_Config::getInstance()->auth->notification->mail->toArray(), 'id' => $user['id'], 'username' => $user['username'], 'firstname' => $user['details']['firstname'], 'lastname' => $user['details']['lastname'])); } // log the event and return Daiquiri_Log::getInstance()->notice("user '{$user['username']}' reenabled"); return array('status' => 'ok'); } } else { return $this->getModelHelper('CRUD')->validationErrorResponse($form); } } return array('form' => $form, 'status' => 'form'); }