initial copy
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 24 Sep 2014 21:00:18 +0000 (17:00 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 24 Sep 2014 21:00:18 +0000 (17:00 -0400)
controllers/admin.php [new file with mode: 0644]
glm-employment.php [new file with mode: 0644]
models/job.php [new file with mode: 0644]
notes.txt [new file with mode: 0644]

diff --git a/controllers/admin.php b/controllers/admin.php
new file mode 100644 (file)
index 0000000..308b142
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+namespace Glm\Employment\Controller;
+defined('ABSPATH') or die();
+
+class AdminController
+{
+    const TABLE_NAME = 'emp_app';
+    const DB_OPTION  = 'glm_emp_db_version';
+    const DB_VERSION = '1.2';
+
+    public function initalizeActivationHooks()
+    {
+        \register_activation_hook(
+            'glm-employment/glm-employment.php',
+            array($this, 'installApplication')
+        );
+        \register_activation_hook(
+            'glm-employment/glm-employment.php',
+            array($this, 'initializeData')
+        );
+        \add_action('plugins_loaded', array($this, 'pluginUpdateDbCheck'));
+    }
+
+    public function installApplication()
+    {
+        global $wpdb;
+
+        $tableName = $wpdb->prefix . SELF::TABLE_NAME;
+
+        $charset_collate = '';
+
+        if (!empty($wpdb->charset)) {
+            $charset_collate .= "DEFAULT CHARACTER SET {$wpdb->charset}";
+        }
+
+        if (!empty($wpdb->collate)) {
+            $charset_collate .= " COLLATE {$wpdb->collate}";
+        }
+
+        $sql = "CREATE TABLE {$tableName} (
+            id mediumint (9) NOT NULL AUTO_INCREMENT,
+            time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
+            name text NOT NULL,
+            description text,
+            qualifications text,
+            benefits text,
+            primary_shift text,
+            comments text,
+            expire_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
+            pay_grade text,
+            job_code text,
+            status text,
+            active bool DEFAULT 0,
+            hr_contact text,
+            hr_phone text,
+            hr_email text,
+            UNIQUE KEY id (id)
+        ) $charset_collate;";
+
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
+        \dbDelta($sql);
+
+        \add_option(SELF::DB_OPTION, SELF::DB_VERSION);
+    }
+
+    public function initializeData()
+    {
+        global $wpdb;
+
+        $tableName = $wpdb->prefix . SELF::TABLE_NAME;
+
+        $testData         = array(
+            'time'        => \current_time('mysql'),
+            'name'        => 'Test 1',
+            'expire_date' => '2015-02-12 00:00:00'
+        );
+        $wpdb->insert(
+            $tableName,
+            $testData
+        );
+    }
+
+    public function pluginUpdateDbCheck()
+    {
+        if (\get_option(SELF::DB_OPTION) != SELF::DB_VERSION) {
+            $this->installApplication();
+        }
+        \update_option(SELF::DB_OPTION, SELF::DB_VERSION);
+    }
+
+}
diff --git a/glm-employment.php b/glm-employment.php
new file mode 100644 (file)
index 0000000..d0ce475
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Plugin Name: Gaslight Media Employment
+ * Description: Online Employment Application for Gaslight Media Clients.
+ * Version: 1.0
+ * Author: Steve Sutton
+ * Author URI: http://www.gaslightmedia.com
+ * License: All right reserved
+ */
+namespace Glm\Employment;
+use Glm\Employment as Emp;
+
+defined('ABSPATH') or die();
+
+require_once 'controllers/admin.php';
+use Glm\Employment\Controller as Controller;
+
+class Setup
+{
+    public function __construct()
+    {
+        $adminController = new Controller\AdminController();
+        $adminController->initalizeActivationHooks();
+    }
+}
+
+$employmentApp = new Emp\Setup();
diff --git a/models/job.php b/models/job.php
new file mode 100644 (file)
index 0000000..90a3e52
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+namespace Glm\Employment\Models;
+
+class Job
+{
+    const TABLE_NAME = 'jobs';
+    const PRI_KEY    = 'id';
+
+
+}
diff --git a/notes.txt b/notes.txt
new file mode 100644 (file)
index 0000000..10d62d8
--- /dev/null
+++ b/notes.txt
@@ -0,0 +1,37 @@
+Gaslight Media Online Employment Application
+    Class setup for  MVC
+
+Models:
+    job.php         = job posting
+    application.php = user submitted application form
+
+
+Views:
+    Admin
+        index.php
+        listJobs.php
+        editJob.php
+        listApplications.php
+        viewApplication.php
+        printApplication.php
+
+    Front
+        index.php
+        listJobs.php
+        viewJob.php
+        applyOnline.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
+        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
+
+