*/
// Translation table for [glm-contacts-list] "show" options to configuration parameters
-$GLOBALS['showOpts'] = array(
-
-);
// Load Contacts data abstract
require_once GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php';
public function modelAction ($actionData = false)
{
- $view = 'index.html';
- $option = 'list';
- $fromMemberMenu = false;
- $loggedInMember = false;
- $refType = false;
- $refTypeName = false;
- $haveMember = false;
+ $view = 'index.html';
+ $option = 'list';
+ $haveMember = false;
$this->memberID = false;
- $memberData = false;
- $memberName = false;
- $membersList = false;
- $contactsList = false;
- $haveContacts = false;
- $contactID = false;
- $contactInfo = false;
- $newContactEmailExists = false;
- $newContactUsernameExists = false;
- $misMatchedWpUsers = false;
- $newContactCreated = false;
- $usingExistingWPContact = false;
- $usernameChangedToWP = false;
- $contactUpdated = false;
+ $memberData = false;
+ $memberName = false;
+ $membersList = false;
+ $contactsList = false;
+ $haveContacts = false;
+ $contactID = false;
+ $contactInfo = false;
$filterArchived = false;
- $filterText = false;
- $countySearch = false;
- $countyList = array();
- $haveCounties = false;
- $haveFilter = false;
- $userDeleted = false;
- $wpUserDeleted = false;
+ $filterText = false;
+ $countySearch = false;
+ $countyList = array();
+ $haveCounties = false;
+ $haveFilter = false;
$contactMembers = array();
- $order = false;
+ $order = false;
+
+ $textSearch = '';
+ $blankStart = false;
+ $membersFound = false;
- $numbContacts = false;
+ // Paging Parameters
+ $paging = true;
$numbDisplayed = false;
$lastDisplayed = false;
- $paging = true;
$prevStart = false;
$nextStart = false;
$start = 1;
'delete',
'list'
);
+
+
+ if (isset($_REQUEST['textSearch'])) {
+ $actionData['request']['text-search'] = $_REQUEST['textSearch'];
+ }
+ if (isset($_REQUEST['alpha'])) {
+ $actionData['request']['alpha'] = $_REQUEST['alpha'];
+ }
+ // If user clicked a page request then we need to check the savedAlpha value
+ if (isset($_REQUEST['savedAlpha']) && isset($_REQUEST['pageSelect'])) {
+ $actionData['request']['alpha'] = $_REQUEST['savedAlpha'];
+ }
// If this is a logged in member user, then show their contacts only
if (isset($this->config['loggedInUser']['contactUser'])) {
}
}
-
- // If we're coming from the Member Contacts Menu/Tab
- if (defined('GLM_MEMBERS_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
- $this->memberID = $_REQUEST['member']-0;
- update_option('glmMembersDatabaseMemberID', $this->memberID);
-
- // Otherwise check if a member is stored in wordpress option
- } else {
- $this->memberID = get_option('glmMembersDatabaseMemberID', false);
- }
-
- }
-
+
// Load members data class
require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php';
$this->Members = new GlmDataMembers($this->wpdb, $this->config);
$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 = '.$this->memberID;
// 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;
}
// Setting $paging to false until we figure it out for contacts
- $paging = false;
+ //$paging = false;
// Get full list of names matching this where clause for search box
$namesList = $this->getIdName($where);
+
+ $contactsList = $this->getList($where, $order, true, 'id',$start, $limit);
+
+ // If doing alpha list
+ $alphaList = false;
+ $alphaWhere = '';
+ if ($this->config['settings']['list_show_search_alpha']) {
+
+ $alphaSelected = false;
+
+ // Check for alpha selected
+ if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) {
+ $alphaSelected = strtoupper($actionData['request']['alpha']);
+ $alphaWhere .= " AND T.lname LIKE '$alphaSelected%'";
+ }
+
+ // Get full list for all other filters, but not filtered by alpha (that would be silly)
+ $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected);
+
+ }
+
+ $order = "lname, fname";
+ // Get list of contacts
+
// Check if we're doing paging
if (isset($_REQUEST['pageSelect'])) {
// If request is for Next
- if ($_REQUEST['pageSelect'][0] == 'N') {
+ if ($_REQUEST['pageSelect'] == 'Next') {
$newStart = $_REQUEST['nextStart'] - 0;
// Otherwise it must be Previous
$start = $newStart;
}
}
- $order = "lname, fname";
- // Get list of contacts
- $contactsList = $this->getList($where, $order);
+
+ $list = $contactsList['list'];
+
+ // If we're not paging, then force $start and $limit to false to data abstract returns everything.
+ $resultParam = 'listResult';
+ if (!$paging) {
+ $start = false;
+ $limit = false;
+ $resultParam = 'list';
+ }
+
+ // Get stats for the current selection
+ $contactsFound = $this->getStats(str_replace('T.', '', $where));
+
+ // Get stats for number of members found matching current selection criteria (includes alpha selection)
+ $filteredContactsFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere));
+
+ // Get member list sorted as specified
+ switch ($this->config['settings']['list_order_list']) {
+
+ // Pseudo-Random list order
+ case $this->config['sort_order_numb']['Pseudo-Random']:
+ ${$resultParam} = $this->getList($where.$alphaWhere, 'pseudo-random', true, 'id', $start, $limit);
+ break;
+
+ // Default is alpha-numeric list order
+ default:
+ case $this->config['sort_order_numb']['Alpha-Numeric']:
+ ${$resultParam} = $this->getList($where.$alphaWhere, $order, true, 'id', $start, $limit);
+ break;
+
+ }
+ if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+ glmMembersFront::addNotice($list, 'DataBlock', 'Member Data');
+ }
+
if ($contactsList != false) {
if ($paging) {
//Get paging results
if ($countyList[0]) {
$haveCounties = true;
}
-//
-//
-//
-// $r = array(
-// 'contactRole' => $contactRole,
-// 'wpRole' => $this->config['contact_role_wordpress'][$contactRole]
-// );
-//
-// return $r;
-
// If the option is "edit" don't let lower-level users assign privileges above the user's pay grade
if (($option == 'edit' || $option == 'create') && $this->config['loggedInUser']['contactUser']) {
}
}
-
-
// Compile template data
$templateData = array(
'option' => $option,
- 'loggedInMember' => $loggedInMember,
- 'fromMemberMenu' => $fromMemberMenu,
'haveMember' => $haveMember,
'memberID' => $this->memberID,
'memberData' => $memberData,
'memberName' => $memberName,
'membersList' => $membersList,
- 'refType' => $refType,
- 'refTypeName' => $refTypeName,
'haveContacts' => $haveContacts,
- 'contactsList' => $contactsList,
+ 'contactsList' => $list,
'numbContacts' => $numbContacts,
'contactID' => $contactID,
'contactInfo' => $contactInfo,
- 'newContactEmailExists' => $newContactEmailExists,
- 'newContactUsernameExists' => $newContactUsernameExists,
- 'misMatchedWpUsers' => $misMatchedWpUsers,
- 'usernameChangedToWP' => $usernameChangedToWP,
- 'newContactCreated' => $newContactCreated,
- 'usingExistingWPContact' => $usingExistingWPContact,
- 'contactUpdated' => $contactUpdated,
'filterArchived' => $filterArchived,
'filterText' => $filterText,
'countyList' => $countyList,
'haveCounties' => $haveCounties,
'countySearch' => $countySearch,
'haveFilter' => $haveFilter,
- 'userDeleted' => $userDeleted,
- 'wpUserDeleted' => $wpUserDeleted,
'contactMembers' => $contactMembers,
-
+ 'alphaList' => $alphaList,
+ 'alphaSelected' => $alphaSelected,
+ 'contactsFound' => $contactsFound,
+ 'filteredContactsFound' => $filteredContactsFound,
'numbDisplayed' => $numbDisplayed,
'lastDisplayed' => $lastDisplayed,
+ 'textSearch' => $textSearch,
'paging' => $paging,
'prevStart' => $prevStart,
'nextStart' => $nextStart,
{if $paging}
<input type="Submit" name="pageSelect" value="Previous {$limit} Contacts" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
<input type="Submit" name="pageSelect" value="Next {$limit} Contacts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
- {/if}
+ {/if}
+
+ {if $settings.list_show_search_alpha}
+ <div class="glm-alpha-links">
+ <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&alpha=" class="glm-alpha-link{if !$alphaSelected} glm-alpha-link-selected{/if}">All</a>
+ {foreach $alphaList as $a}
+ <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&alpha={$a.alpha}" class="glm-alpha-link{if $a.default} glm-alpha-link-selected{/if}">{$a.alpha}</a>
+ {/foreach}
+ </div>
+ {/if}
+
+ {if $paging}
+
+ <br>
+ <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&pageSelect=Previous&prevStart={$prevStart}&nextStart={$nextStart}&limit={$limit}&alpha={$alphaSelected}" class="glm-alpha-link" {if !$prevStart} style="pointer-events: none; opacity: 0.5;"{/if}>Previous page</a>
+ <a href="{$thisUrl}?glm_action=list&textSearch={$textSearch}&pageSelect=Next&prevStart={$prevStart}&nextStart={$nextStart}&limit={$limit}&alpha={$alphaSelected}" class="glm-alpha-link" {if !$nextStart} style="pointer-events: none; opacity: 0.5;"{/if}>Next page</a>
+ <br>
+ showing {$start} through {$lastDisplayed} of {$filteredContactsFound}
+ {/if}
+
{if $haveContacts}
{foreach $contactsList as $contact}
<div class="glm-member-list-container glm-member-container small-12 columns">
<input type="Submit" name="pageSelect" value="Next {$limit} Contacts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}
</form>
-
- <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 text filter
- var filterText = $("#filterText").val();
- if (filterText != '') {
- filter += '&filterText=' + encodeURIComponent(filterText).replace(/%20/g,'+');
- }
-
- window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=index" + filter;
-
- 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:'"':"'"} ( username: {$e.username})", value: "{$e.fname|replace:'"':"'"} {$e.lname|replace:'"':"'"}, {$e.ref_dest_name|replace:'"':"'"}, {$e.username}", 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='front/footer.html'}
</body>