From: Chuck Scott Date: Wed, 4 May 2016 19:19:10 +0000 (-0400) Subject: Last updates before initial deployment X-Git-Tag: v1.0.8^2~8 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f14173bc12697f2271566c6e276094450ccca712;p=WP-Plugins%2Fglm-member-db-contacts.git Last updates before initial deployment --- diff --git a/classes/data/dataContacts.php b/classes/data/dataContacts.php index 6e08ada..77e49b9 100644 --- a/classes/data/dataContacts.php +++ b/classes/data/dataContacts.php @@ -552,7 +552,7 @@ class GlmDataContacts extends GlmDataAbstract * * @return array Simplified contact list or false if nothing returned */ - public function getSimplified($where = 'true', $wpData = false) + public function getSimplified($where = 'true', $wpData = false, $order = '', $fieldVals = true, $idField = 'id', $start = false, $limit = false) { $savedFields = $this->fields; $savedPostProcess = $this->postProcess; @@ -561,13 +561,21 @@ class GlmDataContacts extends GlmDataAbstract $this->fields = array( 'id' => $savedFields['id'], + 'active' => $savedFields['active'], + 'access' => $savedFields['access'], + 'contact_type' => $savedFields['contact_type'], 'fname' => $savedFields['fname'], 'lname' => $savedFields['lname'], 'email' => $savedFields['email'], - 'username' => $savedFields['username'] + 'username' => $savedFields['username_display'], + 'ref_type' => $savedFields['ref_type'], + 'ref_dest' => $savedFields['ref_dest'], + 'ref_dest_name' => $savedFields['ref_dest_name'], + 'city' => $savedFields['city'], + 'state' => $savedFields['state'] ); - $contacts = $this->getList($where); + $contacts = $this->getList($where, $order, $fieldVals, $idField, $start, $limit); // If nothing returned if (!$contacts) { @@ -588,6 +596,38 @@ class GlmDataContacts extends GlmDataAbstract } + /** + * Get ID/Name list + * + * @param string $where + * + * @return array ID/Name pairs + */ + public function getIdName($where = 'true') + { + $savedFields = $this->fields; + // $savedPostProcess = $this->postProcess; -- Post process required for member name + + $this->postProcess = false; + + $this->fields = array( + 'id' => $savedFields['id'], + 'fname' => $savedFields['fname'], + 'lname' => $savedFields['lname'], + 'ref_dest' => $savedFields['ref_dest'], + 'ref_dest_name' => $savedFields['ref_dest_name'] + ); + + $r = $this->getList($where); + + $this->fields = $savedFields; + // $this->postProcess = $savedProcess; + + return $r; + + } + + } diff --git a/models/admin/contacts/index.php b/models/admin/contacts/index.php index 8a02df3..e033693 100644 --- a/models/admin/contacts/index.php +++ b/models/admin/contacts/index.php @@ -38,13 +38,6 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts * @access public */ public $config; - /** - * Contacts List - * - * @var $contacts - * @access public - */ - public $contacts; /* * Constructor @@ -85,53 +78,703 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts } - public function modelAction($actionData = false) { + public function modelAction($actionData = false) + { + + $view = 'index.html'; + $option = 'list'; + $fromMemberMenu = false; + $loggedInMember = false; + $refType = false; + $refTypeName = false; + $haveMember = false; + $memberID = false; + $memberData = false; + $memberName = false; + $contactsList = false; $haveContacts = false; + $contactID = false; + $contactInfo = false; + $newContactExists = false; + $misMatchedWpUsers = false; + $newContactCreated = false; + $usingExistingWPContact = false; + $usernameChangedToWP = false; + $contactUpdated = false; $filterArchived = false; $filterText = false; $haveFilter = false; + $userDeleted = false; + $wpUserDeleted = false; + + $numbContacts = false; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $namesList = false; + + + $validOptions = array( + 'create', + 'addNew', + 'edit', + 'submit', + 'delete', + 'list' + ); + + // If this is a logged in member user, then show their contacts only + if (isset($this->config['loggedInUser']['contactUser'])) { + + // if there's logged in contact user + $contactUser = $this->config['loggedInUser']['contactUser']; + if ($contactUser['ref_type'] = $this->config['ref_type_numb']['Member'] + && $contactUser['ref_dest'] ) { + + $loggedInMember = true; + + // Filter all contact searches to their member contacts + $where .= " AND ref_type = ".$this->config['ref_type_numb']['Member']." + AND ref_dest = ".$contactUser['ref_dest']; + + // Also set their member as the current one + $memberID = $contactUser['ref_dest']; + } + + } + + // If we're coming from the Member Events Menu/Tab + if (defined('GLM_CONTACTS_MEMBER_MENU')) { + + $fromMemberMenu = true; + + // Check if we've received member ID + if (isset($_REQUEST['member'])) { + + // Clean up the member ID and store it in wordpress option + $memberID = $_REQUEST['member']-0; + update_option('glmMembersDatabaseMemberID', $memberID); + + // Otherwise check if a member is stored in wordpress option + } else { + $memberID = get_option('glmMembersDatabaseMemberID', false); + } + + } + + // If we have a member ID - Get Member information + if ($memberID) { + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); + $Members = new GlmDataMembers($this->wpdb, $this->config); + $memberData = $Members->getEntry($memberID); + } + + // Check that we have good member data + if (is_array($memberData) && isset($memberData['id']) && $memberData['id'] > 0) { + $haveMember = true; + $memberName = $memberData['name']; + } + + // If we're adding a new member contact + if (isset($_REQUEST['option']) && in_array($_REQUEST['option'], $validOptions)) { + $option = $_REQUEST['option']; + } + + // Perform selected page option + switch($option) { + + case 'create': + + // Set reference type to Member + $refType = $this->config['ref_type_numb']['Member']; + $refTypeName = $this->config['ref_type'][$refType]; + + $contactInfo = $this->newEntry(); + + require_once(GLM_MEMBERS_CONTACTS_PLUGIN_LIB_PATH.'/EasyPassword/EasyPassword.php'); + $EasyPassword = new EasyPassword(); + $contactInfo['fieldData']['password'] = $EasyPassword->generateEasyPassword('firstlast'); + break; + + case 'addNew': + + // Clean up username to be compatible with WordPress + if (isset($_REQUEST['username'])) { + $_REQUEST['username'] = preg_replace('/[^a-zA-Z0-9_-]+/', '', $_REQUEST['username']); + } + + // Check for existing contact in Wordpress and Contacts + $contactCheck = $this->checkContact($_REQUEST['email'], $_REQUEST['username']); + + // If there's already a contact with this E-Mail address, don't create the contact + if ($contactCheck['contactsEmail'] || $contactCheck['contactsUsername']) { + $newContactExists = true; + break; + } + + // If there is already a WordPress user with the requested Email address and a different user with the requeted Username + if ($contactCheck['wordpressEmail'] && $contactCheck['wordpressLogin'] + && $contactCheck['wpUserEmail']->ID != $contactCheck['wpUserLogin']->ID) { + $misMatchedWpUsers = true; + break; + } + + // Try to insert the new contact + $contactInfo = $this->insertEntry(); + + // If that was successful + if ($contactInfo['status']) { + + // If there's an existing WordPress user matching the E-Mail address but that has a different username + if ($contactCheck['wordpressEmail'] + && $contactCheck['wpUserEmail']->data->user_login != $contactInfo['fieldData']['username']) { + + // Change the contact username to match the Wordpress username + $this->wpdb->query(" + UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts + SET username = '".$contactCheck['wpUserEmail']->data->user_login."' + WHERE id = ".$contactInfo['fieldData']['id']."; + "); + $usernameChangedToWP = true; + + } + + // Determine the Worpress Role to be used + $roleNumb = $contactInfo['fieldData']['contact_role']['value']; + $wpRole = $this->config['contact_role_wordpress'][$roleNumb]; + + // If there's an existing WordPress user we're going to use + if ($contactCheck['wordpressEmail']) { + + // Add appropriate user role + $wpUser = new WP_User($contactCheck['wpUserEmail']->ID); + + /* + * If the current wp user is not an administrator, add their contact role + * + * Note that adding the contact role to an administrator limits the + * administrators capabilities. In otherwords, with multiple roles in + * WordPress it looks like all of the user's roles need to have a + * capability for it to be considered as set. Because of this we can't + * add the contact role or the administrator will be crippled. + */ + // + if (!in_array('administrator', $contactCheck['wpUserEmail']->roles)) { + $wpUser->add_role($wpRole); + } else { + + } + + $usingExistingWPContact = true; + + $userID = $contactCheck['wpUserEmail']->ID; + + // Otherwise + } else { + + // Create a new Wordpress user + $userID = wp_insert_user( + array( + 'user_email' => $contactInfo['fieldData']['email'], + 'user_login' => $contactInfo['fieldData']['username'], + 'user_pass' => trim($_REQUEST['password']), + 'first_name' => $contactInfo['fieldData']['fname'], + 'last_name' => $contactInfo['fieldData']['lname'], + 'role' => $wpRole + ) + ); + + } + + // Get the updated user information + $contactInfo = $this->editEntry($contactInfo['fieldData']['id']); + + // Save the contact ID + $contactID = $contactInfo['fieldData']['id']; + + $newContactCreated = true; + + // Store the contact ID and active status into user meta data + update_user_meta($userID, 'glmMembersContactID', $contactInfo['fieldData']['id']); + update_user_meta($userID, 'glmMembersContactActive', $contactInfo['fieldData']['active']['value']); + + // Check for new cities being submitted + $this->checkNewCities($contactID); + + break; + } + + // Need to retry so set option to create, use unencrypted password, and get ref_type again + $option = 'create'; + $contactInfo['fieldData']['password'] = $_REQUEST['password']; + $refType = $_REQUEST['ref_type']; + $refTypeName = $this->config['ref_type'][$refType]; + + // If addNew was unsuccessful, fall through to edit + + case 'edit': + + // Get contact ID to edit + if (isset($_REQUEST['contact']) && ($_REQUEST['contact'] -0) > 0) { + + // We have a contact ID, so try to edit + $contactID = $_REQUEST['contact'] - 0; + $contactInfo = $this->editEntry($contactID); + + // If the contact wasn't found, then set ID to false + if (!$contactInfo['status']) { + $contactID = false; + } + + $view = 'edit.html'; + } + + break; + + case 'submit': + + // Get current role set in the contacts record along with the matching WP role slug + $contactID = ($_REQUEST['contact']-0); + + // Check for new cities being submitted + $this->checkNewCities($contactID); + + $savedContactRole = $this->getWpRole($contactID); + + $contactInfo = $this->updateEntry($contactID); + + if ($contactInfo['status']) { + $contactInfo = $this->editEntry(($_REQUEST['id']-0)); + $contactUpdated = true; + + // Get the wordpress user ID + $wpUser = get_user_by('email', $contactInfo['fieldData']['email']); + + // Check for password changes and update Wordpress user + if (trim($_REQUEST['password']) != '') { + + // If we got a good user, set the new password + if ($wpUser) { + wp_set_password($_REQUEST['password'], $wpUser->ID); + } + + } + + // Determine the Worpress Role to be used + $roleNumb = $contactInfo['fieldData']['contact_role']['value']; + $wpRole = $this->config['contact_role_wordpress'][$roleNumb]; + + // If there's a role change, update the user role for WordPress + if ($wpRole != $savedContactRole['wpRole']) { + $contactCheck = $this->checkContact($contactInfo['fieldData']['email']); + $wpUser = new WP_User($contactCheck['wpUserEmail']->ID); + $wpUser->remove_role($savedContactRole['wpRole']); + $wpUser->add_role($wpRole); + } + + // Update contact active status in user meta data + update_user_meta($wpUser->ID, 'glmMembersContactActive', $contactInfo['fieldData']['active']['value']); + + } + + $option = 'edit'; + $view = 'edit.html'; + + break; + + case 'delete': + + + // Delete the current entry without further confirmation - pop-up should be confirmation enough. + $oldContactInfo = $this->deleteEntry(($_REQUEST['contact']-0), true); + $userDeleted = true; + + // Get the wordpress user ID + $wpUser = get_user_by('email', $oldContactInfo['email']); + + // Check for other roles assigned to this user and remove our roles + $userHasOtherRole = false; + foreach ($wpUser->roles as $r) { + + // Is this role not one of ours? + if (!in_array($r, $this->config['contact_role_wordpress'])) { + + // Apparently not, so we need to keep the Wordpress user + $userHasOtherRole = true; + + //Otherwise, this is one of our roles so we should remove it just in case the Wordpress user isn't deleted + } else { + + // Remove this role from our user + $wpUser->remove_role($r); + + } + + } + + // If the user doesn't have a role other than our members contact roles + if (!$userHasOtherRole) { + + // Delete the wordpress user + wp_delete_user($wpUser->ID); + $wpUserDeleted = true; + + // Otherwise we need to drop the user meta data we added to the WP user. + } else { + delete_user_meta($wpUser->ID, 'glmMembersContactID'); + delete_user_meta($wpUser->ID, 'glmMembersContactActive'); + } + + // Return to list by falling through here. + // break; + + default: + + // Make sure option is set to list + $option = 'list'; + + $where = true; + + // Only list member contacts for the selected member + if ($haveMember) { + $where .= " AND ref_type = ".$this->config['ref_type_numb']['Member'].' AND ref_dest = '.$memberID; + } + + + + // Filter by text string supplied + if (isset($_REQUEST['filterText'])) { + $filterText = esc_sql($_REQUEST['filterText']); + $where .= " AND ( + lname LIKE '%$filterText%' OR + fname LIKE '%$filterText%' OR + org LIKE '%$filterText%' OR + descr LIKE '%$filterText%' + )"; + $haveFilter = true; + } + + // Get the total number of contacts listed + + $numbContacts = $this->getStats($where); + + // If the number of events is less than a page, don't do paging + if ($numbContacts <= $limit) { + $paging = false; + } + + // Get full list of names matching this where clause for search box + $namesList = $this->getIdName($where); + + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + + // Get list of contacts + $contactsList = $this->getSimplified($where, false, 'lname, fname', true, 'id', $start, $limit ); + + if ($contactsList != false) { + + // Get paging results + $numbDisplayed = $contactsList['returned']; + $lastDisplayed = $contactsList['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } + } + if ($contactsList['returned'] == $limit) { + $nextStart = $start + $limit; + } + + if (count($contactsList['list']) > 0) { + $haveContacts = true; + } + + } + + + + + + + + + + + + + + + /* + + + // Filter by text string supplied + if (isset($_REQUEST['filterText'])) { + $filterText = esc_sql($_REQUEST['filterText']); + $where .= " AND ( + T.lname LIKE '%$filterText%' OR + T.fname LIKE '%$filterText%' OR + T.org LIKE '%$filterText%' OR + T.descr LIKE '%$filterText%' + )"; + $haveFilter = true; + } + + // Check if this is a request to show archived contacts + if (!isset($_REQUEST['filterArchived'])) { + $where .= " AND T.access != ".$this->config['access_numb']['Archived']; + $filterArchived = false; + } else { + $filterArchived = true; + $haveFilter = true; + } + + // Try to get list of contacts + $contacts = $this->getList($where); + + if ($contacts !== false) { + if (count($contacts) > 0) { + $haveContacts = true; + } + } +*/ + + + break; + } + + // If the option is "edit" don't let lower-level users assign privileges above the user's pay grade + if ($option == 'edit' && $this->config['loggedInUser']['contactUser']) { + + // If this is an Entity Manager or lower user, then remove the "MembersManger" role selection + if ($this->config['loggedInUser']['contactUser']['role'] >= $this->config['contact_role_numb']['EntityManager']) { + unset($contactInfo['fieldData']['contact_role']['list'][$this->config['contact_role_numb']['MembersManager']]); + } + + } + + // Compile template data + $templateData = array( + 'option' => $option, + 'loggedInMember' => $loggedInMember, + 'fromMemberMenu' => $fromMemberMenu, + 'haveMember' => $haveMember, + 'memberID' => $memberID, + 'memberData' => $memberData, + 'memberName' => $memberName, + 'refType' => $refType, + 'refTypeName' => $refTypeName, + 'haveContacts' => $haveContacts, + 'contactsList' => $contactsList['list'], + 'numbContacts' => $numbContacts, + 'contactID' => $contactID, + 'contactInfo' => $contactInfo, + 'newContactExists' => $newContactExists, + 'misMatchedWpUsers' => $misMatchedWpUsers, + 'usernameChangedToWP' => $usernameChangedToWP, + 'newContactCreated' => $newContactCreated, + 'usingExistingWPContact' => $usingExistingWPContact, + 'contactUpdated' => $contactUpdated, + 'filterArchived' => $filterArchived, + 'filterText' => $filterText, + 'haveFilter' => $haveFilter, + 'userDeleted' => $userDeleted, + 'wpUserDeleted' => $wpUserDeleted, + + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start = 1, + 'limit' => $limit, + 'namesList' => $namesList + + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/contacts/'.$view, + 'data' => $templateData + ); + + } + + /* + * Check for new Cities being submitted + * + * @return void + */ + public function checkNewCities($contactID) + { + + // If we have a contact ID and this was a submission with a new city (id < 0) + if ($contactID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') { + + // Clean up city name + $cName = trim(filter_var($_REQUEST['newCityName'])); + + // Try to add the city + require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); + $Cities = new GlmDataCities($this->wpdb, $this->config); + $cID = $Cities->addCity($cName); + + // If we got a city id back + if (is_int($cID) && $cID > 0) { + + // Update the city selected for this contact record + $sql = " + UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts + SET city = $cID + WHERE id = ".$contactID." + ;"; + $this->wpdb->query($sql); + + // Update submitted city value to use the new ID + $_REQUEST['city'] = $cID; + + } + } + } + +/* + public function modelAction($actionData = false) { + +// $filterArchived = false; + $loggedInMember = false; + $filterText = false; + $haveFilter = false; + $contactsList = false; + $haveContacts = false; + $numbContacts = false; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $namesList = false; // Only list member contacts for the selected member $where = "true"; + // If this is a logged in member user, then show their contacts only + if (isset($this->config['loggedInUser']['contactUser'])) { + $contactUser = $this->config['loggedInUser']['contactUser']; + if ($contactUser['ref_type'] = $this->config['ref_type_numb']['Member'] + && $contactUser['ref_dest'] ) { + $where .= " AND ref_type = ".$this->config['ref_type_numb']['Member']." + AND ref_dest = ".$contactUser['ref_dest']; + $loggedInMember = $contactUser['ref_dest']; + } + } + // Filter by text string supplied if (isset($_REQUEST['filterText'])) { $filterText = esc_sql($_REQUEST['filterText']); $where .= " AND ( - T.lname LIKE '%$filterText%' OR - T.fname LIKE '%$filterText%' OR - T.org LIKE '%$filterText%' OR - T.descr LIKE '%$filterText%' + lname LIKE '%$filterText%' OR + fname LIKE '%$filterText%' OR + org LIKE '%$filterText%' OR + descr LIKE '%$filterText%' )"; $haveFilter = true; } - // Check if this is a request to show archived contacts - if (!isset($_REQUEST['filterArchived'])) { - $where .= " AND T.access != ".$this->config['access_numb']['Archived']; - $filterArchived = false; - } else { - $filterArchived = true; - $haveFilter = true; + // Get the total number of contacts listed + $numbContacts = $this->getStats($where); + + // If the number of events is less than a page, don't do paging + if ($numbContacts <= $limit) { + $paging = false; + } + + // Get full list of names matching this where clause for search box + $namesList = $this->getIdName($where); + + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } } // Get list of contacts - $this->contacts = $this->getList($where); + $contactsList = $this->getSimplified($where, false, 'lname, fname', true, 'id', $start, $limit ); - if ($this->contacts !== false) { - if (count($this->contacts) > 0) { + if ($contactsList != false) { + + // Get paging results + $numbDisplayed = $contactsList['returned']; + $lastDisplayed = $contactsList['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } + } + if ($contactsList['returned'] == $limit) { + $nextStart = $start + $limit; + } + + if (count($contactsList['list']) > 0) { $haveContacts = true; } + } // Compile template data $templateData = array( 'haveContacts' => $haveContacts, - 'contacts' => $this->contacts, - 'filterArchived' => $filterArchived, + 'contacts' => $contactsList['list'], + 'numbContacts' => $numbContacts, 'filterText' => $filterText, - 'haveFilter' => $haveFilter + 'haveFilter' => $haveFilter, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start = 1, + 'limit' => $limit, + 'namesList' => $namesList ); // Return status, any suggested view, and any data to controller @@ -143,6 +786,8 @@ class GlmMembersAdmin_contacts_index extends GlmDataContacts ); } + +*/ } ?> \ No newline at end of file diff --git a/models/admin/management/contacts.php b/models/admin/management/contacts.php index c1a9b84..eda38b4 100644 --- a/models/admin/management/contacts.php +++ b/models/admin/management/contacts.php @@ -126,6 +126,24 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts switch ($option) { + + case 'clearContacts': + + // Check confirmation field + if (!isset($_REQUEST['clear_contacts_confirm']) || $_REQUEST['clear_contacts_confirm'] != 'Please Clear Contacts') { + $errorMsg = "You did not enter the required text in the confirmation field."; + break; + } + + // Delete current contact list if requested. + $del = $this->checkContactDelete(); + + if (!$del) { + $errorMsg = "There was a problem deleting the contacts. Please check your contacts list to make sure it has been cleared."; + } + + break; + case 'doDbImport': // Get database parameters @@ -162,6 +180,33 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts $this->checkContactDelete(); + // Check for CSV file submitted + if (!isset($_FILES['csv_file']['tmp_name']) || trim($_FILES['csv_file']['tmp_name']) == '') { + $errorMsg = 'CSV file upload not provided. Please select a CSV file by clicking the "Browse" button and try again.'; + break; + } + $csv = $_FILES['csv_file']['tmp_name']; + + $contacts = $this->readCsvContacts($csv); + + // if we got an array back, assume it's contacts + if (is_array($contacts)) { + + $importResult = $this->processCsvContacts($contacts); + + // Check status and error message + if ($importResult['status'] == false) { + $errorMsg = 'Unable to update/import provided contacts.'; + $option = "importSetup"; + break; + } + + // Otherwise we got a string error + } else { + $errorMsg = $contacts; + } + + break; case 'importSetup': @@ -179,7 +224,7 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts 'db_host' => $db_host, 'db_name' => $db_name, 'db_user' => $db_user, - 'db_password' => $db_password + 'db_password' => $db_password, ); // Return status, suggested view, and data to controller @@ -194,6 +239,68 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts } + + /** + * Read in contacts from a csv file + * + * Header line as follows. Data follows immediately below this line. this + * line and all above it are ignored. + * + * 'member_id','member_name','member_login','member_passwd','member_contact_email' + * + * @param string $csv Temporary file name of csv file upload + * + * @return array Array of data from CSV file or an error message + * + */ + public function readCsvContacts($csv) + { + + $contacts = array(); + $startImport = false; + + // Try to open file + if (($handle = fopen($csv, "r")) !== FALSE) { + + // For each line in the file + while (($c = fgetcsv($handle, 1000, ",")) !== FALSE) { + + // If we're past the header, the first item is numeric, and we have at least 5 fields + if($startImport && ($c[0]-0) > 0 && count($c) >= 5) { + + // Add this line of data to Contacts + $contacts[] = $c; + + } + + // If we find the header, assume all data is below that + if ($c[0] == 'member_id' && $c[1] == 'member_name') { + $startImport = true; + } + + } + + fclose($handle); + + } else { + return "No file submitted."; + } + + // If we never found the header + if (!$startImport) { + return "Required header not found in file."; + } + + // If we found no data below the header + if (count($contacts) == 0) { + return "Header found but no data followed"; + } + + return $contacts; + + } + + /** * connectPostgresDb * @@ -354,17 +461,11 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts * * @access public * @return array Results or false if no contacts to import - * array( - * 'errorMsg', - * 'exceptionTable', - * ) * */ public function importContacts() { - - // Initialize our return status/data array $ret = array( 'status' => false, @@ -486,7 +587,7 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts // If contact has an E-Mail address if (trim($c['member_contact_email']) != '') { - //Check if there's an existing WordPress user with this E-Mail address and a different username + // Check if there's an existing WordPress user with this E-Mail address and a different username $contactCheck = $this->checkContact($c['member_contact_email'], $c['member_login']); if ($contactCheck['wordpressEmail'] && $contactCheck['wordpressLogin'] && $contactCheck['wpUserEmail']->ID != $contactCheck['wpUserLogin']->ID) { @@ -557,9 +658,6 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts .", Name = ".$c['primary_contact_fname']." ".$c['primary_contact_lname'] ); - // Put WordPress user stuff here..... - - // Contact imported correctly, proceed with WordPress user } else { @@ -638,6 +736,345 @@ class GlmMembersAdmin_management_contacts extends GlmDataContacts } + /** + * processCsvContacts + * + * Process csv contact data and import or alter contact as appropriate + * + * @param array Array of contacts as produced by readCsvContacts() + * + * @return array Results or false if no contacts to import + * + */ + public function processCsvContacts($contacts) + { + + // Initialize our return status/data array + $ret = array( + 'status' => false, + 'errorMsg' => false, + 'numbContacts' => false, + 'numbContactsUpdated' => 0, + 'numbWpUserUpdated' => 0, + 'numbImported' => 0, + 'numbWpUsersCreated' => 0, + 'exceptionTable' => array() + ); + + // Make sure we have contacts + if (!is_array($contacts) || count($contacts) == 0) { + $ret['errorMsg'] = 'No contacts were supplied.'; + return $ret; + } + + // Instantiate member data class + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'; + $Members = new GlmDataMembers($this->wpdb, $this->config); + + $ret['numbContacts'] = count($contacts); + + // For each contact + foreach ($contacts as $c) { + + $okToProcess = false; + + // Get the contact data into standard parameters + $oldMemberID = ($c[0]-0); + $memberName = trim($c[1]); + $memberLogin = preg_replace('/[^a-zA-Z0-9_-]+/', '', trim($c[2])); + $memberPasswd = trim($c[3]); + $memberContactEmail = trim($c[4]); + + // Check if we had to fix up the username (memberLogin) + if ($memberLogin != $c[2]) { + + // Report that we're stripping illegal characters from the username + $ret['exceptionTable'][] = array( + 'exception' => 'Removed invalid characters from this contact\'s username:', + 'data' => $memberName + .", Old member id = ".$oldMemberID + .", Username = ".$memberLogin." - was ".$c[2] + ); + + } + + // Make sure we have a member matching the member_id + $membData = $Members->getEntry(false, 'id', 'T.old_member_id = '.$oldMemberID); + if (!$membData) { + + // Report that we didn't find the matching member + $ret['exceptionTable'][] = array( + 'exception' => 'No member matching this old member ID:', + 'data' => $c['member_id'] + .", Old member id = ".$c['member_id'] + .", Username = ".$memberLogin." - was ".$c['member_login'] + ); + + $okToProcess = false; + + } else { + + // If we have and existing contact matching this user name (only 1) - Consider doing updates + $contactData = $this->getSimplified("T.username = '".addslashes($memberLogin)."'"); + if ($contactData && count($contactData) ==1 ) { + + $contactData = current($contactData); + + // Check for changes to this contact + if ($memberContactEmail != $contactData['email'] || $memberPasswd != '') { + + // Check if there's an existing WordPress user with this username + $contactCheck = $this->checkContact($memberContactEmail, $memberLogin); + if ($contactCheck['wordpressLogin'] && $contactCheck['wpUserLogin']->ID) { + + $wpUserID = $contactCheck['wpUserLogin']->ID; + + // get the contact ID for the WordPress user and make sure it matches the member with the correct old ID + $contactID = get_user_meta($wpUserID, 'glmMembersContactID', true); + + // Check that the E-mail address isn't in use by another WordPress user + if ($contactCheck['wordpressEmail'] && + $contactCheck['wpUserEmail']->ID != $contactCheck['wpUserLogin']->ID) { + + // The E-Mail address is in use by another user so we can't set that for this contact + $ret['exceptionTable'][] = array( + 'exception' => "Another WordPress user exists with the requested E-Mail address (no dupes allowed): ", + 'data' => $memberName + .", Username = ".$memberLogin + .", Old member id = ".$oldMemberID + .", E-mail address = ".$memberContactEmail + ); + + // Also make sure the WordPress user matches the contact record + } elseif ($contactID != $contactData['id']) { + + // The WordPress user meta data says this user is for a different contact + $ret['exceptionTable'][] = array( + 'exception' => "The WordPress user data says it is associated with a different contact - Not using this data: ", + 'data' => $memberName + .", Username = ".$memberLogin + .", Old member id = ".$oldMemberID + .", E-mail address = ".$memberContactEmail + ); + + // So now we should be OK to update the E-Mail address for this contact and WordPress user + } else { + + // Update the contact Email data + $rows = $this->wpdb->update( + GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', + array('email' => $memberContactEmail), + array( 'id' => $contactData['id']), + array('%s'), + array( '%d' ) + ); + + // Check for failure + if ($rows != 1) { + + // Report that we couldn't update the E-Mail address + $ret['exceptionTable'][] = array( + 'exception' => 'Problem updating E-mail address for this contact:', + 'data' => $memberName + .", Old member id = ".$oldMemberID + .", Username = ".$memberLogin + .", E-Mail address = ".$memberContactEmail + ."
Error Message: ".$rows->get_error_message() + ); + + // If we're still OK, try to update the WordPress user E-Mail address + } else { + + $ret['numbContactsUpdated']++; + + // Build data for updating WordPress user + $updateData = array( + 'ID' => $wpUserID, + 'user_email' => $memberContactEmail + ); + + // if a password is supplied, update that also + $updatePass = ''; + if ($memberPasswd != '') { + $updateData['user_pass'] = $memberPasswd; + $updatePass = ' and password'; + } + + // Try to update the WordPress user - If all is fine, this should return the WordPress user ID, otherwise an error object + $updateStatus = wp_update_user($updateData); + if ($updateStatus != $wpUserID) { + + // Report that we had a problem updating the wordpress user + $ret['exceptionTable'][] = array( + 'exception' => 'Problem updating the E-mail address'.$updatePass.' of the matching WordPress user:', + 'data' => $memberName + .", Old member id = ".$oldMemberID + .", Username = ".$memberLogin + .", E-Mail address = ".$memberContactEmail + ."
Error Message: ".$updateStatus->get_error_message() + ); + + } else { + $ret['numbWpUserUpdated']++; + } + + } // OK to update WordPress user + + } // OK to update contact + + } // Existing WordPress user + + } // Changing existing contact + + // Otherwise we don't have an existing contact, so try to create one + } else { + + // Check if there's an existing WordPress user with this username + $contactCheck = $this->checkContact($memberContactEmail, $memberLogin); + if ($contactCheck['wordpressLogin'] && $contactCheck['wpUserLogin']->ID) { + + $ret['exceptionTable'][] = array( + 'exception' => "A WordPress user already exists with this username - Can't create this contact: ", + 'data' => $memberName + .", Username = ".$memberLogin + .", Old member id = ".$oldMemberID + .", E-mail address = ".$memberContactEmail + ); + + // Otherwise check if another user has this E-Mail address + } elseif ($contactCheck['wordpressEmail'] && + $contactCheck['wpUserEmail']->ID != $contactCheck['wpUserLogin']->ID) { + + // The E-Mail address is in use by another user so we can't set that for this contact + $ret['exceptionTable'][] = array( + 'exception' => "Another WordPress user exists with the requested E-Mail address, not creating this contact: ", + 'data' => $memberName + .", Username = ".$memberLogin + .", Old member id = ".$oldMemberID + .", E-mail address = ".$memberContactEmail + ); + + // Otherwise try to create the contact and WordPress user + } else { + + // We don't have a proper contact name, so do this + $contactFname = $memberName; + $contactLname = '(contact name not provided)'; + + // Determine contact type for import + $contactType = $this->config['contact_type_numb']['Personal']; + + // Determine the Worpress Role to be used for contact import - Using Entity Manager right now + $contactRoleNumb = $this->config['contact_role_numb']['EntityManager']; + $wpRole = $this->config['contact_role_wordpress'][$contactRoleNumb]; + + // Try to create new contact + $this->wpdb->insert( + GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . 'contacts', + array( + 'active' => true, + 'access' => $this->config['access_numb']['NotDisplayedModerated'], + 'fname' => $contactFname, + 'lname' => $contactLname, + 'contact_type' => $contactType, + 'contact_role' => $contactRoleNumb, + 'email' => $memberContactEmail, + 'username' => $memberLogin, + 'notes' => 'Imported from old Web site.', + 'create_time' => date('Y-m-d H:i:s', time()), + 'ref_type' => $this->config['ref_type_numb']['Member'], + 'ref_dest' => $oldMemberID + ), + array( + '%d', + '%d', + '%s', + '%s', + '%d', + '%d', + '%s', + '%s', + '%s', + '%s', + '%d', + '%d' + ) + ); + $newContactID = $this->wpdb->insert_id; + + // If this contact didn't import correctly + if (!$newContactID) { + $ret['exceptionTable'][] = array( + 'exception' => 'Unable to create this contact: ', + 'data' => $c['member_name'] + .", Old member id = ".$oldMemberID + .", E-mail address = ".$memberLogin + .", Username = ".$memberLogin + .", Name = $contactFname $contactLname" + ); + + // Contact imported correctly, proceed with WordPress user + } else { + + if (trim($memberPasswd) == '') { + $memberPasswd = wp_generate_password( $length=12, $include_standard_special_chars=false ); + } + + // Try to create the WordPress user + $wpUserID = wp_insert_user( + array( + 'user_email' => $memberContactEmail, + 'user_login' => $memberLogin, + 'user_pass' => $memberPasswd, + 'first_name' => $contactFname, + 'last_name' => $contactlname, + 'role' => $wpRole + ) + ); + + // If the result is an integer that's positive, the user was created + if (is_int($wpUserID) && $wpUserID > 0) { + + // Store the contact ID and active status into user meta data + update_user_meta($wpUserID, 'glmMembersContactID', $newContactID); + update_user_meta($wpUserID, 'glmMembersContactActive', true); + + $ret['numbWpUsersCreated']++; + + // Else, add a an entry to the exception table for why + } else { + + $ret['exceptionTable'][] = array( + 'exception' => 'Unable to add a WordPress user for this contact: ', + 'data' => $c['member_name'] + .", Old member id = ".$c['member_id'] + .", Member Name = ".$c['member_name'] + .", Name = ".$c['primary_contact_fname']." ".$c['primary_contact_lname'] + .", Username = ".$userLogin + ."
Error Message: ".$wpUserID->get_error_message() + ); + + } + + } + + $ret['numbImported']++; + + } // else try to create contact and wp user + + } // else add contact + + } // else we have a good member ID + + } // for each contact + + $ret['status'] = true; + + return $ret; + + } + + } ?> diff --git a/models/admin/member/contacts.php b/models/admin/member/contacts.php index f43475b..bfb67e8 100644 --- a/models/admin/member/contacts.php +++ b/models/admin/member/contacts.php @@ -13,10 +13,13 @@ * @link http://dev.gaslightmedia.com/ */ -// Load Contacts data abstract -require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); +// Inform the contacts code that we're working from the member area +define('GLM_CONTACTS_MEMBER_MENU', true); -class GlmMembersAdmin_member_contacts extends GlmDataContacts +// Load the events index +require GLM_MEMBERS_CONTACTS_PLUGIN_PATH."/models/admin/contacts/index.php"; + +class GlmMembersAdmin_member_contacts extends GlmMembersAdmin_contacts_index { /** @@ -98,436 +101,8 @@ class GlmMembersAdmin_member_contacts extends GlmDataContacts $this->config = $config; // Run constructor for members data class - parent::__construct(false, false); - - } - - public function modelAction($actionData = false) - { - - $option = false; - $refType = false; - $refTypeName = false; - $haveMember = false; - $memberData = false; - $memberName = false; - $haveContacts = false; - $newContactExists = false; - $misMatchedWpUsers = false; - $newContactCreated = false; - $usingExistingWPContact = false; - $usernameChangedToWP = false; - $contactUpdated = false; - $filterArchived = false; - $filterText = false; - $haveFilter = false; - $userDeleted = false; - $wpUserDeleted = false; - - $validOptions = array( - 'create', - 'addNew', - 'edit', - 'submit', - 'delete', - 'list' - ); - - if (isset($_REQUEST['member'])) { - $this->memberID = $_REQUEST['member']-0; - } - - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'); - $Members = new GlmDataMembers($this->wpdb, $this->config); - $memberData = $Members->getEntry($this->memberID); - - // Check that we have good member data - if (is_array($memberData) && isset($memberData['id']) && $memberData['id'] > 0) { - - // Also store the member id in a WordPress Option in case user clicks "Member" sub-menu - update_option('glmMembersDatabaseMemberID', $this->memberID); - - $haveMember = true; - $memberName = $memberData['name']; - - // If we're adding a new member contact - if (isset($_REQUEST['option']) && in_array($_REQUEST['option'], $validOptions)) { - $option = $_REQUEST['option']; - } - - // Perform selected page option - switch($option) { - - case 'create': - - // Set reference type to Member - $refType = $this->config['ref_type_numb']['Member']; - $refTypeName = $this->config['ref_type'][$refType]; - - $this->contactInfo = $this->newEntry(); - - require_once(GLM_MEMBERS_CONTACTS_PLUGIN_LIB_PATH.'/EasyPassword/EasyPassword.php'); - $EasyPassword = new EasyPassword(); - $this->contactInfo['fieldData']['password'] = $EasyPassword->generateEasyPassword('firstlast'); - break; - - case 'addNew': - - // Clean up username to be compatible with WordPress - if (isset($_REQUEST['username'])) { - $_REQUEST['username'] = preg_replace('/[^a-zA-Z0-9_-]+/', '', $_REQUEST['username']); - } - - // Check for existing contact in Wordpress and Contacts - $contactCheck = $this->checkContact($_REQUEST['email'], $_REQUEST['username']); - - // If there's already a contact with this E-Mail address, don't create the contact - if ($contactCheck['contactsEmail'] || $contactCheck['contactsUsername']) { - $newContactExists = true; - break; - } - - // If there is already a WordPress user with the requested Email address and a different user with the requeted Username - if ($contactCheck['wordpressEmail'] && $contactCheck['wordpressLogin'] - && $contactCheck['wpUserEmail']->ID != $contactCheck['wpUserLogin']->ID) { - $misMatchedWpUsers = true; - break; - } - - // Try to insert the new contact - $this->contactInfo = $this->insertEntry(); - - // If that was successful - if ($this->contactInfo['status']) { - - // If there's an existing WordPress user matching the E-Mail address but that has a different username - if ($contactCheck['wordpressEmail'] - && $contactCheck['wpUserEmail']->data->user_login != $this->contactInfo['fieldData']['username']) { - - // Change the contact username to match the Wordpress username - $this->wpdb->query(" - UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts - SET username = '".$contactCheck['wpUserEmail']->data->user_login."' - WHERE id = ".$this->contactInfo['fieldData']['id']."; - "); - $usernameChangedToWP = true; - - } - - // Determine the Worpress Role to be used - $roleNumb = $this->contactInfo['fieldData']['contact_role']['value']; - $wpRole = $this->config['contact_role_wordpress'][$roleNumb]; - - // If there's an existing WordPress user we're going to use - if ($contactCheck['wordpressEmail']) { - - // Add appropriate user role - $wpUser = new WP_User($contactCheck['wpUserEmail']->ID); - - /* - * If the current wp user is not an administrator, add their contact role - * - * Note that adding the contact role to an administrator limits the - * administrators capabilities. In otherwords, with multiple roles in - * WordPress it looks like all of the user's roles need to have a - * capability for it to be considered as set. Because of this we can't - * add the contact role or the administrator will be crippled. - */ - // - if (!in_array('administrator', $contactCheck['wpUserEmail']->roles)) { - $wpUser->add_role($wpRole); - } else { - - } - - $usingExistingWPContact = true; - - $userID = $contactCheck['wpUserEmail']->ID; - - // Otherwise - } else { - - // Create a new Wordpress user - $userID = wp_insert_user( - array( - 'user_email' => $this->contactInfo['fieldData']['email'], - 'user_login' => $this->contactInfo['fieldData']['username'], - 'user_pass' => trim($_REQUEST['password']), - 'first_name' => $this->contactInfo['fieldData']['fname'], - 'last_name' => $this->contactInfo['fieldData']['lname'], - 'role' => $wpRole - ) - ); - - } - - // Get the updated user information - $this->contactInfo = $this->editEntry($this->contactInfo['fieldData']['id']); - - // Save the contact ID - $this->contactID = $this->contactInfo['fieldData']['id']; - - $newContactCreated = true; - - // Store the contact ID and active status into user meta data - update_user_meta($userID, 'glmMembersContactID', $this->contactInfo['fieldData']['id']); - update_user_meta($userID, 'glmMembersContactActive', $this->contactInfo['fieldData']['active']['value']); - - // Check for new cities being submitted - $this->checkNewCities(); - - break; - } - - // Need to retry so set option to create, use unencrypted password, and get ref_type again - $option = 'create'; - $this->contactInfo['fieldData']['password'] = $_REQUEST['password']; - $refType = $_REQUEST['ref_type']; - $refTypeName = $this->config['ref_type'][$refType]; - - // If addNew was unsuccessful, fall through to edit - - case 'edit': - - // Get contact ID to edit - if (isset($_REQUEST['contact']) && ($_REQUEST['contact'] -0) > 0) { - - // We have a contact ID, so try to edit - $this->contactID = $_REQUEST['contact'] - 0; - $this->contactInfo = $this->editEntry($this->contactID); - - // If the contact wasn't found, then set ID to false - if (!$this->contactInfo['status']) { - $this->contactID = false; - } - - } - - break; - - case 'submit': - - // Get current role set in the contacts record along with the matching WP role slug - $this->contactID = ($_REQUEST['contact']-0); - - // Check for new cities being submitted - $this->checkNewCities(); - - $savedContactRole = $this->getWpRole($this->contactID); - - $this->contactInfo = $this->updateEntry($this->contactID); - - if ($this->contactInfo['status']) { - $this->contactInfo = $this->editEntry(($_REQUEST['id']-0)); - $contactUpdated = true; - - // Get the wordpress user ID - $wpUser = get_user_by('email', $this->contactInfo['fieldData']['email']); - - // Check for password changes and update Wordpress user - if (trim($_REQUEST['password']) != '') { - - // If we got a good user, set the new password - if ($wpUser) { - wp_set_password($_REQUEST['password'], $wpUser->ID); - } - - } - - // Determine the Worpress Role to be used - $roleNumb = $this->contactInfo['fieldData']['contact_role']['value']; - $wpRole = $this->config['contact_role_wordpress'][$roleNumb]; - - // If there's a role change, update the user role for WordPress - if ($wpRole != $savedContactRole['wpRole']) { - $contactCheck = $this->checkContact($this->contactInfo['fieldData']['email']); - $wpUser = new WP_User($contactCheck['wpUserEmail']->ID); - $wpUser->remove_role($savedContactRole['wpRole']); - $wpUser->add_role($wpRole); - } - - // Update contact active status in user meta data - update_user_meta($wpUser->ID, 'glmMembersContactActive', $this->contactInfo['fieldData']['active']['value']); - - } - - $option = 'edit'; - - break; - - case 'delete': - - - // Delete the current entry without further confirmation - pop-up should be confirmation enough. - $oldContactInfo = $this->deleteEntry(($_REQUEST['contact']-0), true); - $userDeleted = true; - - // Get the wordpress user ID - $wpUser = get_user_by('email', $oldContactInfo['email']); - - // Check for other roles assigned to this user and remove our roles - $userHasOtherRole = false; - foreach ($wpUser->roles as $r) { - - // Is this role not one of ours? - if (!in_array($r, $this->config['contact_role_wordpress'])) { - - // Apparently not, so we need to keep the Wordpress user - $userHasOtherRole = true; - - //Otherwise, this is one of our roles so we should remove it just in case the Wordpress user isn't deleted - } else { - - // Remove this role from our user - $wpUser->remove_role($r); - - } - - } - - // If the user doesn't have a role other than our members contact roles - if (!$userHasOtherRole) { - - // Delete the wordpress user - wp_delete_user($wpUser->ID); - $wpUserDeleted = true; - - // Otherwise we need to drop the user meta data we added to the WP user. - } else { - delete_user_meta($wpUser->ID, 'glmMembersContactID'); - delete_user_meta($wpUser->ID, 'glmMembersContactActive'); - } - - // Return to list by falling through here. - // break; - - default: - - // Make sure option is set to list - $option = 'list'; - - // Only list member contacts for the selected member - $where = "T.ref_type = ".$this->config['ref_type_numb']['Member'].' AND T.ref_dest = '.$this->memberID; - - // Filter by text string supplied - if (isset($_REQUEST['filterText'])) { - $filterText = esc_sql($_REQUEST['filterText']); - $where .= " AND ( - T.lname LIKE '%$filterText%' OR - T.fname LIKE '%$filterText%' OR - T.org LIKE '%$filterText%' OR - T.descr LIKE '%$filterText%' - )"; - $haveFilter = true; - } - - // Check if this is a request to show archived contacts - if (!isset($_REQUEST['filterArchived'])) { - $where .= " AND T.access != ".$this->config['access_numb']['Archived']; - $filterArchived = false; - } else { - $filterArchived = true; - $haveFilter = true; - } - - // Try to get list of contacts - $this->contacts = $this->getList($where); - if ($this->contacts !== false) { - if (count($this->contacts) > 0) { - $haveContacts = true; - } - } - break; - } - - // If the option is "edit" don't let lower-level users assign privileges above the user's pay grade - if ($option == 'edit' && $this->config['loggedInUser']['contactUser']) { - - // If this is an Entity Manager or lower user, then remove the "MembersManger" role selection - if ($this->config['loggedInUser']['contactUser']['role'] >= $this->config['contact_role_numb']['EntityManager']) { - unset($this->contactInfo['fieldData']['contact_role']['list'][$this->config['contact_role_numb']['MembersManager']]); - } - - } - - // Also save the mmeber ID in a WordPress "option" in case someone clicks the "Member" sub-menu - update_option('glmMembersDatabaseMemberID', $this->memberID); - - - } // if haveMember - - - // Compile template data - $templateData = array( - 'option' => $option, - 'haveMember' => $haveMember, - 'memberID' => $this->memberID, - 'memberData' => $memberData, - 'memberName' => $memberName, - 'refType' => $refType, - 'refTypeName' => $refTypeName, - 'haveContacts' => $haveContacts, - 'contacts' => $this->contacts, - 'contactID' => $this->contactID, - 'contactInfo' => $this->contactInfo, - 'newContactExists' => $newContactExists, - 'misMatchedWpUsers' => $misMatchedWpUsers, - 'usernameChangedToWP' => $usernameChangedToWP, - 'newContactCreated' => $newContactCreated, - 'usingExistingWPContact' => $usingExistingWPContact, - 'contactUpdated' => $contactUpdated, - 'filterArchived' => $filterArchived, - 'filterText' => $filterText, - 'haveFilter' => $haveFilter, - 'userDeleted' => $userDeleted, - 'wpUserDeleted' => $wpUserDeleted - ); - - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'admin/member/contacts.html', - 'data' => $templateData - ); - - } - - /* - * Check for new Cities being submitted - * - * @return void - */ - public function checkNewCities() - { - - // If we have a contact ID and this was a submission with a new city (id < 0) - if ($this->contactID && isset($_REQUEST['city']) && $_REQUEST['city'] == -1 && isset($_REQUEST['newCityName']) && trim($_REQUEST['newCityName']) != '') { - - // Clean up city name - $cName = trim(filter_var($_REQUEST['newCityName'])); - - // Try to add the city - require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php'); - $Cities = new GlmDataCities($this->wpdb, $this->config); - $cID = $Cities->addCity($cName); - - // If we got a city id back - if (is_int($cID) && $cID > 0) { - - // Update the city selected for this contact record - $sql = " - UPDATE ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX."contacts - SET city = $cID - WHERE id = ".$this->contactID." - ;"; - $this->wpdb->query($sql); - - // Update submitted city value to use the new ID - $_REQUEST['city'] = $cID; + parent::__construct($wpdb, $config); - } - } } } diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 83d0a5f..2e79104 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -31,24 +31,23 @@ */ add_submenu_page( - 'glm-members-admin-menu-members', // Parent slug - 'Contacts', // Page title - 'Contacts', // Menu Title - 'glm_members_members', // Capability required - 'glm-members-admin-menu-contacts-index', // Menu slug + $mainMenuSlug, + 'Contacts', + 'Contacts', + 'glm_members_edit_my_entity', + 'glm-members-admin-menu-contacts', function() {$this->controller('contacts');} ); // If a contact is logged in (ownEntity isn't false), add Contact Profile menu item +// they see the "My Contact" if ($this->config['loggedInUser']['contactUser']) { add_submenu_page( $mainMenuSlug, - 'User Profile', - 'User Profile', + 'My Contact Info', + '  My Contact Info', 'glm_members_edit_my_contact_info', 'glm-members-admin-menu-profile', function() {$this->controller('profile');} ); } - -?> diff --git a/setup/adminTabs.php b/setup/adminTabs.php index bd12f1c..18e6d41 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -50,40 +50,43 @@ add_filter('glm-member-db-add-tab-for-members', ); */ -// Admin Member Contacts Tab -if (apply_filters('glm_members_permit_admin_member_contacts_tab', true)) { - add_filter('glm-member-db-add-tab-for-member', - function($addOnTabs) { - $newTabs = array( - array( +// If user can manage all members +if (current_user_can('glm_members_members')) { + + // Admin Member Contacts Tab + if (apply_filters('glm_members_permit_admin_member_contacts_tab', true)) { + add_filter('glm-member-db-add-tab-for-member', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Contacts', + 'menu' => 'member', + 'action' => 'contacts' + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); + } + + // Admin Management Contacts Tab + if (apply_filters('glm_members_permit_admin_members_contacts_tab', true)) { + add_filter('glm-member-db-add-tab-for-management', + function($addOnTabs) { + $newTabs = array( + array( 'text' => 'Contacts', - 'menu' => 'member', + 'menu' => 'management', 'action' => 'contacts' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } - ); -} + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); + } -// Admin Management Contacts Tab -if (apply_filters('glm_members_permit_admin_members_contacts_tab', true)) { - add_filter('glm-member-db-add-tab-for-management', - function($addOnTabs) { - $newTabs = array( - array( - 'text' => 'Contacts', - 'menu' => 'management', - 'action' => 'contacts' - ) - ); - $addOnTabs = array_merge($addOnTabs, $newTabs); - return $addOnTabs; - } - ); } - - ?> \ No newline at end of file diff --git a/setup/permissions.php b/setup/permissions.php index 4259939..aa812a3 100644 --- a/setup/permissions.php +++ b/setup/permissions.php @@ -24,7 +24,6 @@ add_filter('glm_members_current_logged_in_user', global $wpdb, $config; - // Add default of no current contact user $loggedInUser['contactUser'] = false; @@ -41,7 +40,7 @@ add_filter('glm_members_current_logged_in_user', } // Try to get the matching contact data -// $contactInfo = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE id = $contactID;"); + $contactInfo = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE id = $contactID;"); require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'); $ContactInfo = new GlmDataContacts($wpdb, $config); @@ -250,6 +249,42 @@ add_filter('glm_members_permit_admin_profile_index_edit_profile', } ); +// Access admin Members menu +add_filter('glm_members_menu_members', + function($permit) { + if (!$permit) { return false; } + return current_user_can('glm_members_members'); + } +); +// Access admin Member menu +add_filter('glm_members_menu_member', + function($permit) { + if (!$permit) { return false; } + return current_user_can('glm_members_member'); + } +); + +// Access admin Settings menu +add_filter('glm_members_menu_settings', + function($permit) { + if (!$permit) { return false; } + return current_user_can('glm_members_settings'); + } +); +// Access admin Management menu +add_filter('glm_members_menu_management', + function($permit) { + if (!$permit) { return false; } + return current_user_can('glm_members_management'); + } +); +// Access admin Shortcodes menu +add_filter('glm_members_menu_shortcodes', + function($permit) { + if (!$permit) { return false; } + return current_user_can('glm_members_shortcodes'); + } +); diff --git a/setup/rolesAndCapabilities.php b/setup/rolesAndCapabilities.php index 25c6c62..a57a8b1 100644 --- a/setup/rolesAndCapabilities.php +++ b/setup/rolesAndCapabilities.php @@ -23,15 +23,6 @@ * Some maintenance items first */ -// *** TEMPORARY TO REMOVE OLD ROLSES -/* -remove_role('glm_own_member_manager'); -remove_role('glm_own_entity_manager'); -remove_role('glm_member_contact'); -remove_role('glm_member_restricted_contact'); -remove_role('glm_members_own_member_manager'); -*/ - /* // Un-comment to fully reset all contact roles remove_role('glm_members_manager'); diff --git a/views/admin/contacts/edit.html b/views/admin/contacts/edit.html new file mode 100644 index 0000000..545ee45 --- /dev/null +++ b/views/admin/contacts/edit.html @@ -0,0 +1,628 @@ + +{if $fromMemberMenu} + {include file='admin/member/header.html'} +{else} + {include file='admin/contacts/header.html'} +{/if} + +{if $userDeleted} +

Contact Deleted:

+ +{/if} + + +{if $option == 'edit' && !$contactID} + +

ERROR: Specified contact not found!

+ + {elseif $newContactExists} + +

NOTE: The Email address or username for this contact is already in use. Please check if they already are a contact in this system.

+ + {elseif $misMatchedWpUsers} + +

+ NOTE: + The Email address for this contact is already in use by an existing system user but the username is in use by a different + system user. As such we are unable to match this request to a specific existing system user. We suggest you determine what + the "Username" is for the existing Wordpress user with the Email address you requested. Please call for assistance if needed. +

+ + {elseif $newContactCreated} + +

New Contact Created: {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}

+ {if $usernameChangedToWP || $usingExistingWPContact} +

NOTE:

+ + {/if} + + {else} + + + {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)} + + {if $option == 'create' || $option == 'edit'} + + {if $fromMemberMenu} + Return to Contact List + {else} + Return to Contact List + {/if} + + {if $option == 'create'} +

Add New Contact

+ {else} + {if $contactUpdated}

Contact Updated

{/if} + Delete this Contact +
+
+

Cancel

+

+
+
+

WARNING:

+

+ Clicking the "Delete this Contact" button above will + delete all of the data and images associated with this contact. + +

+

+ Once deleted, this information will no longer be available and cannot be retrieved! +

+
+

+ This contact may instead be "Archived" rather than deleted using the "Contact Display:" pick-list. When archived, the contact is not displayed on the front-end + of the Web site, any login assoicated with this contact is deactivated, and the contact will not show on contact lists unless "Archived" is selected. + Unlike delete, an archived contact may be changed back to normal use. +

+
+

Edit Contact

+ {/if} + + + {if $fromMemberMenu} +
+ + {else} + + + {/if} + + {if $option == 'create'} + + + + + {else} + + + + + {/if} + + + + + + + + + + + {if $option != 'create'} + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + {if $option == 'create'} + + + {else} + + + {/if} + + + + {if $option == 'create'} + + + {else} + + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact For:{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}
Active: + +
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name: + + {if $contactInfo.fieldFail.fname}

{$contactInfo.fieldFail.fname}

{/if} +
Last Name: + + {if $contactInfo.fieldFail.lname}

{$contactInfo.fieldFail.lname}

{/if} +
Contact Type: + + {if $contactInfo.fieldFail.contact_type}

{$contactInfo.fieldFail.contact_type}

{/if} +
Permissions: + + {if $contactInfo.fieldFail.contact_role}

{$contactInfo.fieldFail.contact_role}

{/if} +
Display/Moderate/Archive: + + {if $contactInfo.fieldFail.access}

{$contactInfo.fieldFail.access}

{/if} +
Email Address: + +
NOTE: This field is required for users who will have login privileges. + {if $contactInfo.fieldFail.email}

{$contactInfo.fieldFail.email}

{/if} +
Email Address::{$contactInfo.fieldData.email}
Login Username: + +
NOTE: The username cannot be changed once the contact is created. + {if $contactInfo.fieldFail.username}

{$contactInfo.fieldFail.username}

{/if} +
Login Username:{$contactInfo.fieldData.username}
Login password: + + {if $option == 'create'} + Save this password. +
A randomly generated password has been supplied. You may change this as desired. + There is no way to view a password once it's set. However, a user may recover a password using their + Email address at the login page. + {else} +
NOTE: Enter a password here only if you need to change it. + {/if} +
The password must be at least 8 characters and include at least one number, one letter, and at least one + special character. (# . - _ , $ % & !) + {if $contactInfo.fieldFail.password}

{$contactInfo.fieldFail.password}

{/if} +
Alternate Email Address: + + {if $contactInfo.fieldFail.alt_email}

{$contactInfo.fieldFail.alt_email}

{/if} +
Organization: + + {if $contactInfo.fieldFail.org}

{$contactInfo.fieldFail.org}

{/if} +
Title/Position: + + {if $contactInfo.fieldFail.title}

{$contactInfo.fieldFail.title}

{/if} +
Position/Responsibilities: + {php} + wp_editor('{$contactInfo.fieldData.descr}', 'glm_descr', array( + 'quicktags' => false, + 'media_buttons' => false, + 'wpautop' => false, + 'textarea_name' => 'descr', + 'editor_height' => 100, // Height in px, overrides editor_rows + // 'textarea_rows' => 4, + )); + {/php} + {if $contactInfo.fieldFail.descr}

{$contactInfo.fieldFail.descr}

{/if} +
Image: + {if $contactInfo.fieldData.image} +
+ + Close
+
+ + + + + + +
+ Delete Image
+ {$contactInfo.fieldData.image}
+

Show Large Image

+
+ {/if} + + {if $contactInfo.fieldFail.image}

{$contactInfo.fieldFail.image}

{/if} +
Address Line 1: + + {if $contactInfo.fieldFail.addr1}

{$contactInfo.fieldFail.addr1}

{/if} +
Address Line 2: + + {if $contactInfo.fieldFail.addr2}

{$contactInfo.fieldFail.addr2}

{/if} +
City + +
Add a new City
+
+ + + + + +
City Name: + +
+
+

* Required

+ Cancel + +
+ + + +
State: + + {if $contactInfo.fieldFail.state}

{$contactInfo.fieldFail.state}

{/if} +
ZIP / Postal Code: + + {if $contactInfo.fieldFail.zip}

{$contactInfo.fieldFail.zip}

{/if} +
Country: + + {if $contactInfo.fieldFail.country}

{$contactInfo.fieldFail.country}

{/if} +
Web Address (URL): + {if $contactInfo.fieldData.url} + Test Link + {/if} + http:// + {if $contactInfo.fieldFail.url}

{$contactInfo.fieldFail.url}

{/if} +
Office Phone #: + + {if $contactInfo.fieldFail.office_phone}

{$contactInfo.fieldFail.office_phone}

{/if} +
Home Phone #: + + {if $contactInfo.fieldFail.home_phone}

{$contactInfo.fieldFail.home_phone}

{/if} +
Mobile Phone #: + + {if $contactInfo.fieldFail.mobile_phone}

{$contactInfo.fieldFail.mobile_phone}

{/if} +
Alternate Phone #: + + {if $contactInfo.fieldFail.alt_phone}

{$contactInfo.fieldFail.alt_phone}

{/if} +
FAX #: + + {if $contactInfo.fieldFail.fax}

{$contactInfo.fieldFail.fax}

{/if} +
Notes: + {php} + wp_editor('{$contactInfo.fieldData.notes}', 'glm_notes', array( + 'quicktags' => false, + 'media_buttons' => false, + 'wpautop' => false, + 'textarea_name' => 'notes', + 'editor_height' => 100, // Height in px, overrides editor_rows + // 'textarea_rows' => 4, + )); + {/php} + {if $contactInfo.fieldFail.notes}

{$contactInfo.fieldFail.notes}

{/if} +
+

* Required

+ +
+ + {/if} + + {else} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact For:{$contactInfo.fieldData.ref_type.name} - {$memberData.name}
Active:{$contactInfo.fieldData.active.name}
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name:{$contactInfo.fieldData.fname}
Last Name:{$contactInfo.fieldData.lname}
Contact Type:{$contactInfo.fieldData.contact_type.name}
Email Address::{$contactInfo.fieldData.email}
Alternate Email Address:{$contactInfo.fieldData.alt_email}
Organization:{$contactInfo.fieldData.org}
Title/Position:{$contactInfo.fieldData.title}
Position/Responsibilities:{$contactInfo.fieldData.descr}
Image: + {if $contactInfo.fieldData.image} + + {/if} +
Address Line 1:{$contactInfo.fieldData.addr1}
Address Line 2:{$contactInfo.fieldData.addr2}
City{$contactInfo.fieldData.city.name}
State:{$contactInfo.fieldData.state.name}
ZIP / Postal Code:{$contactInfo.fieldData.zip}
Country:{$contactInfo.fieldData.country.name}
Web Address (URL): + {if $contactInfo.fieldData.url} + {$contactInfo.fieldData.url} + {/if} +
Office Phone #:{$contactInfo.fieldData.office_phone}
Home Phone #:{$contactInfo.fieldData.home_phone}
Mobile Phone #:{$contactInfo.fieldData.mobile_phone}
Alternate Phone #:{$contactInfo.fieldData.alt_phone}
FAX #:{$contactInfo.fieldData.fax}
Notes:{$contactInfo.fieldData.notes}
+ {/if} + + {/if} + + + + +{include file='admin/footer.html'} diff --git a/views/admin/contacts/index.html b/views/admin/contacts/index.html index 78058f7..05e7d56 100644 --- a/views/admin/contacts/index.html +++ b/views/admin/contacts/index.html @@ -1,52 +1,83 @@ -{include file='admin/contacts/header.html'} - -
- List Filters:   - Show Archived   -    - Search - -

Contacts

- - - - - - - - - - - - - - - -{if $haveContacts} - {foreach $contacts as $c} - - - - - - - - - - - {/foreach} +{if $fromMemberMenu} + {include file='admin/member/header.html'} {else} - + {include file='admin/contacts/header.html'} {/if} - -
NameActiveTypeAccessUserEntityOrganizationLocation
{$c.lname}, {$c.fname}{$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.contact_role_short.name} - {$c.ref_type.name}: - {$c.ref_dest_name} - {$c.org}{$c.city.name}, {$c.state.name}
(no contacts listed)
+
+ + + + +
+ List Filters:   +    + + Text Search: + + +
+ +

Contacts

+ +
+ +

Total found: {$numbContacts}  

+ + {if $paging} + {if $prevStart}{/if} + {if $nextStart}{/if} + {/if} + + + + + + + + + + + + + + {if $haveContacts} + {foreach $contactsList as $c} + + + + + + + + + {/foreach} + {else} + + {/if} + +
NameActiveTypeAccessUserEntity
+ {if $fromMemberMenu} + {$c.lname}, {$c.fname} + {else} + {$c.lname}, {$c.fname} + {/if} + {$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.username} + {$c.ref_type.name}: + {$c.ref_dest_name} +
(no contacts listed)
+ + {if $paging} + {if $prevStart}{/if} + {if $nextStart}{/if} + {/if} + +
+ diff --git a/views/admin/management/contacts.html b/views/admin/management/contacts.html index 22f6129..0317a16 100644 --- a/views/admin/management/contacts.html +++ b/views/admin/management/contacts.html @@ -1,21 +1,62 @@ {include file='admin/management/header.html'} {if $errorMsg != false} -

Your import failed because ...

-

{$errorMsg}

+
+

Your request failed because ...

+

{$errorMsg}

+
+

 

{/if} {if $importResult.status}

Contact Import Results

+ {if $option == doCsvImport} + + + + {else} + {/if}
Number of contacts from supplied CSV file:{$importResult.numbContacts}
Number of contacts Updated:{$importResult.numbContactsUpdated}
Number of contacts with WordPress users Updated:{$importResult.numbWpUserUpdated}
Number of contacts from old database:{$importResult.numbContacts}
Number of contacts imported:{$importResult.numbImported}
Number of contacts with WordPress users created:{$importResult.numbWpUsersCreated}
Return to Import Events {else} -

 Option 1: Import contacts from legacy site database.

+
+ + + + +

 Clear All Contacts

+ + + + + + + + + + + + + + +
Clear Contacts: + + WARNING: This will permanently delete all existing contacts! +
Confirm: +
+ Type "Please Clear Contacts" here to confirm you want to clear all contacts. +
 
+ +
+ +

 

+ +

 Import from Gaslight Media Legacy Database

@@ -40,13 +81,6 @@ Password: - - Clear Contacts before Import: - - - WARNING: This will permanently delete all existing contacts! - -   @@ -57,7 +91,7 @@

 

-

 Option 2: Import contacts from a CSV file.

+

 Import/Update Contacts from CSV File

@@ -68,20 +102,20 @@   - (format specification or link to sample file here) +

+ File format must be as follows.
+ * Data must follow this header line.
+ * Anything above this line is ignored.
+ * Any line without at least this number of fields is ignored.
+ * Any line with a non-numeric "member_id" is ignored.
+

  'member_id','member_name','member_login','member_passwd','member_contact_email'
+

Host: - - Clear Contacts before Import: - - - WARNING: This will permanently delete all existing contacts! - -   diff --git a/views/admin/member/contacts--POS_OLD.html b/views/admin/member/contacts--POS_OLD.html new file mode 100644 index 0000000..3c8249f --- /dev/null +++ b/views/admin/member/contacts--POS_OLD.html @@ -0,0 +1,671 @@ +{include file='admin/member/header.html'} + +{if $userDeleted} +

Contact Deleted:

+
    + {if $wpUserDeleted} +
  • The associated system user was also removed.
  • + {else} +
  • Other roles were assigned to the associated system user so that system user has not been removed.
  • + {/if} +
+{/if} + +{if $haveMember} + {if $option == 'list'} + + {if apply_filters('glm_members_permit_admin_member_contacts_add_contact', true)} + Add New {$terms.term_member_cap} Contact + {/if} + + List Filters:   + Show Archived   +    + Search +      + +

 

+ + + + + + + + + + + + + + +{if $haveContacts} + {foreach $contacts as $c} + + + + + + + + + + + {/foreach} +{else} + +{/if} + +
NameActiveTypeAccessUserContact ForOrganizationLocation
+ {if apply_filters('glm_members_permit_admin_member_contacts_view_contact', true)} + {$c.lname}, {$c.fname} + {else} + {$c.lname}, {$c.fname} + {/if} + {$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.contact_role_short.name}{$c.ref_type.name} - {$c.ref_dest_name}{$c.org}{$c.city.name}, {$c.state.name}
(no contacts listed)
+ + + {elseif $option == 'edit' && !$contactID} + +

ERROR: Specified contact not found!

+ + {elseif $newContactExists} + +

NOTE: The Email address or username for this contact is already in use. Please check if they already are a contact in this system.

+ + {elseif $misMatchedWpUsers} + +

+ NOTE: + The Email address for this contact is already in use by an existing system user but the username is in use by a different + system user. As such we are unable to match this request to a specific existing system user. We suggest you determine what + the "Username" is for the existing Wordpress user with the Email address you requested. Please call for assistance if needed. +

+ + {elseif $newContactCreated} + +

New Contact Created: {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}

+ {if $usernameChangedToWP || $usingExistingWPContact} +

NOTE:

+
    + {/if} + {if $usingExistingWPContact} +
  • An existing system user was found with the same Email address. This contact will be associated with that system user.
  • +
  • The password of the existing system user was not updated. The system user will continue to use their existing password.
  • + {/if} + {if $usernameChangedToWP} +
  • The username was changed to match the username of the system user found with the specified Email address.
  • +
  • The username for this contact is: {$contactInfo.fieldData.username}
  • + {/if} + {if $usernameChangedToWP || $usingExistingWPContact} +
+ {/if} + + {else} + + + {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)} + + {if $option == 'create' || $option == 'edit'} + + Return to Contact List + + {if $option == 'create'} +

Add New Contact

+ {else} + {if $contactUpdated}

Contact Updated

{/if} + Delete this Contact +
+
+

Cancel

+

+
+
+

WARNING:

+

+ Clicking the "Delete this Contact" button above will + delete all of the data and images associated with this contact. + +

+

+ Once deleted, this information will no longer be available and cannot be retrieved! +

+
+

+ This contact may instead be "Archived" rather than deleted using the "Contact Display:" pick-list. When archived, the contact is not displayed on the front-end + of the Web site, any login assoicated with this contact is deactivated, and the contact will not show on contact lists unless "Archived" is selected. + Unlike delete, an archived contact may be changed back to normal use. +

+
+

Edit Contact

+ {/if} + + +
+ + + {if $option == 'create'} + + + + + {else} + + + + + {/if} + + + + + + + + + + + {if $option != 'create'} + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + + + + {if $option == 'create'} + + + {else} + + + {/if} + + + + {if $option == 'create'} + + + {else} + + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact For:{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}
Active: + +
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name: + + {if $contactInfo.fieldFail.fname}

{$contactInfo.fieldFail.fname}

{/if} +
Last Name: + + {if $contactInfo.fieldFail.lname}

{$contactInfo.fieldFail.lname}

{/if} +
Contact Type: + + {if $contactInfo.fieldFail.contact_type}

{$contactInfo.fieldFail.contact_type}

{/if} +
Permissions: + + {if $contactInfo.fieldFail.contact_role}

{$contactInfo.fieldFail.contact_role}

{/if} +
Display/Moderate/Archive: + + {if $contactInfo.fieldFail.access}

{$contactInfo.fieldFail.access}

{/if} +
Email Address: + +
NOTE: This field is required for users who will have login privileges. + {if $contactInfo.fieldFail.email}

{$contactInfo.fieldFail.email}

{/if} +
Email Address::{$contactInfo.fieldData.email}
Login Username: + +
NOTE: The username cannot be changed once the contact is created. + {if $contactInfo.fieldFail.username}

{$contactInfo.fieldFail.username}

{/if} +
Login Username:{$contactInfo.fieldData.username}
Login password: + + {if $option == 'create'} + Save this password. +
A randomly generated password has been supplied. You may change this as desired. + There is no way to view a password once it's set. However, a user may recover a password using their + Email address at the login page. + {else} +
NOTE: Enter a password here only if you need to change it. + {/if} +
The password must be at least 8 characters and include at least one number, one letter, and at least one + special character. (# . - _ , $ % & !) + {if $contactInfo.fieldFail.password}

{$contactInfo.fieldFail.password}

{/if} +
Alternate Email Address: + + {if $contactInfo.fieldFail.alt_email}

{$contactInfo.fieldFail.alt_email}

{/if} +
Organization: + + {if $contactInfo.fieldFail.org}

{$contactInfo.fieldFail.org}

{/if} +
Title/Position: + + {if $contactInfo.fieldFail.title}

{$contactInfo.fieldFail.title}

{/if} +
Position/Responsibilities: + {php} + wp_editor('{$contactInfo.fieldData.descr}', 'glm_descr', array( + 'quicktags' => false, + 'media_buttons' => false, + 'wpautop' => false, + 'textarea_name' => 'descr', + 'editor_height' => 100, // Height in px, overrides editor_rows + // 'textarea_rows' => 4, + )); + {/php} + {if $contactInfo.fieldFail.descr}

{$contactInfo.fieldFail.descr}

{/if} +
Image: + {if $contactInfo.fieldData.image} +
+ + Close
+
+ + + + + + +
+ Delete Image
+ {$contactInfo.fieldData.image}
+

Show Large Image

+
+ {/if} + + {if $contactInfo.fieldFail.image}

{$contactInfo.fieldFail.image}

{/if} +
Address Line 1: + + {if $contactInfo.fieldFail.addr1}

{$contactInfo.fieldFail.addr1}

{/if} +
Address Line 2: + + {if $contactInfo.fieldFail.addr2}

{$contactInfo.fieldFail.addr2}

{/if} +
City + +
Add a new City
+
+ + + + + +
City Name: + +
+
+

* Required

+ Cancel + +
+ + + +
State: + + {if $contactInfo.fieldFail.state}

{$contactInfo.fieldFail.state}

{/if} +
ZIP / Postal Code: + + {if $contactInfo.fieldFail.zip}

{$contactInfo.fieldFail.zip}

{/if} +
Country: + + {if $contactInfo.fieldFail.country}

{$contactInfo.fieldFail.country}

{/if} +
Web Address (URL): + {if $contactInfo.fieldData.url} + Test Link + {/if} + http:// + {if $contactInfo.fieldFail.url}

{$contactInfo.fieldFail.url}

{/if} +
Office Phone #: + + {if $contactInfo.fieldFail.office_phone}

{$contactInfo.fieldFail.office_phone}

{/if} +
Home Phone #: + + {if $contactInfo.fieldFail.home_phone}

{$contactInfo.fieldFail.home_phone}

{/if} +
Mobile Phone #: + + {if $contactInfo.fieldFail.mobile_phone}

{$contactInfo.fieldFail.mobile_phone}

{/if} +
Alternate Phone #: + + {if $contactInfo.fieldFail.alt_phone}

{$contactInfo.fieldFail.alt_phone}

{/if} +
FAX #: + + {if $contactInfo.fieldFail.fax}

{$contactInfo.fieldFail.fax}

{/if} +
Notes: + {php} + wp_editor('{$contactInfo.fieldData.notes}', 'glm_notes', array( + 'quicktags' => false, + 'media_buttons' => false, + 'wpautop' => false, + 'textarea_name' => 'notes', + 'editor_height' => 100, // Height in px, overrides editor_rows + // 'textarea_rows' => 4, + )); + {/php} + {if $contactInfo.fieldFail.notes}

{$contactInfo.fieldFail.notes}

{/if} +
+

* Required

+ +
+ + {/if} + + {else} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact For:{$contactInfo.fieldData.ref_type.name} - {$memberData.name}
Active:{$contactInfo.fieldData.active.name}
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name:{$contactInfo.fieldData.fname}
Last Name:{$contactInfo.fieldData.lname}
Contact Type:{$contactInfo.fieldData.contact_type.name}
Email Address::{$contactInfo.fieldData.email}
Alternate Email Address:{$contactInfo.fieldData.alt_email}
Organization:{$contactInfo.fieldData.org}
Title/Position:{$contactInfo.fieldData.title}
Position/Responsibilities:{$contactInfo.fieldData.descr}
Image: + {if $contactInfo.fieldData.image} + + {/if} +
Address Line 1:{$contactInfo.fieldData.addr1}
Address Line 2:{$contactInfo.fieldData.addr2}
City{$contactInfo.fieldData.city.name}
State:{$contactInfo.fieldData.state.name}
ZIP / Postal Code:{$contactInfo.fieldData.zip}
Country:{$contactInfo.fieldData.country.name}
Web Address (URL): + {if $contactInfo.fieldData.url} + {$contactInfo.fieldData.url} + {/if} +
Office Phone #:{$contactInfo.fieldData.office_phone}
Home Phone #:{$contactInfo.fieldData.home_phone}
Mobile Phone #:{$contactInfo.fieldData.mobile_phone}
Alternate Phone #:{$contactInfo.fieldData.alt_phone}
FAX #:{$contactInfo.fieldData.fax}
Notes:{$contactInfo.fieldData.notes}
+ {/if} + + {/if} + +{else} +

No current {$terms.term_member}.

+{/if} + + + + +{include file='admin/footer.html'} diff --git a/views/admin/member/contacts.html b/views/admin/member/contacts.html deleted file mode 100644 index 35ef661..0000000 --- a/views/admin/member/contacts.html +++ /dev/null @@ -1,667 +0,0 @@ -{include file='admin/member/header.html'} - -{if $userDeleted} -

Contact Deleted:

-
    - {if $wpUserDeleted} -
  • The associated system user was also removed.
  • - {else} -
  • Other roles were assigned to the associated system user so that system user has not been removed.
  • - {/if} -
-{/if} - -{if $haveMember} - {if $option == 'list'} - - {if apply_filters('glm_members_permit_admin_member_contacts_add_contact', true)} - Add New {$terms.term_member_cap} Contact - {/if} -
- List Filters:   - Show Archived   -    - Search -      - -

 

- - - - - - - - - - - - - - -{if $haveContacts} - {foreach $contacts as $c} - - - - - - - - - - - {/foreach} -{else} - -{/if} - -
NameActiveTypeAccessUserContact ForOrganizationLocation
- {if apply_filters('glm_members_permit_admin_member_contacts_view_contact', true)} - {$c.lname}, {$c.fname} - {else} - {$c.lname}, {$c.fname} - {/if} - {$c.active.name}{$c.contact_type.name}{$c.access.name}{$c.contact_role_short.name}{$c.ref_type.name} - {$c.ref_dest_name}{$c.org}{$c.city.name}, {$c.state.name}
(no contacts listed)
- - - {elseif $option == 'edit' && !$contactID} - -

ERROR: Specified contact not found!

- - {elseif $newContactExists} - -

NOTE: The Email address or username for this contact is already in use. Please check if they already are a contact in this system.

- - {elseif $misMatchedWpUsers} - -

- NOTE: - The Email address for this contact is already in use by an existing system user but the username is in use by a different - system user. As such we are unable to match this request to a specific existing system user. We suggest you determine what - the "Username" is for the existing Wordpress user with the Email address you requested. Please call for assistance if needed. -

- - {elseif $newContactCreated} - -

New Contact Created: {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}

- {if $usernameChangedToWP || $usingExistingWPContact} -

NOTE:

-
    - {/if} - {if $usingExistingWPContact} -
  • An existing system user was found with the same Email address. This contact will be associated with that system user.
  • -
  • The password of the existing system user was not updated. The system user will continue to use their existing password.
  • - {/if} - {if $usernameChangedToWP} -
  • The username was changed to match the username of the system user found with the specified Email address.
  • -
  • The username for this contact is: {$contactInfo.fieldData.username}
  • - {/if} - {if $usernameChangedToWP || $usingExistingWPContact} -
- {/if} - - {else} - - - {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)} - - {if $option == 'create' || $option == 'edit'} - - Return to Contact List - - {if $option == 'create'} -

Add New Contact

- {else} - {if $contactUpdated}

Contact Updated

{/if} - Delete this Contact -
-
-

Cancel

-

-
-
-

WARNING:

-

- Clicking the "Delete this Contact" button above will - delete all of the data and images associated with this contact. - -

-

- Once deleted, this information will no longer be available and cannot be retrieved! -

-
-

- This contact may instead be "Archived" rather than deleted using the "Contact Display:" pick-list. When archived, the contact is not displayed on the front-end - of the Web site, any login assoicated with this contact is deactivated, and the contact will not show on contact lists unless "Archived" is selected. - Unlike delete, an archived contact may be changed back to normal use. -

-
-

Edit Contact

- {/if} - - -
- - - {if $option == 'create'} - - - - - {else} - - - - - {/if} - - - - - - - - - - - {if $option != 'create'} - - - - - - - - - {/if} - - - - - - - - - - - - - - - - - - - - - - {if $option == 'create'} - - - {else} - - - {/if} - - - - {if $option == 'create'} - - - {else} - - - {/if} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Contact For:{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}
Active: - -
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name: - - {if $contactInfo.fieldFail.fname}

{$contactInfo.fieldFail.fname}

{/if} -
Last Name: - - {if $contactInfo.fieldFail.lname}

{$contactInfo.fieldFail.lname}

{/if} -
Contact Type: - - {if $contactInfo.fieldFail.contact_type}

{$contactInfo.fieldFail.contact_type}

{/if} -
Permissions: - - {if $contactInfo.fieldFail.contact_role}

{$contactInfo.fieldFail.contact_role}

{/if} -
Display/Moderate/Archive: - - {if $contactInfo.fieldFail.access}

{$contactInfo.fieldFail.access}

{/if} -
Email Address: - -
NOTE: This field is required for users who will have login privileges. - {if $contactInfo.fieldFail.email}

{$contactInfo.fieldFail.email}

{/if} -
Email Address::{$contactInfo.fieldData.email}
Login Username: - -
NOTE: The username cannot be changed once the contact is created. - {if $contactInfo.fieldFail.username}

{$contactInfo.fieldFail.username}

{/if} -
Login Username:{$contactInfo.fieldData.username}
Login password: - - {if $option == 'create'} - Save this password. -
A randomly generated password has been supplied. You may change this as desired. - There is no way to view a password once it's set. However, a user may recover a password using their - Email address at the login page. - {/if} - {if $contactInfo.fieldFail.password}

{$contactInfo.fieldFail.password}

{/if} -
Alternate Email Address: - - {if $contactInfo.fieldFail.alt_email}

{$contactInfo.fieldFail.alt_email}

{/if} -
Organization: - - {if $contactInfo.fieldFail.org}

{$contactInfo.fieldFail.org}

{/if} -
Title/Position: - - {if $contactInfo.fieldFail.title}

{$contactInfo.fieldFail.title}

{/if} -
Position/Responsibilities: - {php} - wp_editor('{$contactInfo.fieldData.descr}', 'glm_descr', array( - 'quicktags' => false, - 'media_buttons' => false, - 'wpautop' => false, - 'textarea_name' => 'descr', - 'editor_height' => 100, // Height in px, overrides editor_rows - // 'textarea_rows' => 4, - )); - {/php} - {if $contactInfo.fieldFail.descr}

{$contactInfo.fieldFail.descr}

{/if} -
Image: - {if $contactInfo.fieldData.image} -
- - Close
-
- - - - - - -
- Delete Image
- {$contactInfo.fieldData.image}
-

Show Large Image

-
- {/if} - - {if $contactInfo.fieldFail.image}

{$contactInfo.fieldFail.image}

{/if} -
Address Line 1: - - {if $contactInfo.fieldFail.addr1}

{$contactInfo.fieldFail.addr1}

{/if} -
Address Line 2: - - {if $contactInfo.fieldFail.addr2}

{$contactInfo.fieldFail.addr2}

{/if} -
City - -
Add a new City
-
- - - - - -
City Name: - -
-
-

* Required

- Cancel - -
- - - -
State: - - {if $contactInfo.fieldFail.state}

{$contactInfo.fieldFail.state}

{/if} -
ZIP / Postal Code: - - {if $contactInfo.fieldFail.zip}

{$contactInfo.fieldFail.zip}

{/if} -
Country: - - {if $contactInfo.fieldFail.country}

{$contactInfo.fieldFail.country}

{/if} -
Web Address (URL): - {if $contactInfo.fieldData.url} - Test Link - {/if} - http:// - {if $contactInfo.fieldFail.url}

{$contactInfo.fieldFail.url}

{/if} -
Office Phone #: - - {if $contactInfo.fieldFail.office_phone}

{$contactInfo.fieldFail.office_phone}

{/if} -
Home Phone #: - - {if $contactInfo.fieldFail.home_phone}

{$contactInfo.fieldFail.home_phone}

{/if} -
Mobile Phone #: - - {if $contactInfo.fieldFail.mobile_phone}

{$contactInfo.fieldFail.mobile_phone}

{/if} -
Alternate Phone #: - - {if $contactInfo.fieldFail.alt_phone}

{$contactInfo.fieldFail.alt_phone}

{/if} -
FAX #: - - {if $contactInfo.fieldFail.fax}

{$contactInfo.fieldFail.fax}

{/if} -
Notes: - {php} - wp_editor('{$contactInfo.fieldData.notes}', 'glm_notes', array( - 'quicktags' => false, - 'media_buttons' => false, - 'wpautop' => false, - 'textarea_name' => 'notes', - 'editor_height' => 100, // Height in px, overrides editor_rows - // 'textarea_rows' => 4, - )); - {/php} - {if $contactInfo.fieldFail.notes}

{$contactInfo.fieldFail.notes}

{/if} -
-

* Required

- -
- - {/if} - - {else} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Contact For:{$contactInfo.fieldData.ref_type.name} - {$memberData.name}
Active:{$contactInfo.fieldData.active.name}
Created:{$contactInfo.fieldData.create_time.datetime}
Last Updated:{$contactInfo.fieldData.modify_time.datetime}
First Name:{$contactInfo.fieldData.fname}
Last Name:{$contactInfo.fieldData.lname}
Contact Type:{$contactInfo.fieldData.contact_type.name}
Email Address::{$contactInfo.fieldData.email}
Alternate Email Address:{$contactInfo.fieldData.alt_email}
Organization:{$contactInfo.fieldData.org}
Title/Position:{$contactInfo.fieldData.title}
Position/Responsibilities:{$contactInfo.fieldData.descr}
Image: - {if $contactInfo.fieldData.image} - - {/if} -
Address Line 1:{$contactInfo.fieldData.addr1}
Address Line 2:{$contactInfo.fieldData.addr2}
City{$contactInfo.fieldData.city.name}
State:{$contactInfo.fieldData.state.name}
ZIP / Postal Code:{$contactInfo.fieldData.zip}
Country:{$contactInfo.fieldData.country.name}
Web Address (URL): - {if $contactInfo.fieldData.url} - {$contactInfo.fieldData.url} - {/if} -
Office Phone #:{$contactInfo.fieldData.office_phone}
Home Phone #:{$contactInfo.fieldData.home_phone}
Mobile Phone #:{$contactInfo.fieldData.mobile_phone}
Alternate Phone #:{$contactInfo.fieldData.alt_phone}
FAX #:{$contactInfo.fieldData.fax}
Notes:{$contactInfo.fieldData.notes}
- {/if} - - {/if} - -{else} -

No current {$terms.term_member}.

-{/if} - - - - -{include file='admin/footer.html'} diff --git a/views/admin/profile/header.html b/views/admin/profile/header.html index 7717c57..8732bbf 100644 --- a/views/admin/profile/header.html +++ b/views/admin/profile/header.html @@ -1,7 +1,7 @@
-

Your Contact and Log-in Profile

+

My Contact and Log-In Information