本文整理汇总了PHP中CRM_Contact_DAO_Group::tsEnum方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Group::tsEnum方法的具体用法?PHP CRM_Contact_DAO_Group::tsEnum怎么用?PHP CRM_Contact_DAO_Group::tsEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_DAO_Group
的用法示例。
在下文中一共展示了CRM_Contact_DAO_Group::tsEnum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* We need to do slightly different things for groups vs saved search groups, hence we
* reimplement browse from Page_Basic
* @param int $action
*
* @return void
* @access public
*/
function browse($action = null)
{
require_once 'CRM/Contact/BAO/GroupNesting.php';
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
if ($this->_sortByCharacter == 1 || !empty($_POST)) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$query = " SELECT COUNT(*) FROM civicrm_group";
$groupExists = CRM_Core_DAO::singleValueQuery($query);
$this->assign('groupExists', $groupExists);
$this->search();
$config =& CRM_Core_Config::singleton();
$params = array();
$whereClause = $this->whereClause($params, false);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, true);
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
$select = $from = $where = "";
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && CRM_Core_Permission::check('administer Multiple Organizations')) {
$select = ", contact.display_name as orgName, contact.id as orgID";
$from = " LEFT JOIN civicrm_group_organization gOrg\n ON gOrg.group_id = groups.id \n LEFT JOIN civicrm_contact contact\n ON contact.id = gOrg.organization_id ";
//get the Organization ID
$orgID = CRM_Utils_Request::retrieve('oid', 'Positive', CRM_Core_DAO::$_nullObject);
if ($orgID) {
$where = " AND gOrg.organization_id = {$orgID}";
}
$this->assign('groupOrg', true);
}
$query = "\n SELECT groups.* {$select}\n FROM civicrm_group groups \n {$from}\n WHERE {$whereClause} {$where}\n ORDER BY groups.title asc\n LIMIT {$offset}, {$rowCount}";
$object = CRM_Core_DAO::executeQuery($query, $params, true, 'CRM_Contact_DAO_Group');
$groupPermission = CRM_Core_Permission::check('edit groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW;
$this->assign('groupPermission', $groupPermission);
//FIXME CRM-4418, now we are handling delete separately
//if we introduce 'delete for group' make sure to handle here.
$groupPermissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit groups')) {
$groupPermissions[] = CRM_Core_Permission::EDIT;
$groupPermissions[] = CRM_Core_Permission::DELETE;
}
require_once 'CRM/Core/OptionGroup.php';
$links =& $this->links();
$allTypes = CRM_Core_OptionGroup::values('group_type');
$values = array();
while ($object->fetch()) {
$permission = $this->checkPermission($object->id, $object->title);
if ($permission) {
$newLinks = $links;
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
if ($object->saved_search_id) {
$values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
// check if custom search, if so fix view link
$customSearchID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $object->saved_search_id, 'search_custom_id');
if ($customSearchID) {
$newLinks[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/search/custom';
$newLinks[CRM_Core_Action::VIEW]['qs'] = "reset=1&force=1&ssID={$object->saved_search_id}";
}
}
$action = array_sum(array_keys($newLinks));
if (array_key_exists('is_active', $object)) {
if ($object->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::VIEW;
$action -= CRM_Core_Action::DISABLE;
}
}
$action = $action & CRM_Core_Action::mask($groupPermissions);
$values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
if (isset($values[$object->id]['group_type'])) {
$groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1));
$types = array();
foreach ($groupTypes as $type) {
$types[] = $allTypes[$type];
}
$values[$object->id]['group_type'] = implode(', ', $types);
}
$values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks, $action, array('id' => $object->id, 'ssid' => $object->saved_search_id));
if (array_key_exists('orgName', $object)) {
if ($object->orgName) {
$values[$object->id]['org_name'] = $object->orgName;
$values[$object->id]['org_id'] = $object->orgID;
}
}
}
}
if (isset($values)) {
$this->assign('rows', $values);
}
//.........这里部分代码省略.........
示例2: addDisplayEnums
/**
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_group
*
* @param array $values (reference) the array up for enhancing
* @return void
*/
static function addDisplayEnums(&$values)
{
$enumFields =& CRM_Contact_DAO_Group::getEnums();
foreach ($enumFields as $enum) {
if (isset($values[$enum])) {
$values[$enum . '_display'] = CRM_Contact_DAO_Group::tsEnum($enum, $values[$enum]);
}
}
}
示例3: getGroupList
/**
* This function to get list of groups
*
* @param array $params associated array for params
* @access public
*/
static function getGroupList(&$params)
{
$config = CRM_Core_Config::singleton();
$whereClause = self::whereClause($params, FALSE);
//$this->pagerAToZ( $whereClause, $params );
if (!empty($params['rowCount']) && $params['rowCount'] > 0) {
$limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
}
$orderBy = ' ORDER BY groups.title asc';
if (CRM_Utils_Array::value('sort', $params)) {
$orderBy = ' ORDER BY ' . CRM_Utils_Array::value('sort', $params);
}
$select = $from = $where = "";
$groupOrg = FALSE;
if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
$select = ", contact.display_name as org_name, contact.id as org_id";
$from = " LEFT JOIN civicrm_group_organization gOrg\n ON gOrg.group_id = groups.id\n LEFT JOIN civicrm_contact contact\n ON contact.id = gOrg.organization_id ";
//get the Organization ID
$orgID = CRM_Utils_Request::retrieve('oid', 'Positive', CRM_Core_DAO::$_nullObject);
if ($orgID) {
$where = " AND gOrg.organization_id = {$orgID}";
}
$groupOrg = TRUE;
}
$query = "\n SELECT groups.* {$select}\n FROM civicrm_group groups\n {$from}\n WHERE {$whereClause} {$where}\n {$orderBy}\n {$limit}";
$object = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contact_DAO_Group');
//FIXME CRM-4418, now we are handling delete separately
//if we introduce 'delete for group' make sure to handle here.
$groupPermissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit groups')) {
$groupPermissions[] = CRM_Core_Permission::EDIT;
$groupPermissions[] = CRM_Core_Permission::DELETE;
}
// CRM-9936
$reservedPermission = CRM_Core_Permission::check('administer reserved groups');
$links = self::actionLinks();
$allTypes = CRM_Core_OptionGroup::values('group_type');
$values = array();
while ($object->fetch()) {
$permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title);
if ($permission) {
$newLinks = $links;
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
if ($object->saved_search_id) {
$values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
// check if custom search, if so fix view link
$customSearchID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $object->saved_search_id, 'search_custom_id');
if ($customSearchID) {
$newLinks[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/search/custom';
$newLinks[CRM_Core_Action::VIEW]['qs'] = "reset=1&force=1&ssID={$object->saved_search_id}";
}
}
$action = array_sum(array_keys($newLinks));
// CRM-9936
if (array_key_exists('is_reserved', $object)) {
//if group is reserved and I don't have reserved permission, suppress delete/edit
if ($object->is_reserved && !$reservedPermission) {
$action -= CRM_Core_Action::DELETE;
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
}
}
$values[$object->id]['class'] = '';
if (array_key_exists('is_active', $object)) {
if ($object->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$values[$object->id]['class'] = 'disabled';
$action -= CRM_Core_Action::VIEW;
$action -= CRM_Core_Action::DISABLE;
}
}
$action = $action & CRM_Core_Action::mask($groupPermissions);
$values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
if (isset($values[$object->id]['group_type'])) {
$groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1));
$types = array();
foreach ($groupTypes as $type) {
$types[] = CRM_Utils_Array::value($type, $allTypes);
}
$values[$object->id]['group_type'] = implode(', ', $types);
}
$values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks, $action, array('id' => $object->id, 'ssid' => $object->saved_search_id));
if ($groupOrg) {
if ($object->org_id) {
$contactUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$object->org_id}");
$values[$object->id]['org_info'] = "<a href='{$contactUrl}'>{$object->org_name}</a>";
} else {
$values[$object->id]['org_info'] = '';
// Empty cell
}
} else {
$values[$object->id]['org_info'] = NULL;
//.........这里部分代码省略.........
示例4: browse
/**
* We need to do slightly different things for groups vs saved search groups, hence we
* reimplement browse from Page_Basic
* @param int $action
*
* @return void
* @access public
*/
function browse($action = null)
{
$config =& CRM_Core_Config::singleton();
$values = array();
$object =& new CRM_Contact_BAO_Group();
$object->domain_id = $config->domainID();
$object->orderBy('title asc');
$object->find();
$groupPermission = CRM_Utils_System::checkPermission('edit groups') ? CRM_CORE_PERMISSION_EDIT : CRM_CORE_PERMISSION_VIEW;
$this->assign('groupPermission', $groupPermission);
while ($object->fetch()) {
$permission = $this->checkPermission($object->id, $object->title);
if ($permission) {
$values[$object->id] = array();
CRM_Core_DAO::storeValues($object, $values[$object->id]);
if ($object->saved_search_id) {
$values[$object->id]['title'] = $values[$object->id]['title'] . ' (' . ts('Smart Group') . ')';
$links =& $this->links();
} else {
$links =& $this->links();
}
if ($action == null) {
$action = array_sum(array_keys($links));
}
$action = $action & CRM_Core_Action::mask($groupPermission);
$newAction = $action;
if (array_key_exists('is_active', $object)) {
if ($object->is_active) {
$newAction -= CRM_CORE_ACTION_ENABLE;
} else {
$newAction -= CRM_CORE_ACTION_VIEW;
$newAction -= CRM_CORE_ACTION_DISABLE;
}
}
// make sure we only allow those actions that the user is permissioned for
$newAction = $newAction & CRM_Core_Action::mask($permission);
$values[$object->id]['visibility'] = CRM_Contact_DAO_Group::tsEnum('visibility', $values[$object->id]['visibility']);
$values[$object->id]['action'] = CRM_Core_Action::formLink($links, $newAction, array('id' => $object->id, 'ssid' => $object->saved_search_id));
}
}
$this->assign('rows', $values);
}