diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-02-26 16:21:47 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-02-26 16:21:47 +0400 |
commit | 7c7a8776f526d274fae687d7c74fa682c6a527c5 (patch) | |
tree | 9e66b598d2c9fd29e2ca0366a4c4e465fd472eb0 /plugins/Annotations | |
parent | bba1420dd5effbfde43f592007a5566d7a808697 (diff) |
Refs #4189, add Annotations.deleteAll API method, work around popover issue in phantomjs (modifying window.location.href directly erases JavaScript state for page even if the URL is the same) and tweak user creation in test fixture setup.
Diffstat (limited to 'plugins/Annotations')
-rwxr-xr-x | plugins/Annotations/API.php | 19 | ||||
-rwxr-xr-x | plugins/Annotations/AnnotationList.php | 16 |
2 files changed, 34 insertions, 1 deletions
diff --git a/plugins/Annotations/API.php b/plugins/Annotations/API.php index 35445cc304..a390f01883 100755 --- a/plugins/Annotations/API.php +++ b/plugins/Annotations/API.php @@ -109,7 +109,7 @@ class API extends \Piwik\Plugin\API */ public function delete($idSite, $idNote) { - $this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot delete multiple notes."); + $this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot delete annotations from multiple sites."); $annotations = new AnnotationList($idSite); @@ -122,6 +122,23 @@ class API extends \Piwik\Plugin\API } /** + * Removes all annotations for a single site. Only super users can use this method. + * + * @param string $idSite The ID of the site to remove annotations for. + */ + public function deleteAll($idSite) + { + $this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot delete annotations from multiple sites."); + Piwik::checkUserHasSuperUserAccess(); + + $annotations = new AnnotationList($idSite); + + // remove the notes & save the list + $annotations->removeAll($idSite); + $annotations->save($idSite); + } + + /** * Returns a single note for one site. * * @param string $idSite The site ID to add the annotation to. diff --git a/plugins/Annotations/AnnotationList.php b/plugins/Annotations/AnnotationList.php index 0ba595b8a0..ad95e47f7d 100755 --- a/plugins/Annotations/AnnotationList.php +++ b/plugins/Annotations/AnnotationList.php @@ -162,6 +162,22 @@ class AnnotationList } /** + * Removes all notes for a single site. + * + * Note: This method does not perist the change in the DB. The save method must + * be called for that. + * + * @param int $idSite The ID of the site to get an annotation for. + * @throws Exception if $idSite is not an ID that was supplied upon construction. + */ + public function removeAll($idSite) + { + $this->checkIdSiteIsLoaded($idSite); + + $this->annotations[$idSite] = array(); + } + + /** * Retrieves an annotation by ID. * * This function returns an array with the following elements: |