Skip to content
Snippets Groups Projects
Commit 559865a0 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

CRM-12466, added smart group pane

parent 15128151
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,11 @@
*/
class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
/**
* @var int contact id
*/
public $_contactId;
/**
* This function is called when action is browse
*
......@@ -41,7 +46,7 @@ class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
* @access public
*/
function browse() {
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
// keep track of all 'added' contact groups so we can remove them from the smart group
// section
......@@ -53,8 +58,8 @@ class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
}
$allGroup = CRM_Contact_BAO_GroupContactCache::contactGroup($this->_contactId);
$this->assign('groupSmart' , null);
$this->assign('groupParent', null);
$this->assign('groupSmart' , NULL);
$this->assign('groupParent', NULL);
if (!empty($allGroup)) {
$smart = $parent = array( );
......@@ -84,11 +89,11 @@ class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->assign('action', $this->_action);
}
/**
......
......@@ -62,34 +62,10 @@ class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page {
$this->assign_by_ref('groupPending', $pending);
$this->assign_by_ref('groupOut', $out);
/*
$allGroup = CRM_Contact_BAO_GroupContactCache::contactGroup($this->_contactId);
$this->assign('groupSmart' , null);
$this->assign('groupParent', null);
if (!empty($allGroup)) {
$smart = $parent = array( );
foreach ($allGroup['group'] as $group) {
// delete all smart groups which are also in static groups
if (isset($staticGroups[$group['id']])) {
continue;
}
if (empty($group['children'])) {
$smart[] = $group;
}
else {
$parent[] = $group;
}
}
if (!empty($smart)) {
$this->assign_by_ref('groupSmart', $smart);
}
if (!empty($parent)) {
$this->assign_by_ref('groupParent', $parent);
}
}
*/
// get the info on contact smart groups
$contactSmartGroupSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_smart_group_display');
$this->assign('contactSmartGroupSettings', $contactSmartGroupSettings);
}
/**
......
......@@ -184,6 +184,12 @@
<title>Groups</title>
<page_callback>CRM_Contact_Page_View_GroupContact</page_callback>
</item>
<item>
<path>civicrm/contact/view/smartgroup</path>
<path_arguments>cid=%%cid%%</path_arguments>
<title>Smart Groups</title>
<page_callback>CRM_Contact_Page_View_ContactSmartGroup</page_callback>
</item>
<item>
<path>civicrm/contact/view/sunlight</path>
<title>Sunlight</title>
......
......@@ -24,9 +24,15 @@
+--------------------------------------------------------------------+
*}
<div class="view-content">
{if !$groupSmart AND !$groupParent}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
&nbsp;{ts}This contact does not currently belong to any smart groups.{/ts}
</div>
{/if}
{if $groupSmart}
<div class="ht-one"></div>
<h3>{ts}Smart Groups{/ts}</h3>
<div class="description">
{ts 1=$displayName}%1 is currently included in these Smart group(s) (e.g. saved searches).{/ts}
</div>
......
......@@ -24,7 +24,7 @@
+--------------------------------------------------------------------+
*}
<div class="view-content">
{if $groupCount eq 0 AND ! $groupSmart AND ! $groupParent}
{if $groupCount eq 0}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
&nbsp;{ts}This contact does not currently belong to any groups.{/ts}
......@@ -81,7 +81,21 @@
{/strip}
{/if}
{if $contactSmartGroupSettings neq 3}
<div class="accordion ui-accordion ui-widget ui-helper-reset">
<div class="crm-accordion-wrapper crm-ajax-accordion crm-smartgroup-accordion {if $contactSmartGroupSettings eq 1}collapsed{/if}">
<div class="crm-accordion-header" id="crm-contact_smartgroup" contact_id="{$contactId}">
{ts}Smart Groups{/ts}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<div class="crm-contact_smartgroup"></div>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
</div>
{/if}
{if $groupPending}
<div class="ht-one"></div>
......@@ -166,4 +180,39 @@
</table>
{/strip}
{/if}
</div>
\ No newline at end of file
</div>
{literal}
<script type="text/javascript">
// bind first click of accordion header to load crm-accordion-body with snippet
// everything else taken care of by cj().crm-accordions()
cj(function () {
cj('.crm-ajax-accordion .crm-accordion-header').one('click', function () {
loadPanes(cj(this));
});
cj('.crm-ajax-accordion:not(.collapsed) .crm-accordion-header').each(function (index) {
loadPanes(cj(this));
});
});
// load panes function calls for snippet based on id of crm-accordion-header
function loadPanes(paneObj) {
var id = paneObj.attr('id');
var contactId = paneObj.attr('contact_id');
var dataUrl = CRM.url('civicrm/contact/view/smartgroup', 'snippet=4&cid=' + contactId);
if (!cj('div.' + id).html()) {
var loading = '<img src="{/literal}{$config->resourceBase}i/loading.gif{literal}" alt="{/literal}{ts escape='js'}loading{/ts}{literal}" />&nbsp;{/literal}{ts escape='js'}Loading{/ts}{literal}...';
cj('div.' + id).html(loading);
cj.ajax({
url: dataUrl,
success: function (data) {
cj('div.' + id).html(data);
}
});
}
}
</script>
{/literal}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment