Commit 4295210d authored by mose's avatar mose

added a new feature in tracker with configuration of attachment fields, and some extra of them

parent 31815c2d
......@@ -3169,6 +3169,7 @@ tiki/templates/tiki-view_forum_thread.tpl -text
tiki/templates/tiki-view_irc.tpl -text
tiki/templates/tiki-view_tracker.tpl -text
tiki/templates/tiki-view_tracker_item.tpl -text
tiki/templates/tiki-view_tracker_more_info.tpl -text
tiki/templates/tiki-webmail.tpl -text
tiki/templates/tiki-webmail_contacts.tpl -text
tiki/templates/tiki.tpl -text
......@@ -3540,6 +3541,7 @@ tiki/tiki-view_irc.php -text
tiki/tiki-view_minical_topic.php -text
tiki/tiki-view_tracker.php -text
tiki/tiki-view_tracker_item.php -text
tiki/tiki-view_tracker_more_info.php -text
tiki/tiki-wap.php -text
tiki/tiki-webmail.php -text
tiki/tiki-webmail_contacts.php -text
......
......@@ -2955,14 +2955,16 @@ CREATE TABLE tiki_tracker_fields (
DROP TABLE IF EXISTS tiki_tracker_item_attachments;
CREATE TABLE tiki_tracker_item_attachments (
attId int(12) NOT NULL auto_increment,
itemId varchar(40) NOT NULL default '',
itemId int(12) NOT NULL default 0,
filename varchar(80) default NULL,
filetype varchar(80) default NULL,
filesize int(14) default NULL,
user varchar(200) default NULL,
data longblob,
longdesc blob,
path varchar(255) default NULL,
downloads int(10) default NULL,
version varchar(40) default NULL,
created int(14) default NULL,
comment varchar(250) default NULL,
PRIMARY KEY (attId)
......@@ -3043,6 +3045,7 @@ CREATE TABLE tiki_trackers (
showComments char(1) default NULL,
useAttachments char(1) default NULL,
showAttachments char(1) default NULL,
orderAttachments varchar(255) NOT NULL default 'name,created,filesize,downloads,desc',
items int(10) default NULL,
PRIMARY KEY (trackerId)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
......
......@@ -2954,14 +2954,16 @@ CREATE TABLE tiki_tracker_fields (
DROP TABLE IF EXISTS tiki_tracker_item_attachments;
CREATE TABLE tiki_tracker_item_attachments (
attId int(12) NOT NULL auto_increment,
itemId varchar(40) NOT NULL default '',
itemId int(12) NOT NULL default 0,
filename varchar(80) default NULL,
filetype varchar(80) default NULL,
filesize int(14) default NULL,
user varchar(200) default NULL,
data longblob,
longdesc blob,
path varchar(255) default NULL,
downloads int(10) default NULL,
version varchar(40) default NULL,
created int(14) default NULL,
comment varchar(250) default NULL,
PRIMARY KEY (attId)
......@@ -3042,6 +3044,7 @@ CREATE TABLE tiki_trackers (
showComments char(1) default NULL,
useAttachments char(1) default NULL,
showAttachments char(1) default NULL,
orderAttachments varchar(255) NOT NULL default 'name,created,filesize,downloads,desc',
items int(10) default NULL,
PRIMARY KEY (trackerId)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
......
# $Id: tiki_1.7to1.8.sql,v 1.91 2003-12-15 18:24:33 bburgaud Exp $
# $Id: tiki_1.7to1.8.sql,v 1.92 2003-12-16 07:26:07 mose Exp $
# The following script will update a tiki database from verion 1.7 to 1.8
#
......@@ -843,3 +843,10 @@ ALTER TABLE `tiki_trackers` ADD `showAttachments` CHAR( 1 ) AFTER `useAttachment
# added on 2003-12-15 by baptiste (adding anonymous posts discard possibility to mail-in feature)
ALTER TABLE tiki_mailin_accounts ADD anonymous CHAR(1) NOT NULL DEFAULT 'y';
# added on 2003-12-16 by mose (adding power to trackers attachments)
ALTER TABLE `tiki_tracker_item_attachments` ADD `longdesc` blob after `data` ;
ALTER TABLE `tiki_tracker_item_attachments` ADD `version` varchar(40) after `downloads` ;
ALTER TABLE `tiki_tracker_item_attachments` CHANGE `itemId` `itemId` INT( 12 ) DEFAULT '0' NOT NULL ;
ALTER TABLE `tiki_trackers` ADD `orderAttachments` VARCHAR( 255 ) DEFAULT 'name,created,filesize,downloads,desc' NOT NULL AFTER `showAttachments` ;
......@@ -111,7 +111,7 @@ class TrackerLib extends TikiLib {
$bindvars=array((int) $itemId);
}
$query = "select `user`,`attId`,`itemId`,`filename`,`filesize`,`filetype`,`downloads`,`created`,`comment` from `tiki_tracker_item_attachments` $mid order by ".$this->convert_sortmode($sort_mode);
$query = "select `user`,`attId`,`itemId`,`filename`,`filesize`,`filetype`,`downloads`,`created`,`comment`,`longdesc`,`version` from `tiki_tracker_item_attachments` $mid order by ".$this->convert_sortmode($sort_mode);
$query_cant = "select count(*) from `tiki_tracker_item_attachments` $mid";
$result = $this->query($query,$bindvars,$maxRecords,$offset);
$cant = $this->getOne($query_cant,$bindvars);
......@@ -127,12 +127,12 @@ class TrackerLib extends TikiLib {
return $retval;
}
function item_attach_file($itemId, $name, $type, $size, $data, $comment, $user, $fhash) {
function item_attach_file($itemId, $name, $type, $size, $data, $comment, $user, $fhash, $version, $longdesc) {
$comment = strip_tags($comment);
$now = date("U");
$query = "insert into `tiki_tracker_item_attachments`(`itemId`,`filename`,`filesize`,`filetype`,`data`,`created`,`downloads`,`user`,`comment`,`path`)
values(?,?,?,?,?,?,?,?,?,?)";
$result = $this->query($query,array((int) $itemId,$name,$size,$type,$data,(int) $now,0,$user,$comment,$fhash));
$query = "insert into `tiki_tracker_item_attachments`(`itemId`,`filename`,`filesize`,`filetype`,`data`,`created`,`downloads`,`user`,`comment`,`path`,`version`,`longdesc`)
values(?,?,?,?,?,?,?,?,?,?,?,?)";
$result = $this->query($query,array((int) $itemId,$name,$size,$type,$data,(int) $now,0,$user,$comment,$fhash,$version,$longdesc));
}
function get_item_attachment($attId) {
......@@ -453,15 +453,15 @@ class TrackerLib extends TikiLib {
}
// Inserts or updates a tracker
function replace_tracker($trackerId, $name, $description, $showCreated, $showLastModif, $useComments, $useAttachments, $showStatus, $showComments, $showAttachments) {
function replace_tracker($trackerId, $name, $description, $showCreated, $showLastModif, $useComments, $useAttachments, $showStatus, $showComments, $showAttachments, $orderattachments) {
if ($trackerId) {
$query = "update `tiki_trackers` set `name`=?,`description`=?, `useAttachments`=?,`showAttachments`=?,
`useComments`=?, `showComments`=?,`showCreated`=?,`showLastModif`=?,`showStatus`=?
`useComments`=?, `showComments`=?,`showCreated`=?,`showLastModif`=?,`showStatus`=?, `orderAttachments`=?
where `trackerId`=?";
$bindvars=array($name,$description,$useAttachments,$showAttachments,$useComments,$showComments,$showCreated,
$showLastModif,$showStatus,(int) $trackerId);
$showLastModif,$showStatus,$orderattachments,(int) $trackerId);
$result = $this->query($query,$bindvars);
} else {
......@@ -469,10 +469,10 @@ class TrackerLib extends TikiLib {
$this->getOne("delete from `tiki_trackers` where `name`=?",array($name),false);
$query = "insert into `tiki_trackers`(`name`,`description`,`created`,`lastModif`,
`items`,`showCreated`,`showLastModif`,`useComments`,`showComments``useAttachments`,`showAttachments``showStatus`)
values(?,?,?,?,?,?,?,?,?,?,?,?)";
`items`,`showCreated`,`showLastModif`,`useComments`,`showComments``useAttachments`,`showAttachments`,`showStatus`,`orderAttachments`)
values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
$bindvars=array($name,$description,(int) $now,(int) $now,0,$showCreated,$showLastModif,
$useComments,$showComments,$useAttachments,$showAttachments,$showStatus);
$useComments,$showComments,$useAttachments,$showAttachments,$showStatus,$orderattachments);
$result = $this->query($query,$bindvars);
$trackerId = $this->getOne("select max(`trackerId`) from `tiki_trackers` where `name`=? and `created`=?",array($name,(int) $now));
}
......@@ -563,7 +563,29 @@ class TrackerLib extends TikiLib {
$res = $result->fetchRow();
return $res;
}
/* End of tiki tracker construction functions */
/*
** function only used for the popup for more infos on attachements
* returns an array with field=>value
*/
function get_moreinfo($attId) {
$query = "select `orderAttachments`, t.`trackerId` from tiki_trackers t ";
$query.= " left join `tiki_tracker_items` i on t.`trackerId`=i.`trackerId` ";
$query.= " left join `tiki_tracker_item_attachments` a on i.`itemId`=a.`itemId` ";
$query.= " where a.`attId`=?";
$resu = $this->query($query,((int)$attId));
if (strstr($resu['orderatt'],'|')) {
$fields = split(',',substr($resu['orderat'],strpos($resu['orderatt'],'|')));
$query = "select `".implode("`,`",$fields)."` from `tiki_tracker_item_attachments` where `attId`=?";
$result = $this->query($query,array((int)$attId));
$res = $result->fetchRow();
$res["trackerId"] = $resu['trackerId'];
return $res;
} else {
return array(tra("Sorry") => tra("No extra information for that attached file."));
}
}
}
$trklib = new TrackerLib($dbTiki);
......
......@@ -28,6 +28,7 @@
<option value="u" {if $type eq 'u'}selected="selected"{/if}>{tr}user selector{/tr}</option>
<option value="g" {if $type eq 'g'}selected="selected"{/if}>{tr}group selector{/tr}</option>
<option value="f" {if $type eq 'f'}selected="selected"{/if}>{tr}date and time{/tr}</option>
<option value="j" {if $type eq 'j'}selected="selected"{/if}>{tr}jscalendar{/tr}</option>
<option value="i" {if $type eq 'i'}selected="selected"{/if}>{tr}image{/tr}</option>
</select>
<span id='trkfldoptions' {if $type eq 'd' or $type eq 'i'}style="display:inline;"{else}style="display:none;"{/if}><input type="text" name="options" value="{$options|escape}" /></span>
......
......@@ -35,6 +35,26 @@
{tr}and display comments in listing?{/tr} <input type="checkbox" name="showComments" {if $showComments eq 'y'}checked="checked"{/if} /></td></tr>
<tr><td class="formcolor">{tr}Tracker items allow attachments?{/tr}</td><td class="formcolor"><input type="checkbox" name="useAttachments" {if $useAttachments eq 'y'}checked="checked"{/if} />
{tr}and display attachments in listing?{/tr} <input type="checkbox" name="showAttachments" {if $showAttachments eq 'y'}checked="checked"{/if} /></td></tr>
<tr><td class="formcolor">{tr}Attachement display options{/tr}<br />{tr}(Use numbers to order items, 0 will not be displayed,<br /> and negative values will be displayed in a popup){/tr}</td><td class="formcolor">
<table width="100%"><tr>
<td class="formcolor">{tr}name{/tr}</td>
<td class="formcolor">{tr}date{/tr}</td>
<td class="formcolor">{tr}dls{/tr}</td>
<td class="formcolor">{tr}desc{/tr}</td>
<td class="formcolor">{tr}size{/tr}</td>
<td class="formcolor">{tr}version{/tr}</td>
<td class="formcolor">{tr}type{/tr}</td>
<td class="formcolor">{tr}long desc{/tr}</td></tr>
<tr>
<td class="formcolor"><input type="text" size="2" name="ui[filename]" value="{$ui.filename}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[date]" value="{$ui.created}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[downloads]" value="{$ui.downloads}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[comment]" value="{$ui.comment}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[filesize]" value="{$ui.filesize}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[version]" value="{$ui.version}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[filetype]" value="{$ui.filetype}" /></td>
<td class="formcolor"><input type="text" size="2" name="ui[longdesc]" value="{$ui.longdesc}" /></td>
</tr></table>
</td></tr>
<tr><td class="formcolor">&nbsp;</td><td class="formcolor"><input type="submit" name="save" value="{tr}Save{/tr}" /></td></tr>
</table>
......
......@@ -91,27 +91,31 @@
{/if}
<h3>{tr}Attachments{/tr}</h3>
<table class="normal">
<tr>
<td class="heading">{tr}name{/tr}</td>
<td class="heading">{tr}uploaded{/tr}</td>
<td class="heading">{tr}size{/tr}</td>
<td class="heading">{tr}dls{/tr}</td>
<td class="heading">{tr}desc{/tr}</td>
</tr>
{section name=ix loop=$attfields}
<td class="heading">{tr}{$attfields[ix]}{/tr}</td>
{/section}
<td class="heading">{tr}action{/tr}</td>
</tr>
{cycle values="odd,even" print=false}
{section name=ix loop=$atts}
<tr>
<td class="{cycle advance=false}">
{$atts[ix].filename|iconify}
<a class="tablename" href="tiki-download_item_attachment.php?attId={$atts[ix].attId}">{$atts[ix].filename}</a>
{if $tiki_p_wiki_admin_attachments eq 'y' or ($user and ($atts[ix].user eq $user))}
<a class="link" href="tiki-view_tracker_item.php?trackerId={$trackerId}&amp;itemId={$itemId}&amp;removeattach={$atts[ix].attId}&amp;offset={$offset}&amp;sort_mode={$sort_mode}">[x]</a>
{/if}
</td>
<td class="{cycle advance=false}">{$atts[ix].created|tiki_short_datetime}{if $atts[ix].user} {tr}by{/tr} {$atts[ix].user}{/if}</td>
<td class="{cycle advance=false}">{$atts[ix].filesize}</td>
<td class="{cycle advance=false}">{$atts[ix].downloads}</td>
<td class="{cycle}">{$atts[ix].comment}</td>
{foreach key=k item=x from=$attfields}
<td class="{cycle advance=false}">
{$atts[ix].$x}
</td>
{/foreach}
<td class="{cycle}" align="right" nowrap="nowrap">
{if $attextra eq 'y'}
<a class="tablename" href="#" onclick="javascript:window.open('tiki-view_tracker_more_info.php?attId={$atts[ix].attId}','_blank','menubar=no,toolbar=no,location=no,directories=no,fullscreen=no,titlebar=no,hotkeys=no,status=no,scrollbars=yes,resizable=yes,width=350,height=500');">more</a>
{/if}
<a class="tablename" href="tiki-download_item_attachment.php?attId={$atts[ix].attId}">{$atts[ix].filename|iconify}</a>
{if $tiki_p_wiki_admin_attachments eq 'y' or ($user and ($atts[ix].user eq $user))}
&nbsp;&nbsp;<a class="link" href="tiki-view_tracker_item.php?trackerId={$trackerId}&amp;itemId={$itemId}&amp;removeattach={$atts[ix].attId}&amp;offset={$offset}&amp;sort_mode={$sort_mode}">[x]</a>
{/if}
</td>
</tr>
{sectionelse}
<tr>
......
{include file="header.tpl"}
{if $feature_bidi eq 'y'}
<table dir="rtl" ><tr><td>
{/if}
<div id="tiki-main">
<h3>{tr}Details{/tr}</h3>
<table class="normal">
{foreach key=l item=v from=$info}
<tr><td class="formcolor">{$l}</td>
<td class="formcolor">
{$v}
</td>
</tr>
{/section}
</table>
<div class="cbox">
<a href="#" onclick="javascript:window.close();" class="link">{tr}close{/tr}</a>
</div>
</div>
{if $feature_bidi eq 'y'}
</td></tr></table>
{/if}
{include file="footer.tpl"}
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-admin_trackers.php,v 1.8 2003-12-10 03:51:45 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-admin_trackers.php,v 1.9 2003-12-16 07:26:07 mose Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -36,7 +36,7 @@ if ($userlib->object_has_one_permission($_REQUEST["trackerId"], 'tracker')) {
}
if ($_REQUEST["trackerId"]) {
$info = $trklib->get_tracker($_REQUEST["trackerId"]);
$info = $tikilib->get_tracker($_REQUEST["trackerId"]);
} else {
$info = array();
$info["name"] = '';
......@@ -48,6 +48,7 @@ if ($_REQUEST["trackerId"]) {
$info["useAttachments"] = '';
$info["showComments"] = '';
$info["showAttachments"] = '';
$info["orderAttachments"] = 'name,created,filesize,downloads,desc';
}
$smarty->assign('name', $info["name"]);
......@@ -60,6 +61,25 @@ $smarty->assign('useAttachments', $info["useAttachments"]);
$smarty->assign('showComments', $info["showComments"]);
$smarty->assign('showAttachments', $info["showAttachments"]);
$outatt = array();
$info["orderPopup"] = '';
if (strstr($info["orderAttachments"],'|')) {
$part = split("\|",$info["orderAttachments"]);
$info["orderAttachments"] = $part[0];
$info["orderPopup"] = $part[1];
}
$i = 1;
foreach (split(',',$info["orderAttachments"]) as $it) {
$outatt["$it"] = $i;
$i++;
}
$i = -1;
foreach (split(',',$info["orderPopup"]) as $it) {
$outatt["$it"] = $i;
$i--;
}
$smarty->assign('ui', $outatt);
if (isset($_REQUEST["remove"])) {
$trklib->remove_tracker($_REQUEST["remove"]);
}
......@@ -107,11 +127,27 @@ if (isset($_REQUEST["save"])) {
$showLastModif = 'n';
}
if (isset($_REQUEST['ui']) and is_array($_REQUEST['ui'])) {
$showlist = array();
$popupinfo = array();
foreach ($_REQUEST['ui'] as $kk=>$vv) {
if ($vv > 0) { $showlist[$vv] = $kk; }
if ($vv < 0) { $popupinfo[$vv] = $kk; }
}
ksort($showlist);
krsort($popupinfo);
$orderat = implode(',',$showlist);
if (count($popupinfo)) {
$orderat.= '|'.implode(',',$popupinfo);
}
}
$trklib->replace_tracker($_REQUEST["trackerId"], $_REQUEST["name"], $_REQUEST["description"], $showCreated, $showLastModif,
$useComments, $useAttachments, $showStatus, $showComments, $showAttachments);
$useComments, $useAttachments, $showStatus, $showComments, $showAttachments, $orderat);
$smarty->assign('trackerId', 0);
$smarty->assign('name', '');
$smarty->assign('description', '');
$smarty->assign('ui',array());
}
if (!isset($_REQUEST["sort_mode"])) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker_item.php,v 1.14 2003-12-10 03:51:45 mose Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker_item.php,v 1.15 2003-12-16 07:26:07 mose Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -14,14 +14,12 @@ include_once ('lib/notifications/notificationlib.php');
if ($feature_trackers != 'y') {
$smarty->assign('msg', tra("This feature is disabled").": feature_wiki");
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST["itemId"])) {
$smarty->assign('msg', tra("No item indicated"));
$smarty->display("error.tpl");
die;
}
......@@ -32,7 +30,6 @@ $smarty->assign('item_info', $item_info);
if (!isset($_REQUEST["trackerId"])) {
$smarty->assign('msg', tra("No tracker indicated"));
$smarty->display("error.tpl");
die;
}
......@@ -65,7 +62,6 @@ if ($userlib->object_has_one_permission($_REQUEST["trackerId"], 'tracker')) {
if ($tiki_p_view_trackers != 'y') {
$smarty->assign('msg', tra("You dont have permission to use this feature"));
$smarty->display("error.tpl");
die;
}
......@@ -147,10 +143,8 @@ if ($tiki_p_modify_tracker_items == 'y') {
if ($_REQUEST["itemId"]) {
$info = $trklib->get_tracker_item($_REQUEST["itemId"]);
for ($i = 0; $i < count($fields["data"]); $i++) {
$name = $fields["data"][$i]["name"];
$ins_name = 'ins_' . $name;
$ins_fields["data"][$i]["value"] = $info["$name"];
}
......@@ -333,8 +327,15 @@ if ($tracker_info["useAttachments"] == 'y') {
}
}
$attextra = 'n';
if (strstr($tracker_info["orderAttachments"],'|')) {
$attextra = 'y';
}
$attfields = split(',',strtok($tracker_info["orderAttachments"],'|'));
$atts = $trklib->list_item_attachments($_REQUEST["itemId"], 0, -1, 'created_desc', '');
$smarty->assign('atts', $atts["data"]);
$smarty->assign('attfields', $attfields);
$smarty->assign('attextra', $attextra);
}
if (isset($_REQUEST['show'])) {
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-view_tracker_more_info.php,v 1.1 2003-12-16 07:26:07 mose Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// Initialization
require_once ('tiki-setup.php');
include_once ('lib/trackers/trackerlib.php');
if ($feature_trackers != 'y') {
$smarty->assign('msg', tra("This feature is disabled").": feature_wiki");
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST["attId"])) {
$smarty->assign('msg', tra("No item indicated"));
$smarty->display("error.tpl");
die;
}
$info = $trklib->get_moreinfo($_REQUEST["attId"]);
$_REQUEST["trackerId"] = $info['trackerId'];
if (!isset($_REQUEST["trackerId"])) {
$smarty->assign('msg', tra("No tracker indicated"));
$smarty->display("error.tpl");
die;
}
$smarty->assign('trackerId', $_REQUEST["trackerId"]);
$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');
} else {
$$permName = 'n';
$smarty->assign("$permName", 'n');
}
}
}
}
if ($tiki_p_view_trackers != 'y') {
$smarty->assign('msg', tra("You dont have permission to use this feature"));
$smarty->display("error.tpl");
die;
}
$qmarty->assign("info",$info);
$smarty->display("tiki-view_tracker_more_info.tpl");
?>
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