From acd924de32bb40be3305027b812f83ba7310bf6f Mon Sep 17 00:00:00 2001 From: diosmosis Date: Mon, 16 Mar 2015 18:44:25 -0700 Subject: Fixes #7223, add new INI option [General] process_new_segments_from that controls the start date of archiving for segments that have not been archived before. If a creation date cannot be found, now is used. --- plugins/SegmentEditor/Model.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugins') diff --git a/plugins/SegmentEditor/Model.php b/plugins/SegmentEditor/Model.php index 8bfcc957ae..2192e3ca58 100644 --- a/plugins/SegmentEditor/Model.php +++ b/plugins/SegmentEditor/Model.php @@ -25,6 +25,21 @@ class Model $this->table = Common::prefixTable(self::$rawPrefix); } + /** + * Returns all stored segments that haven't been deleted. Ignores the site the segments are enabled + * for and whether to auto archive or not. + * + * @return array + */ + public function getAllSegmentsAndIgnoreVisibility() + { + $sql = "SELECT * FROM " . $this->table . " WHERE deleted = 0"; + + $segments = $this->getDb()->fetchAll($sql); + + return $segments; + } + /** * Returns all stored segments. * -- cgit v1.2.3 From d92175983c26a964e909c6463a88073e5540ada7 Mon Sep 17 00:00:00 2001 From: mattab Date: Thu, 19 Mar 2015 18:53:04 +1300 Subject: Fix unit tests --- plugins/SegmentEditor/Model.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/SegmentEditor/Model.php b/plugins/SegmentEditor/Model.php index 2192e3ca58..7f312557f9 100644 --- a/plugins/SegmentEditor/Model.php +++ b/plugins/SegmentEditor/Model.php @@ -18,11 +18,10 @@ use Piwik\DbHelper; class Model { private static $rawPrefix = 'segment'; - private $table; - public function __construct() + protected function getTable() { - $this->table = Common::prefixTable(self::$rawPrefix); + return Common::prefixTable(self::$rawPrefix); } /** @@ -33,7 +32,7 @@ class Model */ public function getAllSegmentsAndIgnoreVisibility() { - $sql = "SELECT * FROM " . $this->table . " WHERE deleted = 0"; + $sql = "SELECT * FROM " . $this->getTable() . " WHERE deleted = 0"; $segments = $this->getDb()->fetchAll($sql); @@ -102,7 +101,7 @@ class Model public function deleteSegment($idSegment) { $db = $this->getDb(); - $db->delete($this->table, 'idsegment = ' . (int) $idSegment); + $db->delete($this->getTable(), 'idsegment = ' . (int) $idSegment); } public function updateSegment($idSegment, $segment) @@ -110,7 +109,7 @@ class Model $idSegment = (int) $idSegment; $db = $this->getDb(); - $db->update($this->table, $segment, "idsegment = $idSegment"); + $db->update($this->getTable(), $segment, "idsegment = $idSegment"); return true; } @@ -118,7 +117,7 @@ class Model public function createSegment($segment) { $db = $this->getDb(); - $db->insert($this->table, $segment); + $db->insert($this->getTable(), $segment); $id = $db->lastInsertId(); return $id; @@ -127,7 +126,7 @@ class Model public function getSegment($idSegment) { $db = $this->getDb(); - $segment = $db->fetchRow("SELECT * FROM " . $this->table . " WHERE idsegment = ?", $idSegment); + $segment = $db->fetchRow("SELECT * FROM " . $this->getTable() . " WHERE idsegment = ?", $idSegment); return $segment; } @@ -139,7 +138,7 @@ class Model private function buildQuerySortedByName($where) { - return "SELECT * FROM " . $this->table . " WHERE $where ORDER BY name ASC"; + return "SELECT * FROM " . $this->getTable() . " WHERE $where ORDER BY name ASC"; } public static function install() -- cgit v1.2.3