예제 #1
0
    static function wikiView($args)
    {
        global $tikilib, $headerlib;
        static $Feed_ForwardLink_PageLookup = 0;
        ++$Feed_ForwardLink_PageLookup;
        $wikiAttributes = Tracker_Query::tracker('Wiki Attributes')->byName()->excludeDetails()->filter(array('field' => 'Type', 'value' => 'ForwardLink'))->filter(array('field' => 'Page', 'value' => $args['object']))->render(false)->query();
        $forwardLinks = array();
        foreach ($wikiAttributes as $wikiAttribute) {
            $forwardLinks[] = $forwardLink = json_decode($wikiAttribute['Value']);
            $forwardLink->href = urldecode($forwardLink->href);
            if (isset($forwardLink->href)) {
                $result = Feed_ForwardLink_Send::send(array('page' => $args['object'], 'forwardLink' => $forwardLink, 'textlink' => array('body' => $args['data'], 'href' => $tikilib->tikiUrl() . 'tiki-index.php?page=' . $args['object'])));
            }
        }
        $forwardLinks = json_encode($forwardLinks);
        if (!empty($forwardLinks)) {
            $headerlib->add_jq_onready(<<<JQ
\t\t\tvar forwardLinks = {$forwardLinks};
\t\t\t\$.each(forwardLinks, function() {
\t\t\t\tif (this.href) {
\t\t\t\t\t\$('<a>*</a>')
\t\t\t\t\t\t.attr('href', unescape(this.href))
\t\t\t\t\t\t.appendTo('#page-data');
\t\t\t\t}
\t\t\t});
JQ
);
        }
    }
예제 #2
0
 static function findWikiRevision($phrase)
 {
     global $tikilib;
     $phrase = JisonParser_Phraser_Handler::superSanitize($phrase);
     // This query will *ALWAYS* fail if the destination page had been created/edited *PRIOR* to applying the 'Simple Wiki Attributes' profile!
     // Just recreate the destination page after having applied the profile in order to load it with the proper attributes.
     $query = Tracker_Query::tracker('Wiki Attributes')->byName()->filterFieldByValueLike('Value', $phrase)->render(false)->getLast();
     // TODO: consider adding a test on query failure in order to determine whether:
     //       1) the phrase isn't found, or
     //       2) the Simple Wiki Attributes profile wasn't in place at page-creation
     // ...then display a more meaningful error message
     if (empty($query)) {
         return false;
     }
     //couldn't find it
     $query = end($query);
     //query has a key of itemId, we just need it's details
     $version = $query['Attribute'];
     $page = $query['Page'];
     $data = $query['Value'];
     $date = $tikilib->getOne('SELECT lastModif FROM tiki_pages WHERE pageName = ? AND version = ?', array($page, $version));
     if (empty($date) == true) {
         $date = $tikilib->getOne('SELECT lastModif FROM tiki_history WHERE pageName = ? AND version = ?', array($page, $version));
     }
     return array('page' => $page, 'version' => $version, 'data' => $data, 'date' => $date, 'phrase' => $phrase);
 }
예제 #3
0
 static function wikiSave()
 {
     global $page;
     //We add these to a stack that needs to be sent, rather than just sending all with the view event
     $me = new self();
     foreach ($me->getItems() as $item) {
         Tracker_Query::tracker('Wiki Attributes')->byName()->replaceItem(array('Page' => $page, 'Attribute' => $item->textlink->text, 'Value' => 'true', 'Type' => 'TextLink Send'));
     }
 }
예제 #4
0
 static function wikiView($args)
 {
     return;
     global $tikilib, $headerlib;
     static $Feed_ForwardLink_PageLookup = 0;
     ++$Feed_ForwardLink_PageLookup;
     $wikiAttributes = Tracker_Query::tracker('Wiki Attributes')->byName()->excludeDetails()->filter(array('field' => 'Type', 'value' => 'ForwardLink'))->filter(array('field' => 'Page', 'value' => $args['object']))->render(false)->query();
     $forwardLinks = array();
     foreach ($wikiAttributes as $wikiAttribute) {
         $forwardLinks[] = $forwardLink = json_decode($wikiAttribute['Value']);
         if (isset($forwardLink->href)) {
             $forwardLink->href = urldecode($forwardLink->href);
             $result = Feed_ForwardLink_Send::send(array('forwardLink' => $forwardLink, 'textlink' => array('body' => $args['data'], 'href' => $tikilib->tikiUrl() . 'tiki-index.php?page=' . $args['object'])));
         }
     }
 }
예제 #5
0
파일: Tracker.php 프로젝트: linuxwhy/tiki-1
 private function query($values = array())
 {
     $tracker = $values['tracker'];
     $qry = Tracker_Query::tracker($tracker['value'])->start($tracker['start']['value'])->end($tracker['end']['value'])->itemId($tracker['itemId']['value'])->excludeDetails();
     if (!empty($tracker['status'])) {
         $allStatus = '';
         foreach ($tracker['status'] as $status) {
             if (!empty($status['value'])) {
                 $allStatus .= $status['value'];
             }
         }
         $qry->status($allStatus);
     }
     if (!empty($tracker['search'])) {
         for ($i = 0, $count_tracker_search = count($tracker['search']); $i < $count_tracker_search; $i++) {
             if (!empty($tracker['search'][$i]['value']) && !empty($tracker['search'][$i + 1]['value'])) {
                 $qry->filter(array("field" => trim($tracker['search'][$i]['value']), "value" => trim($tracker['search'][$i + 1]['value'])));
             }
             $i++;
             //searches are in groups of 2
         }
     }
     if (!empty($tracker['limit']['value'])) {
         $qry->limit($tracker['limit']['value']);
     }
     $result = $qry->query();
     if (!empty($tracker['fields'])) {
         $newResult = array();
         foreach ($result as $itemKey => $item) {
             $newResult[$itemKey] = array();
             foreach ($tracker['fields'] as $field) {
                 $newResult[$itemKey][$field['value']] = $result[$itemKey][$field['value']];
             }
         }
         $result = $newResult;
         unset($newResult);
     }
     foreach ($tracker['join'] as $join) {
         $result = $this->innerJoin($result, $this->query($join), $join['left']['value'], $join['right']['value']);
     }
     return $result;
 }
예제 #6
0
        $trklib->remove_tracker_item($itemId);
    }
    //end delete
    header('Location: tiki-view_invoice.php?InvoiceId=' . $_REQUEST['InvoiceId']);
    die;
}
$invoiceItems = array();
if (!empty($_REQUEST['InvoiceId'])) {
    $invoice = Tracker_Query::tracker("Invoices")->byName()->equals($_REQUEST['InvoiceId'])->getOne();
    $invoice['Item Ids'] = implode(',', $invoice['Item Ids']);
    $smarty->assign("invoice", $invoice);
    $invoiceItems = Tracker_Query::tracker("Invoice Items")->byName()->fields(array("Invoice Id"))->search(array($_REQUEST['InvoiceId']))->query();
} else {
    $_REQUEST['InvoiceId'] = 0;
}
//give the user the last invoice number
$LastInvoice = Tracker_Query::tracker("Invoices")->byName()->limit(0)->offset(1)->desc(true)->excludeDetails()->getOne();
$NewInvoiceNumber = isset($LastInvoice["Invoice Number"]) ? $LastInvoice["Invoice Number"] + 1 : 1;
$smarty->assign("NewInvoiceNumber", $NewInvoiceNumber);
$smarty->assign("InvoiceId", $_REQUEST['InvoiceId']);
$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) {
    $invoiceItems[] = array("Quantity" => "", "Work Description" => "", "Taxable" => "", "Amount" => "");
}
$smarty->assign("invoiceItems", $invoiceItems);
$headerlib->add_jq_onready("function setupTotal() {\n\t\t\$('#InvoiceForm :input')\n\t\t\t.unbind('change')\n\t\t\t.change(function() {\n\t\t\t\tfindTotal();\n\t\t\t})\n\t\t\t.change();\n\t}\n\n\tfunction findTotal() {\n\t\tvar total = 0;\n\t\t\$('.InvoiceItem').each(function() {\n\t\t\tvar itemTotal = \$(this).find('.InvoiceQuantity').val() * \$(this).find('.InvoiceAmount').val();\n\t\t\ttotal += itemTotal;\n\t\t});\n\t\t\$('#Amount').text(total);\n\t}\n\n\tsetupTotal();\n\n\t\$('#InvoiceNewItem').click(function() {\n\t\tvar lastInvoiceItem = \$('.InvoiceItem:last');\n\t\tvar newInvoiceItem = lastInvoiceItem.clone();\n\n\t\tnewInvoiceItem.find(':input').not(':checkbox,:button').val('');\n\n\t\tnewInvoiceItem.insertAfter(lastInvoiceItem);\n\n\t\tsetupTotal();\n\t});\n\n\t\$('#InvoiceForm').click(function(e) {\n\t\tif (\$(e.target).hasClass('DeleteItem')) {\n\t\t\tif (\$('.InvoiceItem').length > 1) {\n\t\t\t\t\$(e.target).parent().parent().remove();\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t});\n\n\t\$('#InvoiceForm').submit(function() {\n\t\t\$('.InvoiceTaxable').each(function() {\n\t\t\tvar InvoiceTaxable = \$(this);\n\t\t\tif (!InvoiceTaxable.is(':checked')) {\n\t\t\t\tInvoiceTaxable\n\t\t\t\t\t.val('n')\n\t\t\t\t\t.prop('checked', 'true');\n\t\t\t}\n\t\t});\n\n\t\t\$('.InvoiceItemId').each(function() {\n\t\t\tvar InvoiceItemId = \$(this);\n\t\t\tInvoiceItemId.val(InvoiceItemId.val() ? InvoiceItemId.val() : '0');\n\t\t});\n\n\t\tvar InvoiceId = \$('#InvoiceId');\n\t\tInvoiceId.val(InvoiceId.val() ? InvoiceId.val() : 0);\n\n\t\treturn false;\n\t});");
// Display the template
$smarty->assign('mid', 'tiki-edit_invoice.tpl');
$smarty->display("tiki.tpl");
예제 #7
0
require_once 'tiki-setup.php';
$access->check_feature(array('feature_time_sheet', 'feature_trackers'));
$access->check_permission_either(array('tiki_p_view_trackers', 'tiki_p_create_tracker_items'));
global $user, $prefs, $tiki_p_admin;
$auto_query_args = array('all', 'profile', 'page', 'list');
$trackerId = (int) TikiLib::lib('trk')->get_tracker_by_name('Time sheet');
$smarty->assign("tiki_p_admin", $tiki_p_admin);
$smarty->assign("timeSheetProfileLoaded", $trackerId > 0 ? true : false);
$projectList = Tracker_Query::tracker("Project list")->byName()->query();
if (isset($_REQUEST['all'])) {
    //all views all sheet items
    $smarty->assign("all", true);
    $timeSheet = Tracker_Query::tracker("Time sheet")->byName()->query();
} else {
    //views only your items
    $smarty->assign("all", false);
    $timeSheet = Tracker_Query::tracker("Time sheet")->byName()->filter(array("field" => "Done by", "value" => $user))->query();
}
if (isset($projectList)) {
    if (isset($_REQUEST['save'])) {
        echo json_encode($timeSheetNewInputs = Tracker_Query::tracker("Time sheet")->byName()->queryInput());
        die;
    }
    $smarty->assign("projectList", $projectList);
    $smarty->assign("timeSheet", $timeSheet);
}
TikiLib::lib("sheet")->setup_jquery_sheet();
$headerlib = TikiLib::lib("header")->add_cssfile("vendor/jquery/jtrack/css/jtrack.css")->add_jsfile("vendor/jquery/jtrack/js/domcached-0.1-jquery.js")->add_jsfile("vendor/jquery/jtrack/js/jtrack.js")->add_jq_onready("jTask.init();\n\n\t\$.timesheetSpreadsheet = function() {\n\t\tvar table = \$('<table title=/>').attr('title', tr('Local Cache (Not Committed)'));\n\t\ttable.append('<tr><td>Summary</td><td>Estimate</td><td>Time Spent</td></tr>');\n\n\t\tvar rowI = 1;\n\t\tfor (var namespace in \$.DOMCached.getStorage()) {\n\t\t\tvar row = \$('<tr />').appendTo(table);\n\n\t\t\trow.append('<td>' + namespace + '</td>');\n\t\t\trow.append('<td>' + \$.DOMCached.get('estimate', namespace) + '</td>');\n\t\t\trow.append('<td formula=\\'ROUND(' + (\$.DOMCached.get('timer', namespace) / 60) + ', 2)\\'></td>');\n\t\t\trowI++;\n\t\t}\n\t\tvar row = \$('<tr />').appendTo(table);\n\t\trow.append('<td>Totals</td>');\n\t\trow.append('<td formula=\\'ROUND(SUM(B2:B' + rowI + '), 2)\\'/>');\n\t\trow.append('<td formula=\\'=ROUND(SUM(C2:C' + rowI + '), 2)\\' />');\n\n\t\t\$('#timesheetSpreadsheet').siblings().remove();\n\n\t\tvar jS = \$('#timesheetSpreadsheet').getSheet();\n\t\tif (jS) {\n\t\t\t\$('#timesheetSpreadsheet')\n\t\t\t\t.unbind('visible')\n\t\t\t\t.visible(function() {\n\t\t\t\t\tjS.openSheet(table);\n\t\t\t\t});\n\t\t} else {\n\t\t\t\$('#timesheetSpreadsheet')\n\t\t\t\t.visible(function() {\n\t\t\t\t\t\$(this).sheet({\n\t\t\t\t\t\tbuildSheet: table,\n\t\t\t\t\t\teditable: false,\n\t\t\t\t\t\theight: \$('#jtrack-holder').height()\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\t};\n\n\t\$('.jtrack-create,.jtrack-update,.jtrack-remove,.jtrack-remove-all,.jtrack-cancel,.jtrack-power,#jtrack-button-remove,#jtrack-button-remove-all,#jtrack-button-create,#jtrack-button-update').on('click', function() {\n\t\t\$.timesheetSpreadsheet();\n\t});\n\n\t\$.timesheetSpreadsheet();\n\n\t\$('#timeSheetSaved').visible(function() {\n\t\t\$(this).sheet({\n\t\t\tbuildSheet: true,\n\t\t\teditable: false,\n\t\t\theight: \$('#jtrack-holder').height()\n\t\t});\n\t});\n\n\t\$('#timeSheetCommit').click(function() {\n\t\t\$('#timeSheetTabs').tikiModal(tr('Committing...'));\n\t\tvar stack = [];\n\t\t\$.getJSON('tiki-timesheet.php?save', function(inputs) {\n\t\t\tfor (var namespace in \$.DOMCached.getStorage()) {\n\t\t\t\tvar summary = namespace + '',\n\t\t\t\ttime =  \$.DOMCached.get('timer', summary) / 60;\n\t\t\t\tstack.push(summary);\n\n\t\t\t\tvar form = \$('<form />').submit(function() {\n\t\t\t\t\tvar fields = '';\n\n\t\t\t\t\t\$.each(form.serializeArray(), function() {\n\t\t\t\t\t\tfields += '&fields[' + this.name + ']=' + this.value;\n\t\t\t\t\t});\n\n\t\t\t\t\t\$.post('tiki-ajax_services.php?controller=tracker&trackerId={$trackerId}&action=insert_item' + fields,function() {\n\t\t\t\t\t\t\$.DOMCached.deleteNamespace(namespace);\n\n\t\t\t\t\t\tstack.pop();\n\n\t\t\t\t\t\tif (stack.length == 0) {\n\t\t\t\t\t\t\tdocument.location = document.location + '';\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.error(function() {\n\t\t\t\t\t\t\$('#timeSheetTabs').tikiModal();\n\t\t\t\t\t\talert(tr('Could not save'));\n\t\t\t\t\t});\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\n\t\t\t\tvar input = {\n\t\t\t\t\t'Summary': \$(inputs['Summary']),\n\t\t\t\t\t'Description': \$(inputs['Description']),\n\t\t\t\t\t'Amount of time spent': \$(inputs['Amount of time spent']),\n\t\t\t\t\t'Done by': \$(inputs['Done by'])\n\t\t\t\t};\n\n\t\t\t\tinput['Summary'].val(summary);\n\t\t\t\tinput['Amount of time spent'].val(time);\n\t\t\t\tinput['Done by'].val('" . addslashes($user) . "');\n\t\t\t\tform.append(input['Summary']);\n\t\t\t\tform.append(input['Description']);\n\t\t\t\tform.append(input['Amount of time spent']);\n\t\t\t\tform.append(input['Done by']);\n\t\t\t\tform.submit();\n\t\t\t}\n\t\t});\n\n\t\treturn false;\n\t});\n\n\t\$('#timeSheetTabs')\n\t\t.width(\$('#timeSheetTabs').parent().width())\n\t\t.tabs();");
$smarty->assign('mid', 'tiki-timesheet.tpl');
// use tiki_full to include include CSS and JavaScript
$smarty->display("tiki.tpl");
예제 #8
0
 static function wikiView($args)
 {
     global $prefs, $headerlib, $smarty, $_REQUEST, $user;
     $page = $args['object'];
     $version = $args['version'];
     $date = $args['lastModif'];
     if (isset($_REQUEST['itemId'])) {
         self::getQuestionInputs($page, $_REQUEST['itemId']);
     }
     //self::getTimeStamp();
     $phrase = !empty($_REQUEST['phrase']) ? addslashes(htmlspecialchars($_REQUEST['phrase'])) : '';
     self::goToPhraseExistence($phrase, $page, $version);
     self::restorePhrasesInWikiPage($page, $phrase);
     $questions = Tracker_Query::tracker('Wiki Attributes')->byName()->filter(array('field' => 'Type', 'value' => 'Question'))->filter(array('field' => 'Page', 'value' => $page))->query();
     self::editQuestionsInterface($page, $questions);
     self::createForwardLinksInterface($page, $questions, $date);
 }
예제 #9
0
파일: grid.php 프로젝트: linuxwhy/tiki-1
 function _load(&$sheet)
 {
     $tikilib = TikiLib::lib('tiki');
     $i = 0;
     $trackerName = $this->info['name'];
     $tracker = Tracker_Query::tracker($trackerName)->byName()->excludeDetails()->render(false)->query();
     foreach ($tracker as $item) {
         $j = 0;
         foreach ($item as $key => $field) {
             $sheet->initCell($i, $j);
             if (!empty($field[0]) && $field[0] == '=') {
                 $sheet->setCalculation(substr($field, 1));
             }
             $sheet->setValue($i == 0 ? $key : $field);
             $sheet->setSize(1, 1);
             $j++;
         }
         $i++;
     }
     return true;
 }
예제 #10
0
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-view_invoice.php 44444 2013-01-05 21:24:24Z changi67 $
require_once 'tiki-setup.php';
$trklib = TikiLib::lib('trk');
$access->check_feature('feature_invoice');
$access->check_permission('tiki_p_admin');
//check if profile is created
if ($trklib->get_tracker_by_name("Invoice Items") < 1) {
    $smarty->assign('msg', tra('You need to apply the "Invoice" profile'));
    $smarty->display("error.tpl");
    die;
}
(int) ($_REQUEST['InvoiceId'] = $_REQUEST['InvoiceId']);
$smarty->assign('InvoiceId', $_REQUEST['InvoiceId']);
$invoice = Tracker_Query::tracker("Invoices")->byName()->equals($_REQUEST['InvoiceId'])->getOne();
$amount = 0;
if (is_array($invoice["Item Amounts"])) {
    foreach ($invoice["Item Amounts"] as $key => $sum) {
        $amount += $invoice["Item Amounts"][$key] * $invoice["Item Quantities"][$key];
    }
} else {
    $amount = $invoice["Item Amounts"] * $invoice["Item Quantities"];
}
$smarty->assign("invoice", $invoice);
$smarty->assign("amount", $amount);
$smarty->assign("client", Tracker_Query::tracker("Invoice Clients")->fields(array("Client Id"))->equals(array($invoice['Client Id']))->byName()->getOne());
$smarty->assign("setting", Tracker_Query::tracker("Invoice Settings")->byName()->query());
$smarty->assign("invoiceItems", Tracker_Query::tracker("Invoice Items")->fields(array("Invoice Id"))->equals(array($_REQUEST['InvoiceId']))->byName()->query());
// Display the template
$smarty->assign('mid', 'tiki-view_invoice.tpl');
$smarty->display("tiki.tpl");
예제 #11
0
 function appendToContents(&$contents, $item)
 {
     global $prefs, $_REQUEST;
     if ($this->debug == true) {
         ini_set('error_reporting', E_ALL);
         ini_set('display_errors', 1);
     }
     $this->itemsAdded = false;
     foreach ($item->feed->entry as $i => $newEntry) {
         $this->verifications[$i] = array();
         $this->verifications[$i]["reason"] = array();
         //lets remove the new entry if it has already been accepted in the past
         foreach ($contents->entry as &$existingEntry) {
             if ($existingEntry->textlink->text == $newEntry->textlink->text && $existingEntry->textlink->href == $newEntry->textlink->href) {
                 $this->verifications[$i]['reason'][] = 'exists';
                 unset($item->feed->entry[$i]);
             }
         }
         $revision = Feed_ForwardLink_Search::findWikiRevision($newEntry->forwardlink->text);
         $this->verifications[$i]["hashBy"] = JisonParser_Phraser_Handler::superSanitize($newEntry->forwardlink->author . $newEntry->forwardlink->authorInstitution . $newEntry->forwardlink->authorProfession);
         $this->verifications[$i]['foundRevision'] = $revision;
         $this->verifications[$i]["metadataHere"] = $this->metadata->raw;
         $this->verifications[$i]["phraseThere"] = JisonParser_Phraser_Handler::superSanitize($newEntry->forwardlink->text);
         $this->verifications[$i]["hashHere"] = hash_hmac("md5", $this->verifications[$i]["hashBy"], $this->verifications[$i]["phraseThere"]);
         $this->verifications[$i]["hashThere"] = $newEntry->forwardlink->hash;
         $this->verifications[$i]['exists'] = JisonParser_Phraser_Handler::hasPhrase($revision['data'], $this->verifications[$i]["phraseThere"]);
         if ($this->verifications[$i]['hashHere'] != $this->verifications[$i]['hashThere']) {
             $this->verifications[$i]['reason'][] = 'hash_tampering';
             unset($item->feed->entry[$i]);
         }
         if ($newEntry->forwardlink->websiteTitle != $prefs['browsertitle']) {
             $this->verifications[$i]['reason'][] = 'title';
             unset($item->feed->entry[$i]);
         }
         if ($this->verifications[$i]['exists'] == false) {
             if (empty($this->verifications[$i]['reason'])) {
                 $this->verifications[$i]['reason'][] = 'no_existence_hash_pass';
             } else {
                 $this->verifications[$i]['reason'][] = 'no_existence';
             }
             unset($item->feed->entry[$i]);
         }
         foreach ($newEntry->forwardlink as $key => $value) {
             if (isset(Feed_ForwardLink_Metadata::$acceptableKeys[$key]) && Feed_ForwardLink_Metadata::$acceptableKeys[$key] == true) {
                 //all clear
             } else {
                 $this->verifications[$i]['reason'][] = 'metadata_tampering' . ($this->debug == true ? $key : '');
                 unset($item->feed->entry[$i]);
             }
         }
         foreach ($newEntry->textlink as $key => $value) {
             if (isset(Feed_ForwardLink_Metadata::$acceptableKeys[$key]) && Feed_ForwardLink_Metadata::$acceptableKeys[$key] == true) {
                 //all clear
             } else {
                 $this->verifications[$i]['reason'][] = 'metadata_tampering' . ($this->debug == true ? $key : '');
                 unset($item->feed->entry[$i]);
             }
         }
     }
     if (empty($item->feed->entry) == false) {
         $this->itemsAdded = true;
         foreach ($item->feed->entry as &$entry) {
             Tracker_Query::tracker('Wiki Attributes')->byName()->replaceItem(array('Page' => $this->page, 'Attribute' => '', 'Value' => $entry->forwardlink->text, 'Type' => 'ForwardLink Accepted'));
         }
         if (empty($contents->entry) == true) {
             $contents->entry = array();
         }
         $contents->entry = array_merge($contents->entry, $item->feed->entry);
     }
 }
function wikiplugin_trackeritemcopy( $data, $params )
{
	global $smarty;
	$trklib = TikiLib::lib("trk");
	
	if (!isset($params["trackerId"]) || !isset($params["copyFieldIds"])) {
		return tra('Missing mandatory parameters');
	} else {
		$trackerId = $params["trackerId"];
		if (is_array($trackerId) == false) $trackerId = array($trackerId);
		$copyFieldIds = $params["copyFieldIds"];
	}
	
	$smarty->assign('itemIdSet', 'n');
	$itemId = 0;
	
	if (isset($params["itemId"])) {
		$itemId = $params["itemId"];
		$smarty->assign('itemIdSet', 'y');
	} elseif (isset($_POST["itemIdToCopy"])) {
		$itemId = $_POST["itemIdToCopy"];
	} 

	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		
		function items_copy($trackerId, $updateFieldIds, $updateFieldValues, $copyFieldIds, $itemIds, $linkFieldId, $itemLinkId, $copies)
		{
			global $trklib, $_POST;
			
			if (is_array($itemIds) == false) $itemIds = array($itemIds);
			
			foreach ($itemIds as $itemId) {
				$tracker_fields_info = $trklib->list_tracker_fields($trackerId);
				
				$fieldTypes = array();
				$fieldOptionsArray = array();
				
				foreach ($tracker_fields_info['data'] as $t) {
					$fieldTypes[$t['fieldId']] = $t['type'];
					$fieldOptionsArray[$t['fieldId']] = $t['options_array'];
				}
				
				$ins_fields["data"] = array();
				
				if (isset($linkFieldId) && isset($itemLinkId)) {
					$updateFieldIds[] = $linkFieldId;
					$updateFieldValues[] = $itemLinkId;
				}
				
				//print_r(array($trackerId, $updateFieldIds, $updateFieldValues, $copyFieldIds, $itemIds, $linkFieldId, $itemLinkId, $copies));
				
				for ($i = 0, $count_updateFieldIds = count($updateFieldIds); $i < $count_updateFieldIds; $i++) {
					$ins_fields["data"][] = array(
						'options_array' => $fieldOptionsArray[$updateFieldIds[$i]], 
						'type' => $fieldTypes[$updateFieldIds[$i]], 
						'fieldId' => $updateFieldIds[$i], 
						'value' => $updateFieldValues[$i]
					);
				}
				
				// CUSTOM: this part is totally custom to store admin notes (how to generalize?)
				if (!empty($_POST['admin_notes_for_copy'])) {
					$ins_fields["data"][] = array(
						'type' => 'a',
						'fieldId' => 118,
						'value' => $_POST['admin_notes_for_copy']
					);
				}
				// end totally CUSTOM part
				
				$newitems = array();
				for ($i = 0; $i < $copies; $i++) {
					// Check for -randomstring- and f_xx
					$ins_fields_final["data"] = array();
					foreach ($ins_fields["data"] as $h) {
						if ($h["value"] == '-randomstring-') {
							$h["value"] = $trklib->genPass();
						} else if (substr($h["value"], 0, 2) == 'f_') {
							$sourceFieldId = (int) trim(substr($h["value"], 2));
							$h["value"] = $trklib->get_item_value($trackerId, $itemId, $sourceFieldId);
						}
						$ins_fields_final["data"][] = $h; 
					}
					$newitemsdata[] = $ins_fields_final["data"];
					$newitems[] = $trklib->replace_item($trackerId, 0, $ins_fields_final);		
				}
				
				foreach ($newitems as $n) {
					$trklib->copy_item($itemId, $n, null, $copyFieldIds);
					$newitemslist .= '  ' . $n;
				}
			}
			
			return array(
				"items" => $newitems,
				"data" => $newitemsdata,
				"list" => $newitemslist
			);
		}
		
		$return_array = array();
		$itemIds = array();
		
		foreach ($trackerId as $key => $trackerIdLeft) {
			//ensure that the fields are set and usable
			if (isset($params["updateFieldIds"]) || isset($params["updateFieldValues"])) {
				$updateFieldIds = $params["updateFieldIds"];
				$updateFieldValues = $params["updateFieldValues"];
				
				foreach ($updateFieldIds as $key => $updateFieldId) {
					if (count($updateFieldIds[$key]) != count($updateFieldValues[$key])) {
						return tra('Number of update fields do not match new values');
					}
				}
				
				$copyFieldIds[$key] = array_diff($copyFieldIds[$key], $updateFieldIds);
			}
			
			if ($_SERVER['REQUEST_METHOD'] == 'POST' && $itemId && isset($_POST['copytrackeritem']) && isset($_POST['numberofcopies'])) {
				$copies = (int) $_POST['numberofcopies'];
			} elseif (isset($params['copies_on_load'])) {
				$copies = (int) $params['copies_on_load']; 
			} else {
				$copies = 0;
			}
			
			if ($copies > 0) {
				
				if ($key > 0) {
					$qry = Tracker_Query::tracker($trackerIdLeft)
						->fields($params["linkFieldIds"][0])
						->equals(array($itemId));
						
					$itemIds = array();
					foreach ($qry as $linkedItemIds => $item) {
						$itemIds[] = $linkedItemIds;
					}
				}
				
				$return_array[] = items_copy(
								$trackerId[$key], 
								$updateFieldIds[$key], 
								$updateFieldValues[$key], 
								$copyFieldIds[$key], 
								(
									$key == 0 ? $itemId : $itemIds
								),
								(
									$key == 0 ? null : $params["linkFieldIds"][$key - 1]
								),
								(
									$key == 0 ? null : $return_array[0]['items'][0]
								),
								$copies
				);
			}

		}
		
		$smarty->assign('newitemslist', $return_array['list']);
		
		if ($params['return_array'] == 'y') {
			if (count($return_array) == 1) { //backward compatible
				return $return_array[0];
			} else {
				return $return_array;
			}
		}
	
	}
	
	return $smarty->fetch('wiki-plugins/wikiplugin_trackeritemcopy.tpl');
}
예제 #13
0
 public function minimumStatisticsNeeded($out = true)
 {
     if (empty($this->minimumStatisticsNeeded)) {
         $this->minimumStatisticsNeeded = Tracker_Query::tracker('Wiki Attributes')->byName()->filterFieldByValue('Type', 'Minimum Statistics Needed')->filterFieldByValue('Page', $this->page)->render(false)->query();
     }
     if ($out == true) {
         return $this->endValue($this->minimumStatisticsNeeded, true);
     }
     return $this->minimumStatisticsNeeded;
 }
예제 #14
0
        if ($key == 0) {
            $trackerPrimary = Tracker_Query::tracker($trackerId)->start($_REQUEST['start'][$key])->end($_REQUEST['end'][$key])->equals($_REQUEST['q'][$key])->search($_REQUEST['search'][$key])->fields($_REQUEST['fields'][$key])->status($_REQUEST['status'][$key])->query();
        } else {
            $joinVars = $_REQUEST['itemIdFields'][$key - 1];
            $joinVars = explode('|', $joinVars);
            $trackerPrimary = Tracker_Query::join_trackers($trackerPrimary, Tracker_Query::tracker($trackerId)->start($_REQUEST['start'][$key])->end($_REQUEST['end'][$key])->equals($_REQUEST['q'][$key])->search($_REQUEST['search'][$key])->fields($_REQUEST['fields'][$key])->status($_REQUEST['status'][$key])->query(), $joinVars[0], $joinVars[1]);
        }
        $i++;
    }
}
if (isset($_REQUEST['sortFieldIds']) == true) {
    Tracker_Query::arfsort($trackerPrimary, $_REQUEST['sortFieldIds']);
}
if (isset($_REQUEST['removeFieldIds']) == true || isset($_REQUEST['showFieldIds']) == true) {
    $trackerPrimary = Tracker_Query::filter_fields_from_tracker_query($trackerPrimary, $_REQUEST['removeFieldIds'], $_REQUEST['showFieldIds']);
}
if (isset($_REQUEST['dateFieldIds'])) {
    $trackerPrimary = dateFormat($_REQUEST['dateFieldIds'], $trackerPrimary);
}
$trackerPrimary = Tracker_Query::prepend_field_header($trackerPrimary, $_REQUEST['sortFieldNames']);
if (isset($_REQUEST['time']) == true) {
    $endtime = microtime();
    $endarray = explode(" ", $endtime);
    $endtime = $endarray[1] + $endarray[0];
    $totaltime = $endtime - $starttime;
    $totaltime = round($totaltime, 5);
    echo "This page loaded in {$totaltime} seconds.\n\n\n";
}
if ($_REQUEST['type'] == 'csv' && count($trackerPrimary) > 0) {
    print_r(Tracker_Query::to_csv($trackerPrimary));
}
예제 #15
0
    if (is_array($Invoice["Item Amounts"])) {
        foreach ($Invoice["Item Amounts"] as $Key => $sum) {
            $Amount += $Invoice["Item Amounts"][$Key] * $Invoice["Item Quantities"][$Key];
        }
    } else {
        $Amount = $Invoice["Item Amounts"] * $Invoice["Item Quantities"];
    }
    $Invoices[$I]["Amount"] = $Amount;
    if (is_array($Invoice["Amounts Paid"])) {
        foreach ($Invoice["Amounts Paid"] as $Sum) {
            $Paid += $Sum;
        }
    } else {
        $Paid = $Invoice["Amounts Paid"];
    }
    $Invoices[$I]["Paid"] = $Paid;
    if ($Amount == $Paid) {
        $Status = "Paid";
    } else {
        $Status = "Open";
    }
    $Invoices[$I]["Status"] = $Status;
}
$smarty->assign("Invoices", $Invoices);
$smarty->assign("Settings", Tracker_Query::tracker("Invoice Settings")->byName()->query());
$smarty->assign("Amount", $Amount);
$smarty->assign("Paid", $Paid);
$smarty->assign("Status", $Status);
// Display the template
$smarty->assign('mid', 'tiki-list_invoices.tpl');
$smarty->display("tiki.tpl");
예제 #16
0
 function action_get_item_inputs($input)
 {
     $trackerId = $input->trackerId->int();
     $trackerName = $input->trackerName->string();
     $itemId = $input->itemId->int();
     $byName = $input->byName->bool();
     $defaults = $input->defaults->array();
     $this->trackerNameAndId($trackerId, $trackerName);
     $definition = Tracker_Definition::get($trackerId);
     if (!$definition) {
         throw new Services_Exception_NotFound();
     }
     $itemObject = Tracker_Item::newItem($trackerId);
     if (!$itemObject->canModify()) {
         throw new Services_Exception_Denied();
     }
     $query = Tracker_Query::tracker($byName ? $trackerName : $trackerId)->itemId($itemId);
     if ($input > 0) {
         $query->byName();
     }
     if (!empty($defaults)) {
         $query->inputDefaults($defaults);
     }
     $inputs = $query->queryInput();
     return $inputs;
 }
예제 #17
0
} else {
	$amount = $invoice["Item Amounts"] * $invoice["Item Quantities"];
}

$smarty->assign("invoice", $invoice);
$smarty->assign("amount", $amount);
$smarty->assign(
				"client",
				Tracker_Query::tracker("Invoice Clients")
				->fields(array("Client Id"))->equals(array($invoice['Client Id']))
				->byName()
				->getOne()
);
$smarty->assign(
				"setting", 
				Tracker_Query::tracker("Invoice Settings")
				->byName()
				->query()
);
$smarty->assign(
				"invoiceItems", 
				Tracker_Query::tracker("Invoice Items")
				->fields(array("Invoice Id"))->equals(array($_REQUEST['InvoiceId']))
				->byName()
				->query()
);

// Display the template
$smarty->assign('mid', 'tiki-view_invoice.tpl');
$smarty->display("tiki.tpl");
function wikiplugin_trackerquerytemplate($data, $params)
{
    global $tikilib;
    $params = array_merge(array('tracker' => '', 'debug' => '', 'byname' => 'y', 'render' => 'y', 'likefilters' => '', 'andfilters' => '', 'getlast' => ''), $params);
    if (!empty($params['itemids'])) {
        $itemIds = $params['itemids'];
        unset($params['itemids']);
        $newData = '';
        foreach ($itemIds as $itemId) {
            if (!empty($itemId)) {
                $params['itemid'] = $itemId;
                $newData .= wikiplugin_trackerquerytemplate($data, $params);
            }
        }
        return $newData;
    }
    $handler = new dataToFieldHandler();
    foreach ($params as &$param) {
        //We parse the variables
        $param = $handler->parse($param);
    }
    $query = Tracker_Query::tracker($params['tracker'])->excludeDetails();
    $pattern = 'id';
    if (!empty($params['byname']) && $params['byname'] == 'y') {
        $query->byName();
        $pattern = 'name';
    }
    if (!empty($params['render']) && $params['render'] == 'n') {
        $query->render(false);
    }
    if (!empty($params['itemid']) || isset($_REQUEST['itemId'])) {
        if (isset($_REQUEST['itemId'])) {
            //itemId overrides parameters
            $query->itemId($_REQUEST['itemId']);
            unset($_REQUEST['itemId']);
            //we unset because nested plugins may need to have itemId set
        } else {
            $query->itemId($params['itemid']);
        }
    }
    if (!empty($params['likefilters'])) {
        $likefilters = explode(';', $params['likefilters']);
        foreach ($likefilters as $likefilter) {
            $filter = explode(':', $likefilter);
            $query->filterFieldByValueLike($filter[0], $filter[1]);
        }
    }
    if (!empty($params['andfilters'])) {
        $andfilters = explode(';', $params['andfilters']);
        foreach ($andfilters as $andfilter) {
            $filter = explode(':', $andfilter);
            $query->filterFieldByValue($filter[0], $filter[1]);
        }
    }
    if (!empty($params['orfilters'])) {
        $orfilters = explode(';', $params['orfilters']);
        foreach ($orfilters as $orfilter) {
            $filter = explode(':', $orfilter);
            $query->filterFieldByValueOr($filter[0], $filter[1]);
        }
    }
    if (!empty($params['debug']) && $params['debug'] == 'y') {
        $query->debug();
    }
    if (!empty($params['getlast']) && $params['getlast'] == 'y') {
        $items = $query->getLast();
    } else {
        $items = $query->query();
    }
    $newData = '';
    foreach ($items as $itemId => $fields) {
        $trackerId = $query->trackerId();
        $handler->set($pattern, $fields, $query->itemsRaw[$itemId], $itemId, $trackerId);
        $newData .= $handler->parse($data);
        $newData = "~np~" . $tikilib->parse_data($newData, array('is_html' => true)) . "~/np~";
        $handler->pop();
    }
    return $newData;
}
예제 #19
0
	$timeSheet = Tracker_Query::tracker("Time sheet")
		->byName()
		->query();
} else {//views only your items
	$smarty->assign("all", false);
	
	$timeSheet = Tracker_Query::tracker("Time sheet")
		->byName()
		->filter(array("field" => "Done by", "value" => $user))
		->query();
}

if (isset($projectList)) {
	if (isset($_REQUEST['save'])) {
		echo json_encode(
			$timeSheetNewInputs = Tracker_Query::tracker("Time sheet")
				->byName()
				->queryInput()
		);
		die;
	}

	$smarty->assign("projectList", $projectList);
	$smarty->assign("timeSheet", $timeSheet);
}

TikiLib::lib("sheet")->setup_jquery_sheet();

$headerlib = TikiLib::lib("header")
	->add_cssfile("lib/jquery/jtrack/css/jtrack.css")
	->add_jsfile("lib/jquery/jtrack/js/domcached-0.1-jquery.js")