From: Anthony Talarico Date: Mon, 27 Nov 2017 19:34:19 +0000 (-0500) Subject: adding shortcodes to allow exclusion of specific job title ids from front end output X-Git-Tag: v1.0.0~1^2~16 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b43ba0d5fa143541778395be9ba305217380469e;p=WP-Plugins%2Fglm-member-db-jobs.git adding shortcodes to allow exclusion of specific job title ids from front end output shortcode accepts 2 attrs, one for the job ids, and one to determine if it should members only. --- diff --git a/models/front/jobs/list.php b/models/front/jobs/list.php index fcdcd79..7c94135 100644 --- a/models/front/jobs/list.php +++ b/models/front/jobs/list.php @@ -104,29 +104,45 @@ class GlmMembersFront_jobs_list extends GlmDatajobs public function modelAction($actionData = false) { - $job_titles = new GlmDataJobTitles($this->wpdb,$this->config); - $job_titles = $job_titles->getList(); - $where = ""; + $jobs_where = ' TRUE '; + $job_titles_where = ' TRUE '; + $exclude_jobs = ( !empty( $actionData['request']['exclude-jobs'] ) ) ? $actionData['request']['exclude-jobs'] : false; + $members_only = ( !empty( $actionData['request']['members-only'] ) ) ? $actionData['request']['members-only'] : false; + $members_only_page = get_option(GLM_MEMBERS_PLUGIN_OPTION_MEMBERS_ONLY_ID); + $is_members_only = is_in_tree($members_only_page); + $job_titles = new GlmDataJobTitles($this->wpdb,$this->config); + + + if( $exclude_jobs && ( !$is_members_only && $members_only ) ){ + $job_titles_where .= "AND id NOT IN ( $exclude_jobs ) "; + $jobs_where .= "AND title NOT IN ( $exclude_jobs ) "; + }else if($exclude_jobs){ + $job_titles_where .= "AND id NOT IN ( $exclude_jobs ) "; + $jobs_where .= "AND title NOT IN ( $exclude_jobs ) "; + } + + $job_titles = $job_titles->getList($job_titles_where); $success_message = ""; $option = false; if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { $option = $_REQUEST['option']; } - $where .= "CURDATE() <= DATE_ADD(updated, INTERVAL job_expiration DAY) AND visible = true "; + $jobs_where .= "AND CURDATE() <= DATE_ADD(updated, INTERVAL job_expiration DAY) AND active = true "; + if (isset($_REQUEST['job_titles']) && $_REQUEST['job_titles'] !== '') { // Make sure it's numeric $job_title_id = ($_REQUEST['job_titles'] - 0); - $where .= "AND title = $job_title_id"; - $job_data = $this->getList($where); + $jobs_where .= "AND title = $job_title_id"; + $job_data = $this->getList($jobs_where); } else { - $job_data = $this->getList($where); + $job_data = $this->getList($jobs_where); } $view_file = 'list'; // Compile template data $templateData = array( - 'jobData' => $job_data, + 'jobData' => $job_data, 'jobTitles' => $job_titles, 'siteBaseUrl' => GLM_MEMBERS_JOBS_SITE_BASE_URL, 'currentUrl' => GLM_MEMBERS_JOBS_PLUGIN_CURRENT_URL, diff --git a/setup/shortcodes.php b/setup/shortcodes.php index ee6651f..e53fdbd 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -94,8 +94,10 @@ $glmMembersjobsShortcodes = array( 'action' => 'list', 'table' => false, 'attributes' => array( - 'id' => true, - 'member_only' => true + 'id' => true, + 'member_only' => true, + 'exclude-jobs' => null, + 'members-only' => false ) ), 'glm-members-job-detail' => array( diff --git a/views/admin/settings/jobTitles.html b/views/admin/settings/jobTitles.html index 2a4ec87..d3d35fe 100644 --- a/views/admin/settings/jobTitles.html +++ b/views/admin/settings/jobTitles.html @@ -63,7 +63,10 @@ + + + @@ -79,7 +82,10 @@ {/if} +
ID Job Title  
-
{$job.job_title}
+
{$job.id}
+
+
{$job.job_title}
Edit
Delete