コード例 #1
0
<?php

$Members = new PerchMembers_Members($API);
$MemberForms = new PerchMembers_Forms($API);
$message = false;
$HTML = $API->get('HTML');
if (isset($_GET['id']) && $_GET['id'] != '') {
    $formID = (int) $_GET['id'];
    $MemberForm = $MemberForms->find($formID);
    $details = $MemberForm->to_array();
    $settings = PerchUtil::json_safe_decode($MemberForm->formSettings(), true);
    $heading1 = 'Editing a Member Form';
}
$heading2 = 'Form details';
$Form = $API->get('Form');
$Form->require_field('formTitle', 'Required');
if ($Form->submitted()) {
    $postvars = array('formTitle');
    $data = $Form->receive($postvars);
    $result = false;
    if (is_object($MemberForm)) {
        $postvars = array('moderate', 'moderator_email', 'default_tags');
        $settings_data = $Form->receive($postvars);
        if (!isset($settings_data['moderate'])) {
            $settings_data['moderate'] = '0';
        }
        $data['formSettings'] = PerchUtil::json_safe_encode($settings_data);
        $result = $MemberForm->update($data);
    }
    $message = $HTML->success_message('The form has been successfully updated. Return to %sform listing%s', '<a href="' . $API->app_path() . '/forms/">', '</a>');
    if (is_object($MemberForm)) {
コード例 #2
0
 public function register_with_form($SubmittedForm)
 {
     $key = $SubmittedForm->id . (isset($SubmittedForm->form_attributes['type']) ? '.' . $SubmittedForm->form_attributes['type'] : '');
     $Forms = new PerchMembers_Forms($this->api);
     $Form = $Forms->find_or_create($key);
     $do_login = false;
     if (is_object($Form)) {
         $form_settings = PerchUtil::json_safe_decode($Form->formSettings(), true);
         $member = array('memberAuthType' => 'native', 'memberEmail' => '', 'memberPassword' => '', 'memberStatus' => 'pending', 'memberCreated' => date('Y-m-d H:i:s'));
         $data = $SubmittedForm->data;
         $properties = array();
         foreach ($data as $key => $val) {
             if (array_key_exists($key, $this->field_aliases)) {
                 $member[$this->field_aliases[$key]] = $val;
                 $key = $this->field_aliases[$key];
             }
             if (!in_array($key, $this->static_fields)) {
                 $properties[$key] = $val;
             }
         }
         $member['memberProperties'] = PerchUtil::json_safe_encode($properties);
         // Password
         $clear_pwd = $member['memberPassword'];
         if (defined('PERCH_NONPORTABLE_HASHES') && PERCH_NONPORTABLE_HASHES) {
             $portable_hashes = false;
         } else {
             $portable_hashes = true;
         }
         $Hasher = new PasswordHash(8, $portable_hashes);
         $member['memberPassword'] = $Hasher->HashPassword($clear_pwd);
         $Member = $this->create($member);
         $member = array('memberAuthID' => $Member->memberID());
         if (isset($form_settings['moderate']) && $form_settings['moderate'] == '1') {
             if (isset($form_settings['moderator_email'])) {
                 $this->_email_moderator($form_settings['moderator_email'], $Member);
             }
         } else {
             $member['memberStatus'] = 'active';
             $do_login = true;
         }
         $Member->update($member);
         if (isset($form_settings['default_tags']) && $form_settings['default_tags'] != '') {
             $tags = explode(',', $form_settings['default_tags']);
             if (PerchUtil::count($tags)) {
                 foreach ($tags as $tagDisplay) {
                     $expiry = false;
                     if (strpos($tagDisplay, '|') > 0) {
                         $parts = explode('|', $tagDisplay);
                         $tagDisplay = $parts[0];
                         $expiry = $parts[1];
                     }
                     $tagDisplay = trim($tagDisplay);
                     $tag = PerchUtil::urlify($tagDisplay);
                     $Member->add_tag($tag, $tagDisplay, $expiry);
                 }
             }
         }
         if (is_object($Member) && $do_login) {
             $key = base64_encode('login:perch_members:login/login_form.html');
             $data = array('email' => $Member->memberEmail(), 'password' => $clear_pwd, 'pos');
             $files = array();
             $Perch = Perch::fetch();
             $Perch->dispatch_form($key, $data, $files);
         }
         if (is_object($Member) && $clear_pwd === '__auto__') {
             $Member->update(array('memberPassword' => null));
         }
     }
 }
コード例 #3
0
<?php

$HTML = $API->get('HTML');
$Members = new PerchMembers_Members($API);
$MemberForms = new PerchMembers_Forms($API);
$Paging = $API->get('Paging');
$Paging->set_per_page(20);
$Lang = $API->get('Lang');
$forms = $MemberForms->all();