##Models:
job.php = job posting
- application.php = user submitted application form
+ database.php = database
+
+ list-applications.php = using copy of list table class extends to create
+ list of applications
+ class-glm-list-table.php = copy from wordpress core file to protect against
+ wordpress updates for this class
##Views:
Admin
- index.php
- listJobs.php
- editJob.php
- listApplications.php
- viewApplication.php
- printApplication.php
+ applicationList.php
+ form_1.php
+ job_meta.php
+ view-application.php
Front
- index.php
- listJobs.php
- viewJob.php
- applyOnline.php
+ formTemplate.php
+ jobDetail.php
+ jobList.php
+ jobSearch.php
+ thankYou.php
##Controllers:
- pluginController.php
- Used to setup the actions and hooks for the plugin to function in admin or the front.
-
- adminController.php = for the admin side
+ admin.php = for the admin side
activate-plugin.php
should have an init function for creating the database tables
upgrade-plugin.php
should have functions for upgrading the database versions
- frontController.php = for front end
+ front.php = for front end
+##Config:
+ config files for each form
+ setting{1-7}.php
*/
class glm_employment_admin
{
-
+ /**
+ * Plugin Directory Name
+ * @var type
+ */
public $pluginDirName;
+ /**
+ * Wordpress Database object
+ * @var type
+ */
public $wpdb;
/**
add_action('admin_menu', array($this, 'add_job_menus'));
}
+ /**
+ * Add job menus
+ */
public function add_job_menus()
{
add_submenu_page(
// );
}
+ /**
+ * show job settings
+ */
public function show_job_settings()
{
echo '<p>Job Settings</p>';
}
+ /**
+ * Show the applications
+ *
+ * Will check the Get action and see if it needs to view the application
+ * or show the application list
+ */
public function get_applications()
{
$action = filter_var($_GET['action'], FILTER_SANITIZE_STRING);
}
}
+ /**
+ * View the application for one id
+ */
public function view_application()
{
wp_enqueue_script(
echo '</div>';
}
+ /**
+ * Show application list
+ */
public function show_applications()
{
$path = plugin_dir_path(GLM_EMP_PLUGIN_PATH_FILE);
include $this->pluginDirName . 'views/admin/applicationList.php';
}
- public function glm_jobs($atts)
- {
- extract(shortcode_atts(array('limit' => '10'), $atts));
- global $wpdb;
- $sql = "SELECT * FROM $wpdb->posts WHERE post_type = '"
- . GLM_EMP_POST_TYPE . "'";
- $jobs = $wpdb->get_results($sql, OBJECT);
- ob_start();
- include $this->pluginDirName . 'views/front/jobList.php';
- $out = ob_get_contents();
- ob_end_clean();
- return $out;
- }
-
+ /**
+ * Sets the plugin directory
+ *
+ * @param type $dir Directory name
+ *
+ * @return void
+ */
public function setPluginDir($dir)
{
$this->pluginDirName = $dir;
$this->settingDir = $this->pluginDirName . self::FORM_SETTINGS_DIR;
}
+ /**
+ * Set the form state
+ *
+ * $this->formSubmitted will be true if the form has the
+ * self::FORM_VAR set
+ */
public function set_form_state()
{
$this->formSubmitted = isset($_POST[self::FORM_VAR]);
}
+ /**
+ * Job display short code
+ *
+ * @param type $atts Attributes
+ */
public function glm_jobs_shortcode($atts)
{
extract(shortcode_atts(array('limit' => '10'), $atts));
}
}
+ /**
+ * Load the form setting from the config file
+ *
+ * @param type $form_part Form part to load
+ *
+ * @return type
+ */
+
public function load_form_settings($form_part = '')
{
include $this->settingDir . "/settings{$form_part}.php";
return $form;
}
+ /**
+ * Show the application form
+ */
public function show_apply_form()
{
$formPart = (isset($_REQUEST['form_part']))
}
}
+ /**
+ * Store the application resume file into the directory and the database table
+ *
+ * @return boolean
+ */
public function store_resume_file()
{
echo '<pre>'.print_r($form, true).'</pre>';
}
}
+ /**
+ * Store the main application form data
+ *
+ * @param type $form Form array
+ *
+ * @return type
+ */
public function store_application_data($form)
{
if ($this->appId = filter_var($_REQUEST['appId'], FILTER_VALIDATE_INT)) {
return $this->appId;
}
+ /**
+ * Store the data for the form to the database per form part
+ *
+ * @param type $form Form array
+ * @param type $form_part Part number
+ *
+ * @return boolean
+ */
public function store_form_data($form, $form_part)
{
// check if there's one stored first
);
}
+ /**
+ * Process the form by form part number
+ *
+ * @param type $part Form number
+ *
+ * @return string
+ */
public function form_process($part)
{
$this->clean_post();
return $form;
}
+ /**
+ * Clean the post array (trim each field)
+ */
public function clean_post()
{
foreach ($_POST as $key => $val) {
}
}
+ /**
+ * Display the job for given id
+ *
+ * @global type $wpdb Word Press Database Object
+ * @global type $wp Wordpress global $wp variable
+ *
+ * @param type $job_id Job id to display
+ *
+ * @return type
+ */
public function show_job($job_id)
{
global $wpdb, $wp;
return;
}
+ /**
+ * List the jobs that are currently set to display
+ * based on start and end dates
+ *
+ * @global type $wpdb Word Press Database Object
+ * @global type $wp Global WP object
+ *
+ * @return type
+ */
public function list_jobs()
{
global $wpdb, $wp;
return;
}
+ /**
+ * Front end job search form
+ */
public function search_form()
{
$glm_jobscategory = (isset($_REQUEST['glm_jobscategory']))
include $this->frontViewDir . '/jobSearch.php';
}
+ /**
+ * Sets the plugin directory
+ *
+ * @param type $dir Plugin directory
+ */
public function setPluginDir($dir)
{
$this->pluginDirName = $dir;
}
+ /**
+ * Create session for the online form
+ */
public function startJobSession()
{
if (!session_id()) {
*/
defined('ABSPATH') or die();
-
+/**
+ * Defines for the plugin
+ */
define('GLM_EMP_PLUGIN_PATH_FILE', __FILE__);
define('GLM_EMP_VERSION', '0.0.1');
define('GLM_EMP_VRS_OPTION_NAME', 'glm_jobs_db_version');
$wp_upload_dir = wp_upload_dir();
define('GLM_EMP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/glm-emp/');
define('GLM_EMP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/glm-emp/');
+/**
+ * Create the upload directory for the resume files if not already there
+ */
if (!is_dir(GLM_EMP_UPLOAD_DIR)) {
// create the upload directory
$oldUmask = umask(0);
mkdir(GLM_EMP_UPLOAD_DIR, 0770);
umask($oldUmask);
}
-
+/**
+ * Require the class files
+ */
require_once 'controllers/admin.php';
require_once 'controllers/front.php';
require_once 'models/job.php';
-
require_once 'models/database.php';
+/**
+ * The Database class
+ */
$glm_member_db = new glm_employment_models_database($GLOBALS['wpdb']);
/**
$employmentApp = new glm_employment_setup();
+/**
+ * Load style sheet for displaying the view and print for the application forms
+ */
function glm_load_style()
{
wp_enqueue_style('foundation',
public $applicationTable;
public $appFormTable;
+ /**
+ * Clas constructor for the database
+ *
+ * @param type $wpdb Wordpress db object
+ */
public function __construct($wpdb)
{
$this->wpdb = $wpdb;
$this->appFormTable = $this->wpdb->prefix . GLM_EMP_FORM_TABLE;
}
+ /**
+ * Install the database tables needed for jobs
+ */
public function install()
{
$charset_collate = $this->wpdb->get_charset_collate();
update_option(GLM_EMP_VRS_OPTION_NAME, GLM_EMP_VERSION);
}
+ /**
+ * DB Version update check to update the database tables
+ */
public function glm_emp_update_db_check()
{
if (GLM_EMP_VERSION != get_option(GLM_EMP_VRS_OPTION_NAME)) {
<?php
-
+/**
+ * Sets up the job post type and its taxonomies. Handles also the new fields in
+ * the metaboxes.
+ */
class glm_employment_job
{
public $pluginDirName;
+ /**
+ * Contstructor for the job class
+ *
+ * Calls filters and actions to setup Job post type
+ *
+ * @param type $path Plugin Path
+ */
public function __construct($path)
{
$this->pluginDirName = $path;
add_action('init', array($this, 'addPostTypes'));
- add_action('init', array($this, 'createJobTaxonomy'), 0);
-
+ add_action('init', array($this, 'createJobTaxonomy'));
+
add_filter('post_updated_messages', array($this, 'jobsUpdatedMessages'));
add_filter('manage_edit-glm_jobs_columns',
array($this, 'jobsCustomColumns'));
add_action('admin_init', array($this, 'metaDates'));
add_action('save_post', array($this, 'saveEmpMeta'));
- add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortByDates'));
- add_filter('restrict_manage_posts', array($this, 'jobFilterList'));
+ add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortingColumns'));
+ add_action('restrict_manage_posts', array($this, 'jobFilterList'));
add_filter('parse_query', array($this, 'jobFilter'));
}
- public function sortByDates($columns)
+ /**
+ * Add sorting by columns
+ *
+ * @param type $columns Array of columns
+ *
+ * @return arrray
+ */
+ public function sortingColumns($columns)
{
$columns['glmjobs_col_date'] = 'glmjobs_col_date';
$columns['glmjobs_col_cat'] = 'glmjobs_col_cat';
return $columns;
}
- public function jobFilter(&$query)
+ /**
+ * Filter for the parse_query action
+ *
+ * @param type $query WP_Query object
+ *
+ * @return Object $query
+ */
+ public function jobFilter($query)
{
$qv =& $query->query_vars;
return $query;
}
+ /**
+ * Setup the two drop downs for the Taxonomies
+ *
+ * @global type $wp_query
+ */
public function jobFilterList()
{
$screen = get_current_screen();
}
}
+ /**
+ * Add meta box for dates
+ */
public function metaDates()
{
add_meta_box('glm_employment_meta', 'Position Information',
array($this, 'editJobMeta'), GLM_EMP_POST_TYPE);
}
+ /**
+ * Build the edit part of the date
+ * @global type $post
+ */
public function editJobMeta()
{
global $post;
include $this->pluginDirName . 'views/admin/job_meta.php';
}
+ /**
+ * Save the Employment meta data
+ *
+ * @global type $post Post Object
+ *
+ * @return mixed
+ */
public function saveEmpMeta()
{
global $post;
register_post_type(GLM_EMP_POST_TYPE, $args);
}
+ /**
+ * Update the message text for the job post type
+ *
+ * @global type $post Post object
+ * @global type $post_ID Id of post
+ *
+ * @param type $messages Messages array
+ *
+ * @return type
+ */
public function jobsUpdatedMessages($messages)
{
global $post, $post_ID;
return $messages;
}
+ /**
+ * Create the taxanomies for the post type
+ */
public function createJobTaxonomy()
{
$labels = array(
register_taxonomy_for_object_type(GLM_EMP_TAX_DEPARTMENTS, GLM_EMP_POST_TYPE);
}
+ /**
+ * To set which fields appear in the post type admin list
+ *
+ * @param array $columns Columns for the admin list view
+ *
+ * @return array
+ */
function jobsEditColumns($columns)
{
$columns = array(
return $columns;
}
+ /**
+ * Setup the custom columns for the admin list view
+ *
+ * @global type $post Post
+ *
+ * @param type $column Column
+ */
function jobsCustomColumns($column)
{
global $post;