Current development version:
authorLaury GvR <laury@gaslightmedia.com>
Tue, 29 Mar 2016 15:46:57 +0000 (11:46 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 29 Mar 2016 15:46:57 +0000 (11:46 -0400)
classes/data/dataRecords.php [deleted file]
classes/data/dataSocials.php [new file with mode: 0644]
classes/data/dataUrls.php
models/admin/member/social.php
models/admin/settings/social.php
setup/databaseScripts/create_database_V0.0.1.sql
views/admin/member/social.html
views/admin/settings/social.html

diff --git a/classes/data/dataRecords.php b/classes/data/dataRecords.php
deleted file mode 100644 (file)
index 1ac163d..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * GLM Member-DB WordPress Add-On Plugin
- * Data Class Social
- *
- * PHP version 5.3
- *
- * @category Data
- * @package  GLM Member-DB
- * @author   Gaslight Media <dev@gaslightmedia.com>
- * @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');
-
-/**
- * GlmDataRecords class
- *
- * PHP version 5
- *
- * @category Data
- * @package GLM Member DB
- * @author   Gaslight Media <dev@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 GlmDataRecords 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 . 'records';
-
-        /*
-         * Table Data Fields
-         */
-
-        $this->fields = array (
-
-            // Social ID
-            'id' => array (
-                'field' => 'id',
-                'type' => 'integer',
-                'view_only' => true,
-                'use' => 'a'
-            ),
-
-            // Name of the social record
-            'name' => array (
-                'field' => 'name',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // X Position of icon in sprite
-            'xpos' => 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',
-                'type' => 'text',
-                'required' => true,
-                'use' => 'a'
-            ),
-
-            // Active flag
-            'active' => array (
-                'field' => 'active',
-                'type' => 'checkbox',
-                '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;
-    }
-
-}
-
-?>
\ No newline at end of file
diff --git a/classes/data/dataSocials.php b/classes/data/dataSocials.php
new file mode 100644 (file)
index 0000000..7dba8f1
--- /dev/null
@@ -0,0 +1,202 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Social
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Gaslight Media <dev@gaslightmedia.com>
+ * @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');
+
+/**
+ * GlmDataSocials class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author   Gaslight Media <dev@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 GlmDataSocials 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 . 'socials';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            // The id for this social medium
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+
+            // Name of the social record
+            'name' => array (
+                'field' => 'name',
+                'type' => 'text',
+                'default' => true,
+                'use' => 'a'
+            ),
+            
+            // X Position of icon in sprite
+            'xpos' => 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',
+                'type' => 'text',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Active flag
+            'active' => array (
+                'field' => 'active',
+                'type' => 'checkbox',
+                '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;
+    }
+
+}
+
+?>
\ No newline at end of file
index f0e16db..373a89a 100644 (file)
@@ -128,8 +128,7 @@ class GlmDataUrls extends GlmDataAbstract
          */
 
         $this->fields = array (
-
-            // Social ID
+            // The id of this url record
             'id' => array (
                 'field' => 'id',
                 'type' => 'integer',
@@ -137,96 +136,23 @@ class GlmDataUrls extends GlmDataAbstract
                 'use' => 'a'
             ),
 
-            // The member's URL for facebook
-            'facebook' => array (
-                'field' => 'facebook',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            // The member's URL for twitter
-            'twitter' => array (
-                'field' => 'twitter',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for pinterest
-            'pinterest' => array (
-                'field' => 'pinterest',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for googleplus
-            'googleplus' => array (
-                'field' => 'googleplus',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for digg
-            'digg' => array (
-                'field' => 'digg',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for linkedin
-            'linkedin' => array (
-                'field' => 'linkedin',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for instagram
-            'instagram' => array (
-                'field' => 'instagram',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for rss
-            'rss' => array (
-                'field' => 'rss',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for youtube
-            'youtube' => array (
-                'field' => 'youtube',
-                'type' => 'text',
-                'default' => true,
-                'use' => 'a'
-            ),
-            
-            // The member's URL for flickr
-            'flickr' => array (
-                'field' => 'flickr',
-                'type' => 'text',
+            // The id of the associated member
+            'member_id' => array (
+                'field' => 'member_id',
+                'type' => 'integer',
                 'default' => true,
                 'use' => 'a'
             ),
-            
-            // The member's URL for blog
-            'blog' => array (
-                'field' => 'blog',
+            // The member's URL for a certain medium
+            'url' => array (
+                'field' => 'url',
                 'type' => 'text',
                 'default' => true,
                 'use' => 'a'
             ),
-            
-            // The member's URL for photobucket
-            'photobucket' => array (
-                'field' => 'photobucket',
+            // The social medium
+            'social' => array (
+                'field' => 'social',
                 'type' => 'text',
                 'default' => true,
                 'use' => 'a'
index 20a3236..9dadd0f 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-// Load Contacts data abstract
-require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataUrls.php');
-
-class GlmMembersAdmin_member_social extends GlmDataUrls
+class GlmMembersAdmin_member_social //extends GlmDataUrls
 {
-    
     /**
      * WordPress Database Object
      *
@@ -33,13 +29,6 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
      * @access public
      */
     public $config;
-    /**
-     * Contact Info
-     *
-     * @var $contactInfo
-     * @access public
-     */
-    public $contactInfo = false;
     /**
      * Member ID
      *
@@ -47,33 +36,9 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
      * @access public
      */
     public $memberID = false;
-    /**
-     * Contact ID
-     *
-     * @var $contactID
-     * @access public
-     */
-    public $contactID = false;
-    
-
     /*
      * Constructor
      *
-     * This contructor performs the work for this model. This model returns
-     * an array containing the following.
-     *
-     * 'status'
-     *
-     * True if successfull and false if there was a fatal failure.
-     *
-     * 'view'
-     *
-     * A suggested view name that the contoller should use instead of the
-     * default view for this model or false to indicate that the default view
-     * should be used.
-     *
-     * 'data'
-     *
      * Data that the model is returning for use in merging with the view to
      * produce output.
      *
@@ -83,77 +48,44 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
      */
     public function __construct ($wpdb, $config)
     {
-
         // Save WordPress Database object
         $this->wpdb = $wpdb;
 
         // Save plugin configuration object
         $this->config = $config;
-
-        /*
-         * Run constructor for the Contacts data class
-         *
-         * Note, the third parameter is a flag that indicates to the Contacts
-         * data class that it should flag a group of fields as 'view_only'.
-         */
-//        parent::__construct(false, false, true);
-
-
     }
 
-    
-    
-//    public function updateUrlList(&$existingUrls) {        
-//        $getExistingUrls = "
-//            SELECT * 
-//            FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."urls
-//            ;";
-//        $existingUrls = $this->wpdb->get_results($getExistingUrls, ARRAY_A);
-////        $existingUrls = $queryUrls[0];
-//        return;
-//    }
-    
-//    public function printSocialList(&$array,$name="Array list") {
-//        echo "<hr />$name:<table>";
-//        foreach($array[0] as $key=>$value) {
-//            echo("<tr><td>$key</td><td>$value</td></tr>");
-//        }
-//        echo "</table>";
-//    }
-    
     public function modelAction($actionData = false)
     {
         $displayData = 'Hello, World! This is the Social Add-On "social" model talking to you from inside WordPress.';
         $success = true;
-        $socials = false;
-        $socialUpdated = false;
+        $urlUpdated = false;
         $haveMember = false;
         $socialError = false;
         $option = false;
         $debug = true;
-        $statusMessage = "debug mode";
+        $statusMessage = "Update complete";
         
+        require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataUrls.php');
         $Urls = new GlmDataUrls($this->wpdb, $this->config);
         $urlStats = $Urls->getStats();
         $haveUrls = ($urlStats > 0);
-        
         if ($urlStats && $urlStats > 0) {
             $haveUrls = true;
         }
-        
         $urlList = $Urls->getList();
         
-        require_once(GLM_MEMBERS_SOCIAL_PLUGIN_CLASS_PATH.'/data/dataRecords.php');
-        $Records = new GlmDataRecords($this->wpdb, $this->config);
+        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";
         }
         
-        $recordList = $Records->getList();
-        
         // Get the Member ID
         $memberID = '0';
         if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) {
@@ -169,15 +101,6 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
                 'data' => false
             );
         }
-        
-        echo "<hr />Request:<table>";
-        foreach($_REQUEST as $key=>$value) {
-            echo("<tr><td>$key</td><td>$value</td></tr>");
-        }
-        echo "</table>";
-        echo "<hr />UrlList:<table>";
-        echo "<pre>".print_r($urlList[$memberID], true)."</pre>";
-        echo "</table>";
 
         if (!$Urls->getEntry($memberID)){
             $sql = "
@@ -186,14 +109,16 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
                     VALUES ($memberID)
             ;";
             $this->wpdb->query($sql);
-            echo "sql: $sql";
+            if ($debug) {
+                echo "<hr>Member not found. Created new record in Urls table using id=$memberID with statement: $sql<hr>";
+            }
         }
 
         switch ($option) {
             case "submit":
                 $Urls->updateEntry($memberID);
-                
-                
+                $urlUpdated = true;
+                $statusMessage = "Social Media URLs Updated";
                 
                 break;
             case "social";    
@@ -213,12 +138,27 @@ class GlmMembersAdmin_member_social extends GlmDataUrls
             );
         }
 
+        // Refresh the Url list before returning it
+        $urlList = $Urls->getList();
+        if ($debug) {
+            echo "<hr />Request:<table>";
+            foreach($_REQUEST as $key=>$value) {
+                echo("<tr><td>$key</td><td>$value</td></tr>");
+            }
+            echo "</table>";
+            echo "<hr />UrlList:<table>";
+            echo "<pre>".print_r($urlList[$memberID], true)."</pre>";
+            //echo "<hr />Recordlist:<table>";
+            //echo "<pre>".print_r($socialList, true)."</pre>";
+            echo "</table>";            
+        }
+        
         $templateData = array(
             'displayData' => $displayData,
-            'socials' => $recordList,
+            'socials' => $socialList,
             'urlList' => $urlList[$memberID],
             'assetsUrl' => GLM_MEMBERS_SOCIAL_PLUGIN_ASSETS_URL,
-            'socialUpdated' => $socialUpdated,
+            'urlUpdated' => $urlUpdated,
             'socialError' => $socialError,
             'haveMember' => $haveMember,
             'memberID' => $memberID,
index adb6a8a..e4a2722 100644 (file)
  * @link     http://dev.gaslightmedia.com/
  */
 
-// Load Contacts data abstract
-//require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php');
-
 class GlmMembersAdmin_settings_social // extends GlmDataContacts
 {
-
-
-        
     /**
      * WordPress Database Object
      *
@@ -35,26 +29,19 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts
      * @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.
      *
-     * 'status'
-     *
-     * True if successfull and false if there was a fatal failure.
-     *
-     * 'view'
-     *
-     * A suggested view name that the contoller should use instead of the
-     * default view for this model or false to indicate that the default view
-     * should be used.
-     *
-     * 'data'
-     *
      * Data that the model is returning for use in merging with the view to
      * produce output.
      *
@@ -73,110 +60,47 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts
 
     }
 
-    
-    
-//    public function updateSocialList(&$existingSocials) {        
-//        $getExistingSocials = "
-//            SELECT * 
-//            FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records
-//            ;";
-//        $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A);
-//    }
-//    
-//    public function printSocialList($array,$name="Array list") {
-//        echo "<hr />$name<table>";
-//        $i = 0;
-//        foreach($array as $key=>$socialRecord) {
-//            foreach($socialRecord as $recordKey=>$recordValue)
-//            echo("<tr><td>$recordKey</td><td>$recordValue</td></tr>");
-//            $i++;
-//        }
-//        echo "</table><hr>";
-//    }
-    
     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;
-        $statusMessage = 'Social Updated';
-//        $getExistingSocials = "
-//            SELECT * 
-//            FROM ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records
-//            ;";
-//        $existingSocials = $this->wpdb->get_results($getExistingSocials, ARRAY_A);
-        // If there's an action option
+
+        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";
         }
-        
-        $socials = new GlmDataSocial($this->wpdb, $this->config);
-        $socialInfo = $socials->getEntry();
-        
-        
-        $urls = new GlmDataUrls($this->wpdb, $this->config);
-        $urlList = $urls->getEntry($memberID);
 
         echo "<hr />Request:<table>";
-        foreach($_REQUEST as $socialRecord=>$value) {
-            echo("<tr><td>$socialRecord</td><td>$value</td></tr>");
+        if ($debug) {
+            echo "<hr />Request:<table>";
+            foreach($_REQUEST as $key=>$value) {
+                echo("<tr><td>$key</td><td>$value</td></tr>");
+            }
+            echo "</table>";
+//            echo "<hr />UrlList:<table>";
+//            echo "<pre>".print_r($urlList[$memberID], true)."</pre>";
+//            echo "<hr />Recordlist:<table>";
+            echo "<pre>".print_r($socialList, true)."</pre>";
+//            echo "</table>";            
         }
-        echo "</table>";
         
         switch ($option) {
             case "submit":
-                if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-                    glmMembersAdmin::addNotice("<b>&nbsp;&nbsp;Social Update:</b>", 'Process');
-                }
-
-                foreach($existingSocials as $key => $socialRecord) {
-                    $socialUpdated = false;
-                    $sql = "";
-                    
-                    $recordBool = $socialRecord['active'];
-                    if(isset($_REQUEST['checkname-'.strtolower($socialRecord['name'])])){
-                        $socialBool = 1;
-                    } else {
-                        $socialBool = 0;
-                    }
-//                    echo " | checkname-".strtolower($socialRecord['name'])." | ";
-//                    $socialChecked = $_REQUEST['checkname-'.strtolower($socialRecord['name'])];
-                    if ($socialBool != $recordBool) {
-                        echo " - Unequal, rec:$recordBool and soc:$socialBool<hr>";
-                            $sql = "
-                            UPDATE ".GLM_MEMBERS_SOCIAL_PLUGIN_DB_PREFIX."media_records
-                            SET active = $socialBool
-                            WHERE id = ".$socialRecord['id']."
-                        ;";                    
-                        $socialUpdated = true;
-                        $this->wpdb->query($sql);
-                    } 
-                    if ($socialUpdated) {
-                        if ($debug){
-                            echo "<hr><div>".$statusMessage."</div>";
-                            echo "<div>Social:".$socialRecord."</div>";
-                            echo "<div>Social url:".$value."</div>";
-                            echo "<div>statement:".$sql."</div>";
-                        } 
-                    }               
-                }            
-                if ($debug) {
-                    $this->updateSocialList($existingSocials);
-                    $this->printSocialList($existingSocials,"Existing Socials Post Submit");
-                }
+                $Socials->updateEntry();
                 break;
-            case "social";    
+            case "social";
             default:
-                $this->updateSocialList($existingSocials);
-                
-                if ($debug) {
-                    $this->printSocialList($existingSocials,"Existing Socials Default:");
-                }
+
                 break;
         }
         
@@ -196,7 +120,7 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts
 //            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data');
 //        }
         // Refresh the URL list before sending it to the front
-        $this->updateSocialList($existingSocials);
+
         // Compile template data
         $templateData = array(
             'displayData' => $displayData,
@@ -204,7 +128,7 @@ class GlmMembersAdmin_settings_social // extends GlmDataContacts
             'socialUpdated' => $socialUpdated,
             'socialError' => $socialError,
             'option' => $option,
-            'existingSocials' => $existingSocials,
+            'socials' => $socialList,
             'statusMessage' => $statusMessage
         );
 
index 9912c57..422e44c 100644 (file)
 -- all queries must be separated by a line with four dashes
 
 CREATE TABLE {prefix}urls (
-  id INT NULL,
-  facebook TEXT NULL,
-  twitter TEXT NULL,
-  pinterest TEXT NULL,
-  googleplus TEXT NULL,
-  digg TEXT NULL,
-  linkedin TEXT NULL,
-  instagram TEXT NULL,
-  rss TEXT NULL,
-  youtube TEXT NULL,
-  flickr TEXT NULL,
-  blog TEXT NULL,
-  photobucket TEXT NULL,
-  PRIMARY KEY (id),
-  INDEX(id)
+    id INT NOT NULL AUTO_INCREMENT,
+    member_id INT NULL,
+    url TINYTEXT NULL,
+    medium TINYTEXT NULL,
+    PRIMARY KEY (id),
+    INDEX(id)
 );
 
 ----
 
-CREATE TABLE {prefix}records (
+CREATE TABLE {prefix}socials (
   id INT NOT NULL AUTO_INCREMENT,
   name TINYTEXT NULL,
   xpos int NULL,
@@ -44,7 +35,7 @@ CREATE TABLE {prefix}records (
 
 ----
 
-INSERT INTO {prefix}records
+INSERT INTO {prefix}socials
   (name, xpos, ypos, baseurl, active)
   VALUES ('Facebook',-5,-5,'www.facebook.com',true),
          ('Twitter',-44,-5,'www.twitter.com',true),
@@ -58,4 +49,20 @@ INSERT INTO {prefix}records
          ('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
index 9b7e021..ed983bf 100644 (file)
@@ -1,10 +1,44 @@
 {include file='admin/members/header.html'}
-<h2>{if $socialUpdated}<span class="glm-notice glm-flash-updated glm-right">{$statusMessage}</span>{/if}</h2>
+<h2>{if $urlUpdated}<span class="glm-notice glm-flash-updated glm-right">{$statusMessage}</span>{/if}</h2>
     <h3>Member Social Tab</h3>
     <p>{$displayData}</p>
+    
+    <div id="editMemberTypeDialog" class="glm-dialog-box" title="Edit Member Type">
+        <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+            <input type="hidden" name="glm_action" value="index">
+            <input type="hidden" name="option" value="update">
+            <input id="editMemberTypeID" type="hidden" name="id" value="">
+            <table class="glm-admin-table">
+                <tr>
+                    <th>Social Name:</th>
+                    <td>
+                        <span id="glmSocName"></span>
+                        <!--<input id="editMemberTypeName" type="text" name="name" class="glm-form-text-input">-->
+                    </td>
+                </tr>
+                <tr>
+                    <th>Icon:</th>
+                    <td>
+                        <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
+                        </div>
+                    </td>
+                </tr>
+                <tr>
+                    <th>Description:</th>
+                    <td>
+                        <textarea id="editMemberTypeDescr" name="descr" class="glm-form-textarea"></textarea>
+                    </td>
+                </tr>
+            </table>
+            <p><span class="glm-required">*</span> Required</p>
+            <a id="editMemberTypeCancel" class="button button-primary glm-right">Cancel</a>
+            <input type="submit" value="Update this member type">
+        </form>
+    </div>
+    
     <div id="glm-admin-content-container">
         <a href="{$thisUrl}?page={$thisPage}&glm_action=more">Click me to see more!</a>
-        <form action="{$thisUrl}?page={$thisPage}&glm_action=social&member={$memberID}" method="post" enctype="multipart/form-data">
+        <form action="{$thisUrl}?page={$thisPage}&glm_action=default&member={$memberID}" method="post" enctype="multipart/form-data">
             <input type="submit" class="button glm-button submit" value="submit" name='submit'>
             <input type="hidden" name="option" value="submit">
             <div class="button glm-button right">Update</div>
                     {$socialField = $socialItem.name|lower}
                     <tr>
                         <th>
+                            
+
+
                             <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">
                             </div>
-                            {$socialItem.name}
+                            <a class="editMemberType" data-memberTypeID="{$socialItem.id}">{$socialItem.name}</a>
                         </th>
                         <td>
                             <input type="text" id="{$socialItem.name|lower}" placeholder="{$socialItem.name} url" name="{$socialItem.name|lower}" class="glm-form-text-input" value="{$urlList.$socialField}">
     jQuery(document).ready(function($) {
         // Flash certain elements for a short time after display      
         $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+        $("#editMemberTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+        $('.editMemberType').click( function() {
+        var typeID = $(this).attr('data-memberTypeID');
+        var typeName = $(this).text();
+//        var typeDescr = $('#editMemberTypeDescr_' + typeID).html();
+        $('#glmSocName').text(typeName);
+        $('#editMemberTypeName').val(typeName.trim());
+//        $('#editMemberTypeDescr').val(typeDescr.trim());
+        $("#editMemberTypeDialog").dialog("open");
+        });
+        $('#editMemberTypeCancel').click( function() {
+            $("#editMemberTypeDialog").dialog("close");
+        });
+
     });
+
 </script>
 {include file='admin/footer.html'}
\ No newline at end of file
index 0a47b77..b552145 100644 (file)
@@ -3,17 +3,17 @@
     <h3>Member Social Tab</h3>
     <p>{$displayData}</p>
     <div id="glm-admin-content-container">
-        <a href="{$thisUrl}?page={$thisPage}&glm_action=more">Click me to see more!</a>
-        <form id="glm-member-db-social-management" action="{$thisUrl}?page={$thisPage}&glm_action=social&member=1" method="post" enctype="multipart/form-data">
+        <form id="glm-member-db-social-management" action="{$thisUrl}?page={$thisPage}&glm_action=social" method="post" enctype="multipart/form-data">
             <input type="submit" class="button glm-button submit" value="submit" name='submit'>
             <input type="hidden" name="option" value="submit">
             <div class="button glm-button right">Update</div>
             <table class="glm-admin-table">
-            {foreach from=$existingSocials key=k item=socialItem}
+                aaaa
+            {foreach from=$socials key=k item=socialItem}
                 {$socialField = $socialItem.name|lower}
                 <tr>
                     <th class="glm-member-db-social-management-checkbox">
-                        <input type="checkbox" name="checkname-{$socialItem.name|lower}" class="glm-form-text-input" value="{$socialField}" {if $socialItem.active}checked{/if}>
+                        <input type="checkbox" id="{$socialItem.name|lower}" name="{$socialItem.name|lower}" class="glm-form-text-input" value="{$socialField}" {if $socialItem.active.value == 1}checked{/if}>
                     </th>
                     <td class="glm-member-db-social-management-icon">
                         <div id="glm-member-db-admin-social-{$socialItem.name|lower}" title="{$socialItem.name}" class="glm-member-db-social-icon" style="background: url('{$assetsUrl}/social-few-full-sprite.jpg') repeat scroll {$socialItem.xpos}px {$socialItem.ypos}px;height:33px;width:33px;display:block;">