From: Chuck Scott Date: Fri, 13 May 2016 18:20:43 +0000 (-0400) Subject: Restructure social database tables and move from settings to management. X-Git-Tag: v1.0.0^2~10 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=a025e64902c90d14cd4c9417bcfb8a863f48492c;p=WP-Plugins%2Fglm-member-db-social.git Restructure social database tables and move from settings to management. --- diff --git a/classes/data/dataSocialUrls.php b/classes/data/dataSocialUrls.php new file mode 100644 index 0000000..3ccafe0 --- /dev/null +++ b/classes/data/dataSocialUrls.php @@ -0,0 +1,215 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/********************************************************************** + * NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED + * + * Please change all references to social, Social, or SOCIAL to a name + * appropriate for your new Add-On. + * + * Data fields in this file are social only. + * + * Remove this message before using this file in production! + **********************************************************************/ + +// Member Info Data required +require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); + +/** + * GlmDataUrls class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Gaslight Media + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataSocialUrls 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; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * 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_SOCIAL_PLUGIN_DB_PREFIX . 'social_urls'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + // The id of this url record + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Reference Type - Insert new record + 'ref_type_insert' => array ( + 'field' => 'ref_type', + 'type' => 'integer', + 'use' => 'i' + ), + + // Reference Type - Output only + 'ref_type' => array ( + 'field' => 'ref_type', + 'type' => 'list', + 'list' => $this->config['ref_type'], + 'use' => 'lged' + ), + + // Ref_name (member name - need to update this to be Reference Type aware) + 'ref_dest' => array ( + 'field' => 'ref_dest', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'use' => 'a' + ), + + // Reference Target ID + 'ref_dest_id' => array ( + 'field' => 'ref_dest', + 'as' => 'ref_dest_id', + 'type' => 'integer', + 'use' => 'ilged' + ), + + + // The member's URL for a certain medium + 'url' => array ( + 'field' => 'url', + 'type' => 'text', + 'default' => true, + 'use' => 'a' + ), + // The social medium + 'social' => array ( + 'field' => 'social', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX . 'socials', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + '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 member result and also sort by member 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; + } + +} + +?> diff --git a/classes/data/dataSocials.php b/classes/data/dataSocials.php index 7dba8f1..dc6d5f0 100644 --- a/classes/data/dataSocials.php +++ b/classes/data/dataSocials.php @@ -12,20 +12,6 @@ * @release SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ */ -/********************************************************************** - * NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED - * - * Please change all references to social, Social, or SOCIAL to a name - * appropriate for your new Add-On. - * - * Data fields in this file are social only. - * - * Remove this message before using this file in production! - **********************************************************************/ - -// Member Info Data required -require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); - /** * GlmDataSocials class * @@ -143,23 +129,15 @@ class GlmDataSocials extends GlmDataAbstract 'default' => true, 'use' => 'a' ), - - // X Position of icon in sprite - 'xpos' => array ( + + // Base 64 Image Icon + 'b64icon' => array ( 'field' => 'xpos', 'type' => 'integer', 'view_only' => true, 'use' => 'a' ), - // Y Position of icon in sprite - 'ypos' => array( - 'field' => 'ypos', - 'type' => 'integer', - 'required' => true, - 'use' => 'a' - ), - // Base url of the social record 'baseurl' => array( 'field' => 'baseurl', @@ -176,6 +154,7 @@ class GlmDataSocials extends GlmDataAbstract 'use' => 'a' ) ); + } /* diff --git a/classes/data/dataUrls.php b/classes/data/dataUrls.php deleted file mode 100644 index 2e3218e..0000000 --- a/classes/data/dataUrls.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release SVN: $Id: dataSocial.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ - */ - -/********************************************************************** - * NOTE: THIS IS A SOCIAL FILE - DO NOT USE UNMODIFIED - * - * Please change all references to social, Social, or SOCIAL to a name - * appropriate for your new Add-On. - * - * Data fields in this file are social only. - * - * Remove this message before using this file in production! - **********************************************************************/ - -// Member Info Data required -require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php'); - -/** - * GlmDataUrls class - * - * PHP version 5 - * - * @category Data - * @package GLM Member DB - * @author Gaslight Media - * @license http://www.gaslightmedia.com Gaslightmedia - * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott - * Exp $ - */ -class GlmDataUrls 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; - /** - * MemberInfo DB object - * - * @var $MemberInfo - * @access public - */ - public $MemberInfo; - - /** - * 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_SOCIAL_PLUGIN_DB_PREFIX . 'urls'; - - /* - * Table Data Fields - */ - - $this->fields = array ( - // The id of this url record - 'id' => array ( - 'field' => 'id', - 'type' => 'integer', - 'view_only' => true, - 'use' => 'a' - ), - - // The id of the associated member - 'member_id' => array ( - 'field' => 'member_id', - 'type' => 'integer', - 'default' => true, - 'use' => 'a' - ), - // The member's URL for a certain medium - 'url' => array ( - 'field' => 'url', - 'type' => 'text', - 'default' => true, - 'use' => 'a' - ), - // The social medium - 'medium' => array ( - 'field' => 'medium', - 'type' => 'text', - 'default' => true, - '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 member result and also sort by member 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; - } - -} - -?> diff --git a/index.php b/index.php index d003341..ad639d8 100644 --- a/index.php +++ b/index.php @@ -54,7 +54,7 @@ * version from this plugin. */ define('GLM_MEMBERS_SOCIAL_PLUGIN_VERSION', '0.0.6'); -define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_SOCIAL_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_SOCIAL_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.57'); @@ -91,8 +91,6 @@ if (!defined('ABSPATH')) { * Some initial setup and tests */ -$startupNotices = ''; - // Get standard defined parameters require_once('defines.php'); @@ -117,13 +115,13 @@ function glmMembersSocialPluginRequired() { * Check installation, activation, and version of main Member DB plugin */ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); -$plugin_name = 'glm-member-db/glm-member-db.php'; +$plugin_name = 'glm-member-db/index.php'; $is_active = is_plugin_active($plugin_name); // If it's not active, then warn user and deactivate this add-on plugin if ($is_active != '1') { add_action( 'admin_notices', 'glmMembersSocialPluginRequired' ); - deactivate_plugins('/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'.php'); + deactivate_plugins('/'.GLM_MEMBERS_SOCIAL_PLUGIN_SLUG.'/index.php'); } // Function to generate message regarding main GLM Member DB plugin version is not receint enought to run this add-on diff --git a/models/admin/management/social.php b/models/admin/management/social.php new file mode 100644 index 0000000..1c6b07f --- /dev/null +++ b/models/admin/management/social.php @@ -0,0 +1,144 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Management Social data abstract +require_once GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php'; + +/** + * GlmMembersAdmin_management_socials + * + * PHP version 5 + * + * @category Model + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmMembersAdmin_management_social extends GlmDataSocials +{ + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for social data class + parent::__construct(false, false); + + } + + public function modelAction($actionData = false) + { + + $success = true; + $socialUpdated = false; + $socialError = false; + $statusMessage = 'Social Updated'; + $option = false; + $debug = true; + + $socialList = $this->getList(); + + if (isset($_REQUEST['option'])) { + $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); + } else { + $option = "default"; + } + + switch ($option) { + case "submit": + $Socials->updateEntry(); + break; + case "social"; + default: + + break; + } + + // If we had a fatal error, redirect to the error page + if ($socialError) { + return array( + 'status' => $success, + 'option' => $option, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + +// if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { +// glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); +// } + // Refresh the URL list before sending it to the front + + // Compile template data + $templateData = array( + 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, + 'socialUpdated' => $socialUpdated, + 'socialError' => $socialError, + 'option' => $option, + 'socials' => $socialList, + 'statusMessage' => $statusMessage + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/management/social.html', + 'data' => $templateData + ); + } +} diff --git a/models/admin/member/social.php b/models/admin/member/social.php index 71d0475..6cf0131 100644 --- a/models/admin/member/social.php +++ b/models/admin/member/social.php @@ -13,7 +13,23 @@ * @link http://dev.gaslightmedia.com/ */ -class GlmMembersAdmin_member_social //extends GlmDataUrls + +// Load Management Social data abstract +require_once GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocialUrls.php'; + +/** + * GlmMembersAdmin_member_social + * + * PHP version 5 + * + * @category Model + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmMembersAdmin_member_social extends GlmDataSocialUrls { /** * WordPress Database Object @@ -53,6 +69,10 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls // Save plugin configuration object $this->config = $config; + + // Run constructor for social data class + parent::__construct(false, false); + } public function modelAction($actionData = false) @@ -72,7 +92,6 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls 'data' => false ); } - $displayData = 'Hello, World! This is the Social Add-On "social" model talking to you from inside WordPress.'; $success = true; $urlUpdated = false; $haveMember = true; @@ -80,7 +99,7 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls $option = false; $debug = false; $statusMessage = "Update complete"; - + require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataUrls.php'); $Urls = new GlmDataUrls($this->wpdb, $this->config); $urlStats = $Urls->getStats(); @@ -90,18 +109,18 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls } $urlList = $Urls->getList("member_id = " . $memberID); //$urlList = $Urls->getList(); - + require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php'); $Socials = new GlmDataSocials($this->wpdb, $this->config); $socialList = $Socials->getList(); - + // Get the option or set to default if (isset($_REQUEST['option'])) { $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); } else { $option = "default"; } - + switch ($option) { case "submit": @@ -167,11 +186,11 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls $statusMessage = "Social Media URLs Updated"; $urlList = $Urls->getList("member_id = " . $memberID); break; - case "social"; + case "social"; default: break; } - + // If we had a fatal error, redirect to the error page if ($socialError) { return array( @@ -202,11 +221,10 @@ class GlmMembersAdmin_member_social //extends GlmDataUrls echo "
".print_r($urlList[$memberID], true)."
"; echo "
sociallist:"; echo "
".print_r($socialList, true)."
"; - echo "
"; + echo ""; } - + $templateData = array( - 'displayData' => $displayData, 'socials' => $socialList, 'urlList' => $memberUrlList, 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, diff --git a/models/admin/settings/social.php b/models/admin/settings/social.php deleted file mode 100644 index e4a2722..0000000 --- a/models/admin/settings/social.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ - * @link http://dev.gaslightmedia.com/ - */ - -class GlmMembersAdmin_settings_social // extends GlmDataContacts -{ - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - /** - * Member ID - * - * @var $memberID - * @access public - */ - public $memberID = false; - /* - * Constructor - * - * This contructor performs the work for this model. This model returns - * an array containing the following. - * - * Data that the model is returning for use in merging with the view to - * produce output. - * - * @wpdb object WordPress database object - * - * @return array Array containing status, suggested view, and any data - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - } - - public function modelAction($actionData = false) - { - $displayData = 'Hello, World! This is the Social Add-On "settings" model talking to you from inside WordPress.'; - $success = true; - $socialUpdated = false; - $socialError = false; - $statusMessage = 'Social Updated'; - $option = false; - $debug = true; - - require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataSocials.php'); - $Socials = new GlmDataSocials($this->wpdb, $this->config); - $socialList = $Socials->getList(); - - if (isset($_REQUEST['option'])) { - $option = trim(filter_var($_REQUEST['option'],FILTER_SANITIZE_STRING)); - } else { - $option = "default"; - } - - echo "
Request:"; - if ($debug) { - echo "
Request:
"; - foreach($_REQUEST as $key=>$value) { - echo(""); - } - echo "
$key$value
"; -// echo "
UrlList:"; -// echo "
".print_r($urlList[$memberID], true)."
"; -// echo "
Recordlist:
"; - echo "
".print_r($socialList, true)."
"; -// echo "
"; - } - - switch ($option) { - case "submit": - $Socials->updateEntry(); - break; - case "social"; - default: - - break; - } - - // If we had a fatal error, redirect to the error page - if ($socialError) { - return array( - 'status' => $success, - 'option' => $option, - 'menuItemRedirect' => 'error', - 'modelRedirect' => 'index', - 'view' => 'admin/error/index.html', - 'data' => false - ); - } - -// if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { -// glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data'); -// } - // Refresh the URL list before sending it to the front - - // Compile template data - $templateData = array( - 'displayData' => $displayData, - 'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL, - 'socialUpdated' => $socialUpdated, - 'socialError' => $socialError, - 'option' => $option, - 'socials' => $socialList, - 'statusMessage' => $statusMessage - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/settings/social.html', - 'data' => $templateData - ); - } -} diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 60e25a6..087500c 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -59,7 +59,7 @@ add_filter('glm-member-db-add-tab-for-member', return $addOnTabs; } ); -add_filter('glm-member-db-add-tab-for-settings', +add_filter('glm-member-db-add-tab-for-management', function($addOnTabs) { $newTabs = array( array( diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql deleted file mode 100644 index 422e44c..0000000 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ /dev/null @@ -1,68 +0,0 @@ --- Gaslight Media Members Database - Social --- 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 recent 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 - -CREATE TABLE {prefix}urls ( - id INT NOT NULL AUTO_INCREMENT, - member_id INT NULL, - url TINYTEXT NULL, - medium TINYTEXT NULL, - PRIMARY KEY (id), - INDEX(id) -); - ----- - -CREATE TABLE {prefix}socials ( - id INT NOT NULL AUTO_INCREMENT, - name TINYTEXT NULL, - xpos int NULL, - ypos int NULL, - baseurl TINYTEXT NULL, - active BOOLEAN NOT NULL DEFAULT '1', - PRIMARY KEY (id), - INDEX(id) -); - ----- - -INSERT INTO {prefix}socials - (name, xpos, ypos, baseurl, active) - VALUES ('Facebook',-5,-5,'www.facebook.com',true), - ('Twitter',-44,-5,'www.twitter.com',true), - ('Pinterest',-84,-5,'www.pinterest.com',true), - ('GooglePlus',-124,-5,'www.google.com',true), - ('Digg',-163,-5,'www.digg.com',true), - ('LinkedIn',-203,-5,'www.linkedin.com',true), - ('Instagram',-242,-5,'www.instagram.com',true), - ('YouTube',-322,-5,'www.youtube.com',true), - ('Flickr',-44,-44,'www.flickr.com',true), - ('blog',-124,-45, '#',true), - ('Photobucket',-282,-45,'www.photobucket.com',true), - ('RSS',-282,-5,'#',false) -; - ----- - -INSERT INTO {prefix}urls - (member_id, url, medium) - VALUES (1,'facebook.com/1','Facebook'), - (1,'pinterest.com/1','Pinterest'), - (1,'Twitter.com/1','Twitter'), - (2,'pinterest.com/2','Pinterest'), - (2,'facebook.com/2','Facebook'), - (2,'Twitter.com/2','Twitter'), - (2,'instagram.com/2','Instagram'), - (2,'youtube.com/2','YouTube'), - (2,'flickr.com/2','Flickr'), - (1,'flickr.com/1','Flickr') -; \ No newline at end of file diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql new file mode 100644 index 0000000..30a1bd9 --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -0,0 +1,53 @@ +-- Gaslight Media Members Database - Social +-- 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 recent 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 + +CREATE TABLE {prefix}socials ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NULL, + b64icon TEXT NULL, + baseurl TINYTEXT NULL, + active BOOLEAN NOT NULL DEFAULT '1', + PRIMARY KEY (id), + INDEX(id) +); + +---- + +CREATE TABLE {prefix}social_urls ( + id INT NOT NULL AUTO_INCREMENT, + ref_type TINYINT NULL, + ref_dest INT NULL, + url TINYTEXT NULL, + social TINYINT NULL, + PRIMARY KEY (id), + INDEX(id) +); + +---- + +-- Add default social media types and icons (base64encoded icons) +INSERT INTO {prefix}socials + (name, b64icon, baseurl, active) + VALUES ('Facebook','','www.facebook.com',true), + ('Twitter','','www.twitter.com',true), + ('Pinterest','','www.pinterest.com',true), + ('GooglePlus','','www.google.com',true), + ('Digg','','www.digg.com',true), + ('LinkedIn','','www.linkedin.com',true), + ('Instagram','','www.instagram.com',true), + ('YouTube','','www.youtube.com',true), + ('Flickr','','www.flickr.com',true), + ('blog','', '#',true), + ('Photobucket','','www.photobucket.com',true), + ('RSS','','#',false) +; diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index a721537..f7ffd3f 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -34,5 +34,6 @@ $glmMembersSocialDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 2) + '0.0.1' => array('version' => '0.0.1', 'tables' => 2), + '0.0.2' => array('version' => '0.0.2', 'tables' => 2, 'date' => '5/12/2016') ); diff --git a/setup/databaseScripts/readme.txt b/setup/databaseScripts/readme.txt index ff3b4e7..141d8b5 100644 --- a/setup/databaseScripts/readme.txt +++ b/setup/databaseScripts/readme.txt @@ -1,4 +1,41 @@ This directory contains database creation and update scripts for this add-on. -This directly is optional. If there are no data tables added by this add-on, -this directory should be omitted. +The files in this directory are checked by the checkDatabase() function in the +main plugin classes/glmPluginSupport.php file. + +This directory is optional. If there are no data tables that need to be created +for this add-on, there should be no files in this directory. The directory may +also be deleted. + +See the "examples" directory for a sample of what can go in this directory. +Procedure to update database +----------------------------- + +0) Make a backup copy of the site's database. + +1) Rename "create_database_Vx.x.x.sql" to new version number. + example: create_database_V0.0.9.sql -> create_database_V0.0.10.sql + +2) Edit renamed create database file and make desired changes + +3) Add a new "update_database_Vx.x.x.sql" named with the correct version #. + +4) Edit new update database files with SQL script to make the necessary changes + from the previous version to the new version. (i.e. to add new fields, + rename fields, insert records, ...) + +5) Optionally add an "update_database_Vx.x.x.php" file if PHP scripting is + needed to update database content. (i.e. to make changes to database content) + +6) Edit the "dbVersions.php" file and add a new line for the new version. + *** Now please be sure to add a date for each entry *** + i.e. '1.1.2' => array('version' => '1.1.2', 'tables' => 14, 'date' => '4/11/16') + +7) When this is all done, edit the index.php file for the plugin/add-on and + change "GLM_MEMBERS_{addon}_PLUGIN_DB_VERSION" defined parameter where + {addon} is the add-on name. + +8) Go to an admin menu item for the main member db plugin or any add-on. If all + goes well, the main plugin should have detected the change and updated the + database. If not, restore the database and try again. +9) Check the database to make sure the changes to fields and data are correct. diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql new file mode 100644 index 0000000..6a00440 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.2.sql @@ -0,0 +1,65 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 12/09/14 15:27:15 +-- Database Version: 0.0.9 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashses + + + +-- Drop existing socials table +DROP TABLE {prefix}socials; + +---- + +-- Create new socials table +CREATE TABLE {prefix}socials ( + id INT NOT NULL AUTO_INCREMENT, + name TINYTEXT NULL, + b64icon TEXT NULL, + baseurl TINYTEXT NULL, + active BOOLEAN NOT NULL DEFAULT '1', + PRIMARY KEY (id), + INDEX(id) +); + +---- + +-- Add default social media types and icons (base64encoded icons) +-- NEED TO ADD DEFAULT ICON DATA HERE +INSERT INTO {prefix}socials + (name, b64icon, baseurl, active) + VALUES ('Facebook','','www.facebook.com',true), + ('Twitter','','www.twitter.com',true), + ('Pinterest','','www.pinterest.com',true), + ('GooglePlus','','www.google.com',true), + ('Digg','','www.digg.com',true), + ('LinkedIn','','www.linkedin.com',true), + ('Instagram','','www.instagram.com',true), + ('YouTube','','www.youtube.com',true), + ('Flickr','','www.flickr.com',true), + ('blog','', '#',true), + ('Photobucket','','www.photobucket.com',true), + ('RSS','','#',false) +; + +---- + +-- Drop existing urls table +DROP TABLE {prefix}urls; + +---- + +-- Create new social_urls table (replaces urls) +CREATE TABLE {prefix}social_urls ( + id INT NOT NULL AUTO_INCREMENT, + ref_type TINYINT NULL, + ref_dest INT NULL, + url TINYTEXT NULL, + social TINYINT NULL, + PRIMARY KEY (id), + INDEX(id) +); + + diff --git a/setup/validActions.php b/setup/validActions.php index 4d54cde..62f1bd9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -49,7 +49,7 @@ $glmMembersSocialAddOnValidActions = array( 'member' => array( 'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, ), - 'settings' => array( + 'management' => array( 'social' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG ) ), diff --git a/views/admin/management/social.html b/views/admin/management/social.html new file mode 100644 index 0000000..5b5baa7 --- /dev/null +++ b/views/admin/management/social.html @@ -0,0 +1,55 @@ +{include file='admin/management/header.html'} + +

{if $socialUpdated}{$statusMessage}{/if}

+ +

Social Media Types

+ +
+ + + + {foreach $socials as $s} + + + + + + + + + + + {/foreach} +
ActiveNameImage
+ {$s.active.name} + +
+
+
+ {$socialItem.name} + +
+ +
+ +
+
+
+
+
+
New image:
+ + +
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/member/social.html b/views/admin/member/social.html index 5993e67..c4ac193 100644 --- a/views/admin/member/social.html +++ b/views/admin/member/social.html @@ -1,4 +1,4 @@ -{include file='admin/members/header.html'} +{include file='admin/member/header.html'}

{if $urlUpdated}{$statusMessage}{/if}

Member Social Tab

@@ -67,8 +67,11 @@ -{include file='admin/footer.html'}