/**
  * Store user detail in database
  * 
  * @return response
  */
 public function store()
 {
     $userId = $this->user->createUser(Input::all());
     if (!is_integer($userId)) {
         return Redirect::back()->withInput()->withErrors($this->user->getMessage());
     }
     return Redirect::route('user.downloadHere', $userId)->with('message', "Service Added successfully!");
 }
Example #2
0
/**
 * Does a user setup up routine, if the user exists in turnitintool_users then the Turnitin User ID is returned for that user
 * if not then A call to FID1 to Create the User is called and the ID is returned and stored in turnitintool_users
 *
 * This is required when user not present calls are made or when there may not yet be a class owner to make the call through the API
 * specifically through reset course and add_instance
 *
 * @param object $userdata The moodle user object for the user we are setting up
 * @param string $status The status message that is displayed in the loader bar if the user need to be created
 * @param object $tii The turnitintool_commclass object is passed by reference
 * @param object $loaderbar The turnitintool_loaderbarclass object is passed by reference can be NULL if no loader bar is to be used
 * @return object A turnitintool_users data object that was either created or found during this call
 */
function turnitintool_usersetup($userdata, $status = '', &$tii, &$loaderbar)
{
    global $CFG;
    if (!turnitintool_check_config()) {
        turnitintool_print_error('configureerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
        exit;
    }
    if (!($turnitintool_user = turnitintool_get_record("turnitintool_users", "userid", $userdata->id)) or isset($turnitintool_user->turnitin_uid) and $turnitintool_user->turnitin_uid < 1) {
        if (isset($loaderbar->total)) {
            $loaderbar->total = $loaderbar->total + 3;
        }
        // Do call with NO IDs to check the email address and retrieve the Turnitin UID
        $post = new stdClass();
        $post->idsync = 1;
        if ($tii->utp == 1 and $CFG->turnitin_studentemail != "1") {
            $post->dis = 1;
        } else {
            $post->dis = 0;
        }
        $tii->createUser($post, $status);
        if ($tii->getRerror()) {
            return null;
        }
        $turnitinid = $tii->getUserID();
        $turnitinuser = new stdClass();
        if (isset($turnitintool_user->id) and $turnitintool_user->id) {
            $turnitinuser->id = $turnitintool_user->id;
        }
        $turnitinuser->userid = $userdata->id;
        $turnitinuser->turnitin_uid = $turnitinid;
        $turnitinuser->turnitin_utp = $tii->utp;
        $tii->uid = $turnitinid;
        if (isset($turnitinuser->id) and !turnitintool_update_record('turnitintool_users', $turnitinuser)) {
            turnitintool_print_error('userupdateerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
            exit;
        } else {
            if (!isset($turnitinuser->id) and !($insertid = turnitintool_insert_record('turnitintool_users', $turnitinuser))) {
                turnitintool_print_error('userupdateerror', 'turnitintool', NULL, NULL, __FILE__, __LINE__);
                exit;
            }
        }
        $turnitinuser->id = isset($insertid) ? $insertid : $turnitinuser->id;
        return $turnitinuser;
    } else {
        return $turnitintool_user;
    }
}