Contact edit page updates.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 31 Jul 2018 14:40:24 +0000 (10:40 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 31 Jul 2018 14:40:24 +0000 (10:40 -0400)
Switching the 'My Contact Info' menu to goto the contact edit model
view. I'm adding a template variable for when an contact is editing
their own record. contactEditOwnRecord.

models/admin/contacts/index.php
setup/adminMenus.php
views/admin/contacts/edit.html

index fa127b7..88af86f 100644 (file)
@@ -141,6 +141,7 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
         $member_types             = false;
         $contactUpdateError       = false;
         $billingFieldResults      = false;
+        $contactEditOwnRecord     = false;
 
         $where = '';
 
@@ -161,6 +162,12 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
         // If this is a logged in member user, then show their contacts only
         if (isset($this->config['loggedInUser']['contactUser'])) {
 
+            // Find out if the user has same contact id as the one being edited.
+            $contactID = $_REQUEST['contact'] - 0;
+            if ( $this->config['loggedInUser']['contactUser']['ID'] == $contactID ) {
+                $contactEditOwnRecord = true;
+            }
+
             // if there's logged in contact user
             $contactUser = $this->config['loggedInUser']['contactUser'];
             if ($contactUser['ref_type'] = $this->config['ref_type_numb']['Member']
@@ -763,6 +770,7 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts
             'contactsList'             => $contactsList['list'],
             'numbContacts'             => $numbContacts,
             'contactID'                => $contactID,
+            'contactEditOwnRecord'     => $contactEditOwnRecord,
             'contactInfo'              => $contactInfo,
             'newContactEmailExists'    => $newContactEmailExists,
             'newContactUsernameExists' => $newContactUsernameExists,
index 1a28ae1..d37bcee 100644 (file)
@@ -40,7 +40,13 @@ if ( $lockedToMember && $enable_contact_edit_only ) {
         'My Contact Info',
         'glm_members_edit_my_contact_info',
         'glm-members-admin-menu-profile',
-        function() {$this->controller('profile');}
+        function() {
+            define( 'GLM_MEMBERS_CONTACTS_MEMBER_MENU', true );
+            $_REQUEST['member']  = $lockedToMember;
+            $_REQUEST['contact'] = $this->config['loggedInUser']['contactUser']['ID'];
+            $_REQUEST['option']  = 'edit';
+            $this->controller('contacts', 'index');
+        }
     );
 
 } else {
index f97a4df..9b2778c 100644 (file)
@@ -81,7 +81,9 @@
     {else}
     {if $contactUpdated}<h2 class="glm-notice glm-flash-updated">Contact Updated</h2>{/if}
     {/if}
+    {if !$contactEditOwnRecord}
     <a id="deleteContactButton" class="button button-primary glm-button glm-right">Delete this Contact</a>
+    {/if}
     <div id="deleteContactDialog" class="glm-dialog-box" title="Delete Contact">
         <center>
             <p><a id="deleteContactCancel" class="button button-primary">Cancel</a></p>