/** * edit/add term/taxonomy form to assign access by membership types * * @param taxonomy * @return none */ function mgm_taxonomy_form($taxonomy) { // except tags if (is_object($taxonomy)) { $term = $taxonomy->taxonomy; } else { $term = $taxonomy; } // exit if tags if ($term == 'post_tag') { return; } // member types $access_membership_types = mgm_get_class('post_taxonomy')->get_access_membership_types(); // init $membership_types = array(); // check edit if (isset($taxonomy->term_id) && $taxonomy->term_id > 0) { // check if (isset($access_membership_types[$taxonomy->term_id])) { $membership_types = $access_membership_types[$taxonomy->term_id]; } } // label if ($tax = get_taxonomy($term)) { $label = isset($tax->singular_label) ? $tax->singular_label : (isset($tax->labels->singular_name) ? $tax->labels->singular_name : mgm_singular($term)); $name = isset($tax->name) ? $tax->name : $term; } else { $label = mgm_singular($term); $name = $term; } // access $mgm_taxonomy_access = mgm_make_checkbox_group('mgm_taxonomy_access[]', mgm_get_class('membership_types')->membership_types, $membership_types, MGM_KEY_VALUE); ?> <script language="javascript"> <!-- jQuery(document).ready(function(){ <?php if (isset($taxonomy->term_id) && intval($taxonomy->term_id) > 0) { ?> var html='<tr class="form-field form-required">' + ' <th scope="row" valign="top"><label for="cat_name"><?php printf(__('%s Protection', 'mgm'), $label); ?> </label></th>' + ' <td><div>'+"<?php echo $mgm_taxonomy_access; ?> "+'</div>'+ ' <p><?php printf(__('Only selected membership types can access the <b>%s</b> taxonomy (Leave all unchecked to allow public access)', 'mgm'), $label); ?> </p></td>' + '</tr>'; jQuery("#edittag .form-table:last").append(html); <?php } else { ?> var html='<div class="form-field">'+ '<label for="mgm_taxonomy_access"><?php printf(__('%s Protection', 'mgm'), $label); ?> </label>'+ "<?php echo $mgm_taxonomy_access; ?> "+ '<p><?php printf(__('Only selected membership types can access the <b>%s</b> taxonomy (Leave all unchecked to allow public access)', 'mgm'), $label); ?> .</p>'+ '</div>'; jQuery("#addtag p.submit").before(html); <?php } ?> }); //--> </script> <?php }
<div class="cell mgm_add_edit_post"> <b><?php _e('Please select one or more membership type', 'mgm'); ?> :</b> </div> <?php } ?> </div> <div class="row"> <div class="cell paddingtop10px"> <?php if (count($data['membership_types']) > 0) { echo mgm_make_checkbox_group('access_membership_types[]', $data['membership_types'], '', MGM_KEY_VALUE); } else { _e('Sorry, no membership types available.', 'mgm'); } ?> </div> </div> <div class="row"> <?php if (count($data['posts']) > 0) { ?> <div class="cell mgm_add_edit_post" > <input type="checkbox" name="purchasable" id="purchasable" value="Y"/>
</b> </div> </div> <div class="row"> <div class="cell"> <?php // sections /* $sections = array('general_settings'=>__('General Settings','mgm'),'post_settings'=>__('Post Settings','mgm'), 'user_settings'=>__('User Settings','mgm'), 'coupons'=>__('Coupons','mgm'), 'downloads'=>__('Downloads','mgm'), 'download_posts'=>__('Download Posts','mgm'), 'download_attributes'=>__('Download Attributes','mgm'),'download_attribute_types'=>__('Download Attribute Types','mgm'), 'post_purchase_records'=>__('Post Purchase Records','mgm'), 'post_packs'=>__('Post Packs','mgm'), 'post_pack_posts'=>__('Post Pack Posts','mgm'));*/ $sections = array('general_settings' => __('General Settings', 'mgm'), 'messages_settings' => __('Messages Settings', 'mgm'), 'emails_settings' => __('Emails Settings', 'mgm'), 'content_protection_settings' => __('Content Protection Settings', 'mgm')); // show echo mgm_make_checkbox_group('export_sections[]', $sections, array_keys($sections), MGM_KEY_VALUE); ?> </div> </div> <div class="row"> <div class="cell mgm_migrate_type"> <input type="radio" name="migrate_type" value="export" checked="checked"/> <span><?php _e('Export', 'mgm'); ?> </span> <input type="radio" name="migrate_type" value="import" /> <span><?php _e('Import', 'mgm'); ?> </span>
</div> <?php } ?> <div class="row"> <div class="cell"> <p><b><?php _e('Supported Credit Card Types', 'mgm'); ?> :</b></p> </div> </div> <div class="row"> <div class="cell"> <?php echo mgm_make_checkbox_group('card_types[]', $data['module']->card_types, $data['module']->setting['supported_card_types'], 2, '', 'div'); ?> <p><div class="tips"><?php _e('Enable/Disable the credit card types to be shown in Credit Card Form.', 'mgm'); ?> </div></p> </div> </div> <div class="row"> <div class="cell"> <p><b><?php _e('Callback Success Title', 'mgm'); ?> :</b></p> </div> </div>
function field_type_checkboxg($field, $name, $value) { // options $options = preg_split('/[;,]+/', $field['options']); // check if (count($options)) { // value $value = $this->_filtered_value($field, $name, $value); // return return mgm_make_checkbox_group(sprintf('%s[]', $this->_get_element_name($field, $name)), $options, $value, MGM_VALUE_ONLY, '', 'div'); } // return default return $this->field_type_input($field, $name, $value); }
/** * edit custom fields */ function mgm_edit_custom_fields($user_ID = false, $submit_row = false, $return = false) { // get user if (!$user_ID) { $user_ID = mgm_get_user_id(); } // get form object if (is_object($user_ID)) { $user_ID = $user_ID->ID; } //check logged in user is super admin: $is_admin = is_super_admin() ? true : false; // system $system_obj = mgm_get_class('system'); // get custom_fields $profile_fields = mgm_get_config('default_profile_fields', array()); // get active custom fields on profile page //$cf_profile_page = mgm_get_class('member_custom_fields')->get_fields_where(array('display'=>array('on_profile'=>true))); //issue #844 - get active custom fields for profile page $cf_profile_pg = mgm_get_class('member_custom_fields'); $cf_profile_page = array(); foreach (array_unique($cf_profile_pg->sort_orders) as $id) { foreach ($cf_profile_pg->custom_fields as $field) { // issue #954: show the field only if it is enabled for profile page if ($field['id'] == $id && ($field['display']['on_profile'] || $is_admin)) { $cf_profile_page[] = $field; } } } $member = mgm_get_member($user_ID); //this is a fix for issue#: 589, see the notes for details: //This is to read saved coupons as array in order to fix the fatal error on some servers. //This will change the object on each users profile view. //Also this will avoid using patch for batch update, $arr_coupon = array('upgrade', 'extend'); $oldcoupon_found = 0; foreach ($arr_coupon as $cpn_type) { if (isset($member->{$cpn_type}['coupon']) && is_object($member->{$cpn_type}['coupon'])) { $member->{$cpn_type}['coupon'] = (array) $member->{$cpn_type}['coupon']; $oldcoupon_found++; } } if ($oldcoupon_found) { $member->save(); } // user $user = get_userdata($user_ID); // init $html = ''; // capture $fields = array(); //default and readonly fields: $default_readonly = array(); $arr_images = array(); //issue #844 $skip_fileds = array('subscription_introduction', 'coupon', 'privacy_policy', 'payment_gateways', 'terms_conditions', 'subscription_options', 'autoresponder', 'captcha', 'show_public_profile'); // loop fields foreach ($cf_profile_page as $field) { // issue#: 255 if (in_array($field['name'], array_keys($profile_fields))) { //if custom field = defualt field, is read only if ($field['attributes']['readonly'] && !$is_admin) { $default_readonly[] = $profile_fields[$field['name']]['id']; //email and url id is different than custom fields: if (in_array($field['name'], array('email', 'url'))) { $default_readonly[] = $field['name']; } } continue; } //issue #844 if (in_array($field['name'], $skip_fileds)) { continue; } // init value $value = ''; //disable readonly for admin user(issue#: 515) $ro = $field['attributes']['readonly'] == true && !$is_admin ? 'readonly="readonly"' : false; // value if (isset($member->custom_fields->{$field}['name'])) { $value = $member->custom_fields->{$field}['name']; } // date if ($field['name'] == 'birthdate') { if ($value) { //convert saved date to input field format $value = mgm_get_datepicker_format('date', $value); } else { $value = ''; } $element = '<input type="text" name="mgm_profile_field[' . $field['name'] . ']" value="' . $value . '" ' . $ro . ' class="text ' . ($ro ? '' : 'mgm_date') . ' mgm_custom_profile_birthdate"/>'; } else { if ($field['name'] == 'country') { $countries = mgm_field_values(TBL_MGM_COUNTRY, 'code', 'name'); if ($ro) { $countries = !empty($value) ? array($value => $countries[$value]) : array(" " => " "); } //issue #1782 $value = !empty($value) ? $value : 'US'; $options = mgm_make_combo_options($countries, $value, MGM_KEY_VALUE); $element = '<select name="mgm_profile_field[' . $field['name'] . ']" > ' . $options . ' </select>'; } else { if ($field['type'] == 'text') { $element = '<input type="text" name="mgm_profile_field[' . $field['name'] . ']" value="' . $value . '" ' . $ro . ' class="text mgm_custom_profile_password"/>'; } else { if ($field['type'] == 'password') { continue; } else { if ($field['type'] == 'textarea') { $element = '<textarea name="mgm_profile_field[' . $field['name'] . ']" cols="40" rows="5" ' . $ro . '>' . $value . '</textarea>'; } else { if ($field['type'] == 'checkbox') { $options = preg_split('/[;,]/', $field['options']); //$values = preg_split('/[;,\s]/', $value); $values = @unserialize($value); // pass " " as value to prevent the default value getting selected, if no option is selected $values = empty($values) ? " " : $values; //Issue # 694 $element = mgm_make_checkbox_group('mgm_profile_field[' . $field['name'] . '][]', $options, $values, MGM_VALUE_ONLY, '', 'div'); } else { if ($field['type'] == 'checkboxg') { $options = preg_split('/[;,]/', $field['options']); if (!is_array($value)) { $values = @unserialize($value); } else { $values = $value; } $values = empty($values) ? " " : $values; $element = mgm_make_checkbox_group('mgm_profile_field[' . $field['name'] . '][]', $options, $values, MGM_VALUE_ONLY, '', 'div'); } else { if ($field['type'] == 'radio') { $options = preg_split('/[;,]/', $field['options']); $element = mgm_make_radio_group('mgm_profile_field[' . $field['name'] . ']', $options, $value, MGM_VALUE_ONLY); } else { if ($field['type'] == 'select') { $element = '<select name="mgm_profile_field[' . $field['name'] . ']" ' . $ro . '>'; $options = preg_split('/[;,]/', $field['options']); if ($ro) { $options = !empty($value) ? array($value => $value) : array(" " => " "); } $element .= mgm_make_combo_options($options, $value, MGM_VALUE_ONLY); $element .= '</select>'; } else { if ($field['type'] == 'selectm') { $element = '<select name="mgm_profile_field[' . $field['name'] . '][]" ' . $ro . ' multiple>'; $options = preg_split('/[;,]/', $field['options']); if ($ro) { $options = !empty($value) ? array($value => $value) : array(" " => " "); } $element .= mgm_make_combo_options($options, $value, MGM_VALUE_ONLY); $element .= '</select>'; } else { if ($field['type'] == 'html') { $element = ''; $element .= '<div class="mgm_custom_subs_introduction">' . html_entity_decode(mgm_stripslashes_deep($field['value'])) . '</div>'; } else { if ($field['type'] == 'image') { $form_fields = new mgm_form_fields(); $element = $form_fields->get_field_element($field, 'mgm_profile_field', $value); if (!in_array($field['name'], $arr_images)) { $arr_images[] = $field['name']; } //issue #1258 } else { if ($field['type'] == 'label') { $form_fields = new mgm_form_fields(); $element = $form_fields->get_field_element($field, 'mgm_profile_field', $value); } } } } } } } } } } } } } // set array if ($element) { $fields[] = array('name' => $field['name'], 'label' => $field['label'], 'field' => $element); } } // if fields - issue #1782 if (count($fields)) { $html .= '<table class="form-table">'; foreach ($fields as $i => $row) { $html .= '<tr><th><label>' . mgm_stripslashes_deep($row['label']) . '</label></th>'; $html .= '<td>' . $row['field'] . '</td></tr>'; } // button if ($submit_row) { $html .= '<tr> <td colspan="2"> <input class="button" type="submit" name="submit" value="' . __('Update your profile', 'mgm') . '"/> <input type="hidden" name="update_mgm_custom_fields_submit" value="1" /> </td></tr>'; } $html .= '</table>'; $html .= mgm_attach_scripts(true, array()); $yearRange = mgm_get_calendar_year_range(); //include scripts for image upload: if (!empty($arr_images)) { $html .= mgm_upload_script_js('your-profile', $arr_images); } $html .= '<script language="javascript">jQuery(document).ready(function(){try{mgm_date_picker(".mgm_date",false,{yearRange:"' . $yearRange . '", dateFormat: "' . mgm_get_datepicker_format() . '"});}catch(x){}});</script>'; } if (!empty($default_readonly)) { $html .= '<script language="javascript">'; $html .= 'jQuery(document).ready(function(){try{'; $html .= 'jQuery.each(' . json_encode($default_readonly) . ', function(){jQuery("#"+this).attr("readonly", true)})'; $html .= '}catch(x){}})'; $html .= '</script>'; } // return if ($return) { return $html; } else { echo $html; } }