default to turning it on.
define('GLM_MEMBERS_LEADS_PLUGIN_SHORT_NAME', 'Leads');
define('GLM_MEMBERS_LEADS_PLUGIN_SLUG', 'glm-member-db-leads');
define('GLM_MEMBERS_LEADS_PLUGIN_IMPORT_OPTION', 'glm_member_db_leads_import_option');
+define('GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION', 'glm_member_db_leads_member_access');
// Database table prefixes - change if using add-on tables
global $wpdb;
*/
public function modelAction($actionData = false)
{
- $forms = false;
- $form = false;
- $result = false;
- $sources = false;
- $option2 = false;
- $option = false;
- $form_id = false;
- $import_fields = false;
- $importing = false;
- $option_name = GLM_MEMBERS_LEADS_PLUGIN_IMPORT_OPTION;
- $page_size = 200;
- $offset = false;
- $next_offset = false;
+ $forms = false;
+ $form = false;
+ $result = false;
+ $sources = false;
+ $option2 = false;
+ $option = false;
+ $form_id = false;
+ $import_fields = false;
+ $importing = false;
+ $option_name = GLM_MEMBERS_LEADS_PLUGIN_IMPORT_OPTION;
+ $page_size = 200;
+ $offset = false;
+ $next_offset = false;
+ $settingsUpdated = false;
+ $settingsUpdateError = false;
// Grab data from the Sources table
$sources = $this->wpdb->get_results(
$importing = filter_var( $_REQUEST['importing'], FILTER_VALIDATE_BOOLEAN );
}
+ // Check for GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION option. If
+ // it doesn't exists then set it to true.
+ $memberCanAccessLeads = get_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION, 'default_value' );
+ if ( $memberCanAccessLeads === 'default_value' ) {
+ update_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION, 1 );
+ }
+
+ switch ( $option ) {
+ case 'settings':
+ if ( isset( $_REQUEST['member_can_access_leads'] ) ) {
+ $memberCanAccessLeads = filter_var( $_REQUEST['member_can_access_leads'], FILTER_VALIDATE_BOOLEAN );
+ }
+ update_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION, $memberCanAccessLeads );
+ $settingsUpdated = true;
+ break;
+ default:
+ break;
+
+ }
+
+ $memberCanAccessLeads = get_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION );
+
switch( $option2 ) {
case 'importleads':
}
// Compile template data
- $templateData = array(
- 'import_fields' => $import_fields,
- 'importing' => $importing,
- 'form' => $form,
- 'forms' => $forms,
- 'sources' => $sources,
- 'option2' => $option2,
- 'result' => $result,
- 'offset' => $offset,
- 'next_offset' => $next_offset,
+ $templateData = array(
+ 'import_fields' => $import_fields,
+ 'importing' => $importing,
+ 'form' => $form,
+ 'forms' => $forms,
+ 'sources' => $sources,
+ 'option2' => $option2,
+ 'result' => $result,
+ 'offset' => $offset,
+ 'next_offset' => $next_offset,
+ 'mLeadAccess' => $memberCanAccessLeads,
+ 'settingsUpdated' => $settingsUpdated,
+ 'settingsUpdateError' => $settingsUpdateError,
);
// Return status, suggested view, and data to controller
// If a contact is logged in (ownEntity isn't false), add Contact Profile menu item
if ( isset( $this->config['loggedInUser']['contactUser'] ) && $this->config['loggedInUser']['contactUser'] ) {
- add_submenu_page(
- $mainMenuSlug,
- 'Leads',
- 'Leads',
- 'glm_members_edit_my_entity',
- 'glm-members-admin-menu-leads-index',
- function() {$this->controller('leads');}
- );
+ // Check for the option GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION
+ $memberCanAccessLeads = get_option( GLM_MEMBERS_LEADS_PLUGIN_MEMBER_ACCESS_OPTION );
+ if ( $memberCanAccessLeads ) {
+ add_submenu_page(
+ $mainMenuSlug,
+ 'Leads',
+ 'Leads',
+ 'glm_members_edit_my_entity',
+ 'glm-members-admin-menu-leads-index',
+ function() {$this->controller('leads');}
+ );
+ }
}
<h1>This requires Gravity Forms to be Installed and active</h1>
<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
- <a id="glm-leads-sources" data-show-table="glm-table-sources" class="glm-settings-tab nav-tab {if $option2 == ''} nav-tab-active{/if}">Source List</a>
+ <a id="glm-leads-sources" data-show-table="glm-table-sources" class="glm-settings-tab nav-tab {if $option2 == ''} nav-tab-active{/if}">Settings / Source List</a>
<a id="glm-leads-import" data-show-table="glm-table-import" class="glm-settings-tab nav-tab">Gravity Forms</a>
<a id="glm-leads-importleads" data-show-table="glm-table-importleads" class="glm-settings-tab nav-tab{if $result && $option2 == 'importleads'} nav-tab-active{/if}">Import Leads</a>
</h2>
<table id="glm-table-sources" class="glm-admin-table glm-settings-table{if $option2 != ''} glm-hidden{/if}">
+ <tr>
+ <td colspan="2">
+ {if $settingsUpdated}<h2 class="glm-notice glm-flash-updated glm-right">Settings Updated</h2>{/if}
+ {if $settingsUpdateError}<span class="glm-error glm-flash-updated glm-right">Settings Update Error</span>{/if}
+ <h2>Management Settings</h2>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <form action="{$thisUrl}?page={$thisPage}&glm_action=leads" method="post">
+ <input type="hidden" name="glm_action" value="leads" />
+ <input type="hidden" name="option" value="settings" />
+ <table class="glm-admin-table" width="400">
+ <tr>
+ <th>Members can access leads:</th>
+ <td>
+ <input type="hidden" name="member_can_access_leads" value="0">
+ <label>
+ <input type="checkbox" name="member_can_access_leads" value="1" {if $mLeadAccess}checked{/if} /> Yes
+ </label>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2"><input type="submit" value="Update" /></td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
<tr>
<th> Form Id </th>
<th> Source Name </th>
// Show selected table
var table = $(this).attr('data-show-table');
$('#' + table).removeClass('glm-hidden');
+
+
});
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
});
</script>