Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
civicrm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plugins
civicrm
Commits
fbf56476
Verified
Commit
fbf56476
authored
6 years ago
by
Coleman Watts
Committed by
Kevin Cristiano
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Simple function extraction
Signed-off-by:
Kevin Cristiano
<
kcristiano@tadpole.cc
>
parent
b9fb33da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
civicrm/CRM/Contact/Page/View/Summary.php
+69
-64
69 additions, 64 deletions
civicrm/CRM/Contact/Page/View/Summary.php
civicrm/CRM/Core/Component.php
+3
-3
3 additions, 3 deletions
civicrm/CRM/Core/Component.php
with
72 additions
and
67 deletions
civicrm/CRM/Contact/Page/View/Summary.php
+
69
−
64
View file @
fbf56476
...
...
@@ -264,23 +264,57 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
$lastModified
=
CRM_Core_BAO_Log
::
lastModified
(
$this
->
_contactId
,
'civicrm_contact'
);
$this
->
assign_by_ref
(
'lastModified'
,
$lastModified
);
$allTabs
=
array
();
$weight
=
10
;
$this
->
_viewOptions
=
CRM_Core_BAO_Setting
::
valueOptions
(
CRM_Core_BAO_Setting
::
SYSTEM_PREFERENCES_NAME
,
'contact_view_options'
,
TRUE
);
// show the tabs only if user has generic access to CiviCRM
$accessCiviCRM
=
CRM_Core_Permission
::
check
(
'access CiviCRM'
);
$changeLog
=
$this
->
_viewOptions
[
'log'
];
$this
->
assign_by_ref
(
'changeLog'
,
$changeLog
);
$components
=
CRM_Core_Component
::
getEnabledComponents
();
foreach
(
$components
as
$name
=>
$component
)
{
$this
->
assign
(
'allTabs'
,
$this
->
getTabs
());
// hook for contact summary
// ignored but needed to prevent warnings
$contentPlacement
=
CRM_Utils_Hook
::
SUMMARY_BELOW
;
CRM_Utils_Hook
::
summary
(
$this
->
_contactId
,
$content
,
$contentPlacement
);
if
(
$content
)
{
$this
->
assign_by_ref
(
'hookContent'
,
$content
);
$this
->
assign
(
'hookContentPlacement'
,
$contentPlacement
);
}
}
/**
* @return string
*/
public
function
getTemplateFileName
()
{
if
(
$this
->
_contactId
)
{
$contactSubtypes
=
$this
->
get
(
'contactSubtype'
)
?
explode
(
CRM_Core_DAO
::
VALUE_SEPARATOR
,
$this
->
get
(
'contactSubtype'
))
:
array
();
// there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
foreach
(
$contactSubtypes
as
$csType
)
{
if
(
$csType
)
{
$templateFile
=
"CRM/Contact/Page/View/SubType/
{
$csType
}
.tpl"
;
$template
=
CRM_Core_Page
::
getTemplate
();
if
(
$template
->
template_exists
(
$templateFile
))
{
return
$templateFile
;
}
}
}
}
return
parent
::
getTemplateFileName
();
}
/**
* @return array
* @throws \CRM_Core_Exception
*/
public
function
getTabs
()
{
$allTabs
=
[];
$weight
=
10
;
foreach
(
CRM_Core_Component
::
getEnabledComponents
()
as
$name
=>
$component
)
{
if
(
!
empty
(
$this
->
_viewOptions
[
$name
])
&&
CRM_Core_Permission
::
access
(
$component
->
name
)
)
{
...
...
@@ -302,14 +336,14 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
if
(
CRM_Utils_Request
::
retrieve
(
'isTest'
,
'Positive'
,
$this
))
{
$q
.
=
"&isTest=1"
;
}
$allTabs
[]
=
array
(
$allTabs
[]
=
[
'id'
=>
$i
,
'url'
=>
CRM_Utils_System
::
url
(
"civicrm/contact/view/
$u
"
,
$q
),
'title'
=>
$elem
[
'title'
],
'weight'
=>
$elem
[
'weight'
],
'count'
=>
CRM_Contact_BAO_Contact
::
getCountComponent
(
$u
,
$this
->
_contactId
),
'class'
=>
'livePage'
,
)
;
]
;
// make sure to get maximum weight, rest of tabs go after
// FIXME: not very elegant again
if
(
$weight
<
$elem
[
'weight'
])
{
...
...
@@ -318,34 +352,36 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
}
}
$rest
=
array
(
'activity'
=>
array
(
$rest
=
[
'activity'
=>
[
'title'
=>
ts
(
'Activities'
),
'class'
=>
'livePage'
,
)
,
'rel'
=>
array
(
]
,
'rel'
=>
[
'title'
=>
ts
(
'Relationships'
),
'class'
=>
'livePage'
,
)
,
'group'
=>
array
(
]
,
'group'
=>
[
'title'
=>
ts
(
'Groups'
),
'class'
=>
'ajaxForm'
,
)
,
'note'
=>
array
(
]
,
'note'
=>
[
'title'
=>
ts
(
'Notes'
),
'class'
=>
'livePage'
,
)
,
'tag'
=>
array
(
]
,
'tag'
=>
[
'title'
=>
ts
(
'Tags'
),
)
,
'log'
=>
array
(
]
,
'log'
=>
[
'title'
=>
ts
(
'Change Log'
),
)
,
)
;
]
,
]
;
// show the tabs only if user has generic access to CiviCRM
$accessCiviCRM
=
CRM_Core_Permission
::
check
(
'access CiviCRM'
);
foreach
(
$rest
as
$k
=>
$v
)
{
if
(
$accessCiviCRM
&&
!
empty
(
$this
->
_viewOptions
[
$k
]))
{
$allTabs
[]
=
$v
+
array
(
$allTabs
[]
=
$v
+
[
'id'
=>
$k
,
'url'
=>
CRM_Utils_System
::
url
(
"civicrm/contact/view/
$k
"
,
...
...
@@ -353,7 +389,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
),
'weight'
=>
$weight
,
'count'
=>
CRM_Contact_BAO_Contact
::
getCountComponent
(
$k
,
$this
->
_contactId
),
)
;
]
;
$weight
+=
10
;
}
}
...
...
@@ -368,7 +404,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
foreach
(
$activeGroups
as
$group
)
{
$id
=
"custom_
{
$group
[
'id'
]
}
"
;
$allTabs
[]
=
array
(
$allTabs
[]
=
[
'id'
=>
$id
,
'url'
=>
CRM_Utils_System
::
url
(
$group
[
'path'
],
$group
[
'query'
]
.
"&selectedChild=
$id
"
),
'title'
=>
$group
[
'title'
],
...
...
@@ -376,56 +412,25 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
'count'
=>
CRM_Contact_BAO_Contact
::
getCountComponent
(
$id
,
$this
->
_contactId
,
$group
[
'table_name'
]),
'hideCount'
=>
!
$group
[
'is_multiple'
],
'class'
=>
'livePage'
,
)
;
]
;
$weight
+=
10
;
}
$context
=
array
(
'contact_id'
=>
$this
->
_contactId
)
;
$context
=
[
'contact_id'
=>
$this
->
_contactId
]
;
// see if any other modules want to add any tabs
CRM_Utils_Hook
::
tabs
(
$allTabs
,
$this
->
_contactId
);
CRM_Utils_Hook
::
tabset
(
'civicrm/contact/view'
,
$allTabs
,
$context
);
$allTabs
[]
=
array
(
$allTabs
[]
=
[
'id'
=>
'summary'
,
'url'
=>
'#contact-summary'
,
'title'
=>
ts
(
'Summary'
),
'weight'
=>
0
,
)
;
]
;
// now sort the tabs based on weight
usort
(
$allTabs
,
array
(
'CRM_Utils_Sort'
,
'cmpFunc'
));
$this
->
assign
(
'allTabs'
,
$allTabs
);
// hook for contact summary
// ignored but needed to prevent warnings
$contentPlacement
=
CRM_Utils_Hook
::
SUMMARY_BELOW
;
CRM_Utils_Hook
::
summary
(
$this
->
_contactId
,
$content
,
$contentPlacement
);
if
(
$content
)
{
$this
->
assign_by_ref
(
'hookContent'
,
$content
);
$this
->
assign
(
'hookContentPlacement'
,
$contentPlacement
);
}
}
/**
* @return string
*/
public
function
getTemplateFileName
()
{
if
(
$this
->
_contactId
)
{
$contactSubtypes
=
$this
->
get
(
'contactSubtype'
)
?
explode
(
CRM_Core_DAO
::
VALUE_SEPARATOR
,
$this
->
get
(
'contactSubtype'
))
:
array
();
// there could be multiple subtypes. We check templates for each of the subtype, and return the first one found.
foreach
(
$contactSubtypes
as
$csType
)
{
if
(
$csType
)
{
$templateFile
=
"CRM/Contact/Page/View/SubType/
{
$csType
}
.tpl"
;
$template
=
CRM_Core_Page
::
getTemplate
();
if
(
$template
->
template_exists
(
$templateFile
))
{
return
$templateFile
;
}
}
}
}
return
parent
::
getTemplateFileName
();
usort
(
$allTabs
,
[
'CRM_Utils_Sort'
,
'cmpFunc'
]);
return
$allTabs
;
}
}
This diff is collapsed.
Click to expand it.
civicrm/CRM/Core/Component.php
+
3
−
3
View file @
fbf56476
...
...
@@ -47,7 +47,7 @@ class CRM_Core_Component {
/**
* @param bool $force
*
* @return
array|null
* @return
CRM_Core_Component_Info[]
*/
private
static
function
&
_info
(
$force
=
FALSE
)
{
if
(
!
isset
(
Civi
::
$statics
[
__CLASS__
][
'info'
])
||
$force
)
{
...
...
@@ -84,7 +84,7 @@ class CRM_Core_Component {
/**
* @param bool $force
*
* @return
array
* @return
CRM_Core_Component_Info[]
* @throws Exception
*/
public
static
function
&
getComponents
(
$force
=
FALSE
)
{
...
...
@@ -132,7 +132,7 @@ class CRM_Core_Component {
/**
* @param bool $force
*
* @return
array|null
* @return
CRM_Core_Component_Info[]
*/
static
public
function
&
getEnabledComponents
(
$force
=
FALSE
)
{
return
self
::
_info
(
$force
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment