projects
/
civicrm-core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9082df1
)
improve performance for action links and add button
author
jitendrapurohit
<jitendra.purohit@webaccessglobal.com>
Thu, 6 Oct 2016 10:04:12 +0000
(15:34 +0530)
committer
jitendrapurohit
<jitendra.purohit@webaccessglobal.com>
Thu, 6 Oct 2016 12:59:43 +0000
(18:29 +0530)
CRM/Contact/Form/CustomData.php
patch
|
blob
|
blame
|
history
CRM/Contact/Page/View/CustomData.php
patch
|
blob
|
blame
|
history
CRM/Core/BAO/CustomGroup.php
patch
|
blob
|
blame
|
history
CRM/Custom/Form/CustomData.php
patch
|
blob
|
blame
|
history
CRM/Profile/Page/MultipleRecordFieldsListing.php
patch
|
blob
|
blame
|
history
diff --git
a/CRM/Contact/Form/CustomData.php
b/CRM/Contact/Form/CustomData.php
index bbb3c4e09014990acbac9282eca978d22048c521..6b6c38fb626c3aa420fbec0e5c01c04199a883e0 100644
(file)
--- a/
CRM/Contact/Form/CustomData.php
+++ b/
CRM/Contact/Form/CustomData.php
@@
-233,7
+233,14
@@
class CRM_Contact_Form_CustomData extends CRM_Core_Form {
$groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_type,
$this,
$this->_entityId,
$groupTree = CRM_Core_BAO_CustomGroup::getTree($this->_type,
$this,
$this->_entityId,
- $this->_groupID
+ $this->_groupID,
+ array(),
+ NULL,
+ TRUE,
+ NULL,
+ FALSE,
+ TRUE,
+ $this->_copyValueId
);
$valueIdDefaults = array();
$groupTreeValueId = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, $this->_copyValueId, $this);
);
$valueIdDefaults = array();
$groupTreeValueId = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, $this->_copyValueId, $this);
diff --git
a/CRM/Contact/Page/View/CustomData.php
b/CRM/Contact/Page/View/CustomData.php
index 9a1a45a6968672be47569ebcf6a456769daab913..16cad611792155016463be59442f220c4349b37c 100644
(file)
--- a/
CRM/Contact/Page/View/CustomData.php
+++ b/
CRM/Contact/Page/View/CustomData.php
@@
-136,18
+136,23
@@
class CRM_Contact_Page_View_CustomData extends CRM_Core_Page {
//Custom Groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId);
//Custom Groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId);
- $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId,
- $this->_groupId, $entitySubType
- );
$recId = NULL;
if ($this->_multiRecordDisplay == 'single') {
$groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId);
CRM_Utils_System::setTitle(ts('View %1 Record', array(1 => $groupTitle)));
$recId = NULL;
if ($this->_multiRecordDisplay == 'single') {
$groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId);
CRM_Utils_System::setTitle(ts('View %1 Record', array(1 => $groupTitle)));
+ $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId,
+ $this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, TRUE, $this->_cgcount
+ );
$recId = $this->_recId;
$this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
$this->assign('skipTitle', 1);
}
$recId = $this->_recId;
$this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
$this->assign('skipTitle', 1);
}
+ else {
+ $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId,
+ $this->_groupId, $entitySubType
+ );
+ }
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId, $this->_contactId);
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId, $this->_contactId);
}
}
diff --git
a/CRM/Core/BAO/CustomGroup.php
b/CRM/Core/BAO/CustomGroup.php
index 0e3574b66efda8a66935546986c1bb449c686203..b2f402218d1901e7569acbca0b254c7f8550638f 100644
(file)
--- a/
CRM/Core/BAO/CustomGroup.php
+++ b/
CRM/Core/BAO/CustomGroup.php
@@
-330,6
+330,8
@@
class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
* api - through which it is properly tested - so can be refactored with some comfort.)
*
* @param bool $checkPermission
* api - through which it is properly tested - so can be refactored with some comfort.)
*
* @param bool $checkPermission
+ * @param varchar $singleRecord
+ * holds 'new' or id if view/edit/copy form for a single record is being loaded.
*
* @return array
* Custom field 'tree'.
*
* @return array
* Custom field 'tree'.
@@
-353,7
+355,8
@@
class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
$fromCache = TRUE,
$onlySubType = NULL,
$returnAll = FALSE,
$fromCache = TRUE,
$onlySubType = NULL,
$returnAll = FALSE,
- $checkPermission = TRUE
+ $checkPermission = TRUE,
+ $singleRecord = NULL
) {
if ($entityID) {
$entityID = CRM_Utils_Type::escape($entityID, 'Integer');
) {
if ($entityID) {
$entityID = CRM_Utils_Type::escape($entityID, 'Integer');
@@
-596,7
+599,7
@@
ORDER BY civicrm_custom_group.weight,
// add info to groupTree
if (isset($groupTree['info']) && !empty($groupTree['info']) &&
// add info to groupTree
if (isset($groupTree['info']) && !empty($groupTree['info']) &&
- !empty($groupTree['info']['tables'])
+ !empty($groupTree['info']['tables'])
&& $singleRecord != 'new'
) {
$select = $from = $where = array();
$groupTree['info']['where'] = NULL;
) {
$select = $from = $where = array();
$groupTree['info']['where'] = NULL;
@@
-630,7
+633,7
@@
ORDER BY civicrm_custom_group.weight,
}
$multipleFieldTablesWithEntityData = array_keys($entityMultipleSelectClauses);
if (!empty($multipleFieldTablesWithEntityData)) {
}
$multipleFieldTablesWithEntityData = array_keys($entityMultipleSelectClauses);
if (!empty($multipleFieldTablesWithEntityData)) {
- self::buildEntityTreeMultipleFields($groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData);
+ self::buildEntityTreeMultipleFields($groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData
, $singleRecord
);
}
}
}
}
@@
-751,8
+754,10
@@
ORDER BY civicrm_custom_group.weight,
* Array of select clauses relevant to the entity.
* @param array $multipleFieldTablesWithEntityData
* Array of tables in which this entity has data.
* Array of select clauses relevant to the entity.
* @param array $multipleFieldTablesWithEntityData
* Array of tables in which this entity has data.
+ * @param varchar $singleRecord
+ * holds 'new' or id if view/edit/copy form for a single record is being loaded.
*/
*/
- static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData) {
+ static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData
, $singleRecord = NULL
) {
foreach ($entityMultipleSelectClauses as $table => $selectClauses) {
$select = implode(',', $selectClauses);
$query = "
foreach ($entityMultipleSelectClauses as $table => $selectClauses) {
$select = implode(',', $selectClauses);
$query = "
@@
-760,7
+765,11
@@
ORDER BY civicrm_custom_group.weight,
FROM $table
WHERE entity_id = $entityID
";
FROM $table
WHERE entity_id = $entityID
";
- self::buildTreeEntityDataFromQuery($groupTree, $query, array($table));
+ if ($singleRecord) {
+ $offset = $singleRecord - 1;
+ $query .= " LIMIT {$offset}, 1";
+ }
+ self::buildTreeEntityDataFromQuery($groupTree, $query, array($table), $singleRecord);
}
}
}
}
@@
-776,8
+785,10
@@
ORDER BY civicrm_custom_group.weight,
* @param array $includedTables
* Tables to include - required because the function (for historical reasons).
* iterates through the group tree
* @param array $includedTables
* Tables to include - required because the function (for historical reasons).
* iterates through the group tree
+ * @param varchar $singleRecord
+ * holds 'new' OR id if view/edit/copy form for a single record is being loaded.
*/
*/
- static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables) {
+ static public function buildTreeEntityDataFromQuery(&$groupTree, $query, $includedTables
, $singleRecord = NULL
) {
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
foreach ($groupTree as $groupID => $group) {
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
foreach ($groupTree as $groupID => $group) {
@@
-792,7
+803,7
@@
ORDER BY civicrm_custom_group.weight,
continue;
}
foreach ($group['fields'] as $fieldID => $dontCare) {
continue;
}
foreach ($group['fields'] as $fieldID => $dontCare) {
- self::buildCustomFieldData($dao, $groupTree, $table, $groupID, $fieldID);
+ self::buildCustomFieldData($dao, $groupTree, $table, $groupID, $fieldID
, $singleRecord
);
}
}
}
}
}
}
@@
-811,8
+822,10
@@
ORDER BY civicrm_custom_group.weight,
* Custom group ID.
* @param int $fieldID
* Custom field ID.
* Custom group ID.
* @param int $fieldID
* Custom field ID.
+ * @param varchar $singleRecord
+ * holds 'new' or id if loading view/edit/copy for a single record.
*/
*/
- static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID) {
+ static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $fieldID
, $singleRecord = NULL
) {
$column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
$idName = "{$table}_id";
$fieldName = "{$table}_{$column}";
$column = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
$idName = "{$table}_id";
$fieldName = "{$table}_{$column}";
@@
-896,7
+909,10
@@
ORDER BY civicrm_custom_group.weight,
if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
}
if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array();
}
- if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
+ if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue']) && !empty($singleRecord)) {
+ $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array($singleRecord => $customValue);
+ }
+ elseif (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
}
else {
$groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue);
}
else {
diff --git
a/CRM/Custom/Form/CustomData.php
b/CRM/Custom/Form/CustomData.php
index be7338081aa5ab5fda559b7cf757c18b51faa4ef..51547d825ef4f01c1b6e772c3bdaf72e86e2e5ab 100644
(file)
--- a/
CRM/Custom/Form/CustomData.php
+++ b/
CRM/Custom/Form/CustomData.php
@@
-151,6
+151,14
@@
class CRM_Custom_Form_CustomData {
* @return array
*/
public static function setGroupTree(&$form, $subType, $gid, $onlySubType = NULL, $getCachedTree = FALSE) {
* @return array
*/
public static function setGroupTree(&$form, $subType, $gid, $onlySubType = NULL, $getCachedTree = FALSE) {
+ $singleRecord = NULL;
+ if (!empty($form->_groupCount) && $form->_multiRecordDisplay == 'single') {
+ $singleRecord = $form->_groupCount;
+ }
+ $mode = CRM_Utils_Request::retrieve('mode', 'String', $form);
+ if ($form->_groupCount == 0 && $mode == 'add' && $form->_multiRecordDisplay == 'single') {
+ $singleRecord = 'new';
+ }
$groupTree = CRM_Core_BAO_CustomGroup::getTree($form->_type,
$form,
$groupTree = CRM_Core_BAO_CustomGroup::getTree($form->_type,
$form,
@@
-159,7
+167,10
@@
class CRM_Custom_Form_CustomData {
$subType,
$form->_subName,
$getCachedTree,
$subType,
$form->_subName,
$getCachedTree,
- $onlySubType
+ $onlySubType,
+ FALSE,
+ TRUE,
+ $singleRecord
);
if (property_exists($form, '_customValueCount') && !empty($groupTree)) {
);
if (property_exists($form, '_customValueCount') && !empty($groupTree)) {
diff --git
a/CRM/Profile/Page/MultipleRecordFieldsListing.php
b/CRM/Profile/Page/MultipleRecordFieldsListing.php
index 1598f4f8df1de14593d18fd9e54b6064f48c10f9..63f1e30d4286d43c034f33b30435d8a37de9b2c3 100644
(file)
--- a/
CRM/Profile/Page/MultipleRecordFieldsListing.php
+++ b/
CRM/Profile/Page/MultipleRecordFieldsListing.php
@@
-109,7
+109,7
@@
class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
elseif ($this->_pageViewType == 'customDataView') {
// custom data specific view links
$links[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/view/cd';
elseif ($this->_pageViewType == 'customDataView') {
// custom data specific view links
$links[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/view/cd';
- $links[CRM_Core_Action::VIEW]['qs'] = 'reset=1&gid=%%gid%%&cid=%%cid%%&recId=%%recId%%&multiRecordDisplay=single&mode=view';
+ $links[CRM_Core_Action::VIEW]['qs'] = 'reset=1&gid=%%gid%%&cid=%%cid%%&recId=%%recId%%&
cgcount=%%cgcount%%&
multiRecordDisplay=single&mode=view';
// custom data specific update links
$links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/contact/view/cd/edit';
// custom data specific update links
$links[CRM_Core_Action::UPDATE]['url'] = 'civicrm/contact/view/cd/edit';