Commit b429f6f1 authored by sylvieg's avatar sylvieg

[FIX]tracker; never use options but options_array as other params can be added later

parent 2c8426d5
<?php
// CVS: $Id: trackerlib.php,v 1.227 2007-10-09 14:48:16 sylvieg Exp $
// CVS: $Id: trackerlib.php,v 1.228 2007-10-09 15:29:00 sylvieg Exp $
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
......@@ -1752,8 +1752,10 @@ class TrackerLib extends TikiLib {
function get_tracker_field($fieldId) {
$query = "select * from `tiki_tracker_fields` where `fieldId`=?";
$result = $this->query($query,array((int) $fieldId));
if (!$result->numRows()) return false;
if (!$result->numRows())
return false;
$res = $result->fetchRow();
$res['options_array'] = split(',', $res['options']);
return $res;
}
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_tracker.php,v 1.81 2007-10-05 18:04:33 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_tracker.php,v 1.82 2007-10-09 15:29:00 sylvieg Exp $
// Includes a tracker field
// Usage:
// {TRACKER()}{TRACKER}
......@@ -376,13 +376,13 @@ function wikiplugin_tracker($data, $params) {
// Loop on tracker fields and display form
$back.= '<table class="wikiplugin_tracker">';
foreach ($flds['data'] as $f) {
if ($f['type'] == 'u' and $f['options'] == '1') {
if ($f['type'] == 'u' and $f['options_array'][0] == '1') {
$back.= '<input type="hidden" name="authorfieldid" value="'.$f['fieldId'].'" />';
}
if ($f['type'] == 'I' and $f['options'] == '1') {
if ($f['type'] == 'I' and $f['options_array'][0] == '1') {
$back.= '<input type="hidden" name="authoripid" value="'.$f['fieldId'].'" />';
}
if ($f['type'] == 'g' and $f['options'] == '1') {
if ($f['type'] == 'g' and $f['options_array'][0] == '1') {
$back.= '<input type="hidden" name="authorgroupfieldid" value="'.$f['fieldId'].'" />';
}
if (in_array($f['fieldId'],$outf)) {
......@@ -434,7 +434,7 @@ function wikiplugin_tracker($data, $params) {
$flags = $tikilib->get_flags();
foreach ($flags as $flag) {
$selected = $f['value'] == $flag ? 'selected="selected"' : '';
if (!isset($f['options']) || $f['options'] != '1')
if (!isset($f['options_array'][0]) || $f['options_array'][0] != '1')
$selected .= ' style="background-image:url(\'img/flags/'.$flag.'.gif\');background-repeat:no-repeat;padding-left:25px;padding-bottom:3px;"';
$back.= '<option value="'.$flag.'" '.$selected.'>'.tra($flag).'</option>';
}
......@@ -453,14 +453,14 @@ function wikiplugin_tracker($data, $params) {
$back.= '<textarea cols="29" rows="7" name="track['.$f["fieldId"].']" wrap="soft">'.$f['value'].'</textarea>';
}
// user selector
} elseif ($f['type'] == 'u' and $f['options'] == '1') {
} elseif ($f['type'] == 'u' and $f['options_array'][0] == '1') {
$back.= '<tr><td>'.wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors).'</td><td>'.$user;
// drop down, user selector or group selector
} elseif ($f['type'] == 'd' or $f['type'] == 'D' or $f['type'] == 'u' or $f['type'] == 'g' or $f['type'] == 'r' or $f['type'] == 'R') {
if ($f['type'] == 'd' or $f['type'] == 'D' or $f['type'] == 'R') {
$list = split(',',$f['options']);
} elseif ($f['type'] == 'u') {
if ($f['options'] == 1 or $f['options'] == 2) {
if ($f['options_array'][0] == 1 or $f['options_array'][0] == 2) {
$list = false;
} else {
$list = $userlib->list_all_users();
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_trackerfilter.php,v 1.12 2007-09-02 15:25:12 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_trackerfilter.php,v 1.13 2007-10-09 15:29:00 sylvieg Exp $
function wikiplugin_trackerfilter_help() {
$help = tra("Filters the items of a tracker, fields are indicated with numeric ids.").":\n";
$help .= "~np~{TRACKERFILTER(filters=>2/d:4/r:5,action=>Name of submit button,TRACKERLIST_params )}Notice{TRACKERFILTER}~/np~";
......@@ -72,7 +72,7 @@ function wikiplugin_trackerfilter($data, $params) {
case 'e': // category
global $categlib;
include_once('lib/categories/categlib.php');
$res = $categlib->get_child_categories($field['options']);
$res = $categlib->get_child_categories($field['options_array'][0]);
$opts = array();
foreach ($res as $opt) {
$opt['id'] = $opt['categId'];
......@@ -86,9 +86,8 @@ function wikiplugin_trackerfilter($data, $params) {
}
break;
case 'd': // drop down list
$res = array_unique(split(',', $field['options']));
$opts = array();
foreach ($res as $val) {
foreach ($field['options_array'] as $val) {
$opt['id'] = $val;
$opt['name'] = $val;
if (!empty($_REQUEST['f_'.$fieldId]) && $_REQUEST['f_'.$fieldId][0] == $val) {
......@@ -101,9 +100,8 @@ function wikiplugin_trackerfilter($data, $params) {
}
break;
case 'R': // radio buttons
$res = split(',', $field['options']);
$opts = array();
foreach ($res as $val) {
foreach ($field['options_array'] as $val) {
$opt['id'] = $val;
$opt['name'] = $val;
if (!empty($_REQUEST['f_'.$fieldId]) && $_REQUEST['f_'.$fieldId][0] == $val) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker.php,v 1.135 2007-08-10 13:42:39 guidoscherp Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker.php,v 1.136 2007-10-09 15:29:00 sylvieg Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -34,60 +34,7 @@ if (!isset($_REQUEST["trackerId"])) {
die;
}
$smarty->assign('individual', 'n');
if ($userlib->object_has_one_permission($_REQUEST["trackerId"], 'tracker')) {
$smarty->assign('individual', 'y');
if ($tiki_p_admin != 'y') {
$perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'trackers');
foreach ($perms["data"] as $perm) {
$permName = $perm["permName"];
if ($userlib->object_has_permission($user, $_REQUEST["trackerId"], 'tracker', $permName)) {
$$permName = 'y';
$smarty->assign("$permName", 'y');
if ($permName == 'tiki_p_admin_trackers') {
$propagate = true;
}
} else {
$$permName = 'n';
$smarty->assign("$permName", 'n');
}
}
}
} elseif ($tiki_p_admin != 'y' && $feature_categories == 'y') {
$perms_array = $categlib->get_object_categories_perms($user, 'tracker', $_REQUEST['trackerId']);
if ($perms_array) {
$is_categorized = TRUE;
foreach ($perms_array as $perm => $value) {
$$perm = $value;
}
if ($tiki_p_view_categories == 'y' || $tiki_p_admin_categories == 'y') {
$tiki_p_view_categories = 'y';
$tiki_p_view_trackers = 'y';
$smarty->assign('tiki_p_view_trackers', 'y');
}
} else {
$is_categorized = FALSE;
}
if ($is_categorized && isset($tiki_p_view_categories) && $tiki_p_view_categories != 'y') {
if (!isset($user)){
$smarty->assign('msg',$smarty->fetch('modules/mod-login_box.tpl'));
$smarty->assign('errortitle',tra("Please login"));
} else {
$smarty->assign('msg',tra("Permission denied you cannot view this page"));
}
$smarty->display("error.tpl");
die;
}
}
if (!empty($propagate) && $propagate) { // if local set of tiki_p_admin_trackers, need to other perm
$perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'trackers');
foreach ($perms['data'] as $perm) {
$perm = $perm['permName'];
$smarty->assign("$perm", 'y');
$$perm = 'y';
}
}
$tikilib->get_perm_object($trackerId, 'tracker');
if (!empty($_REQUEST['show']) && $_REQUEST['show'] == 'view') {
$cookietab = '1';
......@@ -251,7 +198,7 @@ for ($i = 0; $i < $temp_max; $i++) {
$listfields[$fid]['isMandatory'] = $xfields["data"][$i]["isMandatory"];
if ($listfields[$fid]['type'] == 'e') { //category
$parentId = $listfields[$fid]["options"];
$parentId = $listfields[$fid]['options_array'][0];
$listfields[$fid]['categories'] = $categlib->get_child_categories($parentId);
}
......@@ -271,7 +218,7 @@ for ($i = 0; $i < $temp_max; $i++) {
}
} elseif ($fields["data"][$i]["type"] == 'e') { // category
include_once('lib/categories/categlib.php');
$parentId = $fields["data"][$i]["options"];
$parentId = $fields["data"][$i]['options_array'][0];
$fields["data"][$i]['categories'] = $categlib->get_child_categories($parentId);
$categId = "ins_cat_$fid";
if (isset($_REQUEST[$categId])) {
......@@ -287,16 +234,16 @@ for ($i = 0; $i < $temp_max; $i++) {
$ins_fields["data"][$i]["value"] = '';
} elseif ($fields["data"][$i]["type"] == 'u') { // user selection
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]["options"] or $tiki_p_admin_trackers == 'y')) {
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]['options_array'][0] or $tiki_p_admin_trackers == 'y')) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ($fields["data"][$i]["options"] == 1 and $user) {
if ($fields["data"][$i]['options_array'][0] == 1 and $user) {
$ins_fields["data"][$i]["value"] = $user;
} else {
$ins_fields["data"][$i]["value"] = '';
}
}
if ($fields["data"][$i]["options"] == 1 and !$writerfield) {
if ($fields["data"][$i]['options_array'][0] == 1 and !$writerfield) {
$writerfield = $fid;
} elseif (isset($_REQUEST["$filter_id"])) {
$fields["data"][$i]["value"] = $_REQUEST["$filter_id"];
......@@ -305,16 +252,16 @@ for ($i = 0; $i < $temp_max; $i++) {
}
} elseif ($fields["data"][$i]["type"] == 'I') { // IP selection
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]["options"] or $tiki_p_admin_trackers == 'y')) {
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]['options_array'][0] or $tiki_p_admin_trackers == 'y')) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ($fields["data"][$i]["options"] == 1 and $_SERVER['REMOTE_ADDR']) {
if ($fields["data"][$i]['options_array'][0] == 1 and $_SERVER['REMOTE_ADDR']) {
$ins_fields["data"][$i]["value"] = $_SERVER['REMOTE_ADDR'];
} else {
$ins_fields["data"][$i]["value"] = '';
}
}
if ($fields["data"][$i]["options"] == 1 and !$writerfield) {
if ($fields["data"][$i]['options_array'][0] == 1 and !$writerfield) {
$writerfield = $fid;
} elseif (isset($_REQUEST["$filter_id"])) {
$fields["data"][$i]["value"] = $_REQUEST["$filter_id"];
......@@ -323,16 +270,16 @@ for ($i = 0; $i < $temp_max; $i++) {
}
} elseif ($fields["data"][$i]["type"] == 'g') { // group selection
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]["options"] or $tiki_p_admin_trackers == 'y')) {
if (isset($_REQUEST["$ins_id"]) and $_REQUEST["$ins_id"] and (!$fields["data"][$i]['options_array'][0] or $tiki_p_admin_trackers == 'y')) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ( $fields["data"][$i]["options"] == 1 and $group) {
if ( $fields["data"][$i]['options_array'][0] == 1 and $group) {
$ins_fields["data"][$i]["value"] = $group;
} else {
$ins_fields["data"][$i]["value"] = '';
}
}
if ($fields["data"][$i]["options"] == 1 and !$writergroupfield) {
if ($fields["data"][$i]['options_array'][0] == 1 and !$writergroupfield) {
$writergroupfield = $fid;
} elseif (isset($_REQUEST["$filter_id"])) {
$fields["data"][$i]["value"] = $_REQUEST["$filter_id"];
......@@ -559,7 +506,7 @@ if ($feature_user_watches == 'y' and $tiki_p_watch_trackers == 'y') {
}
// Check, if the user is watching this tracker by a category.
if ($feature_categories == 'y') {
if ($feature_categories == 'y') {
$watching_categories_temp=$categlib->get_watching_categories($_REQUEST["trackerId"],'tracker',$user);
$smarty->assign('category_watched','n');
if (count($watching_categories_temp) > 0) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker_item.php,v 1.137 2007-10-09 14:48:17 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker_item.php,v 1.138 2007-10-09 15:29:00 sylvieg Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -315,7 +315,7 @@ foreach($xfields["data"] as $i=>$array) {
} elseif ($fields["data"][$i]["type"] == 'e') {
include_once('lib/categories/categlib.php');
$k = $ins_fields["data"][$i]["options"];
$k = $ins_fields["data"][$i]['options_array'][0];
$fields["data"][$i]["$k"] = $categlib->get_child_categories($k);
$categId = "ins_cat_$fid";
if (isset($_REQUEST[$categId]) and is_array($_REQUEST[$categId])) {
......@@ -335,13 +335,13 @@ foreach($xfields["data"] as $i=>$array) {
$fields["data"][$i]["value"] = '';
}
} elseif ($fields["data"][$i]["type"] == 'u' and isset($fields["data"][$i]["options"]) and $user) {
if (isset($_REQUEST["$ins_id"]) and ($fields["data"][$i]["options"] < 1 or $tiki_p_admin_trackers == 'y')) {
} elseif ($fields["data"][$i]["type"] == 'u' and isset($fields["data"][$i]['options_array'][0]) and $user) {
if (isset($_REQUEST["$ins_id"]) and ($fields["data"][$i]['options_array'][0] < 1 or $tiki_p_admin_trackers == 'y')) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ($fields["data"][$i]["options"] == 2) {
if ($fields["data"][$i]['options_array'][0] == 2) {
$ins_fields["data"][$i]["value"] = $user;
} elseif ($fields["data"][$i]["options"] == 1) {
} elseif ($fields["data"][$i]['options_array'][0] == 1) {
if (isset($tracker_info["writerCanModify"]) and $tracker_info["writerCanModify"] == 'y') {
$tracker_info["authorfield"] = $fid;
}
......@@ -356,13 +356,13 @@ foreach($xfields["data"] as $i=>$array) {
$fields["data"][$i]["value"] = '';
}
} elseif ($fields["data"][$i]["type"] == 'I' and isset($fields["data"][$i]["options"]) and isset($IP)) {
if (isset($_REQUEST["$ins_id"]) and ($fields["data"][$i]["options"] < 1 or $tiki_p_admin_trackers == 'y')) {
} elseif ($fields["data"][$i]["type"] == 'I' and isset($fields["data"][$i]['options_array'][0]) and isset($IP)) {
if (isset($_REQUEST["$ins_id"]) and ($fields["data"][$i]['options_array'][0] < 1 or $tiki_p_admin_trackers == 'y')) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ($fields["data"][$i]["options"] == 2) {
if ($fields["data"][$i]['options_array'][0] == 2) {
$ins_fields["data"][$i]["value"] = $IP;
} elseif ($fields["data"][$i]["options"] == 1) {
} elseif ($fields["data"][$i]['options_array'][0] == 1) {
} else {
$ins_fields["data"][$i]["value"] = '';
}
......@@ -373,13 +373,13 @@ foreach($xfields["data"] as $i=>$array) {
$fields["data"][$i]["value"] = '';
}
} elseif ($fields["data"][$i]["type"] == 'g' and isset($fields["data"][$i]["options"]) and $group) {
} elseif ($fields["data"][$i]["type"] == 'g' and isset($fields["data"][$i]['options_array'][0]) and $group) {
if (isset($_REQUEST["$ins_id"])) {
$ins_fields["data"][$i]["value"] = $_REQUEST["$ins_id"];
} else {
if ($fields["data"][$i]["options"] == 2) {
if ($fields["data"][$i]['options_array'][0] == 2) {
$ins_fields["data"][$i]["value"] = $group;
} elseif ($fields["data"][$i]["options"] == 1) {
} elseif ($fields["data"][$i]['options_array'][0] == 1) {
if (isset($tracker_info["writerGroupCanModify"]) and $tracker_info["writerGroupCanModify"] == 'y') {
$tracker_info["authorgroupfield"] = $fid;
}
......@@ -540,10 +540,10 @@ foreach($xfields["data"] as $i=>$array) {
}
}
}
} elseif ($xfields["data"][$i]["type"] == "u" and isset($xfields["data"][$i]["options"]) and $user and $xfields["data"][$i]["options"] == 1 and isset($tracker_info["writerCanModify"]) and $tracker_info["writerCanModify"] == 'y') {
} elseif ($xfields["data"][$i]["type"] == "u" and isset($xfields["data"][$i]['options_array'][0]) and $user and $xfields["data"][$i]['options_array'][0] == 1 and isset($tracker_info["writerCanModify"]) and $tracker_info["writerCanModify"] == 'y') {
// even if field is hidden need to pick up user for perm
$tracker_info["authorfield"] = $fid;
} elseif ($xfields["data"][$i]["type"] == "g" and isset($xfields["data"][$i]["options"]) and $group and $xfields["data"][$i]["options"] == 1 and isset($tracker_info["writerGroupCanModify"]) and $tracker_info["writerGroupCanModify"] == 'y') {
} elseif ($xfields["data"][$i]["type"] == "g" and isset($xfields["data"][$i]['options_array'][0]) and $group and $xfields["data"][$i]['options_array'][0] == 1 and isset($tracker_info["writerGroupCanModify"]) and $tracker_info["writerGroupCanModify"] == 'y') {
// even if field hidden need to pick up the group for perm
$tracker_info["authorgroupfield"] = $fid;
}
......@@ -718,7 +718,7 @@ if ($_REQUEST["itemId"]) {
}
if ($fields["data"][$i]["type"] == 'e') {
global $categlib; include_once('lib/categories/categlib.php');
$k = $fields["data"][$i]["options"];
$k = $fields["data"][$i]['options_array'][0];
$ins_fields["data"][$i]["$k"] = $categlib->get_child_categories($k);
if (!isset($cat)) {
$cat = $categlib->get_object_categories("tracker ".$_REQUEST["trackerId"],$_REQUEST["itemId"]);
......@@ -772,7 +772,7 @@ if ($_REQUEST["itemId"]) {
$ins_fields["data"][$i]["listdisplay"] =$trklib->concat_all_items_from_fieldslist($fields["data"][$i]["options_array"][0],$fields["data"][$i]["options_array"][3]);
}
} elseif ($fields["data"][$i]["type"] == 'u') {
if ($fields["data"][$i]['options'] == 2 and !$info["$fid"]) {
if (isset($fields["data"][$i]['options_array'][0]) && $fields["data"][$i]['options_array'][0] == 2 and !$info["$fid"]) {
$ins_fields["data"][$i]["defvalue"] = $user;
}
$ins_fields["data"][$i]["value"] = $info["$fid"];
......@@ -829,12 +829,12 @@ if ($_REQUEST["itemId"]) {
$smarty->assign("U_liste",$U_liste);
} elseif ($fields["data"][$i]["type"] == 'C') {
$calc = preg_replace('/#([0-9]+)/','$info[\1]',$fields["data"][$i]['options']);
$calc = preg_replace('/#([0-9]+)/','$info[\1]',$fields["data"][$i]['options_array'][0]);
eval('$computed = '.$calc.';');
$ins_fields["data"][$i]["value"] = $computed;
$info[$fields['data'][$i]['fieldId']] = $computed; // in case a computed field use this one
} elseif ($fields["data"][$i]["type"] == 'g') {
if ($fields["data"][$i]['options'] == 2 and !$info["$fid"]) {
if (isset($fields["data"][$i]['options_array'][0]) && $fields["data"][$i]['options_array'][0] == 2 and !$info["$fid"]) {
$ins_fields["data"][$i]["defvalue"] = $group;
}
$ins_fields["data"][$i]["value"] = $info["$fid"];
......
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