public function saveOperator($realName, $userName, $userPwd, $roles, $teacher) { $instId = session('instId'); try { $operator = new \Home\Model\OperatorModel(); $operator->startTrans(); $operatorId = $operator->addOperator($instId, $userName, $userPwd, 0, $realName, $teacher); $roleIds = explode('|', $roles); for ($i = 0; $i < count($roleIds); $i++) { $operator->addOperatorAndRoleRela($operatorId[0]['operator_id'], (int) $roleIds[$i]); } $operator->commit(); $data = "true"; } catch (Exception $e) { $operator->rollback(); $data = "false"; } $this->ajaxReturn($data); }
public function saveTeacher($teacher, $loginname) { if ($teacher == "") { return; } $instId = session('instId'); $model = new \Home\Model\TeacherModel(); $operator = new \Home\Model\OperatorModel(); try { $model->startTrans(); $result = $model->saveTeacher($teacher, $instId); //TODO 稍后改成用户自定义密码 $operatorId = $operator->addOperator($instId, $loginname, '123456', 0, $teacher, $result[0]['teacher_id']); //TODO 稍后改成查数据库code=ROLE_TEACHER的 $operator->addOperatorAndRoleRela($operatorId[0]['operator_id'], 1); $model->commit(); $data = "true"; } catch (Exception $e) { $model->rollback(); $data = "false"; } $this->ajaxReturn($data); }
public function doRegister($instName, $applicant, $classType, $studentAges, $email, $wechat, $remark, $loginname, $password, $confirmCode, $isOnline, $province, $city, $district) { if ($confirmCode != "thankyouforusing893!") { $this->ajaxReturn("false"); return; } try { //save inst $instModel = new \Home\Model\InstitutionModel(); $instModel->startTrans(); $instArr = $instModel->saveInstitution($instName); $instId = (int) $instArr[0]['inst_id']; //save operator $isSuperAdmin = 1; $operatorModel = new \Home\Model\OperatorModel(); $operatorModel->addOperator($instId, $loginname, $password, $isSuperAdmin, $applicant, 0); //save register info $registerModel = new \Home\Model\RegisterModel(); $registerModel->saveRegister($instName, $applicant, $classType, $studentAges, $email, $wechat, $remark, $instId, (int) $isOnline, (int) $province, (int) $city, (int) $district); $instModel->commit(); $data = "true"; } catch (Exception $e) { $instModel->rollback(); $data = "false"; } $this->ajaxReturn($data); }