From 07abe31aad36f53812db0455438ae6fa4bd4b976 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 4 Oct 2018 14:37:37 -0400 Subject: [PATCH] working on text search autocomplete --- models/admin/dashboard/contacts.php | 0 setup/adminHooks.php | 104 ++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 models/admin/dashboard/contacts.php diff --git a/models/admin/dashboard/contacts.php b/models/admin/dashboard/contacts.php new file mode 100644 index 0000000..e69de29 diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 7c43eed..b274698 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -126,5 +126,109 @@ add_filter( 'glm_contact_is_moderated', function( $user ) { return false; } } ); +add_filter( + GLM_MEMBERS_CONTACTS_PLUGIN_SLUG .'-dashboard-widget', + function ( $member = null ) { + require_once GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php'; + $Contacts = new GlmDataContacts($this->wpdb, $this->config); + + // Set default values for using getList() later, where the custom set of fields below will be used. + $where = ''; + $order = ''; + $fieldVals = true; + $idField = 'id'; + $start = false; + $limit = false; + + // Save the current fields array and make a copy. Will be restored before the return. + $fSave = $Events->fields; + + // Remove what we don't want from the copy and get the list + $Events->fields = array( + 'id' => $fSave['id'], + 'name' => $fSave['name'], + 'name_slug' => $fSave['name_slug'], + 'ref_type' => $fSave['ref_type'], + 'ref_dest' => $fSave['ref_dest'], + 'ref_dest_id' => $fSave['ref_dest_id'], + 'status' => $fSave['status'], + ); + + $contactsIndexPage = GLM_MEMBERS_CONTACTS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-contacts-index&glm_action=edit'; + $contactsTable = GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts"; + $contactsEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'contacts-index&glm_action=list&option=edit'; + $contactsListPage = GLM_MEMBERS_CONTACTS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-contacts-list'; + $contactsRefLink = GLM_MEMBERS_CONTACTS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index'; + $content = [ + 'title' => 'Contacts', + 'components' => [ + [ + 'id' => 'quickLinks', + 'order' => -1, + 'template' => 'quickLinks', + 'quickLinks' => [ + 'dashboard' => [ + 'content' => 'Dashboard', + 'url' => $contactsIndexPage . "&option=dashboard", + ], + 'search' => [ + 'content' => 'Advanced Search', + 'url' => $contactsIndexPage . "&option=search", + ], + 'settings' => [ + 'content' => 'Settings', + 'url' => '#set', + ] + ], + ], + [ + 'id' => 'topButtons', + 'order' => 0, + 'template' => 'buttons', + 'buttons' => [ + 'add-event' => [ + 'content' => 'Add Contact', + 'url' => $contactsIndexPage . "&option=create", + 'classes' => '', + 'styles' => '', + 'data' => '' + ], + 'export-button' => [ + 'content' => 'Export', + 'url' => '#', + 'classes' => 'btn-small widget-export-btn waves-effect waves-light btn modal-trigger', + 'styles' => '', + 'data' => 'contacts' + ], + ], + ], + [ + 'id' => 'entityAmount', + 'title' => 'Number of Contacts', + 'order' => 1, + 'template' => 'entityAmount', + 'url' => $contactsIndexPage . "&option=search", + 'result' => $Contacts->getStats() + ], + [ + 'id' => 'textSearch', + 'order' => 2, + 'template' => 'textSearch', + 'entityID' => 'event', + 'table' => $contactsTable, + 'fields' => "concat(fname, ' ', lname) as name,id,image,ref_dest", + 'resultUrl' => $contactsEditPage.'&contact=', + 'where' => 'fname OR lname' + ], + ] + ]; + + // Restore the fields list + $Events->fields = $fSave; + return $content; + }, + 13, + 1 +); ?> -- 2.17.1