public function indexAction() { $authService = $this->GetAuthenticationService(); if (!$authService->hasIdentity()) { // // Set the redirect url in the session // $sessionContainer = new Container(); $sessionContainer->redirect_url = $this->getRequest()->getUriString(); return array('loginForm' => new LoginForm(), 'courseList' => $this->GetCourseModel()->FetchNewestCourseMetadata(6)); } else { $session = new Session(); $username = $session->read(); $profileModel = $this->GetProfileModel(); $profile = $profileModel->FetchProfileByUsername($username); $courseModel = $this->GetCourseModel(); $profileForm = new ProfileForm(); $profileForm->setData($profile->GetArrayCopy()); //setting existing data from the database //$gradeModel = $this->GetGradeModel(); return array('user' => $profile, 'myCourseList' => $courseModel->FetchMyCourses($profile->id), 'myProfileForm' => $profileForm); } }
public function editAction() { $request = $this->getRequest(); if ($request->isPost()) { $profile = new Profile(); $profileForm = new ProfileForm(); $profileForm->setInputFilter($profile->getInputFilter()); if ($request->getPost('new_password') === $request->getPost('confirm_password')) { $postData = $request->getPost(); $postData['new_pasword'] = sha1($postData['new_password']); $profileForm->setData($postData); if ($profileForm->isValid()) { $profile->ExchangeArray($profileForm->getData()); $this->GetProfileModel()->UpdateProfile($profile); return new JsonModel(array('success' => true, 'id' => $profile->id, 'username' => $profile->username, 'id_default_role' => $profile->id_default_role)); } else { return new JsonModel(array('success' => false, 'message' => $profileForm->getMessages())); } } return new JsonModel(array('success' => false, 'message' => 'Password and Password Confirmation do not match')); } }