public static function menu()
 {
     global $frm_vars, $frm_settings;
     if (current_user_can('administrator') && !current_user_can('frm_view_forms')) {
         global $current_user;
         $frm_roles = FrmAppHelper::frm_capabilities();
         foreach ($frm_roles as $frm_role => $frm_role_description) {
             $current_user->add_cap($frm_role);
         }
         unset($frm_roles);
         unset($frm_role);
         unset($frm_role_description);
     }
     $count = count(get_post_types(array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true)));
     $pos = (int) $count > 0 ? '22.7' : '29.3';
     $pos = apply_filters('frm_menu_position', $pos);
     if (current_user_can('frm_view_forms')) {
         add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', $pos);
     } else {
         if (current_user_can('frm_view_entries') and $frm_vars['pro_is_installed']) {
             add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', 'FrmProEntriesController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', $pos);
         }
     }
     add_filter('admin_body_class', 'FrmAppController::wp_admin_body_class');
 }
 public static function display_form($errors = array(), $message = '')
 {
     global $frm_settings, $frm_vars;
     $frm_roles = FrmAppHelper::frm_capabilities();
     $uploads = wp_upload_dir();
     $target_path = $uploads['basedir'] . '/formidable/css';
     $sections = apply_filters('frm_add_settings_section', array('styling' => array('name' => __('Form Styling', 'formidable'), 'class' => 'FrmSettingsController', 'function' => 'styling_tab')));
     $recaptcha_themes = array('red' => __('Red', 'formidable'), 'white' => __('White', 'formidable'), 'blackglass' => __('Black Glass', 'formidable'), 'clean' => __('Clean', 'formidable'));
     require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
 }
 public static function display_form($errors = array(), $message = '')
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     $frm_roles = FrmAppHelper::frm_capabilities();
     $uploads = wp_upload_dir();
     $target_path = $uploads['basedir'] . '/formidable/css';
     $sections = apply_filters('frm_add_settings_section', array());
     $captcha_lang = FrmAppHelper::locales('captcha');
     require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
 }
 function process_form()
 {
     global $frm_settings, $frm_ajax_url, $frmpro_is_installed, $frm_update;
     //$errors = $frm_settings->validate($_POST,array());
     $errors = array();
     $frm_settings->update($_POST);
     if (empty($errors)) {
         $frm_settings->store();
         $message = __('Settings Saved', 'formidable');
     }
     $frm_roles = FrmAppHelper::frm_capabilities();
     $sections = apply_filters('frm_add_settings_section', array());
     require FRM_VIEWS_PATH . '/frm-settings/form.php';
 }
 public static function display_form($errors = array(), $message = '')
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     $frm_roles = FrmAppHelper::frm_capabilities();
     $uploads = wp_upload_dir();
     $target_path = $uploads['basedir'] . '/formidable/css';
     $sections = array();
     if (apply_filters('frm_include_addon_page', false)) {
         $sections['licenses'] = array('class' => 'FrmAddonsController', 'function' => 'license_settings', 'name' => __('Plugin Licenses', 'formidable'));
     }
     $sections = apply_filters('frm_add_settings_section', $sections);
     $captcha_lang = FrmAppHelper::locales('captcha');
     require FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php';
 }
 function menu()
 {
     global $frm_settings;
     if (current_user_can('administrator') and !current_user_can('frm_view_entries')) {
         global $wp_roles;
         $frm_roles = FrmAppHelper::frm_capabilities();
         foreach ($frm_roles as $frm_role => $frm_role_description) {
             if (!in_array($frm_role, array('frm_view_forms', 'frm_edit_forms', 'frm_delete_forms', 'frm_change_settings'))) {
                 $wp_roles->add_cap('administrator', $frm_role);
             }
         }
     }
     add_submenu_page('formidable', $frm_settings->menu . ' | ' . __('Form Entries', 'formidable'), __('Form Entries', 'formidable'), 'frm_view_entries', 'formidable-entries', array(&$this, 'route'));
     if (class_exists('WP_List_Table') and (!isset($_GET['frm_action']) or !in_array($_GET['frm_action'], array('edit', 'show')))) {
         add_filter('manage_' . sanitize_title($frm_settings->menu) . '_page_formidable-entries_columns', array(&$this, 'manage_columns'));
         add_filter('manage_' . sanitize_title($frm_settings->menu) . '_page_formidable-entries_sortable_columns', array(&$this, 'sortable_columns'));
         add_filter('get_user_option_manage' . sanitize_title($frm_settings->menu) . '_page_formidable-entriescolumnshidden', array(&$this, 'hidden_columns'));
     }
     //add_filter( 'bulk_actions-' . sanitize_title($frm_settings->menu) .'_page_formidable-entries', array(&$this, 'bulk_action_options'));
     add_action('admin_head-' . sanitize_title($frm_settings->menu) . '_page_formidable-entries', array(&$this, 'head'));
 }
Beispiel #7
0
 function menu()
 {
     global $frmpro_is_installed, $frm_settings;
     if (current_user_can('administrator') and !current_user_can('frm_view_forms')) {
         global $current_user;
         $frm_roles = FrmAppHelper::frm_capabilities();
         foreach ($frm_roles as $frm_role => $frm_role_description) {
             $current_user->add_cap($frm_role);
         }
         unset($frm_roles);
         unset($frm_role);
         unset($frm_role_description);
     }
     if (current_user_can('frm_view_forms')) {
         global $frm_forms_controller;
         add_object_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', array($frm_forms_controller, 'route'), 'div');
     } elseif (current_user_can('frm_view_entries') and $frmpro_is_installed) {
         global $frmpro_entries_controller;
         add_object_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', array($frmpro_entries_controller, 'route'), 'div');
     }
 }
Beispiel #8
0
 public function uninstall()
 {
     if (!current_user_can('administrator')) {
         $frm_settings = FrmAppHelper::get_settings();
         wp_die($frm_settings->admin_permission);
     }
     global $wpdb, $wp_roles;
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->fields);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->forms);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->entries);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->entry_metas);
     delete_option('frm_options');
     delete_option('frm_db_version');
     //delete roles
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         foreach ($roles as $role => $details) {
             $wp_roles->remove_cap($role, $frm_role);
             unset($role, $details);
         }
         unset($frm_role, $frm_role_description);
     }
     unset($roles, $frm_roles);
     // delete actions, views, and styles
     // prevent the post deletion from triggering entries to be deleted
     remove_action('before_delete_post', 'FrmProDisplaysController::before_delete_post');
     remove_action('deleted_post', 'FrmProEntriesController::delete_entry');
     $post_ids = $wpdb->get_col($wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type in (%s, %s, %s)', FrmFormActionsController::$action_post_type, FrmStylesController::$post_type, 'frm_display'));
     foreach ($post_ids as $post_id) {
         // Delete's each post.
         wp_delete_post($post_id, true);
     }
     unset($post_ids);
     // delete transients
     delete_transient('frmpro_css');
     delete_transient('frm_options');
     delete_transient('frmpro_options');
     $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%'));
     do_action('frm_after_uninstall');
     return true;
 }
Beispiel #9
0
 function update($params)
 {
     global $wp_roles;
     $this->menu = $params['frm_menu'];
     $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
     if ($this->mu_menu) {
         update_site_option('frm_admin_menu_name', $this->menu);
     } else {
         if (FrmAppHelper::is_super_admin()) {
             update_site_option('frm_admin_menu_name', false);
         }
     }
     $this->preview_page_id = (int) $params[$this->preview_page_id_str];
     $this->lock_keys = isset($params['frm_lock_keys']) ? $params['frm_lock_keys'] : 0;
     $this->track = isset($params['frm_track']) ? $params['frm_track'] : 0;
     $this->pubkey = $params['frm_pubkey'];
     $this->privkey = $params['frm_privkey'];
     $this->re_theme = $params['frm_re_theme'];
     $this->re_lang = $params['frm_re_lang'];
     $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
     $this->load_style = $params['frm_load_style'];
     //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
     //$this->custom_stylesheet = isset($params['frm_custom_stylesheet']) ? $params['frm_custom_stylesheet'] : 0;
     $this->jquery_css = isset($params['frm_jquery_css']) ? $params['frm_jquery_css'] : 0;
     $this->accordion_js = isset($params['frm_accordion_js']) ? $params['frm_accordion_js'] : 0;
     $this->success_msg = $params['frm_success_msg'];
     $this->invalid_msg = $params['frm_invalid_msg'];
     $this->failed_msg = $params['frm_failed_msg'];
     $this->submit_value = $params['frm_submit_value'];
     $this->login_msg = $params['frm_login_msg'];
     //update roles
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         $this->{$frm_role} = isset($params[$frm_role]) ? $params[$frm_role] : 'administrator';
         foreach ($roles as $role => $details) {
             if ($this->{$frm_role} == $role or $this->{$frm_role} == 'editor' and $role == 'administrator' or $this->{$frm_role} == 'author' and in_array($role, array('administrator', 'editor')) or $this->{$frm_role} == 'contributor' and in_array($role, array('administrator', 'editor', 'author')) or $this->{$frm_role} == 'subscriber') {
                 $wp_roles->add_cap($role, $frm_role);
             } else {
                 $wp_roles->remove_cap($role, $frm_role);
             }
         }
     }
     do_action('frm_update_settings', $params);
 }
Beispiel #10
0
 function update($params)
 {
     global $wp_roles;
     $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0;
     if ($this->mu_menu) {
         update_site_option('frm_admin_menu_name', $this->menu);
     } else {
         if (current_user_can('administrator')) {
             update_site_option('frm_admin_menu_name', false);
         }
     }
     $this->pubkey = trim($params['frm_pubkey']);
     $this->privkey = $params['frm_privkey'];
     $this->re_theme = $params['frm_re_theme'];
     $this->re_lang = $params['frm_re_lang'];
     $settings = $this->default_options();
     foreach ($settings as $setting => $default) {
         if (isset($params['frm_' . $setting])) {
             $this->{$setting} = $params['frm_' . $setting];
         }
         unset($setting);
         unset($default);
     }
     $this->load_style = $params['frm_load_style'];
     $this->preview_page_id = (int) $params['frm-preview-page-id'];
     $this->lock_keys = isset($params['frm_lock_keys']) ? $params['frm_lock_keys'] : 0;
     $this->track = isset($params['frm_track']) ? $params['frm_track'] : 0;
     $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0;
     //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0;
     //$this->custom_stylesheet = isset($params['frm_custom_stylesheet']) ? $params['frm_custom_stylesheet'] : 0;
     $this->jquery_css = isset($params['frm_jquery_css']) ? $params['frm_jquery_css'] : 0;
     $this->accordion_js = isset($params['frm_accordion_js']) ? $params['frm_accordion_js'] : 0;
     //update roles
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         $this->{$frm_role} = isset($params[$frm_role]) ? $params[$frm_role] : 'administrator';
         foreach ($roles as $role => $details) {
             if ($this->{$frm_role} == $role or $this->{$frm_role} == 'editor' and $role == 'administrator' or $this->{$frm_role} == 'author' and in_array($role, array('administrator', 'editor')) or $this->{$frm_role} == 'contributor' and in_array($role, array('administrator', 'editor', 'author')) or $this->{$frm_role} == 'subscriber') {
                 $wp_roles->add_cap($role, $frm_role);
             } else {
                 $wp_roles->remove_cap($role, $frm_role);
             }
         }
     }
     do_action('frm_update_settings', $params);
 }
Beispiel #11
0
 function uninstall()
 {
     if (!current_user_can('administrator')) {
         global $frm_settings;
         wp_die($frm_settings->admin_permission);
     }
     global $frm_update, $wpdb;
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->fields);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->forms);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->entries);
     $wpdb->query('DROP TABLE IF EXISTS ' . $this->entry_metas);
     delete_option('frm_options');
     delete_option('frm_db_version');
     delete_option($frm_update->pro_last_checked_store);
     delete_option($frm_update->pro_auth_store);
     delete_option($frm_update->pro_cred_store);
     //delete roles
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         foreach ($roles as $role => $details) {
             $wp_roles->remove_cap($role, $frm_role);
             unset($role);
             unset($details);
         }
         unset($role);
         unset($details);
         unset($frm_role);
         unset($frm_role_description);
     }
     unset($roles);
     unset($frm_roles);
     do_action('frm_after_uninstall');
 }
Beispiel #12
0
 private function update_roles($params)
 {
     //update roles
     global $wp_roles;
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         $this->{$frm_role} = (array) (isset($params[$frm_role]) ? $params[$frm_role] : 'administrator');
         if (count($this->{$frm_role}) === 1) {
             $set_role = reset($this->{$frm_role});
             switch ($set_role) {
                 case 'subscriber':
                     array_push($this->{$frm_role}, 'contributor');
                 case 'contributor':
                     array_push($this->{$frm_role}, 'author');
                 case 'author':
                     array_push($this->{$frm_role}, 'editor');
                 case 'editor':
                     array_push($this->{$frm_role}, 'administrator');
             }
             unset($set_role);
         }
         foreach ($roles as $role => $details) {
             if (in_array($role, $this->{$frm_role})) {
                 $wp_roles->add_cap($role, $frm_role);
             } else {
                 $wp_roles->remove_cap($role, $frm_role);
             }
             unset($role, $details);
         }
     }
 }
 /**
  * @covers FrmAppHelper::maybe_add_permissions
  */
 function test_maybe_add_permissions()
 {
     $this->set_as_user_role('subscriber');
     $this->assertFalse(current_user_can('frm_view_forms'), 'Subscriber can frm_view_forms');
     $this->assertFalse(current_user_can('frm_edit_forms'), 'Subscriber can frm_edit_forms');
     $this->set_as_user_role('administrator');
     $frm_roles = FrmAppHelper::frm_capabilities();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         $this->assertTrue(current_user_can($frm_role), 'Admin cannot ' . $frm_role);
     }
 }
 private function update_roles($params)
 {
     global $wp_roles;
     $frm_roles = FrmAppHelper::frm_capabilities();
     $roles = get_editable_roles();
     foreach ($frm_roles as $frm_role => $frm_role_description) {
         $this->{$frm_role} = (array) (isset($params[$frm_role]) ? $params[$frm_role] : 'administrator');
         // Make sure administrators always have permissions
         if (!in_array('administrator', $this->{$frm_role})) {
             array_push($this->{$frm_role}, 'administrator');
         }
         foreach ($roles as $role => $details) {
             if (in_array($role, $this->{$frm_role})) {
                 $wp_roles->add_cap($role, $frm_role);
             } else {
                 $wp_roles->remove_cap($role, $frm_role);
             }
         }
     }
 }