Example #1
0
 /**
  * Function to get the uf group for a module
  *
  * @param string $moduleName module name 
  * $param int    $count no to increment the weight
  *
  * @return array $ufGroups array of ufgroups for a module
  * @access public
  * @static
  */
 public static function getModuleUFGroup($moduleName = null, $count = 0, $skipPermission = true)
 {
     require_once 'CRM/Core/DAO.php';
     $dao =& new CRM_Core_DAO();
     $queryString = 'SELECT civicrm_uf_group.id, title, civicrm_uf_group.is_active, is_reserved, group_type
                     FROM civicrm_uf_group
                     LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
     $p = array();
     if ($moduleName) {
         $queryString .= ' AND civicrm_uf_group.is_active = 1
                           WHERE civicrm_uf_join.module = %2';
         $p[2] = array($moduleName, 'String');
     }
     // add permissioning for profiles only if not registration
     if (!$skipPermission) {
         require_once 'CRM/Core/Permission.php';
         $permissionClause = CRM_Core_Permission::ufGroupClause(CRM_Core_Permission::VIEW, 'civicrm_uf_group.');
         if (strpos($queryString, 'WHERE') !== false) {
             $queryString .= " AND {$permissionClause} ";
         } else {
             $queryString .= " {$permissionClause} ";
         }
     }
     $queryString .= ' ORDER BY civicrm_uf_join.weight, civicrm_uf_group.title';
     $dao =& CRM_Core_DAO::executeQuery($queryString, $p);
     $ufGroups = array();
     require_once 'CRM/Core/BAO/UFField.php';
     while ($dao->fetch()) {
         //skip mix profiles in user Registration / User Account
         if (($moduleName == 'User Registration' || $moduleName == 'User Account') && CRM_Core_BAO_UFField::checkProfileType($dao->id)) {
             continue;
         }
         $ufGroups[$dao->id]['name'] = $dao->title;
         $ufGroups[$dao->id]['title'] = $dao->title;
         $ufGroups[$dao->id]['is_active'] = $dao->is_active;
         $ufGroups[$dao->id]['group_type'] = $dao->group_type;
         $ufGroups[$dao->id]['is_reserved'] = $dao->is_reserved;
     }
     return $ufGroups;
 }
Example #2
0
 /**
  * Get the uf group for a module.
  *
  * @param string $moduleName
  *   Module name.
  * @param int $count
  *   No to increment the weight.
  * @param bool $skipPermission
  * @param int $op
  *   Which operation (view, edit, create, etc) to check permission for.
  * @param array|NULL $returnFields list of UFGroup fields to return; NULL for default
  *
  * @return array
  *   array of ufgroups for a module
  */
 public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL)
 {
     $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type');
     if (!CRM_Core_Config::isUpgradeMode()) {
         // CRM-13555, since description field was added later (4.4), and to avoid any problems with upgrade
         $selectFields[] = 'description';
     }
     if (!empty($returnFields)) {
         $selectFields = array_merge($returnFields, array_diff($selectFields, $returnFields));
     }
     $queryString = 'SELECT civicrm_uf_group.' . implode(', civicrm_uf_group.', $selectFields) . '
                     FROM civicrm_uf_group
                     LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
     $p = array();
     if ($moduleName) {
         $queryString .= ' AND civicrm_uf_group.is_active = 1
                           WHERE civicrm_uf_join.module = %2';
         $p[2] = array($moduleName, 'String');
     }
     // add permissioning for profiles only if not registration
     if (!$skipPermission) {
         $permissionClause = CRM_Core_Permission::ufGroupClause($op, 'civicrm_uf_group.');
         if (strpos($queryString, 'WHERE') !== FALSE) {
             $queryString .= " AND {$permissionClause} ";
         } else {
             $queryString .= " {$permissionClause} ";
         }
     }
     $queryString .= ' ORDER BY civicrm_uf_join.weight, civicrm_uf_group.title';
     $dao = CRM_Core_DAO::executeQuery($queryString, $p);
     $ufGroups = array();
     while ($dao->fetch()) {
         //skip mix profiles in user Registration / User Account
         if (($moduleName == 'User Registration' || $moduleName == 'User Account') && CRM_Core_BAO_UFField::checkProfileType($dao->id)) {
             continue;
         }
         foreach ($selectFields as $key => $field) {
             if ($field == 'id') {
                 continue;
             }
             $ufGroups[$dao->id][$field] = $dao->{$field};
         }
     }
     // Allow other modules to alter/override the UFGroups.
     CRM_Utils_Hook::buildUFGroupsForModule($moduleName, $ufGroups);
     return $ufGroups;
 }
 /**
  * Function to get the uf group for a module
  *
  * @param string $moduleName module name
  * $param int    $count no to increment the weight
  *
  * @return array $ufGroups array of ufgroups for a module
  * @access public
  * @static
  */
 public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE)
 {
     $dao = new CRM_Core_DAO();
     $queryString = 'SELECT civicrm_uf_group.id, title, civicrm_uf_group.is_active, is_reserved, group_type
                     FROM civicrm_uf_group
                     LEFT JOIN civicrm_uf_join ON (civicrm_uf_group.id = uf_group_id)';
     $p = array();
     if ($moduleName) {
         $queryString .= ' AND civicrm_uf_group.is_active = 1
                           WHERE civicrm_uf_join.module = %2';
         $p[2] = array($moduleName, 'String');
     }
     // add permissioning for profiles only if not registration
     if (!$skipPermission) {
         $permissionClause = CRM_Core_Permission::ufGroupClause(CRM_Core_Permission::VIEW, 'civicrm_uf_group.');
         if (strpos($queryString, 'WHERE') !== FALSE) {
             $queryString .= " AND {$permissionClause} ";
         } else {
             $queryString .= " {$permissionClause} ";
         }
     }
     $queryString .= ' ORDER BY civicrm_uf_join.weight, civicrm_uf_group.title';
     $dao = CRM_Core_DAO::executeQuery($queryString, $p);
     $ufGroups = array();
     while ($dao->fetch()) {
         //skip mix profiles in user Registration / User Account
         if (($moduleName == 'User Registration' || $moduleName == 'User Account') && CRM_Core_BAO_UFField::checkProfileType($dao->id)) {
             continue;
         }
         $ufGroups[$dao->id]['name'] = $dao->title;
         $ufGroups[$dao->id]['title'] = $dao->title;
         $ufGroups[$dao->id]['is_active'] = $dao->is_active;
         $ufGroups[$dao->id]['group_type'] = $dao->group_type;
         $ufGroups[$dao->id]['is_reserved'] = $dao->is_reserved;
     }
     // Allow other modules to alter/override the UFGroups.
     CRM_Utils_Hook::buildUFGroupsForModule($moduleName, $ufGroups);
     return $ufGroups;
 }