adding shortcodes to allow exclusion of specific job title ids from front end output
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 27 Nov 2017 19:34:19 +0000 (14:34 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 27 Nov 2017 19:34:19 +0000 (14:34 -0500)
shortcode accepts 2 attrs, one for the job ids, and one to determine if it should
members only.

models/front/jobs/list.php
setup/shortcodes.php
views/admin/settings/jobTitles.html

index fcdcd79..7c94135 100644 (file)
@@ -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,
index ee6651f..e53fdbd 100644 (file)
@@ -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(
index 2a4ec87..d3d35fe 100644 (file)
 
         <table class="wp-list-table wideFat fixed posts glm-admin-table" style="width: 90%;">
             <thead>
+      
                 <tr>
+                    <th style="width: 75px;"> ID</th>
+    
                     <th> Job Title </th>
                     <th>&nbsp;</th>
                 </tr>
                         <tr class="alternate">
                     {/if}
                             <td>
-                                <div class="jobTitle-record" id="jobTitle_{$job.id}" data-jobTitleID="{$job.id}" >{$job.job_title}</div>
+                                <div class="jobTitle-record" id="jobID_{$job.id}" data-jobID="{$job.id}" >{$job.id}</div>
+                            </td>
+                            <td>
+                                <div style="float: left;" class="jobTitle-record" id="jobTitle_{$job.id}" data-jobTitleID="{$job.id}" >{$job.job_title}</div>
                                 <div class="editJobTitleButton editJobTitle button button-secondary glm-button-small glm-right" data-jobTitleID="{$job.id}">Edit</div> 
                                 <div class="deleteJobTitleButton button button-secondary glm-button-small glm-right" data-jobTitleID="{$job.id}">Delete</div>
                             </td>