setting up data classes and basic data for memberlocked
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 15 Sep 2017 19:12:08 +0000 (15:12 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 15 Sep 2017 19:12:08 +0000 (15:12 -0400)
setting up data and database related files, setting up menus, shortcodes
and initial setup files

classes/data/dataBuySell.php [new file with mode: 0644]
config/plugin.ini
setup/adminMenus.php
setup/adminTabs.php
setup/databaseScripts/create_database_V0.0.1.sql [new file with mode: 0644]
setup/permissions.php
setup/shortcodes.php
setup/validActions.php

diff --git a/classes/data/dataBuySell.php b/classes/data/dataBuySell.php
new file mode 100644 (file)
index 0000000..032d885
--- /dev/null
@@ -0,0 +1,257 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Buy Sell Postings
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataConditions.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**********************************************************************
+ *  NOTE: THIS IS A Buy Sell Postings FILE - DO NOT USE UNMODIFIED
+ *
+ *  Please change all references to conditions, Conditions, or CONDITIONS to a name
+ *  appropriate for your new Add-On.
+ *
+ *  Data fields in this file are conditions only.
+ *
+ *  Remove this message before using this file in production!
+ **********************************************************************/
+
+/**
+ * GlmDataBuy Sells class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataBuySell extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Data Table Name
+     *
+     * @var $table
+     * @access public
+     */
+    public $table;
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = false;
+    
+    /**
+     * Constructor
+     *
+     * @param object $d database connection
+     * @param array $config Configuration array
+     * @param bool $limitedEdit Flag to say indicate limited edit requested
+     *
+     * @return void
+     * @access public
+     */
+    public function __construct($wpdb, $config, $limitedEdit = false)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+        if (!$this->wpdb) {
+
+            // Save WordPress Database object
+            $this->wpdb = $wpdb;
+
+            // Save plugin configuration object
+            $this->config = $config;
+
+        }
+
+        /*
+         * Table Name
+         */
+        
+        $this->table = GLM_MEMBERS_BUY_SELL_PLUGIN_DB_PREFIX . 'buy_sell';
+
+        //        -- Conditions Table
+        //CREATE TABLE {prefix}conditions (
+        //  id INT NOT NULL AUTO_INCREMENT,
+        //  name TEXT NOT NULL,
+        //  descr_short TEXT NULL,
+        //  descr TEXT NULL,
+        //  last_update DATE NULL,
+        //  PRIMARY KEY (id)
+        //);
+        
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+            'topic' => array (
+                'field' => 'topic',
+                'type' => 'list',
+                    'list' => $this->config['topics'],
+                    'default' => 'For Sale',
+                    'force_list' => true,
+                'use' => 'a'
+            ),
+            'title' => array (
+                'field' => 'title',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'descr' => array (
+                'field' => 'descr',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'terms' => array (
+                'field' => 'terms',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'contact_email' => array (
+                'field' => 'contact_email',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'contact_name' => array (
+                'field' => 'contact_name',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'contact_phone' => array (
+                'field' => 'contact_phone',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'post_date' => array (
+                'field' => 'post_date',
+                'type' => 'datetime',
+                'use' => 'lge'
+            ),
+            'visible' => array (
+                'field' => 'visible',
+                'type' => 'checkbox',
+                'use' => 'a'
+            ),
+            'post' => array (
+                'field' => 'post',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'location' => array (
+                'field' => 'location',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'item_expiration' => array (
+                'field' => 'item_expiration',
+                'type' => 'list',
+                    'list' => $this->config['item_expiration'],
+                    'default' => '120 Days',
+                    'force_list' => true,
+                'use' => 'a'
+            ),
+            'image_1' => array (
+                'field' => 'image_1',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'image_2' => array (
+                'field' => 'image_2',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'company' => array (
+                'field' => 'company',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'image_3' => array (
+                'field' => 'image_3',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+            'member' => array (
+                'field' => 'member',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX  . 'members',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                'use' => 'a'
+            ),
+        );
+    }
+
+    /*
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * In this case we're using it to append an array of category
+     * data to each row result and also sort by name.
+     *
+     * @param array $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing($r, $a)
+    {
+        return $r;
+    }
+
+}
+
+?>
\ No newline at end of file
index 9222f7e..eae9133 100644 (file)
@@ -6,3 +6,9 @@
 ;
 
 [common]
+item_expiration[60] = '60 Days'
+item_expiration[90] = '90 Days'
+item_expiration[120] = '120 Days'
+
+topics[1] = 'Buy'
+topics[2] = 'For Sale'
\ No newline at end of file
index a025c97..d983c68 100644 (file)
  * is named the same as the "glm_action" parameter.
  *
  */
-
+ if (isset($this->config['loggedInUser']) && isset($this->config['loggedInUser']['contactUser']) && $this->config['loggedInUser']['contactUser']) {
+    add_submenu_page(
+        $mainMenuSlug,
+        'Buy Sell',
+        'Buy Sell',
+        'glm_members_edit_my_entity',
+        'glm-members-admin-menu-buy-sell-index',
+        function(){$this->controller('buy-sell');}
+    );
+} else {
+    add_submenu_page(
+        'glm-members-admin-menu-members',
+        'Buy Sell',
+        'Buy Sell',
+        'edit_posts',
+        'glm-members-admin-menu-jobs-index',
+        function(){$this->controller('buy-sell');}
+    );
+}
index 36af8bd..d3d0d5c 100644 (file)
@@ -31,5 +31,5 @@
  *     }
  * );
  *
- */
 
+} */
\ No newline at end of file
diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql
new file mode 100644 (file)
index 0000000..9a048b7
--- /dev/null
@@ -0,0 +1,47 @@
+-- Gaslight Media Members Database - Buy Sell
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.1
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most receint database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Conditions Table
+CREATE TABLE {prefix}buy_sell (
+    id INT NOT NULL AUTO_INCREMENT,
+    topic int NULL ,
+    title TEXT NULL ,
+    company TINYTEXT NULL ,
+    location TEXT NULL ,
+    descr TEXT NULL ,
+    contact_email TINYTEXT NULL ,
+    contact_name TINYTEXT NULL ,
+    contact_phone TINYTEXT NULL ,
+    post_date DATETIME NULL DEFAULT NOW(),
+    visible BOOL NULL,
+    terms TEXT NULL,
+    post TEXT NULL,
+    item_expiration INT NULL,
+    image_1 TINYTEXT NULL ,
+    image_2 TINYTEXT NULL ,
+    image_3 TINYTEXT NULL ,
+    member INT NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Job Titles default entries in table
+INSERT INTO {prefix}buy_sell ( 
+id,title,descr,topic,contact_email,contact_name,contact_phone,post_date,visible, 
+terms,location,item_expiration,image_3,post,image_1,
+company,member,image_2
+) VALUES ( 1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'CONTACT NAME', '453-3443', NOW(), true,
+'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE',
+'COMPANY', 1, 'JOB BENEFITS'
+);
\ No newline at end of file
index 68554ec..2cd34cd 100644 (file)
  *
  *  $permit is a boolean set before this function call for passing on permissions.
 */
+add_filter('glm_members_permit_admin_members_buy_sell',
+function($permit) {
+    return glmMembersUserCan('glm_members_edit_any_member', $permit);
+}
+);
+
+// Logged in member user may edit an event only for their own entity
+add_filter('glm_members_permit_admin_member_buy_sell',
+function($permit) {
+    return glmMembersUserCan('glm_members_edit_my_member', $permit);
+}
+);
\ No newline at end of file
index fdc1d3b..70b5de8 100644 (file)
  *       </tr>
  */
 
-$glmMembersBuySellShortcodes = array(
+ $glmMembersBuySellShortcodes = array(
+    'glm-members-BuySell' => array(
+        'plugin'     => GLM_MEMBERS_BuySell_PLUGIN_SLUG,
+        'menu'       => 'BuySell',
+        'action'     => 'list',
+        'table'      => false,
+        'attributes' => array(
+            'id'         => true,
+            'member_only' => true
+        )
+    ),
+    'glm-members-job-detail' => array(
+        'plugin'     => GLM_MEMBERS_BuySell_PLUGIN_SLUG,
+        'menu'       => 'BuySell',
+        'action'     => 'detail',
+        'table'      => false,
+        'attributes' => array(
+            'id'         => false,
+        )
+    ),
 );
 
+
 $glmMembersBuySellShortcodesDescription = '';
 
index 1acee66..ef56e72 100644 (file)
  *
  */
 
-$glmMembersBuySellAddOnValidActions = array(
+
+ $glmMembersBuySellAddOnValidActions = array(
     'adminActions' => array(
+        'BuySell' => array( 
+            'index' => GLM_MEMBERS_BuySell_PLUGIN_SLUG,
+        ),
     ),
     'frontActions' => array(
+        'BuySell' => array( 
+            'list' => GLM_MEMBERS_BuySell_PLUGIN_SLUG,
+            'detail'   => GLM_MEMBERS_BuySell_PLUGIN_SLUG,
+        ),
     )
 );