Commit 6d35a3f4 authored by RobertPlummer's avatar RobertPlummer

[ENH] TrackerQueryLib becomes Tracker_Query, and is now included as part of the Zend class system

[ENH] Before TrackerQueryLib was initiated at startup, but now needed to change a few methods to static to ensure loading correctly
parent 68dfa7ee
......@@ -2611,6 +2611,7 @@ lib/core/Tracker/Field/UserSubscription.php -text
lib/core/Tracker/Field/WebService.php -text
lib/core/Tracker/Field/index.php -text
lib/core/Tracker/Item.php -text
lib/core/Tracker/Query.php -text
lib/core/Tracker/index.php -text
lib/core/Transition.php -text
lib/core/WikiParser/OutputLink.php -text
......@@ -4138,7 +4139,6 @@ lib/toolbars/tiki-admin_toolbars.js -text
lib/toolbars/toolbarslib.php -text
lib/trackers/index.php -text
lib/trackers/trackerlib.php -text
lib/trackers/trackerquerylib.php -text
lib/transitionlib.php -text
lib/tree/BrowseTreeMaker.php -text
lib/tree/index.php -text
......
......@@ -167,8 +167,7 @@ JQ
JQ
);
$wikiAttributes = TikiLib::lib('trkqry')
->tracker('Wiki Attributes')
$wikiAttributes = Tracker_Query::tracker('Wiki Attributes')
->byName()
->filter(array('field'=> 'Type','value'=> 'Question'))
->filter(array('field'=> 'Page','value'=> $args['object']))
......@@ -196,15 +195,14 @@ JQ
->add_jsfile('lib/jquery/md5.js');
$authorDetails = json_encode(
end(
TikiLib::lib('trkqry')
->tracker('ForwardLink Author Details')
->byName()
->excludeDetails()
->filter(array('field'=> 'User','value'=> $user))
->render(false)
->query()
)
end(
Tracker_Query::tracker('ForwardLink Author Details')
->byName()
->excludeDetails()
->filter(array('field'=> 'User','value'=> $user))
->render(false)
->query()
)
);
$page = urlencode($args['object']);
......
......@@ -25,8 +25,7 @@ class Feed_ForwardLink_PageLookup extends Feed_Abstract
static $Feed_ForwardLink_PageLookup = 0;
++$Feed_ForwardLink_PageLookup;
$wikiAttributes = TikiLib::lib('trkqry')
->tracker('Wiki Attributes')
$wikiAttributes = Tracker_Query::tracker('Wiki Attributes')
->byName()
->excludeDetails()
->filter(array('field'=> 'Type', 'value'=> 'ForwardLink'))
......
......@@ -131,7 +131,7 @@ class Report_Definition_Tracker
{
$tracker = $values['tracker'];
$qry = TikiLib::lib('trkqry')->tracker($tracker['value'])
$qry = Tracker_Query::tracker($tracker['value'])
->start($tracker['start']['value'])
->end($tracker['end']['value'])
->itemId($tracker['itemId']['value'])
......
......@@ -22,15 +22,7 @@
* @since TIki 8
*/
/**
* This script may only be included, so it is better to die if called directly.
*/
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
header("location: index.php");
exit;
}
class TrackerQueryLib
class Tracker_Query
{
private $tracker;
private $start = 0;
......@@ -269,7 +261,7 @@ class TrackerQueryLib
* Adds the field names to the beginning of the array of tracker items
*
*/
function prepend_field_header(&$trackerPrimary = array(), $nameOrder = array())
static function prepend_field_header(&$trackerPrimary = array(), $nameOrder = array())
{
global $tikilib;
$result = $tikilib->fetchAll("SELECT fieldId, trackerId, name FROM tiki_tracker_fields");
......@@ -312,7 +304,7 @@ class TrackerQueryLib
* Simple direction parsing from string to type
*
*/
private function sort_direction($dir)
static private function sort_direction($dir)
{
switch ( $dir ) {
case "asc":
......@@ -342,15 +334,15 @@ class TrackerQueryLib
return $dir;
}
function arfsort( &$array, $fieldList )
static function arfsort( &$array, $fieldList )
{
if (!is_array($fieldList)) {
$fieldList = explode('|', $fieldList);
$fieldList = array(array($fieldList[0], $this->sort_direction($fieldList[1])));
$fieldList = array(array($fieldList[0], self::sort_direction($fieldList[1])));
} else {
for ($i = 0, $count_fieldList = count($fieldList); $i < $count_fieldList; ++$i) {
$fieldList[$i] = explode('|', $fieldList[$i]);
$fieldList[$i] = array($fieldList[$i][0], $this->sort_direction($fieldList[$i][1]));
$fieldList[$i] = array($fieldList[$i][0], self::sort_direction($fieldList[$i][1]));
}
}
......@@ -648,7 +640,7 @@ class TrackerQueryLib
* Removes fields from an array of items, can use either fields to show, or fields to remove, but not both
*
*/
function filter_fields_from_tracker_query($tracker, $fieldIdsToRemove = array(), $fieldIdsToShow = array())
static function filter_fields_from_tracker_query($tracker, $fieldIdsToRemove = array(), $fieldIdsToShow = array())
{
if (empty($fieldIdsToShow) == false) {
$newTracker = array();
......@@ -677,7 +669,7 @@ class TrackerQueryLib
* Joins tracker arrays together.
*
*/
function join_trackers($trackerLeft, $trackerRight, $fieldLeftId, $joinType)
static function join_trackers($trackerLeft, $trackerRight, $fieldLeftId, $joinType)
{
$joinedTracker = array();
......@@ -714,7 +706,7 @@ class TrackerQueryLib
}
function to_csv($array, $header = false, $col_sep = ",", $row_sep = "\n", $qut = '"', $fileName = 'file.csv')
static function to_csv($array, $header = false, $col_sep = ",", $row_sep = "\n", $qut = '"', $fileName = 'file.csv')
{
header("Content-type: application/csv");
......@@ -761,6 +753,4 @@ class TrackerQueryLib
return $output;
}
}
$trkqrylib = new TrackerQueryLib();
}
\ No newline at end of file
......@@ -1036,10 +1036,10 @@ class TikiSheetTrackerHandler extends TikiSheetDataHandler
// _load {{{2
function _load( &$sheet ) {
global $tikilib;
TikiLib::lib("trkqry");
$i = 0;
$trackerName = $this->info['name'];
$tracker = TrackerQueryLib::tracker($trackerName)
$tracker = Tracker_Query::tracker($trackerName)
->byName()
->excludeDetails()
->render(false)
......
......@@ -78,9 +78,6 @@ class TikiLib extends TikiDb_Bridge
case 'trk':
global $trklib; require_once('lib/trackers/trackerlib.php');
return self::$libraries[$name] = $trklib;
case 'trkqry':
global $trkqrylib; require_once('lib/trackers/trackerquerylib.php');
return self::$libraries[$name] = $trkqrylib;
case 'wiki':
global $wikilib; include_once('lib/wiki/wikilib.php');
return self::$libraries[$name] = $wikilib;
......
......@@ -47,7 +47,6 @@ function wikiplugin_contributionsdashboard($data, $params)
{
global $tikilib, $headerlib, $user;
$trklib = TikiLib::lib("trk");
$trkqrylib = TikiLib::lib("trkqry");
$logsqrylib = TikiLib::lib("logsqry");
$smarty = TikiLib::lib("smarty");
......
......@@ -86,7 +86,6 @@ function wikiplugin_trackeritemcopy( $data, $params )
{
global $smarty;
$trklib = TikiLib::lib("trk");
TikiLib::lib("trkqry");
if (!isset($params["trackerId"]) || !isset($params["copyFieldIds"])) {
return tra('Missing mandatory parameters');
......@@ -212,7 +211,7 @@ function wikiplugin_trackeritemcopy( $data, $params )
if ($copies > 0) {
if ($key > 0) {
$qry = TrackerQueryLib::tracker($trackerIdLeft)
$qry = Tracker_Query::tracker($trackerIdLeft)
->fields($params["linkFieldIds"][0])
->equals(array($itemId));
......
......@@ -7,7 +7,6 @@
require_once('tiki-setup.php');
$trklib = TikiLib::lib('trk');
TikiLib::lib('trkqry');
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
......@@ -89,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$invoiceItems = array();
if (!empty($_REQUEST['InvoiceId'])) {
$invoice = TrackerQueryLib::tracker("Invoices")
$invoice = Tracker_Query::tracker("Invoices")
->byName()
->equals($_REQUEST['InvoiceId'])
->getOne();
......@@ -97,7 +96,7 @@ if (!empty($_REQUEST['InvoiceId'])) {
$invoice['Item Ids'] = implode(',', $invoice['Item Ids']);
$smarty->assign("invoice", $invoice);
$invoiceItems = TrackerQueryLib::tracker("Invoice Items")
$invoiceItems = Tracker_Query::tracker("Invoice Items")
->byName()
->fields(array("Invoice Id"))
->search(array($_REQUEST['InvoiceId']))
......@@ -107,7 +106,7 @@ if (!empty($_REQUEST['InvoiceId'])) {
}
//give the user the last invoice number
$LastInvoice = TrackerQueryLib::tracker("Invoices")
$LastInvoice = Tracker_Query::tracker("Invoices")
->byName()
->limit(0)
->offset(1)
......@@ -119,8 +118,8 @@ $NewInvoiceNumber = (isset($LastInvoice["Invoice Number"]) ? $LastInvoice["Invoi
$smarty->assign("NewInvoiceNumber", $NewInvoiceNumber);
$smarty->assign("InvoiceId", $_REQUEST['InvoiceId']);
$smarty->assign("clients", TrackerQueryLib::tracker("Invoice Clients")->byName()->query());
$smarty->assign("setting", TrackerQueryLib::tracker("Invoice Settings")->byName()->getOne());
$smarty->assign("clients", Tracker_Query::tracker("Invoice Clients")->byName()->query());
$smarty->assign("setting", Tracker_Query::tracker("Invoice Settings")->byName()->getOne());
//we add an extra item to the end of invoiceItems, so we can duplicate it on the page
if (count($invoiceItems) < 1) {
......
......@@ -7,7 +7,6 @@
require_once('tiki-setup.php');
$trklib = TikiLib::lib('trk');
TikiLib::lib('trkqry');
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
......@@ -29,8 +28,8 @@ $headerlib->add_jq_onready(
});"
);
$smarty->assign("Clients", TrackerQueryLib::tracker("Invoice Clients")->byName()->query());
$smarty->assign("Settings", TrackerQueryLib::tracker("Invoice Settings")->byName()->getOne());
$smarty->assign("Clients", Tracker_Query::tracker("Invoice Clients")->byName()->query());
$smarty->assign("Settings", Tracker_Query::tracker("Invoice Settings")->byName()->getOne());
// Display the template
$smarty->assign('mid', 'tiki-list_invoice_clients.tpl');
......
......@@ -7,7 +7,6 @@
require_once('tiki-setup.php');
$trklib = TikiLib::lib('trk');
TikiLib::lib('trkqry');
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
......@@ -19,7 +18,7 @@ if ($trklib->get_tracker_by_name("Invoice Items") < 1) {
die;
}
$Invoices = TrackerQueryLib::tracker("Invoices")
$Invoices = Tracker_Query::tracker("Invoices")
->byName(true)
->query();
......@@ -58,7 +57,7 @@ foreach ($Invoices as $I => $Invoice) {
}
$smarty->assign("Invoices", $Invoices);
$smarty->assign("Settings", TrackerQueryLib::tracker("Invoice Settings")->byName()->query());
$smarty->assign("Settings", Tracker_Query::tracker("Invoice Settings")->byName()->query());
$smarty->assign("Amount", $Amount);
$smarty->assign("Paid", $Paid);
$smarty->assign("Status", $Status);
......
......@@ -17,20 +17,18 @@ $auto_query_args = array(
'list'
);
TikiLib::lib("trkqry");
$projectList = TrackerQueryLib::tracker("Project list")->byName()->query();
$projectList = Tracker_Query::tracker("Project list")->byName()->query();
if (isset($_REQUEST['all'])) { //all views all sheet items
$smarty->assign("all", true);
$timeSheet = TrackerQueryLib::tracker("Time sheet")
$timeSheet = Tracker_Query::tracker("Time sheet")
->byName()
->query();
} else {//views only your items
$smarty->assign("all", false);
$timeSheet = TrackerQueryLib::tracker("Time sheet")
$timeSheet = Tracker_Query::tracker("Time sheet")
->byName()
->search(array($user))->fields(array("Done by"))
->query();
......
......@@ -18,7 +18,6 @@ if ($tiki_p_admin_trackers != 'y') {
}
$trklib = TikiLib::lib("trk");
$trkqrylib = TikiLib::lib("trkqry");
//TODO: This needs rewritten to match tiki
function dateFormat($fieldIds, $tracker)
......@@ -98,7 +97,7 @@ if (isset($_REQUEST['trackerIds']) == true) {
$i = 0;
foreach ($_REQUEST['trackerIds'] as $key => $trackerId) {
if ($key == 0) {
$trackerPrimary = TrackerQueryLib::tracker($trackerId)
$trackerPrimary = Tracker_Query::tracker($trackerId)
->start($_REQUEST['start'][$key])
->end($_REQUEST['end'][$key])
->equals($_REQUEST['q'][$key])
......@@ -110,9 +109,9 @@ if (isset($_REQUEST['trackerIds']) == true) {
$joinVars = $_REQUEST['itemIdFields'][$key - 1];
$joinVars = explode('|', $joinVars);
$trackerPrimary = $trkqrylib->join_trackers(
$trackerPrimary = Tracker_Query::join_trackers(
$trackerPrimary,
TrackerQueryLib::tracker($trackerId)
Tracker_Query::tracker($trackerId)
->start($_REQUEST['start'][$key])
->end($_REQUEST['end'][$key])
->equals($_REQUEST['q'][$key])
......@@ -129,21 +128,21 @@ if (isset($_REQUEST['trackerIds']) == true) {
}
if (isset($_REQUEST['sortFieldIds']) == true) {
$trkqrylib->arfsort($trackerPrimary, $_REQUEST['sortFieldIds']);
Tracker_Query::arfsort($trackerPrimary, $_REQUEST['sortFieldIds']);
}
if (
isset($_REQUEST['removeFieldIds']) == true ||
isset($_REQUEST['showFieldIds']) == true
) {
$trackerPrimary = $trkqrylib->filter_fields_from_tracker_query($trackerPrimary, $_REQUEST['removeFieldIds'], $_REQUEST['showFieldIds']);
$trackerPrimary = Tracker_Query::filter_fields_from_tracker_query($trackerPrimary, $_REQUEST['removeFieldIds'], $_REQUEST['showFieldIds']);
}
if (isset($_REQUEST['dateFieldIds'])) {
$trackerPrimary = dateFormat($_REQUEST['dateFieldIds'], $trackerPrimary);
}
$trackerPrimary = $trkqrylib->prepend_field_header($trackerPrimary, $_REQUEST['sortFieldNames']);
$trackerPrimary = Tracker_Query::prepend_field_header($trackerPrimary, $_REQUEST['sortFieldNames']);
if (isset($_REQUEST['time']) == true) {
$endtime = microtime();
......@@ -155,5 +154,5 @@ if (isset($_REQUEST['time']) == true) {
}
if ($_REQUEST['type'] == 'csv' && count($trackerPrimary) > 0) {
print_r($trkqrylib->to_csv($trackerPrimary));
print_r(Tracker_Query::to_csv($trackerPrimary));
}
......@@ -6,7 +6,6 @@
// $Id$
require_once('tiki-setup.php');
$trkqry = TikiLib::lib("trk");
if ($tiki_p_admin_trackers != 'y') {
$access->display_error('', tra('Permission denied').": ". 'tiki_p_admin_trackers', '403');
......
......@@ -7,7 +7,6 @@
require_once('tiki-setup.php');
$trklib = TikiLib::lib('trk');
TikiLib::lib('trkqry');
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
......@@ -21,7 +20,7 @@ if ($trklib->get_tracker_by_name("Invoice Items") < 1) {
(int)$_REQUEST['InvoiceId'] = $_REQUEST['InvoiceId'];
$smarty->assign('InvoiceId', $_REQUEST['InvoiceId']);
$invoice = TrackerQueryLib::tracker("Invoices")
$invoice = Tracker_Query::tracker("Invoices")
->byName()
->equals($_REQUEST['InvoiceId'])
->getOne();
......@@ -40,20 +39,20 @@ $smarty->assign("invoice", $invoice);
$smarty->assign("amount", $amount);
$smarty->assign(
"client",
TrackerQueryLib::tracker("Invoice Clients")
Tracker_Query::tracker("Invoice Clients")
->fields(array("Client Id"))->equals(array($invoice['Client Id']))
->byName()
->getOne()
);
$smarty->assign(
"setting",
TrackerQueryLib::tracker("Invoice Settings")
Tracker_Query::tracker("Invoice Settings")
->byName()
->query()
);
$smarty->assign(
"invoiceItems",
TrackerQueryLib::tracker("Invoice Items")
Tracker_Query::tracker("Invoice Items")
->fields(array("Invoice Id"))->equals(array($_REQUEST['InvoiceId']))
->byName()
->query()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment