*/
class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page {
+ /**
+ * @var int contact id
+ */
+ public $_contactId;
+
/**
* This function is called when action is browse
*
* @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
}
$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( );
$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);
}
/**
$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);
}
/**
<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>
+--------------------------------------------------------------------+
*}
<div class="view-content">
+ {if !$groupSmart AND !$groupParent}
+ <div class="messages status no-popup">
+ <div class="icon inform-icon"></div>
+ {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>
+--------------------------------------------------------------------+
*}
<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>
{ts}This contact does not currently belong to any groups.{/ts}
{/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>
</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}" /> {/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