/** * Update listed resources * * @access public * @param array $dataArray * @param bool $isAdminUser * @param string $userEmail */ public function updateListedResources($dataArray, $isAdminUser, $userEmail) { if (isset($dataArray['editedName'])) { $editedResourceNames = $dataArray['editedName']; foreach ($editedResourceNames as $key => $name) { $resource = $this->query->findOneBy('Courses\\Entity\\Resource', array('id' => $key)); $resource->setName($name); if ($isAdminUser === false) { $resource->setStatus(Status::STATUS_NOT_APPROVED); } if (isset($dataArray['editedType'][$key])) { $resource->setType($dataArray['editedType'][$key]); unset($dataArray['editedType'][$key]); } $this->query->save($resource); } } if (isset($dataArray['editedType'])) { $editedResourceType = $dataArray['editedType']; foreach ($editedResourceType as $key => $Type) { $resource = $this->query->findOneBy('Courses\\Entity\\Resource', array('id' => $key)); $resource->setType($Type); if ($isAdminUser === false) { $resource->setStatus(Status::STATUS_NOT_APPROVED); } $this->query->save($resource); } } if ($isAdminUser === false) { $this->sendMail($userEmail, true); } }
public function updateQuestion($oldQuestionTitle, $newQuestionTitle, $evaluation) { $evaluationId = $evaluation->getId(); $question = $this->query->findOneBy("Courses\\Entity\\Question", array('questionTitle' => $oldQuestionTitle, 'evaluation' => $evaluationId)); $question->setQuestionTitle($newQuestionTitle); $question->setStatus($evaluation->getStatus()); $this->query->save($question); }
/** * Validate Access Control for actions * * @access public * * @param Zend\Http\PhpEnvironment\Response $response * @param mixed $roleArray string or array of roles * @param Organizations\Entity\Organization $organization ,default is null * @param bool $atLeastOneRoleFlag ,default is false * @return array bool is access valid or not and redirect url if redirect is needed */ public function validateOrganizationAccessControl($response, $roleArray, $organization = null, $atLeastOneRoleFlag = false) { $accessValid = true; $url = null; $auth = new AuthenticationService(); $storage = $auth->getIdentity(); if ($auth->hasIdentity() && !in_array(Role::ADMIN_ROLE, $storage['roles'])) { if (!is_null($organization)) { $currentUserOrganizationUser = $this->query->findOneBy('Organizations\\Entity\\OrganizationUser', array("user" => $storage['id'], "organization" => $organization->getId())); if (!is_object($currentUserOrganizationUser)) { $url = $this->router->assemble(array(), array('name' => 'noaccess')); $accessValid = false; } } if ($accessValid === true) { if (!is_array($roleArray)) { $roleArray = array($roleArray); } $notacceptedAgreementRoles = array(); $acceptedAgreementRoles = array(); foreach ($roleArray as $role) { if (!(isset($storage["agreements"][$role]) && (int) $storage["agreements"][$role] === Status::STATUS_ACTIVE)) { $notacceptedAgreementRoles[] = $role; } elseif ($atLeastOneRoleFlag === true) { $acceptedAgreementRoles[] = $role; } } if (count($notacceptedAgreementRoles) > 0 && $atLeastOneRoleFlag === false || $atLeastOneRoleFlag === true && count($acceptedAgreementRoles) == 0) { $glue = ", "; if ($atLeastOneRoleFlag === true) { $glue = ", or "; } $notacceptedAgreementRolesString = implode($glue, $notacceptedAgreementRoles); $url = $this->router->assemble(array('id' => $storage['id'], 'role' => $notacceptedAgreementRolesString), array('name' => 'noAgreement')); $accessValid = false; } } if ($accessValid === false) { $response->setStatusCode(302); } } return array("isValid" => $accessValid, "redirectUrl" => $url); }
public function saveCourseVotes($questionIds, $values, $userObj, $evalObj) { // removing unset value form array unset($values['submit']); //looping over values for ($i = 0; $i < count($questionIds); $i++) { $vote = new \Courses\Entity\Vote(); $questionObj = $this->query->findOneBy('Courses\\Entity\\Question', array('id' => $questionIds[$i])); $vote->setEvaluation($evalObj); $vote->setUser($userObj); $vote->setQuestion($questionObj); // each key is radios_XX where x is question Id $vote->setVote($values['radios_' . $questionIds[$i]]); // save vote $this->query->setEntity('Courses\\Entity\\Vote')->save($vote); // update course evaluation percentage $evalObj->setPercentage($this->getVotePercentage($evalObj)); $this->query->setEntity('Courses\\Entity\\Evaluation')->save($evalObj); } }
public function respondeToExamRequest($response, $requestId, $tvtcResponse = null) { $request = $this->query->findOneBy('Courses\\Entity\\ExamBook', array('id' => $requestId)); // tvtc response if ($tvtcResponse != null) { $request->setTvtcStatus($response); $this->query->save($request); } else { $request->setAdminStatus($response); $this->query->save($request); } }