Esempio n. 1
0
 function wysija_form_manage_field()
 {
     $response = array('result' => true, 'error' => null);
     // get data
     $data = $this->_wysija_form_get_data();
     $form_id = (int) $_REQUEST['form_id'];
     // check for required fields
     if (!isset($data['type']) || isset($data['type']) && strlen(trim($data['type'])) === 0) {
         $response['error'] = __('You need to select a type for this field', WYSIJA);
         $response['result'] = false;
     }
     if (!isset($data['name']) || isset($data['name']) && strlen(trim($data['name'])) === 0) {
         $response['error'] = __('You need to specify a name for this field', WYSIJA);
         $response['result'] = false;
     }
     // only proceed if there is no error
     if ($response['error'] === null) {
         $is_required = isset($data['params']['required']) ? WJ_Utils::to_bool($data['params']['required']) : false;
         if (isset($data['field_id']) && (int) $data['field_id'] > 0) {
             // it's an update
             $custom_field = WJ_Field::get($data['field_id']);
             if ($custom_field !== NULL) {
                 $data['params'] = array_merge($custom_field->settings, $data['params']);
                 // update fields
                 $custom_field->name = $data['name'];
                 $custom_field->type = $data['type'];
                 $custom_field->required = $is_required;
                 $custom_field->settings = $data['params'];
                 $custom_field->save();
             } else {
                 // throw error if field does not exist
                 $response['error'] = __('This field does not exist', WYSIJA);
                 $response['result'] = false;
             }
         } else {
             // create new custom field
             $custom_field = new WJ_Field();
             $custom_field->set(array('name' => $data['name'], 'type' => $data['type'], 'required' => $is_required, 'settings' => $data['params']));
             $custom_field->save();
         }
         if ($response['error'] === null) {
             $helper_form_engine = WYSIJA::get('form_engine', 'helper');
             // need to update each block instance of this custom field
             $block = $helper_form_engine->refresh_custom_field($form_id, array('name' => $data['name'], 'field' => $custom_field->user_column_name(), 'type' => $data['type'], 'required' => $is_required, 'settings' => $data['params']));
             // render editor toolbar & templates
             $response['data'] = array('toolbar' => base64_encode($helper_form_engine->render_editor_toolbar()), 'templates' => base64_encode($helper_form_engine->render_editor_templates()));
             if ($block !== null) {
                 // refresh block using this custom field in the current form
                 $block_template = $helper_form_engine->render_editor_template($block);
                 if ($block_template !== null) {
                     $response['data']['block'] = base64_encode($block_template);
                 }
             }
         }
     }
     return $response;
 }
Esempio n. 2
0
 function getApplicationData()
 {
     $app = array();
     $app['domain'] = WJ_Utils::get_domain();
     return $app;
 }
Esempio n. 3
0
 function main()
 {
     parent::WYSIJA_control_back();
     wp_enqueue_style('thickbox');
     if (!isset($_REQUEST['action'])) {
         $this->action = 'main';
     } else {
         $this->action = $_REQUEST['action'];
     }
     $this->jsTrans['testemail'] = __('Sending a test email', WYSIJA);
     $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
     $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
     $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
     $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newsletters from now on without the need to activate their subscriptions.', WYSIJA);
     $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
     $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
     // form list
     $this->jsTrans['suredelete'] = __('Are you sure you want to delete this form?', WYSIJA);
     switch ($this->action) {
         case 'log':
         case 'save':
         case 'clearlog':
             wp_enqueue_script('wysija-config-settings', WYSIJA_URL . 'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
             wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
             wp_enqueue_script('jquery-cookie', WYSIJA_URL . 'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
         case 'form_add':
         case 'form_edit':
         case 'form_duplicate':
         case 'form_delete':
         case 'form_widget_settings':
         case 'form_add_field':
             return $this->{$this->action}();
             break;
         case 'reinstall':
             $this->reinstall();
             return;
             break;
         case 'dkimcheck':
             $this->dkimcheck();
             if (defined('WYSIJA_REDIRECT')) {
                 $this->redirectProcess();
             }
             return;
             break;
         case 'doreinstall':
             $this->doreinstall();
             if (defined('WYSIJA_REDIRECT')) {
                 global $wysi_location;
                 $wysi_location = 'admin.php?page=wysija_campaigns';
                 $this->redirectProcess();
             }
             return;
             break;
         default:
             wp_enqueue_script('mailpoet.tooltip', WYSIJA_URL . 'js/vendor/bootstrap.tooltip.js', array('jquery'), WYSIJA::get_version(), true);
             wp_enqueue_style('mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen');
             wp_enqueue_script('wysija-config-settings', WYSIJA_URL . 'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version(), true);
             wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
             wp_enqueue_script('jquery-cookie', WYSIJA_URL . 'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
     }
     if (WYSIJA_DBG > 1) {
         $this->viewObj->arrayMenus = array('log' => 'View log');
     }
     $this->data = array();
     $hook_settings_super_advanced_params = array();
     $this->data['hooks']['hook_settings_super_advanced'] = apply_filters('hook_settings_super_advanced', WYSIJA_module::execute_hook('hook_settings_super_advanced', $hook_settings_super_advanced_params), $hook_settings_super_advanced_params);
     $this->action = 'main';
     if (isset($_REQUEST['validate'])) {
         $this->notice(str_replace(array('[link]', '[/link]'), array('<a title="' . __('Get Premium now', WYSIJA) . '" class="premium-activate" href="javascript:;">', '</a>'), __('You\'re almost there. Click this [link]link[/link] to activate the licence you have just purchased.', WYSIJA)));
     }
 }
Esempio n. 4
0
 function popup_autopost($data = array())
 {
     echo $this->messages(true);
     $output = '';
     // container
     $output .= '<div class="popup_content inline_form autopost">';
     // form
     $output .= '<form enctype="multipart/form-data" method="post" action="" class="" id="autopost-form">';
     // basic options
     $output .= '<div id="basic">';
     $helper_articles = WYSIJA::get('articles', 'helper');
     $output .= '<div class="block clearfix">';
     $output .= '    <label>' . __('Post type', WYSIJA) . '</label>';
     $output .= $helper_articles->field_select_post_type(array('value' => $data['params']['post_type']));
     $output .= '</div>';
     // post limit
     if ($data['autopost_type'] === 'single') {
         $output .= '<input type="hidden" name="post_limit" value="1" />';
     } else {
         $output .= '<div class="block clearfix">';
         $output .= '    <label>' . __('Maximum of posts to show', WYSIJA) . '</label>';
         $output .= '    <select name="post_limit" id="post_limit">';
         foreach ($data['post_limits'] as $limit) {
             $output .= '    <option value="' . $limit . '" ' . ($limit === (int) $data['params']['post_limit'] ? 'selected="selected"' : '') . ' >' . $limit . '</option>';
         }
         $output .= '    </select>';
         $output .= '</div>';
     }
     // Get selected terms IDs
     $terms_selected = array_filter(isset($data['params']['category_ids']) ? explode(',', trim($data['params']['category_ids'])) : array());
     // Create the init selection in to be in the Select2 format of results
     $_attr_init_selection = array();
     // Only build if there are any selected terms
     if (!empty($terms_selected)) {
         $taxonomies = get_taxonomies(array(), 'objects');
         $terms = get_terms(array_keys($taxonomies), array('include' => $terms_selected, 'hide_empty' => false));
         foreach ($terms as $term) {
             $_attr_init_selection[] = array('id' => $term->term_id, 'text' => wp_kses($taxonomies[$term->taxonomy]->labels->singular_name . ': ' . $term->name, array()));
         }
     }
     // categories
     $output .= '<div class="block clearfix" id="categories_filters">' . '<label title="' . esc_attr__('And taxonomies as well...', WYSIJA) . '">' . __('Categories and tags', WYSIJA) . '</label>' . '<div class="group">' . '<p class="category_select clearfix">' . '<input data-placeholder="' . __('Select...', WYSIJA) . '" name="category_ids" style="width: 300px" class="category_ids mailpoet-field-select2-terms" data-multiple="true" data-value=\'' . WJ_Utils::esc_json_attr($_attr_init_selection) . '\' value="' . esc_attr(implode(',', $terms_selected)) . '" type="hidden">' . '</p>' . '</div>' . '</div>';
     // end - basic options
     $output .= '</div>';
     // display options
     $output .= '<p><a id="toggle-advanced" href="javascript:;">' . __('Show display options', WYSIJA) . '</a></p>';
     $output .= '<div id="advanced">';
     $output .= $this->_post_display_options($data);
     $output .= '</div>';
     $output .= '    <p class="submit_button"><input type="submit" id="autopost-submit" class="button-primary" name="submit" value="' . __('Done', WYSIJA) . '" /></p>';
     $output .= '</form>';
     $output .= '</div>';
     echo $output;
 }
Esempio n. 5
0
 function editDetails()
 {
     if (!$this->_checkEmailExists($_REQUEST['id'])) {
         return;
     }
     $this->viewObj->title = __('Final step: last details', WYSIJA);
     $this->viewShow = 'editDetails';
     $this->js[] = 'wysija-validator';
     $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
     $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
     $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
     $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
     $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
     $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
     $this->js[] = 'jquery-ui-datepicker';
     $this->js[] = 'wysija-tooltip';
     $model_list = WYSIJA::get('list', 'model');
     $model_list->limitON = false;
     $this->data = array();
     $this->data['lists'] = $this->_getLists(false, true, true);
     $model_email = WYSIJA::get('email', 'model');
     $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
     // The first newsletter, we don't have replyto_email and replyto_name
     if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
         $current_user = wp_get_current_user();
         $this->data['email']['replyto_email'] = $current_user->data->user_email;
         $this->data['email']['replyto_name'] = $current_user->data->display_name;
     }
     if ((int) $this->data['email']['type'] == 2) {
         $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
         $this->jsTrans['autonl'] = true;
         $this->immediateWarning();
         $this->jsTrans['send'] = __('Activate now', WYSIJA);
     } else {
         $this->jsTrans['autonl'] = true;
         $this->viewObj->immediatewarning = '';
         $this->jsTrans['send'] = __('Send', WYSIJA);
     }
     if ((int) $this->data['email']['type'] == 1) {
         $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
     } else {
         if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
             $this->data['autoresponder'] = 1;
             foreach ($this->data['lists'] as $list) {
                 if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
                     break;
                 }
             }
             $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
         }
     }
     $this->checkIsEditable();
     $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
     $this->dataAutoNl();
     $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
     $modelCL = WYSIJA::get('campaign_list', 'model');
     $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
 }
Esempio n. 6
0
 private function update()
 {
     global $wpdb;
     $required = WJ_Utils::to_int($this->required);
     $result = $wpdb->update($this->table, array('name' => $this->name, 'type' => $this->type, 'required' => $required, 'settings' => maybe_serialize($this->settings)), array('id' => $this->id), array('%s', '%s', '%d'), array('%d'));
     return $result;
 }
Esempio n. 7
0
 function defaultSettings(&$values)
 {
     /* get the user data for the admin */
     //$datauser=wp_get_current_user();
     $current_user = WYSIJA::wp_get_userdata();
     $values['replyto_name'] = $values['from_name'] = $current_user->user_login;
     $values['emails_notified'] = $current_user->user_email;
     $values['replyto_email'] = $values['from_email'] = 'info@' . WJ_Utils::get_domain();
 }