*
* @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;
$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) {
}
+ /**
+ * 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;
+
+ }
+
+
}
* @access public
*/
public $config;
- /**
- * Contacts List
- *
- * @var $contacts
- * @access public
- */
- public $contacts;
/*
* Constructor
}
- 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
);
}
+
+*/
}
?>
\ No newline at end of file
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
$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':
'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
}
+
+ /**
+ * 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
*
*
* @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,
// 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) {
.", Name = ".$c['primary_contact_fname']." ".$c['primary_contact_lname']
);
- // Put WordPress user stuff here.....
-
-
// Contact imported correctly, proceed with WordPress user
} else {
}
+ /**
+ * 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
+ ."<br>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
+ ."<br>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
+ ."<br>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;
+
+ }
+
+
}
?>
* @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
{
/**
$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);
- }
- }
}
}
*/
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');}
);
}
-
-?>
);
*/
-// 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
global $wpdb, $config;
-
// Add default of no current contact user
$loggedInUser['contactUser'] = false;
}
// 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);
}
);
+// 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');
+ }
+);
* 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');
--- /dev/null
+
+{if $fromMemberMenu}
+ {include file='admin/member/header.html'}
+{else}
+ {include file='admin/contacts/header.html'}
+{/if}
+
+{if $userDeleted}
+ <h3><span class="glm-warning">Contact Deleted:</span></h3>
+ <ul class="glm-li">
+ {if $wpUserDeleted}
+ <li>The associated system user was also removed.</li>
+ {else}
+ <li>Other roles were assigned to the associated system user so that system user has not been removed.</li>
+ {/if}
+ </ul>
+{/if}
+
+<!-- Check for invalid contact ID to edit -->
+{if $option == 'edit' && !$contactID}
+
+ <h3><span class="glm-error">ERROR:</span> Specified contact not found!</h3>
+
+ {elseif $newContactExists}
+
+ <h4><span class="glm-warning">NOTE:</span> The Email address or username for this contact is already in use. Please check if they already are a contact in this system.</h3>
+
+ {elseif $misMatchedWpUsers}
+
+ <h3>
+ <span class="glm-warning">NOTE:</span>
+ 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.
+ </h3>
+
+ {elseif $newContactCreated}
+
+ <h3><span class="glm-warning">New Contact Created:</span> {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}</h3>
+ {if $usernameChangedToWP || $usingExistingWPContact}
+ <h3><span class="glm-notice">NOTE:</span></h3>
+ <ul class="glm-li">
+ {/if}
+ {if $usingExistingWPContact}
+ <li>An existing system user was found with the same Email address. This contact will be associated with that system user. </li>
+ <li>The password of the existing system user was not updated. The system user will continue to use their existing password.</li>
+ {/if}
+ {if $usernameChangedToWP}
+ <li>The username was changed to match the username of the system user found with the specified Email address.</li>
+ <li>The username for this contact is: <span class="glm-notice">{$contactInfo.fieldData.username}</span></li>
+ {/if}
+ {if $usernameChangedToWP || $usingExistingWPContact}
+ </ul>
+ {/if}
+
+ {else} <!-- !$option -->
+
+
+ {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)}
+
+ {if $option == 'create' || $option == 'edit'}
+
+ {if $fromMemberMenu}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&member={$memberID}" class="button button-primary glm-button glm-right">Return to Contact List</a>
+ {else}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-contacts&glm_action=index&member={$memberID}" class="button button-primary glm-button glm-right">Return to Contact List</a>
+ {/if}
+
+ {if $option == 'create'}
+ <h2 class="glm-left">Add New Contact</h2>
+ {else}
+ {if $contactUpdated}<h2 class="glm-notice glm-flash-updated">Contact Updated</h2>{/if}
+ <a id="deleteContactButton" class="button button-primary glm-button glm-right">Delete this Contact</a>
+ <div id="deleteContactDialog" class="glm-dialog-box" title="Delete Contact">
+ <center>
+ <p><a id="deleteContactCancel" class="button button-primary">Cancel</a></p>
+ <p><input id="deleteContactSubmit" type="submit" value="Delete this contact"></p>
+ </center>
+ <div class="glm-item-container">
+ <p><center><span class="glm-error">WARNING:</span></center></p>
+ <p>
+ <span class="glm-warning">Clicking the "Delete this Contact" button above will
+ delete all of the data and images associated with this contact.
+ </span>
+ </p>
+ <p>
+ <span class="glm-error">Once deleted, this information will no longer be available and cannot be retrieved!</span>
+ </p>
+ </div>
+ <p>
+ 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.
+ </p>
+ </div>
+ <h2 class="glm-left">Edit Contact</h2>
+ {/if}
+
+
+ {if $fromMemberMenu}
+ <form action="{$thisUrl}?page=glm-members-admin-menu-member" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="contacts">
+ {else}
+ <form action="{$thisUrl}?page=glm-members-admin-menu-contacts" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="index">
+ {/if}
+ <input type="hidden" name="member" value="{$memberData.id}">
+ {if $option == 'create'}
+ <input type="hidden" name="option" value="addNew">
+ <input type="hidden" name="create_time" value="now">
+ <input type="hidden" name="ref_type" value="{$refType}">
+ <input type="hidden" name="ref_dest" value="{$memberData.id}">
+ {else}
+ <input type="hidden" name="option" value="submit">
+ <input type="hidden" name="contact" value="{$contactInfo.fieldData.id}">
+ <input type="hidden" name="id" value="{$contactInfo.fieldData.id}">
+ <input type="hidden" name="modify_time" value="now">
+ {/if}
+
+ <table class="glm-admin-table glm-shrink">
+ <tr>
+ <th>Contact For:</th>
+ <td>{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}</td>
+ </tr>
+ <tr>
+ <th>Active:</th>
+ <td>
+ <input type="checkbox" name="active" {if $contactInfo.fieldData.active.value} checked{/if}>
+ </td>
+ </tr>
+ {if $option != 'create'}
+ <tr>
+ <th>Created:</th>
+ <td>{$contactInfo.fieldData.create_time.datetime}</td>
+ </tr>
+ <tr>
+ <th>Last Updated:</th>
+ <td>{$contactInfo.fieldData.modify_time.datetime}</td>
+ </tr>
+ {/if}
+ <tr>
+ <th {if $contactInfo.fieldRequired.fname}class="glm-required"{/if}>First Name:</th>
+ <td {if $contactInfo.fieldFail.fname}class="glm-form-bad-input"{/if}>
+ <input type="text" name="fname" value="{$contactInfo.fieldData.fname}" class="glm-form-text-input-short">
+ {if $contactInfo.fieldFail.fname}<p>{$contactInfo.fieldFail.fname}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.lname}class="glm-required"{/if}>Last Name:</th>
+ <td {if $contactInfo.fieldFail.lname}class="glm-form-bad-input"{/if}>
+ <input type="text" name="lname" value="{$contactInfo.fieldData.lname}" class="glm-form-text-input-short">
+ {if $contactInfo.fieldFail.lname}<p>{$contactInfo.fieldFail.lname}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.contact_type}class="glm-required"{/if}>Contact Type:</th>
+ <td {if $contactInfo.fieldFail.contact_type}class="glm-form-bad-input"{/if}>
+ <select name="contact_type">
+ {foreach from=$contactInfo.fieldData.contact_type.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.contact_type}<p>{$contactInfo.fieldFail.contact_type}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.contact_role}class="glm-required"{/if}>Permissions:</th>
+ <td {if $contactInfo.fieldFail.contact_role}class="glm-form-bad-input"{/if}>
+ <select name="contact_role">
+ {foreach from=$contactInfo.fieldData.contact_role.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.contact_role}<p>{$contactInfo.fieldFail.contact_role}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.access}class="glm-required"{/if}>Display/Moderate/Archive:</th>
+ <td {if $contactInfo.fieldFail.access}class="glm-form-bad-input"{/if}>
+ <select name="access">
+ {foreach from=$contactInfo.fieldData.access.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.access}<p>{$contactInfo.fieldFail.access}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ {if $option == 'create'}
+ <th {if $contactInfo.fieldRequired.email}class="glm-required"{/if}>Email Address:</th>
+ <td {if $contactInfo.fieldFail.email}class="glm-form-bad-input"{/if}>
+ <input type="text" name="email" value="{$contactInfo.fieldData.email}" class="glm-form-text-input-medium" placeholder="(ex: name@domain.com)">
+ <br><span class="glm-notice">NOTE:</span> This field is required for users who will have login privileges.
+ {if $contactInfo.fieldFail.email}<p>{$contactInfo.fieldFail.email}</p>{/if}
+ </td>
+ {else}
+ <th>Email Address::</th>
+ <td>{$contactInfo.fieldData.email}</td>
+ {/if}
+ </tr>
+ <tr>
+
+ {if $option == 'create'}
+ <th {if $contactInfo.fieldRequired.username}class="glm-required"{/if}>Login Username:</th>
+ <td {if $contactInfo.fieldFail.username}class="glm-form-bad-input"{/if}>
+ <input type="text" name="username" value="{$contactInfo.fieldData.username}" class="glm-form-text-input-medium" placeholder="(no spaces permitted)">
+ <br><span class="glm-notice">NOTE:</span> The username cannot be changed once the contact is created.
+ {if $contactInfo.fieldFail.username}<p>{$contactInfo.fieldFail.username}</p>{/if}
+ </td>
+ {else}
+ <th>Login Username:</th>
+ <td>{$contactInfo.fieldData.username}</td>
+ {/if}
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.password}class="glm-required"{/if}>Login password:</th>
+ <td {if $contactInfo.fieldFail.password}class="glm-form-bad-input"{/if}>
+ <input type="text" name="password" value="{$contactInfo.fieldData.password}" class="glm-form-text-input-medium" placeholder="{if $option=='create'}(no spaces permitted){else}(Password does not show, only enter to change password.){/if}">
+ {if $option == 'create'}
+ <span class="glm-notice">Save this password.</span>
+ <br>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}
+ <br>NOTE: Enter a password here <b><i>only</i></b> if you need to change it.
+ {/if}
+ <br>The password must be at least 8 characters and include at least one number, one letter, and at least one
+ special character. (# . - _ , $ % & !)</b>
+ {if $contactInfo.fieldFail.password}<p>{$contactInfo.fieldFail.password}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.alt_email}class="glm-required"{/if}>Alternate Email Address:</th>
+ <td {if $contactInfo.fieldFail.alt_email}class="glm-form-bad-input"{/if}>
+ <input type="text" name="alt_email" value="{$contactInfo.fieldData.alt_email}" class="glm-form-text-input-short" placeholder="ex: name@domain.com">
+ {if $contactInfo.fieldFail.alt_email}<p>{$contactInfo.fieldFail.alt_email}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.org}class="glm-required"{/if}>Organization:</th>
+ <td {if $contactInfo.fieldFail.org}class="glm-form-bad-input"{/if}>
+ <input type="text" name="org" value="{$contactInfo.fieldData.org}" class="glm-form-text-input-medium">
+ {if $contactInfo.fieldFail.org}<p>{$contactInfo.fieldFail.org}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.title}class="glm-required"{/if}>Title/Position:</th>
+ <td {if $contactInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
+ <input type="text" name="title" value="{$contactInfo.fieldData.title}" class="glm-form-text-input-medium">
+ {if $contactInfo.fieldFail.title}<p>{$contactInfo.fieldFail.title}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.descr}class="glm-required"{/if}>Position/Responsibilities:</th>
+ <td {if $contactInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
+ {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}<p>{$contactInfo.fieldFail.descr}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.image}class="glm-required"{/if}>Image:</th>
+ <td {if $contactInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
+ {if $contactInfo.fieldData.image}
+ <div id="largeImageDialog" class="glm-dialog-box" title="Large sized image">
+ <img src="{$glmPluginMediaUrl}/images/large/{$contactInfo.fieldData.image}">
+ <a id="largeImageCancel" class="button button-primary glm-right">Close</a><br>
+ </div>
+ <table class="glm-admin-image-edit-table">
+ <tr>
+ <td><img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}"></td>
+ <td>
+ <input type="checkbox" name="image_delete"> Delete Image<br>
+ {$contactInfo.fieldData.image}<br>
+ <p><div id="largeImageButton" class="button button-primary">Show Large Image</div></p>
+ </td>
+
+ </tr>
+ </table>
+ {/if}
+ <input type="file" name="image_new">
+ {if $contactInfo.fieldFail.image}<p>{$contactInfo.fieldFail.image}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.addr1}class="glm-required"{/if}>Address Line 1:</th>
+ <td {if $contactInfo.fieldFail.addr1}class="glm-form-bad-input"{/if}>
+ <input type="text" id="addr1" name="addr1" value="{$contactInfo.fieldData.addr1}" class="glm-form-text-input glm-geocodeAction">
+ {if $contactInfo.fieldFail.addr1}<p>{$contactInfo.fieldFail.addr1}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.addr2}class="glm-required"{/if}>Address Line 2:</th>
+ <td {if $contactInfo.fieldFail.addr2}class="glm-form-bad-input"{/if}>
+ <input id="addr2" type="text" name="addr2" value="{$contactInfo.fieldData.addr2}" class="glm-form-text-input glm-geocodeAction">
+ {if $contactInfo.fieldFail.addr2}<p>{$contactInfo.fieldFail.addr2}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th>City</th>
+ <td class="glm-item-container">
+ <!-- Add new city dialog -->
+ <div id="newCityButton" class="button button-secondary glm-right">Add a new City</div>
+ <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">City Name:</th>
+ <td id="newCityNameTD">
+ <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
+ <div id="newCityNameRequired"></div>
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
+ <input id="newCitySubmit" type="submit" value="Add new City">
+ </div>
+ <!-- City Selection -->
+ <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
+ <select name="city" id="city" class="glm-geocodeAction">
+ <option value="0"><option>
+ {foreach from=$contactInfo.fieldData.city.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.state}class="glm-required"{/if}>State:</th>
+ <td {if $contactInfo.fieldFail.state}class="glm-form-bad-input"{/if}>
+ <select id="state" name="state" class="glm-geocodeAction">
+ {foreach from=$contactInfo.fieldData.state.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.state}<p>{$contactInfo.fieldFail.state}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.zip}class="glm-required"{/if}>ZIP / Postal Code:</th>
+ <td {if $contactInfo.fieldFail.zip}class="glm-form-bad-input"{/if}>
+ <input id="zip" type="text" name="zip" value="{$contactInfo.fieldData.zip}" class="glm-form-text-input-short glm-geocodeAction">
+ {if $contactInfo.fieldFail.zip}<p>{$contactInfo.fieldFail.zip}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.country}class="glm-required"{/if}>Country:</th>
+ <td {if $contactInfo.fieldFail.country}class="glm-form-bad-input"{/if}>
+ <select id="country" name="country" class="glm-geocodeAction">
+ {foreach from=$contactInfo.fieldData.country.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name} {$v.value}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.country}<p>{$contactInfo.fieldFail.country}</p>{/if}
+ </td>
+ </tr>
+ <!-- NOT DOING LAT/LON FOR NOW -->
+ <tr>
+ <th {if $contactInfo.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
+ <td {if $contactInfo.fieldFail.url}class="glm-form-bad-input"{/if}>
+ {if $contactInfo.fieldData.url}
+ <a class="button button-secondary glm-right" href="http://{$contactInfo.fieldData.url}" target="urlTarget">Test Link</a>
+ {/if}
+ http://<input type="text" name="url" value="{$contactInfo.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: www.gaslightmedia.com">
+ {if $contactInfo.fieldFail.url}<p>{$contactInfo.fieldFail.url}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.office_phone}class="glm-required"{/if}>Office Phone #:</th>
+ <td {if $contactInfo.fieldFail.office_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="office_phone" value="{$contactInfo.fieldData.office_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.office_phone}<p>{$contactInfo.fieldFail.office_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.home_phone}class="glm-required"{/if}>Home Phone #:</th>
+ <td {if $contactInfo.fieldFail.home_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="home_phone" value="{$contactInfo.fieldData.home_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.home_phone}<p>{$contactInfo.fieldFail.home_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.mobile_phone}class="glm-required"{/if}>Mobile Phone #:</th>
+ <td {if $contactInfo.fieldFail.mobile_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="mobile_phone" value="{$contactInfo.fieldData.mobile_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.mobile_phone}<p>{$contactInfo.fieldFail.mobile_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.alt_phone}class="glm-required"{/if}>Alternate Phone #:</th>
+ <td {if $contactInfo.fieldFail.alt_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="alt_phone" value="{$contactInfo.fieldData.alt_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.alt_phone}<p>{$contactInfo.fieldFail.alt_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.fax}class="glm-required"{/if}>FAX #:</th>
+ <td {if $contactInfo.fieldFail.fax}class="glm-form-bad-input"{/if}>
+ <input type="text" name="fax" value="{$contactInfo.fieldData.fax}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.fax}<p>{$contactInfo.fieldFail.fax}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.notes}class="glm-required"{/if}>Notes:</th>
+ <td {if $contactInfo.fieldFail.notes}class="glm-form-bad-input"{/if}>
+ {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}<p>{$contactInfo.fieldFail.notes}</p>{/if}
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <input id="updateContact" type="submit" value="{if $contactID && $contactInfo}Update contact{else}Add new contact{/if}">
+ </form>
+
+ {/if}
+
+ {else} <!-- may edit contact -->
+
+ <table class="glm-admin-table glm-shrink">
+ <tr><th>Contact For:</th><td>{$contactInfo.fieldData.ref_type.name} - {$memberData.name}</td></tr>
+ <tr><th>Active:</th><td>{$contactInfo.fieldData.active.name}</td></tr>
+ <tr><th>Created:</th><td>{$contactInfo.fieldData.create_time.datetime}</td></tr>
+ <tr><th>Last Updated:</th><td>{$contactInfo.fieldData.modify_time.datetime}</td></tr>
+ <tr><th>First Name:</th><td>{$contactInfo.fieldData.fname}</td></tr>
+ <tr><th>Last Name:</th><td>{$contactInfo.fieldData.lname}</td></tr>
+ <tr><th>Contact Type:</th><td>{$contactInfo.fieldData.contact_type.name}</td></tr>
+ <tr><th>Email Address::</th><td>{$contactInfo.fieldData.email}</td></tr>
+ <tr><th>Alternate Email Address:</th><td>{$contactInfo.fieldData.alt_email}</td></tr>
+ <tr><th>Organization:</th><td>{$contactInfo.fieldData.org}</td></tr>
+ <tr><th>Title/Position:</th><td>{$contactInfo.fieldData.title}</td></tr>
+ <tr><th>Position/Responsibilities:</th><td>{$contactInfo.fieldData.descr}</td></tr>
+ <tr>
+ <th>Image:</th>
+ <td>
+ {if $contactInfo.fieldData.image}
+ <img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}">
+ {/if}
+ </td>
+ </tr>
+ <tr><th>Address Line 1:</th><td>{$contactInfo.fieldData.addr1}</td></tr>
+ <tr><th>Address Line 2:</th><td>{$contactInfo.fieldData.addr2}</td></tr>
+ <tr><th>City</th><td>{$contactInfo.fieldData.city.name}</td></tr>
+ <tr><th>State:</th><td>{$contactInfo.fieldData.state.name}</td></tr>
+ <tr><th>ZIP / Postal Code:</th><td>{$contactInfo.fieldData.zip}</td></tr>
+ <tr><th>Country:</th><td>{$contactInfo.fieldData.country.name}</td></tr>
+ <tr>
+ <th>Web Address (URL):</th>
+ <td>
+ {if $contactInfo.fieldData.url}
+ <a href="http://{$contactInfo.fieldData.url}" target="urlTarget">{$contactInfo.fieldData.url}</a>
+ {/if}
+ </td>
+ </tr>
+ <tr><th>Office Phone #:</th><td>{$contactInfo.fieldData.office_phone}</td></tr>
+ <tr><th>Home Phone #:</th><td>{$contactInfo.fieldData.home_phone}</td></tr>
+ <tr><th>Mobile Phone #:</th><td>{$contactInfo.fieldData.mobile_phone}</td></tr>
+ <tr><th>Alternate Phone #:</th><td>{$contactInfo.fieldData.alt_phone}</td></tr>
+ <tr><th>FAX #:</th><td>{$contactInfo.fieldData.fax}</td></tr>
+ <tr><th>Notes:</th><td>{$contactInfo.fieldData.notes}</td></tr>
+ </table>
+ {/if} <!-- mey edit contact -->
+
+ {/if} <!-- /if option -->
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ // Filter triggers
+ $(".listFilter" ).change( function() {
+
+ var filter = '';
+
+ // Check for archived filter
+ if ($("#filterArchived").attr('checked')) {
+ filter += '&filterArchived=true';
+ }
+
+ // Check for name filter
+ var filterText = $("#filterText").val();
+ if (filterText != '') {
+ filter += '&filterText=' + encodeURIComponent(filterText).replace(/%20/g,'+');
+ }
+
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" + filter;
+
+ return false;
+ });
+
+ /*
+ * New City Dialog
+ */
+
+ // Setup dialog box for adding a new city
+ $("#newCityDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#newCityCancel').click( function() {
+ $("#newCityDialog").dialog("close");
+ });
+
+ // Ad a new city button action - pop-up dialog
+ $('#newCityButton').click( function() {
+ $("#newCityDialog").dialog("open");
+ });
+
+ // Submit new city
+ var newCityAdded = false;
+ $('#newCitySubmit').click( function() {
+
+ // Get new city name
+ var newCityName = $('#newCityName').val();
+
+ // If no name is supplied, notify used it's required
+ if (newCityName == '') {
+ $('#newCityNameTD').addClass('glm-form-bad-input');
+ $('#newCityNameRequired').text('A city name is required!');
+ return false;
+ }
+
+ // Add new city name to the hidden field that will pass the new name to PHP.
+ $('#cityName').val(newCityName);
+
+ // Add new city name to picklist and for storing - Only one permitted per submission
+ if (newCityAdded) {
+
+ // New city already added, so just update the name and select that one
+ $('#city').val(-1);
+ $('#city option:selected').text(newCityName);
+
+ } else {
+
+ // Add the new city name to the city picklist
+ $('#city').append('<option value="-1">' + newCityName + '</option>');
+ $('#city').val(-1);
+ $('#newCityNameTD').append('<input type="hidden" name="newCity" value="' + newCityName + '">');
+ newCityAdded = true;
+
+ }
+
+ // Clear new city name from form
+ $('#newCityName').val('');
+
+ $("#newCityDialog").dialog("close");
+
+ });
+
+ /*
+ * Large Image Dialog
+ */
+
+ // Setup dialog box for showing enlarged image image
+ x = $('#largeImageDialog').dialog({
+ autoOpen: false,
+ resizable: false,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#largeImageCancel').click( function() {
+ $('#largeImageDialog').dialog("close");
+ });
+
+ // Show large image - pop-up dialog - resize at time of pop-up
+ $('#largeImageButton').click( function() {
+ $("#largeImageDialog").dialog("open");
+ $( "#largesImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
+ var newWidth = $(window).width() * .8;
+ $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
+ });
+
+ // Resize whenever window size changes
+ $(window).resize(function(){
+ $( "#largeImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
+ var newWidth = $(window).width() * .8;
+ $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
+ });
+
+ // Delete Contact dialog
+ $("#deleteContactDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#deleteContactButton').click( function() {
+ $('#deleteContactDialog').dialog('open');
+ });
+ $('#deleteContactCancel').click( function() {
+ $("#deleteContactDialog").dialog("close");
+ });
+ $('#deleteContactSubmit').click( function() {
+ window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=delete&contact={$contactID}");
+ });
+
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+ });
+ </script>
+
+
+{include file='admin/footer.html'}
-{include file='admin/contacts/header.html'}
-
- <form class="glm-right" onSubmit="return false;">
- <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b> </span>
- <input type="checkbox" id="filterArchived" class="listFilter"{if $filterArchived} checked{/if}>Show Archived
-
- <input type="text" id="filterText" class="listFilter" value="{$filterText}"> Search
- </form>
- <h2 class="glm-left">Contacts</h2>
-
- <table class="wp-list-table striped glm-admin-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Active</th>
- <th>Type</th>
- <th>Access</th>
- <th>User</th>
- <th>Entity</th>
- <th>Organization</th>
- <th>Location</th>
- </tr>
- </thead>
- <tbody>
-{if $haveContacts}
- {foreach $contacts as $c}
- <tr>
- <td class="glm-shrink"><a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a></td>
- <td class="glm-shrink">{$c.active.name}</td>
- <td>{$c.contact_type.name}</td>
- <td class="glm-shrink">{$c.access.name}</td>
- <td class="glm-nowrap">{$c.contact_role_short.name}</td>
- <td class="glm-nowrap">
- {$c.ref_type.name}:
- <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=index&member={$c.ref_dest}">{$c.ref_dest_name}</a>
- </td>
- <td class="glm-shrink">{$c.org}</td>
- <td class="glm-shrink">{$c.city.name}, {$c.state.name}</td>
- </tr>
- {/foreach}
+{if $fromMemberMenu}
+ {include file='admin/member/header.html'}
{else}
- <tr class="alternate"><td colspan="2">(no contacts listed)</td></tr>
+ {include file='admin/contacts/header.html'}
{/if}
- </tbody>
- </table>
+ <form action="{$thisUrl}?page={$thisPage}" method="post" id="searchForm">
+ <input type="hidden" name="prevStart" value="{$prevStart}">
+ <input type="hidden" name="nextStart" value="{$nextStart}">
+ <input type="hidden" name="limit" value="{$limit}">
+
+ <div class="glm-right">
+ <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b> </span>
+
+ <span class="glm-nowrap">
+ <b>Text Search: </b><input id="glmContactsSearch" name="filterText" type="text" id="autoTest" value="{$filterText}">
+ <input type="submit" value="Submit">
+ </span>
+ </div>
+
+ <h2 class="glm-left">Contacts</h2>
+
+ <br clear="all">
+
+ <p><b>Total found:</b> {$numbContacts} </p>
+
+ {if $paging}
+ {if $prevStart}<input type="Submit" name="pageSelect" value="Previous {$limit} Contacts" class="button button-secondary glm-button">{/if}
+ {if $nextStart}<input type="Submit" name="pageSelect" value="Next {$limit} Contacts" class="button button-secondary glm-button">{/if}
+ {/if}
+
+ <table class="wp-list-table striped glm-admin-table">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Active</th>
+ <th>Type</th>
+ <th>Access</th>
+ <th>User</th>
+ <th>Entity</th>
+ </tr>
+ </thead>
+ <tbody>
+ {if $haveContacts}
+ {foreach $contactsList as $c}
+ <tr>
+ <td class="glm-shrink">
+ {if $fromMemberMenu}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a>
+ {else}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-contacts&glm_action=index&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a>
+ {/if}
+ </td>
+ <td class="glm-shrink">{$c.active.name}</td>
+ <td>{$c.contact_type.name}</td>
+ <td class="glm-shrink">{$c.access.name}</td>
+ <td class="glm-nowrap">{$c.username}</td>
+ <td class="glm-nowrap">
+ {$c.ref_type.name}:
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=index&member={$c.ref_dest}">{$c.ref_dest_name}</a>
+ </td>
+ </tr>
+ {/foreach}
+ {else}
+ <tr class="alternate"><td colspan="7">(no contacts listed)</td></tr>
+ {/if}
+ </tbody>
+ </table>
+
+ {if $paging}
+ {if $prevStart}<input type="Submit" name="pageSelect" value="Previous {$limit} Contacts" class="button button-secondary glm-button">{/if}
+ {if $nextStart}<input type="Submit" name="pageSelect" value="Next {$limit} Contacts" class="button button-secondary glm-button">{/if}
+ {/if}
+
+ </form>
+
<script type="text/javascript">
jQuery(document).ready(function($) {
+/*
// Filter triggers
$(".listFilter" ).change( function() {
return false;
});
+*/
+
+ /*
+ * Do autocomplete search for member
+ * label: What will be searched
+ * value: What will be displayed when selected
+ * id: Member id added so we can go to the member while showing what was selected
+ * Also note that autocomplete does not properly render HTML codes, so we
+ * "unescape" them for HTML in Smarty.
+ */
+
+ var availableTags = [
+ {foreach $namesList as $e}
+ { label: "{$e.fname|replace:'"':"'"} {$e.lname|replace:'"':"'"} {$e.ref_dest_name|replace:'"':"'"}", value: "{$e.fname|replace:'"':"'"} {$e.lname|replace:'"':"'"}, {$e.ref_dest_name|replace:'"':"'"}", id: '{$e.id}', member: '{$e.ref_dest}' },
+ {/foreach}
+ ];
+
+ $( "#glmContactsSearch" ).autocomplete({
+ source: availableTags,
+ html: true,
+ position: { my : "right top", at: "right bottom" },
+ select: function( event, ui ) {
+ var contactID = ui.item.id;
+ var memberID = ui.item.member;
+ window.location.replace("{$adminUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member=" + memberID + "&contact=" + contactID );
+ },
+ response: function(event, ui) {
+ if (!ui.content.length) {
+ var noResult = { value:"",label:"No results found" };
+ ui.content.push(noResult);
+ }
+ }
+ });
+
});
</script>
{include file='admin/management/header.html'}
{if $errorMsg != false}
- <h2 class="glm-error">Your import failed because ...</h2>
- <p>{$errorMsg}</p>
+ <div style="border: 1px black solid; padding: 1em; margin-top: 2em; width: auto;">
+ <h2 class="glm-error">Your request failed because ...</h2>
+ <p>{$errorMsg}</p>
+ </div>
+ <p> </p>
{/if}
{if $importResult.status}
<h2 class="glm-notice">Contact Import Results</h2>
<table class="glm-admin-table">
+ {if $option == doCsvImport}
+ <tr><th>Number of contacts from supplied CSV file:</th><td>{$importResult.numbContacts}</td></tr>
+ <tr><th>Number of contacts Updated:</th><td>{$importResult.numbContactsUpdated}</td></tr>
+ <tr><th>Number of contacts with WordPress users Updated:</th><td>{$importResult.numbWpUserUpdated}</td></tr>
+ {else}
<tr><th>Number of contacts from old database:</th><td>{$importResult.numbContacts}</td></tr>
+ {/if}
<tr><th>Number of contacts imported:</th><td>{$importResult.numbImported}</td></tr>
<tr><th>Number of contacts with WordPress users created:</th><td>{$importResult.numbWpUsersCreated}</td></tr>
</table>
<a href="{$thisUrl}?page={$thisPage}&glm_action=contacts">Return to Import Events</a>
{else}
- <h2> </th><th>Option 1: Import contacts from legacy site database.</h2>
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="page" value="{$thisPage}">
+ <input type="hidden" name="glm_action" value="contacts">
+ <input type="hidden" name="option" value="clearContacts">
+
+ <h2> </th><th>Clear All Contacts</h2>
+
+ <table id="glm-table-contactImport" class="glm-admin-table glm-settings-table">
+ <tr>
+ <th>Clear Contacts:</th>
+ <td>
+ <input type="checkbox" name="import_clear_contacts">
+ <span class="glm-warning">WARNING: This will permanently delete all existing contacts!</span>
+ </td>
+ </tr>
+ <tr>
+ <th>Confirm:</th>
+ <td>
+ <input type="text" name="clear_contacts_confirm" value="{$db_host}"><br>
+ Type "Please Clear Contacts" here to confirm you want to clear all contacts.
+ </td>
+ </tr>
+ <tr>
+ <th> </th>
+ <td><input type="submit" value="CLick Here to clear ALL contacts"></td>
+ </tr>
+ </table>
+
+ </form>
+
+ <p> </p>
+
+ <h2> </th><th>Import from Gaslight Media Legacy Database</h2>
<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
<input type="hidden" name="page" value="{$thisPage}">
<th>Password:</th>
<td><input type="text" name="db_password" value="{$db_password}"></td>
</tr>
- <tr>
- <th>Clear Contacts before Import:</th>
- <td>
- <input type="checkbox" name="import_clear_contacts">
- <span class="glm-warning">WARNING: This will permanently delete all existing contacts!</span>
- </td>
- </tr>
<tr>
<th> </th>
<td><input type="submit" value="Import Contacts"></td>
<p> </p>
- <h2> </th><th>Option 2: Import contacts from a CSV file.</h2>
+ <h2> </th><th>Import/Update Contacts from CSV File</h2>
<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
<input type="hidden" name="page" value="{$thisPage}">
<tr>
<th> </th>
<td>
- (format specification or link to sample file here)
+ <p>
+ <b>File format must be as follows.</b><br>
+ * Data must follow this header line.<br>
+ * Anything above this line is ignored.<br>
+ * Any line without at least this number of fields is ignored.<br>
+ * Any line with a non-numeric "member_id" is ignored.<br>
+ <pre> 'member_id','member_name','member_login','member_passwd','member_contact_email'</pre>
+ </p>
</td>
</tr>
<tr>
<th>Host:</th>
<td><input type="file" name="csv_file"></td>
</tr>
- <tr>
- <th>Clear Contacts before Import:</th>
- <td>
- <input type="checkbox" name="import_clear_contacts">
- <span class="glm-warning">WARNING: This will permanently delete all existing contacts!</span>
- </td>
- </tr>
<tr>
<th> </th>
<td><input type="submit" value="Import Contacts"></td>
--- /dev/null
+{include file='admin/member/header.html'}
+
+{if $userDeleted}
+ <h3><span class="glm-warning">Contact Deleted:</span></h3>
+ <ul class="glm-li">
+ {if $wpUserDeleted}
+ <li>The associated system user was also removed.</li>
+ {else}
+ <li>Other roles were assigned to the associated system user so that system user has not been removed.</li>
+ {/if}
+ </ul>
+{/if}
+
+{if $haveMember}
+ {if $option == 'list'}
+
+ {if apply_filters('glm_members_permit_admin_member_contacts_add_contact', true)}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=create" class="button button-primary glm-button glm-right">Add New {$terms.term_member_cap} Contact</a>
+ {/if}
+ <form class="glm-right" onSubmit="return false;">
+ <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b> </span>
+ <input type="checkbox" id="filterArchived" class="listFilter"{if $filterArchived} checked{/if}>Show Archived
+
+ <input type="text" id="filterText" class="listFilter" value="{$filterText}"> Search
+
+ </form>
+ <p> </p>
+ <table class="wp-list-table striped glm-admin-table">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Active</th>
+ <th>Type</th>
+ <th>Access</th>
+ <th>User</th>
+ <th>Contact For</th>
+ <th>Organization</th>
+ <th>Location</th>
+ </tr>
+ </thead>
+ <tbody>
+{if $haveContacts}
+ {foreach $contacts as $c}
+ <tr>
+ <td class="glm-shrink">
+ {if apply_filters('glm_members_permit_admin_member_contacts_view_contact', true)}
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a>
+ {else}
+ {$c.lname}, {$c.fname}
+ {/if}
+ </td>
+ <td class="glm-shrink">{$c.active.name}</td>
+ <td>{$c.contact_type.name}</td>
+ <td class="glm-shrink">{$c.access.name}</td>
+ <td class="glm-nowrap">{$c.contact_role_short.name}</td>
+ <td class="glm-nowrap">{$c.ref_type.name} - {$c.ref_dest_name}</td>
+ <td class="glm-shrink">{$c.org}</td>
+ <td class="glm-shrink">{$c.city.name}, {$c.state.name}</td>
+ </tr>
+ {/foreach}
+{else}
+ <tr class="alternate"><td colspan="2">(no contacts listed)</td></tr>
+{/if}
+ </tbody>
+ </table>
+
+<!-- Check for invalid contact ID to edit -->
+ {elseif $option == 'edit' && !$contactID}
+
+ <h3><span class="glm-error">ERROR:</span> Specified contact not found!</h3>
+
+ {elseif $newContactExists}
+
+ <h4><span class="glm-warning">NOTE:</span> The Email address or username for this contact is already in use. Please check if they already are a contact in this system.</h3>
+
+ {elseif $misMatchedWpUsers}
+
+ <h3>
+ <span class="glm-warning">NOTE:</span>
+ 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.
+ </h3>
+
+ {elseif $newContactCreated}
+
+ <h3><span class="glm-warning">New Contact Created:</span> {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}</h3>
+ {if $usernameChangedToWP || $usingExistingWPContact}
+ <h3><span class="glm-notice">NOTE:</span></h3>
+ <ul class="glm-li">
+ {/if}
+ {if $usingExistingWPContact}
+ <li>An existing system user was found with the same Email address. This contact will be associated with that system user. </li>
+ <li>The password of the existing system user was not updated. The system user will continue to use their existing password.</li>
+ {/if}
+ {if $usernameChangedToWP}
+ <li>The username was changed to match the username of the system user found with the specified Email address.</li>
+ <li>The username for this contact is: <span class="glm-notice">{$contactInfo.fieldData.username}</span></li>
+ {/if}
+ {if $usernameChangedToWP || $usingExistingWPContact}
+ </ul>
+ {/if}
+
+ {else} <!-- !$option -->
+
+
+ {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)}
+
+ {if $option == 'create' || $option == 'edit'}
+
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" class="button button-primary glm-button glm-right">Return to Contact List</a>
+
+ {if $option == 'create'}
+ <h2 class="glm-left">Add New Contact</h2>
+ {else}
+ {if $contactUpdated}<h2 class="glm-notice glm-flash-updated">Contact Updated</h2>{/if}
+ <a id="deleteContactButton" class="button button-primary glm-button glm-right">Delete this Contact</a>
+ <div id="deleteContactDialog" class="glm-dialog-box" title="Delete Contact">
+ <center>
+ <p><a id="deleteContactCancel" class="button button-primary">Cancel</a></p>
+ <p><input id="deleteContactSubmit" type="submit" value="Delete this contact"></p>
+ </center>
+ <div class="glm-item-container">
+ <p><center><span class="glm-error">WARNING:</span></center></p>
+ <p>
+ <span class="glm-warning">Clicking the "Delete this Contact" button above will
+ delete all of the data and images associated with this contact.
+ </span>
+ </p>
+ <p>
+ <span class="glm-error">Once deleted, this information will no longer be available and cannot be retrieved!</span>
+ </p>
+ </div>
+ <p>
+ 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.
+ </p>
+ </div>
+ <h2 class="glm-left">Edit Contact</h2>
+ {/if}
+
+
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="contacts">
+ <input type="hidden" name="member" value="{$memberData.id}">
+ {if $option == 'create'}
+ <input type="hidden" name="option" value="addNew">
+ <input type="hidden" name="create_time" value="now">
+ <input type="hidden" name="ref_type" value="{$refType}">
+ <input type="hidden" name="ref_dest" value="{$memberData.id}">
+ {else}
+ <input type="hidden" name="option" value="submit">
+ <input type="hidden" name="contact" value="{$contactInfo.fieldData.id}">
+ <input type="hidden" name="id" value="{$contactInfo.fieldData.id}">
+ <input type="hidden" name="modify_time" value="now">
+ {/if}
+
+ <table class="glm-admin-table glm-shrink">
+ <tr>
+ <th>Contact For:</th>
+ <td>{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}</td>
+ </tr>
+ <tr>
+ <th>Active:</th>
+ <td>
+ <input type="checkbox" name="active" {if $contactInfo.fieldData.active.value} checked{/if}>
+ </td>
+ </tr>
+ {if $option != 'create'}
+ <tr>
+ <th>Created:</th>
+ <td>{$contactInfo.fieldData.create_time.datetime}</td>
+ </tr>
+ <tr>
+ <th>Last Updated:</th>
+ <td>{$contactInfo.fieldData.modify_time.datetime}</td>
+ </tr>
+ {/if}
+ <tr>
+ <th {if $contactInfo.fieldRequired.fname}class="glm-required"{/if}>First Name:</th>
+ <td {if $contactInfo.fieldFail.fname}class="glm-form-bad-input"{/if}>
+ <input type="text" name="fname" value="{$contactInfo.fieldData.fname}" class="glm-form-text-input-short">
+ {if $contactInfo.fieldFail.fname}<p>{$contactInfo.fieldFail.fname}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.lname}class="glm-required"{/if}>Last Name:</th>
+ <td {if $contactInfo.fieldFail.lname}class="glm-form-bad-input"{/if}>
+ <input type="text" name="lname" value="{$contactInfo.fieldData.lname}" class="glm-form-text-input-short">
+ {if $contactInfo.fieldFail.lname}<p>{$contactInfo.fieldFail.lname}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.contact_type}class="glm-required"{/if}>Contact Type:</th>
+ <td {if $contactInfo.fieldFail.contact_type}class="glm-form-bad-input"{/if}>
+ <select name="contact_type">
+ {foreach from=$contactInfo.fieldData.contact_type.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.contact_type}<p>{$contactInfo.fieldFail.contact_type}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.contact_role}class="glm-required"{/if}>Permissions:</th>
+ <td {if $contactInfo.fieldFail.contact_role}class="glm-form-bad-input"{/if}>
+ <select name="contact_role">
+ {foreach from=$contactInfo.fieldData.contact_role.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.contact_role}<p>{$contactInfo.fieldFail.contact_role}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.access}class="glm-required"{/if}>Display/Moderate/Archive:</th>
+ <td {if $contactInfo.fieldFail.access}class="glm-form-bad-input"{/if}>
+ <select name="access">
+ {foreach from=$contactInfo.fieldData.access.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.access}<p>{$contactInfo.fieldFail.access}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ {if $option == 'create'}
+ <th {if $contactInfo.fieldRequired.email}class="glm-required"{/if}>Email Address:</th>
+ <td {if $contactInfo.fieldFail.email}class="glm-form-bad-input"{/if}>
+ <input type="text" name="email" value="{$contactInfo.fieldData.email}" class="glm-form-text-input-medium" placeholder="(ex: name@domain.com)">
+ <br><span class="glm-notice">NOTE:</span> This field is required for users who will have login privileges.
+ {if $contactInfo.fieldFail.email}<p>{$contactInfo.fieldFail.email}</p>{/if}
+ </td>
+ {else}
+ <th>Email Address::</th>
+ <td>{$contactInfo.fieldData.email}</td>
+ {/if}
+ </tr>
+ <tr>
+
+ {if $option == 'create'}
+ <th {if $contactInfo.fieldRequired.username}class="glm-required"{/if}>Login Username:</th>
+ <td {if $contactInfo.fieldFail.username}class="glm-form-bad-input"{/if}>
+ <input type="text" name="username" value="{$contactInfo.fieldData.username}" class="glm-form-text-input-medium" placeholder="(no spaces permitted)">
+ <br><span class="glm-notice">NOTE:</span> The username cannot be changed once the contact is created.
+ {if $contactInfo.fieldFail.username}<p>{$contactInfo.fieldFail.username}</p>{/if}
+ </td>
+ {else}
+ <th>Login Username:</th>
+ <td>{$contactInfo.fieldData.username}</td>
+ {/if}
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.password}class="glm-required"{/if}>Login password:</th>
+ <td {if $contactInfo.fieldFail.password}class="glm-form-bad-input"{/if}>
+ <input type="text" name="password" value="{$contactInfo.fieldData.password}" class="glm-form-text-input-medium" placeholder="{if $option=='create'}(no spaces permitted){else}(Password does not show, only enter to change password.){/if}">
+ {if $option == 'create'}
+ <span class="glm-notice">Save this password.</span>
+ <br>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}
+ <br>NOTE: Enter a password here <b><i>only</i></b> if you need to change it.
+ {/if}
+ <br>The password must be at least 8 characters and include at least one number, one letter, and at least one
+ special character. (# . - _ , $ % & !)</b>
+ {if $contactInfo.fieldFail.password}<p>{$contactInfo.fieldFail.password}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.alt_email}class="glm-required"{/if}>Alternate Email Address:</th>
+ <td {if $contactInfo.fieldFail.alt_email}class="glm-form-bad-input"{/if}>
+ <input type="text" name="alt_email" value="{$contactInfo.fieldData.alt_email}" class="glm-form-text-input-short" placeholder="ex: name@domain.com">
+ {if $contactInfo.fieldFail.alt_email}<p>{$contactInfo.fieldFail.alt_email}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.org}class="glm-required"{/if}>Organization:</th>
+ <td {if $contactInfo.fieldFail.org}class="glm-form-bad-input"{/if}>
+ <input type="text" name="org" value="{$contactInfo.fieldData.org}" class="glm-form-text-input-medium">
+ {if $contactInfo.fieldFail.org}<p>{$contactInfo.fieldFail.org}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.title}class="glm-required"{/if}>Title/Position:</th>
+ <td {if $contactInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
+ <input type="text" name="title" value="{$contactInfo.fieldData.title}" class="glm-form-text-input-medium">
+ {if $contactInfo.fieldFail.title}<p>{$contactInfo.fieldFail.title}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.descr}class="glm-required"{/if}>Position/Responsibilities:</th>
+ <td {if $contactInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
+ {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}<p>{$contactInfo.fieldFail.descr}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.image}class="glm-required"{/if}>Image:</th>
+ <td {if $contactInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
+ {if $contactInfo.fieldData.image}
+ <div id="largeImageDialog" class="glm-dialog-box" title="Large sized image">
+ <img src="{$glmPluginMediaUrl}/images/large/{$contactInfo.fieldData.image}">
+ <a id="largeImageCancel" class="button button-primary glm-right">Close</a><br>
+ </div>
+ <table class="glm-admin-image-edit-table">
+ <tr>
+ <td><img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}"></td>
+ <td>
+ <input type="checkbox" name="image_delete"> Delete Image<br>
+ {$contactInfo.fieldData.image}<br>
+ <p><div id="largeImageButton" class="button button-primary">Show Large Image</div></p>
+ </td>
+
+ </tr>
+ </table>
+ {/if}
+ <input type="file" name="image_new">
+ {if $contactInfo.fieldFail.image}<p>{$contactInfo.fieldFail.image}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.addr1}class="glm-required"{/if}>Address Line 1:</th>
+ <td {if $contactInfo.fieldFail.addr1}class="glm-form-bad-input"{/if}>
+ <input type="text" id="addr1" name="addr1" value="{$contactInfo.fieldData.addr1}" class="glm-form-text-input glm-geocodeAction">
+ {if $contactInfo.fieldFail.addr1}<p>{$contactInfo.fieldFail.addr1}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.addr2}class="glm-required"{/if}>Address Line 2:</th>
+ <td {if $contactInfo.fieldFail.addr2}class="glm-form-bad-input"{/if}>
+ <input id="addr2" type="text" name="addr2" value="{$contactInfo.fieldData.addr2}" class="glm-form-text-input glm-geocodeAction">
+ {if $contactInfo.fieldFail.addr2}<p>{$contactInfo.fieldFail.addr2}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th>City</th>
+ <td class="glm-item-container">
+ <!-- Add new city dialog -->
+ <div id="newCityButton" class="button button-secondary glm-right">Add a new City</div>
+ <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
+ <table class="glm-admin-table">
+ <tr>
+ <th class="glm-required">City Name:</th>
+ <td id="newCityNameTD">
+ <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
+ <div id="newCityNameRequired"></div>
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
+ <input id="newCitySubmit" type="submit" value="Add new City">
+ </div>
+ <!-- City Selection -->
+ <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
+ <select name="city" id="city" class="glm-geocodeAction">
+ <option value="0"><option>
+ {foreach from=$contactInfo.fieldData.city.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.state}class="glm-required"{/if}>State:</th>
+ <td {if $contactInfo.fieldFail.state}class="glm-form-bad-input"{/if}>
+ <select id="state" name="state" class="glm-geocodeAction">
+ {foreach from=$contactInfo.fieldData.state.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.state}<p>{$contactInfo.fieldFail.state}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.zip}class="glm-required"{/if}>ZIP / Postal Code:</th>
+ <td {if $contactInfo.fieldFail.zip}class="glm-form-bad-input"{/if}>
+ <input id="zip" type="text" name="zip" value="{$contactInfo.fieldData.zip}" class="glm-form-text-input-short glm-geocodeAction">
+ {if $contactInfo.fieldFail.zip}<p>{$contactInfo.fieldFail.zip}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.country}class="glm-required"{/if}>Country:</th>
+ <td {if $contactInfo.fieldFail.country}class="glm-form-bad-input"{/if}>
+ <select id="country" name="country" class="glm-geocodeAction">
+ {foreach from=$contactInfo.fieldData.country.list item=v}
+ <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+ {$v.name} {$v.value}
+ </option>
+ {/foreach}
+ </select>
+ {if $contactInfo.fieldFail.country}<p>{$contactInfo.fieldFail.country}</p>{/if}
+ </td>
+ </tr>
+ <!-- NOT DOING LAT/LON FOR NOW -->
+ <tr>
+ <th {if $contactInfo.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
+ <td {if $contactInfo.fieldFail.url}class="glm-form-bad-input"{/if}>
+ {if $contactInfo.fieldData.url}
+ <a class="button button-secondary glm-right" href="http://{$contactInfo.fieldData.url}" target="urlTarget">Test Link</a>
+ {/if}
+ http://<input type="text" name="url" value="{$contactInfo.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: www.gaslightmedia.com">
+ {if $contactInfo.fieldFail.url}<p>{$contactInfo.fieldFail.url}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.office_phone}class="glm-required"{/if}>Office Phone #:</th>
+ <td {if $contactInfo.fieldFail.office_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="office_phone" value="{$contactInfo.fieldData.office_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.office_phone}<p>{$contactInfo.fieldFail.office_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.home_phone}class="glm-required"{/if}>Home Phone #:</th>
+ <td {if $contactInfo.fieldFail.home_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="home_phone" value="{$contactInfo.fieldData.home_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.home_phone}<p>{$contactInfo.fieldFail.home_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.mobile_phone}class="glm-required"{/if}>Mobile Phone #:</th>
+ <td {if $contactInfo.fieldFail.mobile_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="mobile_phone" value="{$contactInfo.fieldData.mobile_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.mobile_phone}<p>{$contactInfo.fieldFail.mobile_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.alt_phone}class="glm-required"{/if}>Alternate Phone #:</th>
+ <td {if $contactInfo.fieldFail.alt_phone}class="glm-form-bad-input"{/if}>
+ <input type="text" name="alt_phone" value="{$contactInfo.fieldData.alt_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.alt_phone}<p>{$contactInfo.fieldFail.alt_phone}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.fax}class="glm-required"{/if}>FAX #:</th>
+ <td {if $contactInfo.fieldFail.fax}class="glm-form-bad-input"{/if}>
+ <input type="text" name="fax" value="{$contactInfo.fieldData.fax}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
+ {if $contactInfo.fieldFail.fax}<p>{$contactInfo.fieldFail.fax}</p>{/if}
+ </td>
+ </tr>
+ <tr>
+ <th {if $contactInfo.fieldRequired.notes}class="glm-required"{/if}>Notes:</th>
+ <td {if $contactInfo.fieldFail.notes}class="glm-form-bad-input"{/if}>
+ {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}<p>{$contactInfo.fieldFail.notes}</p>{/if}
+ </td>
+ </tr>
+ </table>
+ <p><span class="glm-required">*</span> Required</p>
+ <input id="updateContact" type="submit" value="{if $contactID && $contactInfo}Update contact{else}Add new contact{/if}">
+ </form>
+
+ {/if}
+
+ {else} <!-- may edit contact -->
+
+ <table class="glm-admin-table glm-shrink">
+ <tr><th>Contact For:</th><td>{$contactInfo.fieldData.ref_type.name} - {$memberData.name}</td></tr>
+ <tr><th>Active:</th><td>{$contactInfo.fieldData.active.name}</td></tr>
+ <tr><th>Created:</th><td>{$contactInfo.fieldData.create_time.datetime}</td></tr>
+ <tr><th>Last Updated:</th><td>{$contactInfo.fieldData.modify_time.datetime}</td></tr>
+ <tr><th>First Name:</th><td>{$contactInfo.fieldData.fname}</td></tr>
+ <tr><th>Last Name:</th><td>{$contactInfo.fieldData.lname}</td></tr>
+ <tr><th>Contact Type:</th><td>{$contactInfo.fieldData.contact_type.name}</td></tr>
+ <tr><th>Email Address::</th><td>{$contactInfo.fieldData.email}</td></tr>
+ <tr><th>Alternate Email Address:</th><td>{$contactInfo.fieldData.alt_email}</td></tr>
+ <tr><th>Organization:</th><td>{$contactInfo.fieldData.org}</td></tr>
+ <tr><th>Title/Position:</th><td>{$contactInfo.fieldData.title}</td></tr>
+ <tr><th>Position/Responsibilities:</th><td>{$contactInfo.fieldData.descr}</td></tr>
+ <tr>
+ <th>Image:</th>
+ <td>
+ {if $contactInfo.fieldData.image}
+ <img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}">
+ {/if}
+ </td>
+ </tr>
+ <tr><th>Address Line 1:</th><td>{$contactInfo.fieldData.addr1}</td></tr>
+ <tr><th>Address Line 2:</th><td>{$contactInfo.fieldData.addr2}</td></tr>
+ <tr><th>City</th><td>{$contactInfo.fieldData.city.name}</td></tr>
+ <tr><th>State:</th><td>{$contactInfo.fieldData.state.name}</td></tr>
+ <tr><th>ZIP / Postal Code:</th><td>{$contactInfo.fieldData.zip}</td></tr>
+ <tr><th>Country:</th><td>{$contactInfo.fieldData.country.name}</td></tr>
+ <tr>
+ <th>Web Address (URL):</th>
+ <td>
+ {if $contactInfo.fieldData.url}
+ <a href="http://{$contactInfo.fieldData.url}" target="urlTarget">{$contactInfo.fieldData.url}</a>
+ {/if}
+ </td>
+ </tr>
+ <tr><th>Office Phone #:</th><td>{$contactInfo.fieldData.office_phone}</td></tr>
+ <tr><th>Home Phone #:</th><td>{$contactInfo.fieldData.home_phone}</td></tr>
+ <tr><th>Mobile Phone #:</th><td>{$contactInfo.fieldData.mobile_phone}</td></tr>
+ <tr><th>Alternate Phone #:</th><td>{$contactInfo.fieldData.alt_phone}</td></tr>
+ <tr><th>FAX #:</th><td>{$contactInfo.fieldData.fax}</td></tr>
+ <tr><th>Notes:</th><td>{$contactInfo.fieldData.notes}</td></tr>
+ </table>
+ {/if} <!-- mey edit contact -->
+
+ {/if} <!-- /if option -->
+
+{else} <!-- Member not specified or not found -->
+ <h2 class="glm-error">No current {$terms.term_member}.</h2>
+{/if}
+
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ // Filter triggers
+ $(".listFilter" ).change( function() {
+
+ var filter = '';
+
+ // Check for archived filter
+ if ($("#filterArchived").attr('checked')) {
+ filter += '&filterArchived=true';
+ }
+
+ // Check for name filter
+ var filterText = $("#filterText").val();
+ if (filterText != '') {
+ filter += '&filterText=' + encodeURIComponent(filterText).replace(/%20/g,'+');
+ }
+
+ window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" + filter;
+
+ return false;
+ });
+
+ /*
+ * New City Dialog
+ */
+
+ // Setup dialog box for adding a new city
+ $("#newCityDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#newCityCancel').click( function() {
+ $("#newCityDialog").dialog("close");
+ });
+
+ // Ad a new city button action - pop-up dialog
+ $('#newCityButton').click( function() {
+ $("#newCityDialog").dialog("open");
+ });
+
+ // Submit new city
+ var newCityAdded = false;
+ $('#newCitySubmit').click( function() {
+
+ // Get new city name
+ var newCityName = $('#newCityName').val();
+
+ // If no name is supplied, notify used it's required
+ if (newCityName == '') {
+ $('#newCityNameTD').addClass('glm-form-bad-input');
+ $('#newCityNameRequired').text('A city name is required!');
+ return false;
+ }
+
+ // Add new city name to the hidden field that will pass the new name to PHP.
+ $('#cityName').val(newCityName);
+
+ // Add new city name to picklist and for storing - Only one permitted per submission
+ if (newCityAdded) {
+
+ // New city already added, so just update the name and select that one
+ $('#city').val(-1);
+ $('#city option:selected').text(newCityName);
+
+ } else {
+
+ // Add the new city name to the city picklist
+ $('#city').append('<option value="-1">' + newCityName + '</option>');
+ $('#city').val(-1);
+ $('#newCityNameTD').append('<input type="hidden" name="newCity" value="' + newCityName + '">');
+ newCityAdded = true;
+
+ }
+
+ // Clear new city name from form
+ $('#newCityName').val('');
+
+ $("#newCityDialog").dialog("close");
+
+ });
+
+ /*
+ * Large Image Dialog
+ */
+
+ // Setup dialog box for showing enlarged image image
+ x = $('#largeImageDialog').dialog({
+ autoOpen: false,
+ resizable: false,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#largeImageCancel').click( function() {
+ $('#largeImageDialog').dialog("close");
+ });
+
+ // Show large image - pop-up dialog - resize at time of pop-up
+ $('#largeImageButton').click( function() {
+ $("#largeImageDialog").dialog("open");
+ $( "#largesImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
+ var newWidth = $(window).width() * .8;
+ $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
+ });
+
+ // Resize whenever window size changes
+ $(window).resize(function(){
+ $( "#largeImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
+ var newWidth = $(window).width() * .8;
+ $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
+ });
+
+ // Delete Contact dialog
+ $("#deleteContactDialog").dialog({
+ autoOpen: false,
+ minWidth: 400,
+ dialogClass: "glm-dialog-no-close"
+ });
+ $('#deleteContactButton').click( function() {
+ $('#deleteContactDialog').dialog('open');
+ });
+ $('#deleteContactCancel').click( function() {
+ $("#deleteContactDialog").dialog("close");
+ });
+ $('#deleteContactSubmit').click( function() {
+ window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=delete&contact={$contactID}");
+ });
+
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+ });
+ </script>
+
+
+{include file='admin/footer.html'}
+++ /dev/null
-{include file='admin/member/header.html'}
-
-{if $userDeleted}
- <h3><span class="glm-warning">Contact Deleted:</span></h3>
- <ul class="glm-li">
- {if $wpUserDeleted}
- <li>The associated system user was also removed.</li>
- {else}
- <li>Other roles were assigned to the associated system user so that system user has not been removed.</li>
- {/if}
- </ul>
-{/if}
-
-{if $haveMember}
- {if $option == 'list'}
-
- {if apply_filters('glm_members_permit_admin_member_contacts_add_contact', true)}
- <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=create" class="button button-primary glm-button glm-right">Add New {$terms.term_member_cap} Contact</a>
- {/if}
- <form class="glm-right" onSubmit="return false;">
- <span{if $haveFilter} class="glm-notice"{/if}><b>List Filters:</b> </span>
- <input type="checkbox" id="filterArchived" class="listFilter"{if $filterArchived} checked{/if}>Show Archived
-
- <input type="text" id="filterText" class="listFilter" value="{$filterText}"> Search
-
- </form>
- <p> </p>
- <table class="wp-list-table striped glm-admin-table">
- <thead>
- <tr>
- <th>Name</th>
- <th>Active</th>
- <th>Type</th>
- <th>Access</th>
- <th>User</th>
- <th>Contact For</th>
- <th>Organization</th>
- <th>Location</th>
- </tr>
- </thead>
- <tbody>
-{if $haveContacts}
- {foreach $contacts as $c}
- <tr>
- <td class="glm-shrink">
- {if apply_filters('glm_members_permit_admin_member_contacts_view_contact', true)}
- <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a>
- {else}
- {$c.lname}, {$c.fname}
- {/if}
- </td>
- <td class="glm-shrink">{$c.active.name}</td>
- <td>{$c.contact_type.name}</td>
- <td class="glm-shrink">{$c.access.name}</td>
- <td class="glm-nowrap">{$c.contact_role_short.name}</td>
- <td class="glm-nowrap">{$c.ref_type.name} - {$c.ref_dest_name}</td>
- <td class="glm-shrink">{$c.org}</td>
- <td class="glm-shrink">{$c.city.name}, {$c.state.name}</td>
- </tr>
- {/foreach}
-{else}
- <tr class="alternate"><td colspan="2">(no contacts listed)</td></tr>
-{/if}
- </tbody>
- </table>
-
-<!-- Check for invalid contact ID to edit -->
- {elseif $option == 'edit' && !$contactID}
-
- <h3><span class="glm-error">ERROR:</span> Specified contact not found!</h3>
-
- {elseif $newContactExists}
-
- <h4><span class="glm-warning">NOTE:</span> The Email address or username for this contact is already in use. Please check if they already are a contact in this system.</h3>
-
- {elseif $misMatchedWpUsers}
-
- <h3>
- <span class="glm-warning">NOTE:</span>
- 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.
- </h3>
-
- {elseif $newContactCreated}
-
- <h3><span class="glm-warning">New Contact Created:</span> {$contactInfo.fieldData.fname} {$contactInfo.fieldData.lname} - {$contactInfo.fieldData.email}</h3>
- {if $usernameChangedToWP || $usingExistingWPContact}
- <h3><span class="glm-notice">NOTE:</span></h3>
- <ul class="glm-li">
- {/if}
- {if $usingExistingWPContact}
- <li>An existing system user was found with the same Email address. This contact will be associated with that system user. </li>
- <li>The password of the existing system user was not updated. The system user will continue to use their existing password.</li>
- {/if}
- {if $usernameChangedToWP}
- <li>The username was changed to match the username of the system user found with the specified Email address.</li>
- <li>The username for this contact is: <span class="glm-notice">{$contactInfo.fieldData.username}</span></li>
- {/if}
- {if $usernameChangedToWP || $usingExistingWPContact}
- </ul>
- {/if}
-
- {else} <!-- !$option -->
-
-
- {if apply_filters('glm_members_permit_admin_member_contacts_edit_contact', true)}
-
- {if $option == 'create' || $option == 'edit'}
-
- <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" class="button button-primary glm-button glm-right">Return to Contact List</a>
-
- {if $option == 'create'}
- <h2 class="glm-left">Add New Contact</h2>
- {else}
- {if $contactUpdated}<h2 class="glm-notice glm-flash-updated">Contact Updated</h2>{/if}
- <a id="deleteContactButton" class="button button-primary glm-button glm-right">Delete this Contact</a>
- <div id="deleteContactDialog" class="glm-dialog-box" title="Delete Contact">
- <center>
- <p><a id="deleteContactCancel" class="button button-primary">Cancel</a></p>
- <p><input id="deleteContactSubmit" type="submit" value="Delete this contact"></p>
- </center>
- <div class="glm-item-container">
- <p><center><span class="glm-error">WARNING:</span></center></p>
- <p>
- <span class="glm-warning">Clicking the "Delete this Contact" button above will
- delete all of the data and images associated with this contact.
- </span>
- </p>
- <p>
- <span class="glm-error">Once deleted, this information will no longer be available and cannot be retrieved!</span>
- </p>
- </div>
- <p>
- 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.
- </p>
- </div>
- <h2 class="glm-left">Edit Contact</h2>
- {/if}
-
-
- <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
- <input type="hidden" name="glm_action" value="contacts">
- <input type="hidden" name="member" value="{$memberData.id}">
- {if $option == 'create'}
- <input type="hidden" name="option" value="addNew">
- <input type="hidden" name="create_time" value="now">
- <input type="hidden" name="ref_type" value="{$refType}">
- <input type="hidden" name="ref_dest" value="{$memberData.id}">
- {else}
- <input type="hidden" name="option" value="submit">
- <input type="hidden" name="contact" value="{$contactInfo.fieldData.id}">
- <input type="hidden" name="id" value="{$contactInfo.fieldData.id}">
- <input type="hidden" name="modify_time" value="now">
- {/if}
-
- <table class="glm-admin-table glm-shrink">
- <tr>
- <th>Contact For:</th>
- <td>{if $option=='create'}{$refTypeName}{else}{$contactInfo.fieldData.ref_type.name}{/if} - {$memberData.name}</td>
- </tr>
- <tr>
- <th>Active:</th>
- <td>
- <input type="checkbox" name="active" {if $contactInfo.fieldData.active.value} checked{/if}>
- </td>
- </tr>
- {if $option != 'create'}
- <tr>
- <th>Created:</th>
- <td>{$contactInfo.fieldData.create_time.datetime}</td>
- </tr>
- <tr>
- <th>Last Updated:</th>
- <td>{$contactInfo.fieldData.modify_time.datetime}</td>
- </tr>
- {/if}
- <tr>
- <th {if $contactInfo.fieldRequired.fname}class="glm-required"{/if}>First Name:</th>
- <td {if $contactInfo.fieldFail.fname}class="glm-form-bad-input"{/if}>
- <input type="text" name="fname" value="{$contactInfo.fieldData.fname}" class="glm-form-text-input-short">
- {if $contactInfo.fieldFail.fname}<p>{$contactInfo.fieldFail.fname}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.lname}class="glm-required"{/if}>Last Name:</th>
- <td {if $contactInfo.fieldFail.lname}class="glm-form-bad-input"{/if}>
- <input type="text" name="lname" value="{$contactInfo.fieldData.lname}" class="glm-form-text-input-short">
- {if $contactInfo.fieldFail.lname}<p>{$contactInfo.fieldFail.lname}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.contact_type}class="glm-required"{/if}>Contact Type:</th>
- <td {if $contactInfo.fieldFail.contact_type}class="glm-form-bad-input"{/if}>
- <select name="contact_type">
- {foreach from=$contactInfo.fieldData.contact_type.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- {if $contactInfo.fieldFail.contact_type}<p>{$contactInfo.fieldFail.contact_type}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.contact_role}class="glm-required"{/if}>Permissions:</th>
- <td {if $contactInfo.fieldFail.contact_role}class="glm-form-bad-input"{/if}>
- <select name="contact_role">
- {foreach from=$contactInfo.fieldData.contact_role.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- {if $contactInfo.fieldFail.contact_role}<p>{$contactInfo.fieldFail.contact_role}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.access}class="glm-required"{/if}>Display/Moderate/Archive:</th>
- <td {if $contactInfo.fieldFail.access}class="glm-form-bad-input"{/if}>
- <select name="access">
- {foreach from=$contactInfo.fieldData.access.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
- {/foreach}
- </select>
- {if $contactInfo.fieldFail.access}<p>{$contactInfo.fieldFail.access}</p>{/if}
- </td>
- </tr>
- <tr>
- {if $option == 'create'}
- <th {if $contactInfo.fieldRequired.email}class="glm-required"{/if}>Email Address:</th>
- <td {if $contactInfo.fieldFail.email}class="glm-form-bad-input"{/if}>
- <input type="text" name="email" value="{$contactInfo.fieldData.email}" class="glm-form-text-input-medium" placeholder="(ex: name@domain.com)">
- <br><span class="glm-notice">NOTE:</span> This field is required for users who will have login privileges.
- {if $contactInfo.fieldFail.email}<p>{$contactInfo.fieldFail.email}</p>{/if}
- </td>
- {else}
- <th>Email Address::</th>
- <td>{$contactInfo.fieldData.email}</td>
- {/if}
- </tr>
- <tr>
-
- {if $option == 'create'}
- <th {if $contactInfo.fieldRequired.username}class="glm-required"{/if}>Login Username:</th>
- <td {if $contactInfo.fieldFail.username}class="glm-form-bad-input"{/if}>
- <input type="text" name="username" value="{$contactInfo.fieldData.username}" class="glm-form-text-input-medium" placeholder="(no spaces permitted)">
- <br><span class="glm-notice">NOTE:</span> The username cannot be changed once the contact is created.
- {if $contactInfo.fieldFail.username}<p>{$contactInfo.fieldFail.username}</p>{/if}
- </td>
- {else}
- <th>Login Username:</th>
- <td>{$contactInfo.fieldData.username}</td>
- {/if}
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.password}class="glm-required"{/if}>Login password:</th>
- <td {if $contactInfo.fieldFail.password}class="glm-form-bad-input"{/if}>
- <input type="text" name="password" value="{$contactInfo.fieldData.password}" class="glm-form-text-input-medium" placeholder="{if $option=='create'}(no spaces permitted){else}(Password does not show, only enter to change password.){/if}">
- {if $option == 'create'}
- <span class="glm-notice">Save this password.</span>
- <br>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}<p>{$contactInfo.fieldFail.password}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.alt_email}class="glm-required"{/if}>Alternate Email Address:</th>
- <td {if $contactInfo.fieldFail.alt_email}class="glm-form-bad-input"{/if}>
- <input type="text" name="alt_email" value="{$contactInfo.fieldData.alt_email}" class="glm-form-text-input-short" placeholder="ex: name@domain.com">
- {if $contactInfo.fieldFail.alt_email}<p>{$contactInfo.fieldFail.alt_email}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.org}class="glm-required"{/if}>Organization:</th>
- <td {if $contactInfo.fieldFail.org}class="glm-form-bad-input"{/if}>
- <input type="text" name="org" value="{$contactInfo.fieldData.org}" class="glm-form-text-input-medium">
- {if $contactInfo.fieldFail.org}<p>{$contactInfo.fieldFail.org}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.title}class="glm-required"{/if}>Title/Position:</th>
- <td {if $contactInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
- <input type="text" name="title" value="{$contactInfo.fieldData.title}" class="glm-form-text-input-medium">
- {if $contactInfo.fieldFail.title}<p>{$contactInfo.fieldFail.title}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.descr}class="glm-required"{/if}>Position/Responsibilities:</th>
- <td {if $contactInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
- {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}<p>{$contactInfo.fieldFail.descr}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.image}class="glm-required"{/if}>Image:</th>
- <td {if $contactInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
- {if $contactInfo.fieldData.image}
- <div id="largeImageDialog" class="glm-dialog-box" title="Large sized image">
- <img src="{$glmPluginMediaUrl}/images/large/{$contactInfo.fieldData.image}">
- <a id="largeImageCancel" class="button button-primary glm-right">Close</a><br>
- </div>
- <table class="glm-admin-image-edit-table">
- <tr>
- <td><img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}"></td>
- <td>
- <input type="checkbox" name="image_delete"> Delete Image<br>
- {$contactInfo.fieldData.image}<br>
- <p><div id="largeImageButton" class="button button-primary">Show Large Image</div></p>
- </td>
-
- </tr>
- </table>
- {/if}
- <input type="file" name="image_new">
- {if $contactInfo.fieldFail.image}<p>{$contactInfo.fieldFail.image}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.addr1}class="glm-required"{/if}>Address Line 1:</th>
- <td {if $contactInfo.fieldFail.addr1}class="glm-form-bad-input"{/if}>
- <input type="text" id="addr1" name="addr1" value="{$contactInfo.fieldData.addr1}" class="glm-form-text-input glm-geocodeAction">
- {if $contactInfo.fieldFail.addr1}<p>{$contactInfo.fieldFail.addr1}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.addr2}class="glm-required"{/if}>Address Line 2:</th>
- <td {if $contactInfo.fieldFail.addr2}class="glm-form-bad-input"{/if}>
- <input id="addr2" type="text" name="addr2" value="{$contactInfo.fieldData.addr2}" class="glm-form-text-input glm-geocodeAction">
- {if $contactInfo.fieldFail.addr2}<p>{$contactInfo.fieldFail.addr2}</p>{/if}
- </td>
- </tr>
- <tr>
- <th>City</th>
- <td class="glm-item-container">
- <!-- Add new city dialog -->
- <div id="newCityButton" class="button button-secondary glm-right">Add a new City</div>
- <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
- <table class="glm-admin-table">
- <tr>
- <th class="glm-required">City Name:</th>
- <td id="newCityNameTD">
- <input id="newCityName" type="text" name="newCityName" class="glm-form-text-input">
- <div id="newCityNameRequired"></div>
- </td>
- </tr>
- </table>
- <p><span class="glm-required">*</span> Required</p>
- <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
- <input id="newCitySubmit" type="submit" value="Add new City">
- </div>
- <!-- City Selection -->
- <input id="cityName" type="hidden" name="newCityName" value=""><!-- this field is only used if adding a new city to pass the new name -->
- <select name="city" id="city" class="glm-geocodeAction">
- <option value="0"><option>
- {foreach from=$contactInfo.fieldData.city.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.state}class="glm-required"{/if}>State:</th>
- <td {if $contactInfo.fieldFail.state}class="glm-form-bad-input"{/if}>
- <select id="state" name="state" class="glm-geocodeAction">
- {foreach from=$contactInfo.fieldData.state.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name}
- </option>
- {/foreach}
- </select>
- {if $contactInfo.fieldFail.state}<p>{$contactInfo.fieldFail.state}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.zip}class="glm-required"{/if}>ZIP / Postal Code:</th>
- <td {if $contactInfo.fieldFail.zip}class="glm-form-bad-input"{/if}>
- <input id="zip" type="text" name="zip" value="{$contactInfo.fieldData.zip}" class="glm-form-text-input-short glm-geocodeAction">
- {if $contactInfo.fieldFail.zip}<p>{$contactInfo.fieldFail.zip}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.country}class="glm-required"{/if}>Country:</th>
- <td {if $contactInfo.fieldFail.country}class="glm-form-bad-input"{/if}>
- <select id="country" name="country" class="glm-geocodeAction">
- {foreach from=$contactInfo.fieldData.country.list item=v}
- <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
- {$v.name} {$v.value}
- </option>
- {/foreach}
- </select>
- {if $contactInfo.fieldFail.country}<p>{$contactInfo.fieldFail.country}</p>{/if}
- </td>
- </tr>
- <!-- NOT DOING LAT/LON FOR NOW -->
- <tr>
- <th {if $contactInfo.fieldRequired.url}class="glm-required"{/if}>Web Address (URL):</th>
- <td {if $contactInfo.fieldFail.url}class="glm-form-bad-input"{/if}>
- {if $contactInfo.fieldData.url}
- <a class="button button-secondary glm-right" href="http://{$contactInfo.fieldData.url}" target="urlTarget">Test Link</a>
- {/if}
- http://<input type="text" name="url" value="{$contactInfo.fieldData.url}" class="glm-form-text-input-medium" placeholder="ex: www.gaslightmedia.com">
- {if $contactInfo.fieldFail.url}<p>{$contactInfo.fieldFail.url}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.office_phone}class="glm-required"{/if}>Office Phone #:</th>
- <td {if $contactInfo.fieldFail.office_phone}class="glm-form-bad-input"{/if}>
- <input type="text" name="office_phone" value="{$contactInfo.fieldData.office_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
- {if $contactInfo.fieldFail.office_phone}<p>{$contactInfo.fieldFail.office_phone}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.home_phone}class="glm-required"{/if}>Home Phone #:</th>
- <td {if $contactInfo.fieldFail.home_phone}class="glm-form-bad-input"{/if}>
- <input type="text" name="home_phone" value="{$contactInfo.fieldData.home_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
- {if $contactInfo.fieldFail.home_phone}<p>{$contactInfo.fieldFail.home_phone}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.mobile_phone}class="glm-required"{/if}>Mobile Phone #:</th>
- <td {if $contactInfo.fieldFail.mobile_phone}class="glm-form-bad-input"{/if}>
- <input type="text" name="mobile_phone" value="{$contactInfo.fieldData.mobile_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
- {if $contactInfo.fieldFail.mobile_phone}<p>{$contactInfo.fieldFail.mobile_phone}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.alt_phone}class="glm-required"{/if}>Alternate Phone #:</th>
- <td {if $contactInfo.fieldFail.alt_phone}class="glm-form-bad-input"{/if}>
- <input type="text" name="alt_phone" value="{$contactInfo.fieldData.alt_phone}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
- {if $contactInfo.fieldFail.alt_phone}<p>{$contactInfo.fieldFail.alt_phone}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.fax}class="glm-required"{/if}>FAX #:</th>
- <td {if $contactInfo.fieldFail.fax}class="glm-form-bad-input"{/if}>
- <input type="text" name="fax" value="{$contactInfo.fieldData.fax}" class="glm-form-text-input-short" placeholder="ex: 123-456-7890 ext 123">
- {if $contactInfo.fieldFail.fax}<p>{$contactInfo.fieldFail.fax}</p>{/if}
- </td>
- </tr>
- <tr>
- <th {if $contactInfo.fieldRequired.notes}class="glm-required"{/if}>Notes:</th>
- <td {if $contactInfo.fieldFail.notes}class="glm-form-bad-input"{/if}>
- {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}<p>{$contactInfo.fieldFail.notes}</p>{/if}
- </td>
- </tr>
- </table>
- <p><span class="glm-required">*</span> Required</p>
- <input id="updateContact" type="submit" value="{if $contactID && $contactInfo}Update contact{else}Add new contact{/if}">
- </form>
-
- {/if}
-
- {else} <!-- may edit contact -->
-
- <table class="glm-admin-table glm-shrink">
- <tr><th>Contact For:</th><td>{$contactInfo.fieldData.ref_type.name} - {$memberData.name}</td></tr>
- <tr><th>Active:</th><td>{$contactInfo.fieldData.active.name}</td></tr>
- <tr><th>Created:</th><td>{$contactInfo.fieldData.create_time.datetime}</td></tr>
- <tr><th>Last Updated:</th><td>{$contactInfo.fieldData.modify_time.datetime}</td></tr>
- <tr><th>First Name:</th><td>{$contactInfo.fieldData.fname}</td></tr>
- <tr><th>Last Name:</th><td>{$contactInfo.fieldData.lname}</td></tr>
- <tr><th>Contact Type:</th><td>{$contactInfo.fieldData.contact_type.name}</td></tr>
- <tr><th>Email Address::</th><td>{$contactInfo.fieldData.email}</td></tr>
- <tr><th>Alternate Email Address:</th><td>{$contactInfo.fieldData.alt_email}</td></tr>
- <tr><th>Organization:</th><td>{$contactInfo.fieldData.org}</td></tr>
- <tr><th>Title/Position:</th><td>{$contactInfo.fieldData.title}</td></tr>
- <tr><th>Position/Responsibilities:</th><td>{$contactInfo.fieldData.descr}</td></tr>
- <tr>
- <th>Image:</th>
- <td>
- {if $contactInfo.fieldData.image}
- <img src="{$glmPluginMediaUrl}/images/thumb/{$contactInfo.fieldData.image}">
- {/if}
- </td>
- </tr>
- <tr><th>Address Line 1:</th><td>{$contactInfo.fieldData.addr1}</td></tr>
- <tr><th>Address Line 2:</th><td>{$contactInfo.fieldData.addr2}</td></tr>
- <tr><th>City</th><td>{$contactInfo.fieldData.city.name}</td></tr>
- <tr><th>State:</th><td>{$contactInfo.fieldData.state.name}</td></tr>
- <tr><th>ZIP / Postal Code:</th><td>{$contactInfo.fieldData.zip}</td></tr>
- <tr><th>Country:</th><td>{$contactInfo.fieldData.country.name}</td></tr>
- <tr>
- <th>Web Address (URL):</th>
- <td>
- {if $contactInfo.fieldData.url}
- <a href="http://{$contactInfo.fieldData.url}" target="urlTarget">{$contactInfo.fieldData.url}</a>
- {/if}
- </td>
- </tr>
- <tr><th>Office Phone #:</th><td>{$contactInfo.fieldData.office_phone}</td></tr>
- <tr><th>Home Phone #:</th><td>{$contactInfo.fieldData.home_phone}</td></tr>
- <tr><th>Mobile Phone #:</th><td>{$contactInfo.fieldData.mobile_phone}</td></tr>
- <tr><th>Alternate Phone #:</th><td>{$contactInfo.fieldData.alt_phone}</td></tr>
- <tr><th>FAX #:</th><td>{$contactInfo.fieldData.fax}</td></tr>
- <tr><th>Notes:</th><td>{$contactInfo.fieldData.notes}</td></tr>
- </table>
- {/if} <!-- mey edit contact -->
-
- {/if} <!-- /if option -->
-
-{else} <!-- Member not specified or not found -->
- <h2 class="glm-error">No current {$terms.term_member}.</h2>
-{/if}
-
- <script type="text/javascript">
- jQuery(document).ready(function($) {
-
- // Filter triggers
- $(".listFilter" ).change( function() {
-
- var filter = '';
-
- // Check for archived filter
- if ($("#filterArchived").attr('checked')) {
- filter += '&filterArchived=true';
- }
-
- // Check for name filter
- var filterText = $("#filterText").val();
- if (filterText != '') {
- filter += '&filterText=' + encodeURIComponent(filterText).replace(/%20/g,'+');
- }
-
- window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}" + filter;
-
- return false;
- });
-
- /*
- * New City Dialog
- */
-
- // Setup dialog box for adding a new city
- $("#newCityDialog").dialog({
- autoOpen: false,
- minWidth: 400,
- dialogClass: "glm-dialog-no-close"
- });
- $('#newCityCancel').click( function() {
- $("#newCityDialog").dialog("close");
- });
-
- // Ad a new city button action - pop-up dialog
- $('#newCityButton').click( function() {
- $("#newCityDialog").dialog("open");
- });
-
- // Submit new city
- var newCityAdded = false;
- $('#newCitySubmit').click( function() {
-
- // Get new city name
- var newCityName = $('#newCityName').val();
-
- // If no name is supplied, notify used it's required
- if (newCityName == '') {
- $('#newCityNameTD').addClass('glm-form-bad-input');
- $('#newCityNameRequired').text('A city name is required!');
- return false;
- }
-
- // Add new city name to the hidden field that will pass the new name to PHP.
- $('#cityName').val(newCityName);
-
- // Add new city name to picklist and for storing - Only one permitted per submission
- if (newCityAdded) {
-
- // New city already added, so just update the name and select that one
- $('#city').val(-1);
- $('#city option:selected').text(newCityName);
-
- } else {
-
- // Add the new city name to the city picklist
- $('#city').append('<option value="-1">' + newCityName + '</option>');
- $('#city').val(-1);
- $('#newCityNameTD').append('<input type="hidden" name="newCity" value="' + newCityName + '">');
- newCityAdded = true;
-
- }
-
- // Clear new city name from form
- $('#newCityName').val('');
-
- $("#newCityDialog").dialog("close");
-
- });
-
- /*
- * Large Image Dialog
- */
-
- // Setup dialog box for showing enlarged image image
- x = $('#largeImageDialog').dialog({
- autoOpen: false,
- resizable: false,
- dialogClass: "glm-dialog-no-close"
- });
- $('#largeImageCancel').click( function() {
- $('#largeImageDialog').dialog("close");
- });
-
- // Show large image - pop-up dialog - resize at time of pop-up
- $('#largeImageButton').click( function() {
- $("#largeImageDialog").dialog("open");
- $( "#largesImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
- var newWidth = $(window).width() * .8;
- $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
- });
-
- // Resize whenever window size changes
- $(window).resize(function(){
- $( "#largeImageDialog" ).dialog( "option", "position", { my: "center", at: "center", of: window } );
- var newWidth = $(window).width() * .8;
- $( "#largeImageDialog" ).dialog( "option", "width", newWidth );
- });
-
- // Delete Contact dialog
- $("#deleteContactDialog").dialog({
- autoOpen: false,
- minWidth: 400,
- dialogClass: "glm-dialog-no-close"
- });
- $('#deleteContactButton').click( function() {
- $('#deleteContactDialog').dialog('open');
- });
- $('#deleteContactCancel').click( function() {
- $("#deleteContactDialog").dialog("close");
- });
- $('#deleteContactSubmit').click( function() {
- window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=delete&contact={$contactID}");
- });
-
- // Flash certain elements for a short time after display
- $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
-
- });
- </script>
-
-
-{include file='admin/footer.html'}
<div class="wrap">
- <h2>Your Contact and Log-in Profile</h2>
+ <h2>My Contact and Log-In Information</h2>
<h2 class="nav-tab-wrapper">
- <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">User Profile</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">My Contact Info</a>
{foreach $addOnTabs as $a}
<a href="{$thisUrl}?page=glm-members-admin-menu-{$a.menu}&glm_action={$a.action}" class="nav-tab{if $thisAction==$a.action} nav-tab-active{/if}">{$a.text}</a>
{/foreach}