function change_gallery_id()
{
    if (!tf_current_user_can(array('manage_options', 'edit_posts', 'tf_admin_boutique'), false)) {
        return false;
    }
    global $TFUSE;
    $post_id = $TFUSE->request->REQUEST('post_id');
    if (!tfuse_parse_boolean($TFUSE->request->REQUEST('change'))) {
        echo json_encode(array('id' => $post_id));
        die;
    }
    $id = $TFUSE->request->REQUEST('input_id');
    $media = $TFUSE->request->REQUEST('media');
    $_token = trim($id) != '' ? $id . '_' . $post_id : $post_id;
    $post_fnc = $media == 'image' ? 'tfuse_gallery_group_post' : 'tfuse_download_group_post';
    $post_type = str_replace('_post', '', $post_fnc);
    $post = get_post($post_id);
    if ($post->post_type != $post_type) {
        $post_id = $post_fnc($_token);
    }
    echo json_encode(array('id' => $post_id));
    die;
}
 /**
  * @ajax
  */
 function save_form()
 {
     if (!tf_current_user_can(array('manage_options'), false)) {
         die('Access denied');
     }
     if (wp_verify_nonce($this->request->POST('form_setup_nonce'), 'form_setup_nonce_action')) {
         $form_to_save = array();
         if (trim($this->request->POST('tf_cf_formname_input') == '')) {
             return;
         }
         $form_to_save['form_name'] = $this->request->POST('tf_cf_formname_input');
         if (!count($this->request->POST('tf_cf_input')) > 0) {
             return;
         }
         foreach ($this->request->POST('tf_cf_input') as $key => $value) {
             $form_to_save['input'][$key]['label'] = $value;
         }
         if ($this->request->POST('menu-item')) {
             foreach ((array) $this->request->POST('tf_cf_column') as $key => $value) {
                 $form_to_save['input'][$key]['column'] = $value;
             }
         }
         foreach ($this->request->POST('tf_cf_input_options_label') as $key => $value) {
             if ($this->request->POST('tf_cf_select.' . $key) == 2 || $this->request->POST('tf_cf_select.' . $key) == 4) {
                 $form_to_save['input'][$key]['options'] = $value;
             }
         }
         foreach ($this->request->POST('tf_cf_input_shortcode') as $key => $value) {
             $form_to_save['input'][$key]['shortcode'] = $value;
         }
         foreach ($this->request->POST('tf_cf_select') as $key => $value) {
             $form_to_save['input'][$key]['type'] = $value;
             if ($this->request->isset_POST('tf_cf_input_newline_' . $key) && tfuse_parse_boolean($this->request->POST('tf_cf_input_newline_' . $key))) {
                 $form_to_save['input'][$key]['newline'] = 1;
             }
             if ($this->request->isset_POST('tf_cf_input_required_' . $key) && tfuse_parse_boolean($this->request->POST('tf_cf_input_required_' . $key))) {
                 $form_to_save['input'][$key]['required'] = 1;
             }
         }
         foreach ($this->request->POST('tf_cf_input_width') as $key => $value) {
             $form_to_save['input'][$key]['width'] = $value;
         }
         $form_to_save['submit_mess'] = trim($this->request->POST('tf_cf_mess_submit')) == '' ? 'Submit' : $this->request->POST('tf_cf_mess_submit');
         $form_to_save['succes_mess'] = $this->request->POST('tf_cf_succ_mess');
         $form_to_save['fail_mess'] = $this->request->POST('tf_cf_failure_mess');
         $form_to_save['email_template'] = $this->request->POST('tf_cf_email_template');
         $form_to_save['header_message'] = $this->request->POST('tf_cf_heading_text');
         if ($this->request->isset_POST('tf_cf_mess_reset')) {
             $form_to_save['reset_button'] = $this->request->POST('tf_cf_mess_reset');
         }
         $form_to_save['email_from'] = $this->request->POST('tf_cf_email_from');
         $form_to_save['email_to'] = $this->request->POST('tf_cf_email_to');
         $form_to_save['form_template'] = $this->request->POST('tf_cf_form_template');
         $form_to_save['email_subject'] = $this->request->POST('tf_cf_email_subject');
         $form_to_save['position'] = $this->request->POST('tf_cf_position');
         $form_to_save['required_text'] = $this->request->POST('tf_cf_required_text');
         if ($this->request->isset_GET('id')) {
             $this->defined_forms[$this->request->GET('id')] = $form_to_save;
         } else {
             $this->defined_forms[] = $form_to_save;
             $this->model->save_form($this->defined_forms);
             end($this->defined_forms);
             $curr_formId = key($this->defined_forms);
             $pageURL = 'http';
             if ($_SERVER['HTTPS'] == 'on') {
                 $pageURL .= 's';
             }
             $pageURL .= '://';
             $pageURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '&id=' . $curr_formId;
             header('Location:' . $pageURL);
         }
     } else {
         echo __('Your nonce did not pass verification', 'tfuse');
     }
 }
Example #3
0
 function prepare_ajax_data($form_data)
 {
     $form_to_save = array();
     foreach ($form_data['tf_rf_select'] as $key => $type) {
         $form_to_save['input'][$key]['type'] = $type;
         if (@tfuse_parse_boolean($form_data['tf_rf_input_newline_' . $key])) {
             $form_to_save['input'][$key]['newline'] = 1;
         }
         if (@tfuse_parse_boolean($form_data['tf_rf_input_required_' . $key])) {
             $form_to_save['input'][$key]['required'] = 1;
         }
         if (@tfuse_parse_boolean($form_data['tf_rf_column_' . $key])) {
             $form_to_save['input'][$key]['column'] = 1;
         }
     }
     unset($form_data['tf_rf_select']);
     foreach ($form_data['tf_rf_input_shortcode'] as $key => $shortcode) {
         $form_to_save['input'][$key]['shortcode'] = $shortcode;
     }
     unset($form_data['tf_rf_input_shortcode']);
     foreach ($form_data['tf_rf_input'] as $key => $label) {
         $form_to_save['input'][$key]['label'] = urlencode($label);
     }
     unset($form_data['tf_rf_input']);
     foreach ($form_data['tf_rf_input_width'] as $key => $width) {
         $form_to_save['input'][$key]['width'] = $width;
     }
     unset($form_data['tf_rf_input_width']);
     if (isset($form_data['tf_rf_exclude_date'])) {
         foreach ($form_data['tf_rf_exclude_date'] as $key => $exclude_date) {
             $form_to_save['exclude_dates'][$key] = $exclude_date;
         }
         unset($form_data['tf_rf_exclude_date']);
     }
     if (isset($form_data['tf_rf_input_options_label'])) {
         foreach ($form_data['tf_rf_input_options_label'] as $key => $options) {
             $form_to_save['input'][$key]['options'] = $options;
         }
         unset($form_data['tf_rf_input_options_label']);
     }
     $form_to_save['header_message'] = urlencode($form_data['tf_rf_heading_text']);
     $form_to_save['reset_button'] = urlencode($form_data['tf_rf_mess_reset']);
     $form_to_save['submit_mess'] = urlencode($form_data['tf_rf_mess_submit']);
     $form_to_save['tf_rf_form_notice'] = @urlencode($form_data['tf_rf_form_notice']);
     $form_to_save['position'] = @urlencode($form_data['tf_rf_position']);
     return $form_to_save;
 }