Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
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
Development
CiviCRM Core
Commits
1f591bab
Commit
1f591bab
authored
3 years ago
by
colemanw
Browse files
Options
Downloads
Patches
Plain Diff
Deprecate 2 del() functions in favor of generics and hook callbacks
#2757
parent
81e4aa09
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Campaign/BAO/Survey.php
+17
-10
17 additions, 10 deletions
CRM/Campaign/BAO/Survey.php
CRM/Report/BAO/ReportInstance.php
+18
-13
18 additions, 13 deletions
CRM/Report/BAO/ReportInstance.php
with
35 additions
and
23 deletions
CRM/Campaign/BAO/Survey.php
+
17
−
10
View file @
1f591bab
...
...
@@ -18,7 +18,7 @@
/**
* Class CRM_Campaign_BAO_Survey.
*/
class
CRM_Campaign_BAO_Survey
extends
CRM_Campaign_DAO_Survey
{
class
CRM_Campaign_BAO_Survey
extends
CRM_Campaign_DAO_Survey
implements
Civi\Test\HookInterface
{
/**
* Retrieve DB object based on input parameters.
...
...
@@ -366,24 +366,31 @@ SELECT survey.id as id,
}
/**
* Delete
the
survey.
* Delete
a
survey.
*
* @param int $id
* Survey id.
*
* @deprecated
* @return mixed|null
*/
public
static
function
del
(
$id
)
{
if
(
!
$id
)
{
return
NULL
;
}
$reportId
=
CRM_Campaign_BAO_Survey
::
getReportID
(
$id
);
if
(
$reportId
)
{
CRM_Report_BAO_ReportInstance
::
del
(
$reportId
);
self
::
deleteRecord
([
'id'
=>
$id
]);
return
1
;
}
/**
* Event fired prior to modifying a Survey.
* @param \Civi\Core\Event\PreEvent $event
*/
public
static
function
self_hook_civicrm_pre
(
\Civi\Core\Event\PreEvent
$event
)
{
if
(
$event
->
action
===
'delete'
&&
$event
->
id
)
{
$reportId
=
self
::
getReportID
(
$event
->
id
);
if
(
$reportId
)
{
CRM_Report_BAO_ReportInstance
::
deleteRecord
([
'id'
=>
$reportId
]);
}
}
$dao
=
new
CRM_Campaign_DAO_Survey
();
$dao
->
id
=
$id
;
return
$dao
->
delete
();
}
/**
...
...
This diff is collapsed.
Click to expand it.
CRM/Report/BAO/ReportInstance.php
+
18
−
13
View file @
1f591bab
...
...
@@ -14,7 +14,7 @@
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
class
CRM_Report_BAO_ReportInstance
extends
CRM_Report_DAO_ReportInstance
{
class
CRM_Report_BAO_ReportInstance
extends
CRM_Report_DAO_ReportInstance
implements
Civi\Test\HookInterface
{
/**
* Takes an associative array and creates an instance object.
...
...
@@ -219,22 +219,27 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance {
* Delete the instance of the Report.
*
* @param int $id
*
*
@deprecated
* @return mixed
* $results no of deleted Instance on success, false otherwise
*/
public
static
function
del
(
$id
=
NULL
)
{
$navId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Report_DAO_ReportInstance'
,
$id
,
'navigation_id'
,
'id'
);
$dao
=
new
CRM_Report_DAO_ReportInstance
();
$dao
->
id
=
$id
;
$result
=
$dao
->
delete
();
// Delete navigation if exists.
if
(
$navId
)
{
CRM_Core_BAO_Navigation
::
processDelete
(
$navId
);
CRM_Core_BAO_Navigation
::
resetNavigation
();
self
::
deleteRecord
([
'id'
=>
$id
]);
return
1
;
}
/**
* Event fired prior to modifying a ReportInstance.
* @param \Civi\Core\Event\PreEvent $event
*/
public
static
function
self_hook_civicrm_pre
(
\Civi\Core\Event\PreEvent
$event
)
{
if
(
$event
->
action
===
'delete'
&&
$event
->
id
)
{
// When deleting a report, also delete from navigation menu
$navId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Report_DAO_ReportInstance'
,
$event
->
id
,
'navigation_id'
);
if
(
$navId
)
{
CRM_Core_BAO_Navigation
::
processDelete
(
$navId
);
CRM_Core_BAO_Navigation
::
resetNavigation
();
}
}
return
$result
;
}
/**
...
...
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