/** * Create a new Instructor User on Turnitin. * * Takes a {@link TiiUser.html TiiUser} or a * {@link TiiPseudoUser.html TiiPseudoUser} object containing the required parameters * and returns a {@link Response.html Response} object containing the data from the response. * * Convenience method that adds the Instructor role (see: {@link TurnitinAPI.html#createUser createUser}) * * @param TiiUser $user * @return Response */ public function createInstructorUser($user) { $userSoap = $this->setOptions(new UserSoap($this->personwsdl, $this->getServiceOptions('person'))); $user->setDefaultRole('Instructor'); return $userSoap->createUser($user); }
/** * Edit the user's details on Turnitin (only name can be updated) * * @param object $user_details A data object for the user * @param var $role user role to create */ public function edit_tii_user() { $config = turnitintooltwo_admin_config(); $turnitincomms = new turnitintooltwo_comms(); $turnitincall = $turnitincomms->initialise_api(); // Only update if pseudo is not enabled. if (empty($config->enablepseudo)) { $user = new TiiUser(); $user->setFirstName($this->firstname); $user->setLastName($this->lastname); $user->setUserId($this->tii_user_id); $user->setDefaultRole($this->role); try { $turnitincall->updateUser($user); turnitintooltwo_activitylog("Turnitin User updated: " . $this->id . " (" . $this->tii_user_id . ")", "REQUEST"); } catch (Exception $e) { $toscreen = $this->workflowcontext == "cron" ? false : true; $turnitincomms->handle_exceptions($e, 'userupdateerror', $toscreen); } } }
public function readUser($user) { try { $soap = $this->readPerson(array('sourcedId' => $user->getUserId())); $response = new Response($this); if ($response->getStatus() == 'error') { throw new TurnitinSDKException($response->getStatusCode(), $response->getDescription()); } else { $tiiUser = new TiiUser(); $tiiUser->setUserId($soap->personRecord->sourcedGUID->sourcedId); $tiiUser->setDefaultRole($soap->personRecord->person->roles->institutionRole->institutionroletype->instanceValue->textString); $tiiUser->setEmail($soap->personRecord->person->contactinfo->contactinfoValue->textString); foreach ($soap->personRecord->person->name->partName as $partname) { if ($partname->instanceName->textString == 'First') { $tiiUser->setFirstname($partname->instanceValue->textString); } else { if ($partname->instanceName->textString == 'Last') { $tiiUser->setLastname($partname->instanceValue->textString); } } } $soap->personRecord->person->extension->extensionField = is_array($soap->personRecord->person->extension->extensionField) ? $soap->personRecord->person->extension->extensionField : array($soap->personRecord->person->extension->extensionField); foreach ($soap->personRecord->person->extension->extensionField as $field) { $name = $field->fieldName; $method = 'set' . $name; if (is_callable(array($tiiUser, $method))) { $tiiUser->{$method}($field->fieldValue); } } $response->setUser($tiiUser); } return $response; } catch (SoapFault $e) { throw new TurnitinSDKException($e->faultcode, $e->faultstring, parent::getLogPath()); } }