<?php if (!defined('ABSPATH')) { die('Security check'); } $settings = CRED_Helper::mergeArrays(array('type' => 'new', 'action' => 'form', 'user_role' => '', 'action_page' => '', 'action_message' => '', 'redirect_delay' => 0, 'hide_comments' => 0, 'theme' => 'minimal', 'has_media_button' => 0, 'include_wpml_scaffold' => 0, 'include_captcha_scaffold' => 0), (array) $settings); ?> <fieldset class="cred-fieldset"> <h4><?php _e('Basic Settings', 'wp-cred'); ?> </h4> <?php wp_nonce_field('cred-admin-post-page-action', 'cred-admin-post-page-field'); ?> <p class='cred-explain-text'><?php _e('Forms can create new user or edit existing user. Choose what this form will do:', 'wp-cred'); ?> </p> <select id="cred_form_type" name="_cred[form][type]"> <?php $form_types = apply_filters('cred_admin_form_type_options', array("new" => __('Create a user', 'wp-cred'), "edit" => __('Edit a user', 'wp-cred')), $settings['type'], $form); foreach ($form_types as $_v => $_l) { if ($settings['type'] == $_v) { ?> <option value="<?php echo $_v; ?> " selected="selected"><?php
/** * * $HeadURL: https://www.onthegosystems.com/misc_svn/crud/trunk_new/embedded/views/templates/notification.tpl.php $ * $LastChangedDate: 2014-07-18 14:52:48 +0200 (ven, 18 lug 2014) $ * $LastChangedRevision: 25108 $ * $LastChangedBy: marcin $ * */ if (!defined('ABSPATH')) { die('Security check'); } if (!is_array($notification)) { $notification = array(); } $notification = CRED_Helper::mergeArrays(array('event' => array('type' => 'form_submit', 'post_status' => 'publish', 'condition' => array(), 'any_all' => 'ALL'), 'to' => array('type' => array(), 'wp_user' => array('to_type' => 'to', 'user' => ''), 'mail_field' => array('to_type' => 'to', 'address_field' => '', 'name_field' => '', 'lastname_field' => ''), 'user_id_field' => array('to_type' => 'to', 'field_name' => ''), 'specific_mail' => array('address' => '')), 'from' => array('address' => '', 'name' => ''), 'mail' => array('subject' => '', 'body' => '')), $notification); // make sure everything needign to be array, is array $notification = (array) $notification; $notification['event'] = (array) $notification['event']; $notification['to'] = (array) $notification['to']; if (!isset($notification['to']['type'])) { $notification['to']['type'] = array(); } if (!is_array($notification['to']['type'])) { $notification['to']['type'] = (array) $notification['to']['type']; } ?> <div id="cred_notification_settings_panel-<?php echo $ii; ?> " class='cred_notification_settings_panel cred_validation_section'>
/** * * $HeadURL: https://www.onthegosystems.com/misc_svn/crud/trunk_new/embedded/views/templates/notification-condition.tpl.php $ * $LastChangedDate: 2014-07-21 16:02:20 +0200 (lun, 21 lug 2014) $ * $LastChangedRevision: 25151 $ * $LastChangedBy: marcin $ * */ if (!defined('ABSPATH')) { die('Security check'); } if (!is_array($condition)) { $condition = array(); } $condition = CRED_Helper::mergeArrays(array('field' => '', 'op' => '=', 'value' => '', 'only_if_changed' => 1), $condition); ?> <p id="cred_notification_field_condition-<?php echo $ii; ?> -<?php echo $jj; ?> "> <i title="<?php echo esc_attr(__('Please select a field', 'wp-cred')); ?> " id="notification_field_required-<?php echo $ii; ?> -<?php
public static function saveFormCustomFields($post_id, $post) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (wp_is_post_revision($post_id)) { return; } if (CRED_FORMS_CUSTOM_POST_NAME != $post->post_type && CRED_USER_FORMS_CUSTOM_POST_NAME != $post->post_type) { return; } if (!current_user_can('edit_post', $post_id)) { return; } // hook not called from admin edit page, return if (empty($_POST) || !isset($_POST['cred-admin-post-page-field']) || !wp_verify_nonce($_POST['cred-admin-post-page-field'], 'cred-admin-post-page-action')) { return; } if (isset($_POST['_cred']) && is_array($_POST['_cred']) && !empty($_POST['_cred'])) { // new format if (CRED_FORMS_CUSTOM_POST_NAME == $post->post_type) { $model = CRED_Loader::get('MODEL/Forms'); $add_merge = array('hide_comments' => 0, 'has_media_button' => 0, 'action_message' => ''); } if (CRED_USER_FORMS_CUSTOM_POST_NAME == $post->post_type) { $model = CRED_Loader::get('MODEL/UserForms'); if (isset($_POST['_cred']['form']['user_role'])) { $_POST['_cred']['form']['user_role'] = json_encode($_POST['_cred']['form']['user_role']); } $add_merge = array('hide_comments' => 0, 'has_media_button' => 0, 'action_message' => '', 'autogenerate_username_scaffold' => isset($_POST['_cred']['form']['autogenerate_username_scaffold']) ? 1 : 0, 'autogenerate_nickname_scaffold' => isset($_POST['_cred']['form']['autogenerate_nickname_scaffold']) ? 1 : 0, 'autogenerate_password_scaffold' => isset($_POST['_cred']['form']['autogenerate_password_scaffold']) ? 1 : 0); } // settings (form, post, actions, messages, css etc..) $settings = new stdClass(); $settings->form = isset($_POST['_cred']['form']) ? $_POST['_cred']['form'] : array(); $settings->post = isset($_POST['_cred']['post']) ? $_POST['_cred']['post'] : array(); $settings->form = CRED_Helper::mergeArrays($add_merge, $settings->form); // notifications $notification = new stdClass(); $notification->notifications = array(); // normalize order of notifications using array_values $notification->notifications = isset($_POST['_cred']['notification']['notifications']) ? array_values($_POST['_cred']['notification']['notifications']) : array(); //we have notifications allways enabled //$notification->enable=isset($_POST['_cred']['notification']['enable'])?1:0; $notification->enable = 1; foreach ($notification->notifications as $ii => $nott) { if (isset($nott['event']['condition']) && is_array($nott['event']['condition'])) { // normalize order $notification->notifications[$ii]['event']['condition'] = array_values($notification->notifications[$ii]['event']['condition']); $notification->notifications[$ii]['event']['condition'] = CRED_Helper::applyDefaults($notification->notifications[$ii]['event']['condition'], array('field' => '', 'op' => '', 'value' => '', 'only_if_changed' => 0)); } else { $notification->notifications[$ii]['event']['condition'] = array(); } } // extra $__allowed_tags = wp_kses_allowed_html('post'); $__allowed_protocols = array('http', 'https', 'mailto'); $allowed_tags = $__allowed_tags; $allowed_protocols = $__allowed_protocols; $extra_js = isset($_POST['_cred']['extra']['js']) ? $_POST['_cred']['extra']['js'] : ''; $extra_css = isset($_POST['_cred']['extra']['css']) ? $_POST['_cred']['extra']['css'] : ''; if (!empty($extra_js)) { $extra_js = wp_kses($extra_js, $allowed_tags, $allowed_protocols); } if (!empty($extra_css)) { $extra_css = wp_kses($extra_css, $allowed_tags, $allowed_protocols); } $messages = $model->getDefaultMessages(); $extra = new stdClass(); $extra->css = $extra_css; $extra->js = $extra_js; $extra->messages = isset($_POST['_cred']['extra']['messages']) ? $_POST['_cred']['extra']['messages'] : $model->getDefaultMessages(); // update $model->updateFormCustomFields($post_id, array('form_settings' => $settings, 'notification' => $notification, 'extra' => $extra)); // wizard if (isset($_POST['_cred']['wizard'])) { $model->updateFormCustomField($post_id, 'wizard', intval($_POST['_cred']['wizard'])); } // validation if (isset($_POST['_cred']['validation'])) { $model->updateFormCustomField($post_id, 'validation', $_POST['_cred']['validation']); } else { $model->updateFormCustomField($post_id, 'validation', array('success' => 1)); } // allow 3rd-party to do its own stuff on CRED form save do_action('cred_admin_save_form', $post_id, $post); // localize form with WPML //THIS code make notification on cred to be lost /* $data=CRED_Helper::localizeFormOnSave(array( 'post'=>$post, 'notification'=>$notification, 'message'=>$settings->form['action_message'], 'messages'=>$extra->messages )); $model->updateFormCustomField($post_id, 'notification', $data['notification']); */ CRED_Helper::localizeFormOnSave(array('post' => $post, 'notification' => $notification, 'message' => $settings->form['action_message'], 'messages' => $extra->messages)); } }