コード例 #1
0
 public function actionUpdatestudentaccess()
 {
     $session = Yii::$app->session;
     if ($session->has('accountTypeID')) {
         $accountTypeID = (int) $session->get('accountTypeID');
         if ($accountTypeID == DefaultForm::ACCOUNT_TYPE_SUPERUSER || $accountTypeID == DefaultForm::ACCOUNT_TYPE_ADMINISTRATOR || $accountTypeID == DefaultForm::ACCOUNT_TYPE_REGISTRAR || $accountTypeID == DefaultForm::ACCOUNT_TYPE_BACK_OFFICE) {
             $request = Yii::$app->request;
             if ($request->isAjax) {
                 $post = $request->post();
                 $studentID = $post['StudentID'];
                 $_AccountStudentsForm = new AccountStudentsForm();
                 $studentAccess = $_AccountStudentsForm->getStudentUsernameAndPasswordAndStatusByID($studentID);
                 $usernameResult = $studentAccess['Username'];
                 if (is_null($usernameResult) || $usernameResult == "") {
                     $username = "******";
                 } else {
                     $username = $usernameResult;
                 }
                 $passwordResult = $studentAccess['Password'];
                 if (is_null($passwordResult) || $passwordResult == "") {
                     $isPasswordSet = "No password yet";
                 } else {
                     $isPasswordSet = "Already has password";
                 }
                 $statusResult = $studentAccess['Status'];
                 if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_INACTIVE || $studentAccess['Status'] == '0') {
                     $status = 'Inactive';
                 } else {
                     if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_ACTIVE || $studentAccess['Status'] == '1') {
                         $status = 'Active';
                     } else {
                         if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_DEACTIVATED || $studentAccess['Status'] == '2') {
                             $status = 'Deactivated';
                         } else {
                             if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_LOCKED_BY_SELF || $studentAccess['Status'] == '3') {
                                 $status = 'Locked By Self';
                             } else {
                                 if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_LOCKED_BY_THE_ADMINISTRATOR || $studentAccess['Status'] == '4') {
                                     $status = 'Locked By The Administrator';
                                 } else {
                                     if ($statusResult == DefaultForm::ACCOUNT_STATUS_STUDENT_DELETED || $studentAccess['Status'] == '5') {
                                         $status = 'Deleted';
                                     } else {
                                         $status = 'Status not set yet';
                                     }
                                 }
                             }
                         }
                     }
                 }
                 return $this->renderPartial('updatestudentaccess', array('status' => DefaultForm::ERROR_CODE_NO_ERROR, 'message' => '', 'username' => $username, 'status' => $status, 'statusResult' => $statusResult, 'isPasswordSet' => $isPasswordSet, 'studentID' => $studentID));
             } else {
                 return $this->renderPartial('errorpartial');
             }
         } else {
             return $this->renderPartial('errorpartial');
         }
     } else {
         return DefaultController::redirectToLogOut();
     }
 }