示例#1
0
 function save($data, $options = array())
 {
     $options = array_merge($this->getOptions(), $options);
     if (!(isset($options['related_form_id']) && $options['related_form_id'])) {
         trigger_error(sprintf(AMP_TEXT_ERROR_NOT_DEFINED, get_class($this), 'related_form_id'));
         return;
     }
     foreach ($this->_included_fieldnames as $fieldname) {
         if ($this->fields[$fieldname]['type'] == 'select') {
             $data[$fieldname] = $_POST[$this->addPrefix($fieldname)];
         }
     }
     # this is weak, but deep within quickform our shit is getting
     # overridden with values from the original udm (constant vs default vs submit values)
     $temp_post = $_POST;
     unset($_POST['modin']);
     $data_sets = $this->convert_to_sets($data);
     foreach ($data_sets as $values) {
         if (isset($options['related_form_owner_field']) && $options['related_form_owner_field']) {
             $values[$options['related_form_owner_field']] = $this->udm->uid;
         }
         $udm = new UserDataInput($this->dbcon, $options['related_form_id'], $this->udm->admin);
         # here's where the lameness comes in
         foreach (array_keys($values) as $key) {
             unset($_POST[$key]);
             # we also have to make everything public, or it won't save
             $udm->fields[$key]['public'] = 1;
         }
         $udm->setData($values);
         $results[] = $udm->saveUser();
         unset($udm);
     }
     $_POST = $temp_post;
     return true;
 }
示例#2
0
} else {
    ampredirect("modinput4_list.php");
}
$admin = AMP_Authorized(AMP_PERMISSION_FORM_DATA_EDIT) && AMP_Authorized($modin_permission);
// Fetch the form instance specified by submitted modin value.
$udm = new UserDataInput($dbcon, $modin, $admin);
// User ID.
$udm->authorized = true;
$udm->uid = $uid;
// Was data submitted via the web?
$sub = isset($_REQUEST['btnUdmSubmit']) ? $_REQUEST['btnUdmSubmit'] : false;
// Fetch or save user data.
if ($sub) {
    // Save only if submitted data is present, and the user is
    // authenticated, or if the submission is anonymous (i.e., !$uid)
    if ($udm->saveUser()) {
        ampredirect(AMP_SYSTEM_URL_FORM_DATA . "?modin=" . $udm->instance);
    }
    $udm->showForm = true;
} elseif (!$sub && $uid) {
    // Fetch the user data for $uid if there is no submitted data
    // and the user is authenticated.
    $udm->getUser($uid);
}
/* Now Output the Form.

   Any necessary changes to the form should have been registered
   before now, including any error messages, notices, or
   complete form overhauls. This can happen either within the
   $udm object, or from print() or echo() statements.
示例#3
0
if ($modin && !$pid) {
    $pid = Petition::findByModin($modin);
}
$current_petition->read($pid);
if ($current_petition->id) {
    // Fetch the form instance specified by submitted modin value.
    $udm = new UserDataInput($dbcon, $current_petition->getFormId());
    // Was data submitted via the web?
    $sub = isset($_REQUEST['btnUdmSubmit']) && $_REQUEST['btnUdmSubmit'];
    //OUTPUT THE PAGE
    echo $current_petition->progressBox();
    // Fetch or save user data.
    if ($udm->submitted) {
        // Save only if submitted data is present, and the user is
        // authenticated, or if the submission is anonymous (i.e., !$uid)
        $save_success = $udm->saveUser();
        echo $udm->output();
        if ($save_success) {
            echo $current_petition->petition_signers();
        }
    }
    if (isset($_REQUEST['signers']) && $_REQUEST['signers']) {
        echo $current_petition->petition_signers();
    }
    if (!$_REQUEST['btnUdmSubmit'] and !$_REQUEST["signers"] and !$_REQUEST["uid"]) {
        echo $current_petition->intro_text();
        echo $current_petition->signature_link();
        echo '<p class="title">Sign Petition</p>';
        print $udm->output();
    }
} else {
示例#4
0
$udm = new UserDataInput(AMP_dbcon(), 20);
$udm->getUser($AMP_Authen_Handler->getUserId());
// Hide fields that should be present on the signup form, but not on the edit form
// Custom1 = username
// Custom2 = password
// remember users email field so we can use it later when we save
$email = $udm->fields['Email'];
// Remove non-editable fields so that they don't display on the form
$non_editable_fields = array('custom1', 'custom2', 'Email');
foreach ($non_editable_fields as $field_name) {
    unset($udm->fields[$field_name]);
}
// if there is POST data, save and redirect back to self.
if (isset($_POST['btnUdmSubmit'])) {
    // add email field back in so DIA syncing works
    if (empty($udm->fields['Email'])) {
        $udm->fields['Email'] = $email;
        //add the email back in the post so that the udm save function doesn't throw a validation error.
        $_POST['Email'] = $email['value'];
    }
    $udm->saveUser();
    AMP_flashMessage('Profile Updated');
    AMP_redirect('profile.php');
}
//BaseModuleIntro uses this local variable to decide what intro text to display for this page.
//$intro_id = $udm->modTemplateID;
$intro_id = AMP_CONTENT_EDIT_PROFILE_INTROTEXT_ID;
AMP_directDisplay('<div id="' . sprintf(AMP_UDM_FORM_CONTAINER, 20) . '">' . $udm->output() . '</div>');
require_once 'AMP/BaseTemplate.php';
require_once 'AMP/BaseModuleIntro.php';
require_once 'AMP/BaseFooter.php';