예제 #1
0
 /**
  * @param $entityType
  * @param $path
  * @param string $cidToken
  *
  * @return array
  */
 public static function &getActiveGroups($entityType, $path, $cidToken = '%%cid%%')
 {
     // for Group's
     $customGroupDAO = new CRM_Core_DAO_CustomGroup();
     // get 'Tab' and 'Tab with table' groups
     $customGroupDAO->whereAdd("style IN ('Tab', 'Tab with table')");
     $customGroupDAO->whereAdd("is_active = 1");
     // add whereAdd for entity type
     self::_addWhereAdd($customGroupDAO, $entityType, $cidToken);
     $groups = array();
     $permissionClause = CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, NULL, TRUE);
     $customGroupDAO->whereAdd($permissionClause);
     // order by weight
     $customGroupDAO->orderBy('weight');
     $customGroupDAO->find();
     // process each group with menu tab
     while ($customGroupDAO->fetch()) {
         $group = array();
         $group['id'] = $customGroupDAO->id;
         $group['path'] = $path;
         $group['title'] = "{$customGroupDAO->title}";
         $group['query'] = "reset=1&gid={$customGroupDAO->id}&cid={$cidToken}";
         $group['extra'] = array('gid' => $customGroupDAO->id);
         $group['table_name'] = $customGroupDAO->table_name;
         $group['is_multiple'] = $customGroupDAO->is_multiple;
         $groups[] = $group;
     }
     return $groups;
 }
예제 #2
0
 /**
  * Delete Contact SubTypes.
  *
  * @param int $contactTypeId
  *   ID of the Contact Subtype to be deleted.
  *
  * @return bool
  */
 public static function del($contactTypeId)
 {
     if (!$contactTypeId) {
         return FALSE;
     }
     $params = array('id' => $contactTypeId);
     self::retrieve($params, $typeInfo);
     $name = $typeInfo['name'];
     // check if any custom group
     $custom = new CRM_Core_DAO_CustomGroup();
     $custom->whereAdd("extends_entity_column_value LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . $name . CRM_Core_DAO::VALUE_SEPARATOR . "%'");
     if ($custom->find()) {
         return FALSE;
     }
     // remove subtype for existing contacts
     $sql = "\nUPDATE civicrm_contact SET contact_sub_type = NULL\nWHERE contact_sub_type = '{$name}'";
     CRM_Core_DAO::executeQuery($sql);
     // remove subtype from contact type table
     $contactType = new CRM_Contact_DAO_ContactType();
     $contactType->id = $contactTypeId;
     $contactType->delete();
     // remove navigation entry if any
     if ($name) {
         $sql = "\nDELETE\nFROM civicrm_navigation\nWHERE name = %1";
         $params = array(1 => array("New {$name}", 'String'));
         $dao = CRM_Core_DAO::executeQuery($sql, $params);
         CRM_Core_BAO_Navigation::resetNavigation();
     }
     return TRUE;
 }