Example #1
0
function amuCSVToForm()
{
    global $wpdb;
    $rawCSVdata = $_POST['filecontents'];
    $parsedData = parse_csv($rawCSVdata);
    $userData = reorder_csv($parsedData);
    $source = 'csvlist';
    $newForm = new amuFormCreator($source, $userData);
    $newForm->amuCreateFormInterface();
    //show form field info
    $infotype = 'formfields';
    showPluginInfo($infotype);
}
Example #2
0
function amuProcessEmailInput($regType)
{
    global $wpdb;
    //clean up input
    $rawEmailList = trim($_POST['emailfillbox']);
    $order = array('\\r\\n', '\\n', '\\r', ' ');
    $replace = '';
    $cleanEmailList = str_replace($order, $replace, $rawEmailList);
    //verify array is not empty
    if ($cleanEmailList !== '') {
        $verifySymbol = strpos($cleanEmailList, '@');
        if ($verifySymbol == false) {
            $emailListError = '<p class="amu_error">' . __('Error: No valid email addresses were found in your input data! Please try again.', 'amulang') . '</p>';
            addByEmailList($emailListError);
            $infotype = 'emaillisting';
            showPluginInfo($infotype);
        } else {
            //new array for user data
            $userArray = array();
            $emailListArray = explode(',', $cleanEmailList);
            foreach ($emailListArray as $userEntry) {
                //create username/email vars
                $em_useremail = $userEntry;
                $pos = strpos($em_useremail, '@');
                $em_username = substr($em_useremail, 0, $pos);
                //verify is email address
                if ($pos !== false) {
                    $userEntryArray = array();
                    //push some values plus some dummy ones
                    $userEntryArray['user_login'] = $em_username;
                    $userEntryArray['user_pass'] = '';
                    $userEntryArray['user_email'] = $em_useremail;
                    //push role variable if it exists
                    $theDefRole = get_option('amu_setallroles');
                    if ($theDefRole == 'notset') {
                        $userEntryArray['role'] = '';
                    } else {
                        $userEntryArray['role'] = $theDefRole;
                    }
                    if ($regType == 'form') {
                        //send some other ones
                        $userEntryArray['first_name'] = '';
                        $userEntryArray['last_name'] = '';
                        //add selected standard values
                        $stdamumetaoption = get_option('amu_showblankmeta');
                        if ($stdamumetaoption !== '') {
                            $stdMetaOptions = json_decode(get_option('amu_showblankmeta'));
                            foreach ($stdMetaOptions as $stdmeta) {
                                $userEntryArray[$stdmeta->keyname] = '';
                            }
                        }
                        //add custom meta options
                        $extraamumetaoptions = get_option('amu_extrameta');
                        if ($extraamumetaoptions !== '') {
                            $extraMetaOptions = json_decode(get_option('amu_extrameta'));
                            foreach ($extraMetaOptions as $extmeta) {
                                $userEntryArray[$extmeta->keyname] = '';
                            }
                        }
                    }
                    //add this entry array to full user data array
                    $userArray[] = $userEntryArray;
                    //kill it for reuse
                    unset($userEntryArray);
                }
            }
            //encode full user array
            $userData = json_encode($userArray);
            //send to form creator
            if ($regType == 'form') {
                $source = 'email';
                $newForm = new amuFormCreator($source, $userData);
                $newForm->amuCreateFormInterface();
                //show form field info
                $infotype = 'formfields';
                showPluginInfo($infotype);
                //or process direct
            } else {
                if ($regType == 'direct') {
                    $eachUserData = json_decode($userData);
                    $confirmationStack = array();
                    $line = 0;
                    foreach ($eachUserData as $userRow) {
                        $line++;
                        if ($userRow->user_login !== '') {
                            //create new user object
                            $newUser = new amuUserObject($userRow);
                            //register initial user info
                            $newid = $newUser->amuRegisterUser();
                            if (is_int($newid)) {
                                //update users data based on input
                                $newUser->amuUpdateUserData();
                                //send user a notification email
                                $newUser->amuSendUserEmail();
                                //set confirmation message
                                $confirmUpdate = '<p><strong>' . $line . '</strong>. ' . __('New user successfully registered.', 'amulang') . ' <strong>' . __('Login', 'amulang') . ':</strong> ' . $newUser->user_login . ' <strong>' . __('Password', 'amulang') . ':</strong> ' . $newUser->user_pass . ' <strong>' . __('Email', 'amulang') . ':</strong> ' . $newUser->user_email . '</p>';
                            } else {
                                //return failure message
                                $confirmUpdate = '<p>' . $line . '. ' . $newid . '</p>';
                            }
                            //kill reusable object
                            unset($newUser);
                        } else {
                            //return failure message
                            $confirmUpdate = '<p>' . $line . '. ' . __('No user_login was found. This line was skipped.', 'amulang') . '</p>';
                        }
                        //add success or failure message to stack
                        $confirmationStack[] = $confirmUpdate;
                    }
                    echo '<h3>' . __('Results of your new user registrations', 'amulang') . '</h3>';
                    //admin notifications
                    $adminUser = new amuAdminObject();
                    $sendRegResults = $adminUser->amuAdminConfirmation($confirmationStack);
                    $stackDisplay = $adminUser->amuShowStack($confirmationStack);
                    //print notifications to screen
                    echo $sendRegResults;
                    echo '<div class="stackwrap">' . $stackDisplay . '</div>';
                    //or throw error
                } else {
                    echo '<p>' . __('Unknown request.', 'amulang') . '</p>';
                }
            }
        }
    } else {
        $emailListError = '<p class="amu_error">' . __('Error: No valid email addresses were found in your input data! Please try again.', 'amulang') . '</p>';
        addByEmailList($emailListError);
        $infotype = 'emaillisting';
        showPluginInfo($infotype);
    }
}
Example #3
0
function amuCreateManualForm()
{
    global $wpdb;
    //get number of lines
    $manprocs = $_POST['manualprocs'];
    //confirm post is not empty, is a number and is larger than zero
    if ($manprocs !== '' && ctype_digit($manprocs) && $manprocs > 0) {
        //create dummy arrays
        $userArray = array();
        $userEntryArray = array();
        //push standard values
        $userEntryArray['user_login'] = '';
        $userEntryArray['user_pass'] = '';
        $userEntryArray['user_email'] = '';
        //push role value, set if chosen in settings
        $theDefRole = get_option('amu_setallroles');
        if ($theDefRole == 'notset') {
            $userEntryArray['role'] = '';
        } else {
            $userEntryArray['role'] = $theDefRole;
        }
        //send remaining standard values
        $userEntryArray['first_name'] = '';
        $userEntryArray['last_name'] = '';
        //push remaining standard meta options
        $stdamumetaoption = get_option('amu_showblankmeta');
        if ($stdamumetaoption !== '') {
            $stdMetaOptions = json_decode(get_option('amu_showblankmeta'));
            foreach ($stdMetaOptions as $stdmeta) {
                $userEntryArray[$stdmeta->keyname] = '';
            }
        }
        //push custom meta options
        $extraamumetaoptions = get_option('amu_extrameta');
        if ($extraamumetaoptions !== '') {
            $extraMetaOptions = json_decode(get_option('amu_extrameta'));
            foreach ($extraMetaOptions as $extmeta) {
                $userEntryArray[$extmeta->keyname] = '';
            }
        }
        //create array of empty arrays
        while ($manprocs > 0) {
            //add blank array as many times as needed
            $userArray[] = $userEntryArray;
            //decrement
            $manprocs--;
        }
        //send to form creator
        $userData = json_encode($userArray);
        $source = 'manual';
        $newForm = new amuFormCreator($source, $userData);
        $newForm->amuCreateFormInterface();
        //show form field info
        $infotype = 'formfields';
        showPluginInfo($infotype);
        //error message
    } else {
        $manualInputError = '<p class="amu_error">' . __('Error: either the number you entered was zero, empty, or a non-numeric character was entered. Please try again.', 'amulang') . '</p>';
        amuGenerateManualForm($manualInputError);
    }
}