Commit a1f87c22 authored by lrargerich's avatar lrargerich

stuff

parent 277df826
......@@ -1892,6 +1892,7 @@ tiki/tiki-view_eph.php -text
tiki/tiki-view_faq.php -text
tiki/tiki-view_forum.php -text
tiki/tiki-view_forum_thread.php -text
tiki/tiki-view_minical_topic.php -text
tiki/tiki-view_tracker.php -text
tiki/tiki-view_tracker_item.php -text
tiki/tiki-webmail.php -text
......
## THIS FILE IS JUST A HELP FOR DEVELOPERS IT SHOULDNT BE USED IN A 1.5 DISTRIBUTION
drop table if exists tiki_minical;
drop table if exists tiki_minical_topics;
create table tiki_minical_topics(
user varchar(200),
topicId integer(12) not null auto_increment,
name varchar(250),
filename varchar(200),
filetype varchar(200),
filesize varchar(200),
data longblob,
path varchar(250),
isIcon char(1),
primary key(topicId)
);
drop table if exists tiki_minical_events;
create table tiki_minical_events(
user varchar(200),
eventId integer(12) not null auto_increment,
......@@ -10,6 +24,7 @@ create table tiki_minical_events(
end integer(14),
security char(1),
duration integer(3),
topicId integer(12),
primary key(eventId)
);
......
......@@ -30,6 +30,7 @@ class MiniCalLib extends TikiLib {
$result = $this->query($query);
$events=Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$res['end']=$res['start']+$res['duration'];
$events[] = $res;
}
$aux['events']=$events;
......@@ -39,12 +40,59 @@ class MiniCalLib extends TikiLib {
return $slots;
}
function minical_upload_topic($user,$topicname,$name,$type,$size, $data,$path)
{
$topicname= addslashes($topicname);
$data=addslashes($data);
if(strlen($data)==0) {
$isIcon = 'y';
} else {
$isIcon = 'n';
}
$query = "insert into tiki_minical_topics(user,name,filename,filetype,filesize,data,isIcon,path)
values('$user','$topicname','$name','$type',$size,'$data','$isIcon','$path')";
$this->query($query);
}
function minical_list_topics($user,$offset,$maxRecords,$sort_mode,$find)
{
$sort_mode = str_replace("_desc"," desc",$sort_mode);
$sort_mode = str_replace("_asc"," asc",$sort_mode);
if($find) {
$mid=" and (name like '%".$find."%' or filename like '%".$find."%')";
} else {
$mid=" ";
}
$query = "select isIcon,path,name,topicId from tiki_minical_topics where
user='$user' $mid order by $sort_mode limit $offset,$maxRecords";
$query_cant = "select count(*) from tiki_minical_topics where
user='$user' $mid";
$result = $this->query($query);
$cant = $this->getOne($query_cant);
$ret = Array();
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$ret[] = $res;
}
$retval = Array();
$retval["data"] = $ret;
$retval["cant"] = $cant;
return $retval;
}
function minical_get_topic($user,$topicId)
{
$query = "select * from tiki_minical_topics where user='$user' and topicId=$topicId";
$result = $this->query($query);
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $res;
}
function minical_list_events($user,$offset,$maxRecords,$sort_mode,$find)
{
$sort_mode = str_replace("_desc"," desc",$sort_mode);
$sort_mode = str_replace("_asc"," asc",$sort_mode);
if($find) {
$mid=" and (name like '%".$find."%' or url like '%".$find."%')";
$mid=" and (title like '%".$find."%' or description like '%".$find."%')";
} else {
$mid=" ";
}
......@@ -73,6 +121,12 @@ user='$user' and eventId='$eventId'";
return $res;
}
function minical_remove_topic($user,$topicId)
{
$query = "delete from tiki_minical_topics where user='$user' and topicId=$topicId";
$this->query($query);
}
function minical_replace_event($user,$eventId,$title,$description,$start,$duration)
{
......@@ -81,14 +135,14 @@ user='$user' and eventId='$eventId'";
$now = date("U");
if($eventId) {
$query = "update tiki_minical_events set
title='$title', description='$description',start=$start,duration=$duration
end=$start+$duration,title='$title', description='$description',start=$start,duration=$duration
where user='$user' and
eventId=$eventId";
$this->query($query);
return $eventId;
} else {
$query = "insert into tiki_minical_events(user,title,description,start,duration)
values('$user','$title','$description',$start,$duration)";
$query = "insert into tiki_minical_events(user,title,description,start,duration,end)
values('$user','$title','$description',$start,$duration,$start+$duration)";
$this->query($query);
$Id = $this->getOne("select max(eventId) from
tiki_minical_events where user='$user' and start=$start");
......@@ -107,4 +161,4 @@ tiki_minical_events where user='$user' and start=$start");
}
$minicallib= new MiniCalLib($dbTiki);
?>
?>
\ No newline at end of file
......@@ -5,7 +5,8 @@
[<a class="link" href="#add">{tr}Add{/tr}</a>]
[<a class="link" href="tiki-minical_prefs.php">{tr}Prefs{/tr}</a>]
[<a class="link" href="tiki-minical.php?view=daily">{tr}Daily{/tr}</a> |
<a class="link" href="tiki-minical.php?view=weekly">{tr}Weekly{/tr}</a>]
<a class="link" href="tiki-minical.php?view=weekly">{tr}Weekly{/tr}</a>|
<a class="link" href="tiki-minical.php?view=list">{tr}List{/tr}</a>]
<br/><br/>
<!-- Time here -->
......@@ -29,7 +30,7 @@
</td>
<td>
{section name=jj loop=$slots[ix].events}
<a title="{$slots[ix].events[jj].start|tiki_short_time}:{$slots[ix].events[jj].description}" class="link" href="tiki-minical.php?view={$view}&amp;eventId={$slots[ix].events[jj].eventId}">{$slots[ix].events[jj].title}</a>
<a title="{$slots[ix].events[jj].start|tiki_short_time}-{$slots[ix].events[jj].end|tiki_short_time}:{$slots[ix].events[jj].description}" class="link" href="tiki-minical.php?view={$view}&amp;eventId={$slots[ix].events[jj].eventId}">{$slots[ix].events[jj].title}</a>
[<a class="link" href="tiki-minical.php?view={$view}&amp;remove={$slots[ix].events[jj].eventId}">x</a>]
<br/>
{/section}
......@@ -71,12 +72,68 @@
</table>
{/if}
{if $view eq 'list'}
<table class="findtable">
<tr><td class="findtable">{tr}Find{/tr}</td>
<td class="findtable">
<form method="get" action="tiki-minical.php">
<input type="text" name="find" value="{$find}" />
<input type="submit" value="{tr}find{/tr}" name="search" />
<input type="hidden" name="sort_mode" value="{$sort_mode}" />
<input type="hidden" name="view" value="{$view}" />
</form>
</td>
</tr>
</table>
<form action="tiki-minical.php" method="post">
<input type="hidden" name="view" value="{$view}" />
<table class="normal">
<tr>
<td class="heading"><input type="submit" name="delete" value="{tr}del{/tr}" /></td>
<td class="heading" ><a class="tableheading" href="tiki-minical.php?view={$view}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'title_desc'}title_asc{else}title_desc{/if}">{tr}title{/tr}</a></td>
<td class="heading" ><a class="tableheading" href="tiki-minical.php?view={$view}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'start_desc'}start{else}start_desc{/if}">{tr}start{/tr}</a></td>
<td class="heading" ><a class="tableheading" href="tiki-minical.php?view={$view}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'duration_desc'}duration_asc{else}duration_desc{/if}">{tr}duration{/tr}</a></td>
</tr>
{cycle values="odd,even" print=false}
{section name=user loop=$channels}
<tr>
<td class="{cycle advance=false}">
<input type="checkbox" name="event[{$channels[user].eventId}]" />
</td>
<td class="{cycle advance=false}"><a class="link" href="tiki-minical.php?view={$view}&amp;eventId={$channels[user].eventId}&amp;offset={$offset}&amp;sort_mode={$sort_mode}&amp;find={$find}">{$channels[user].title}</a></td>
<td class="{cycle advance=false}">{$channels[user].start|tiki_short_datetime}</td>
<td class="{cycle advance=false}">{math equation="x / 3600" x=$channels[user].duration format="%d"} {tr}h{/tr} {math equation="(x % 3600) / 60" x=$channels[user].duration} {tr}mins{/tr}</td>
</tr>
{/section}
</table>
</form>
<div class="mini">
<div align="center">
{if $prev_offset >= 0}
[<a class="prevnext" href="tiki-minical.php?view={$view}&amp;find={$find}&amp;offset={$prev_offset}&amp;sort_mode={$sort_mode}">{tr}prev{/tr}</a>]&nbsp;
{/if}
{tr}Page{/tr}: {$actual_page}/{$cant_pages}
{if $next_offset >= 0}
&nbsp;[<a class="prevnext" href="tiki-minical.php?view={$view}&amp;find={$find}&amp;offset={$next_offset}&amp;sort_mode={$sort_mode}">{tr}next{/tr}</a>]
{/if}
{if $direct_pagination eq 'y'}
<br/>
{section loop=$cant_pages name=foo}
{assign var=selector_offset value=$smarty.section.foo.index|times:$maxRecords}
<a class="prevnext" href="tiki-minical.php?vew={$view}&amp;find={$find}&amp;offset={$selector_offset}&amp;sort_mode={$sort_mode}">
{$smarty.section.foo.index_next}</a>&nbsp;
{/section}
{/if}
</div>
</div>
{/if}
<a name="add"></a>
<h3>{tr}Add an event{/tr}</h3>
<h3>{tr}Add or edit event{/tr}</h3>
<form action="tiki-minical.php" method="post">
<input type="hidden" name="eventId" value="{$eventId}" />
<input type="hidden" name="duration" value="2" />
<input type="hidden" name="description" value="dummy" />
<input type="hidden" name="view" value="{$view}" />
<input type="hidden" name="duration" value="60*60" />
<table class="normal">
<tr><td class="formcolor">{tr}Title{/tr}</td>
<td class="formcolor"><input type="text" name="title" value="{$info.title}" /><input type="submit" name="save" value="{tr}save{/tr}" /></td>
......@@ -88,6 +145,25 @@
{html_select_time time=$ev_pdate_h display_seconds=false use_24_hours=true}
</td>
</tr>
<tr>
<td class="formcolor">{tr}Duration{/tr}</td>
<td class="formcolor">
<select name="duration_hours">
{html_options output=$hours values=$hours selected=$duration_hours}
</select>{if $duration_hours>1}{tr}hours{/tr}{else}{tr}hour{/tr}{/if}
<select name="duration_minutes">
{html_options output=$minutes values=$minutes selected=$duration_minutes}
</select> {tr}minutes{/tr}
</td>
</tr>
<tr>
<td class="formcolor">{tr}Description{/tr}</td>
<td class="formcolor">
<textarea name="description" rows="5" cols="80">{$info.description}</textarea>
</td>
</tr>
</table>
</form>
......
......@@ -46,4 +46,56 @@
</tr>
</table>
</form>
<h3>{tr}Admin topics{/tr}</h3>
<form enctype="multipart/form-data" action="tiki-minical_prefs.php" method="post">
<table class="normal">
<tr>
<td class="formcolor">{tr}Name{/tr}:</td><td class="formcolor"><input type="text" name="name" /></td>
</tr>
<tr>
<td class="formcolor">{tr}Upload file{/tr}:</td><td class="formcolor"><input type="hidden" name="MAX_FILE_SIZE" value="10000000000000"><input size="16" name="userfile1" type="file"></td>
</tr>
<tr>
<td class="formcolor">{tr}Or enter path{/tr}:</td><td class="formcolor"><input type="text" name="path" /></td>
</tr>
<tr>
<td class="formcolor">&nbsp;</td>
<td class="formcolor">
<input type="submit" name="addtopic" value="{tr}add topic{/tr}" />
</td>
</table>
</form>
<div class="simplebox">
<table width="100%">
<tr>
{section name=numloop loop=$topics}
<td>
{if $topics[numloop].isIcon eq 'y'}
<img src="{$topics[numloop].path}" alt="{tr}topic image{/tr}" />
{else}
<img src="tiki-view_minical_topic.php?topicId={$topics[numloop].topicId}" alt="{tr}topic image{/tr}" />
{/if}
{$topics[numloop].name}
[<a class="link" href="tiki-minical_prefs.php?removetopic={$topics[numloop].topicId}">x</a>]
</td>
{* see if we should go to the next row *}
{if not ($smarty.section.numloop.rownum mod $cols)}
{if not $smarty.section.numloop.last}
</tr><tr>
{/if}
{/if}
{if $smarty.section.numloop.last}
{* pad the cells not yet created *}
{math equation = "n - a % n" n=$cols a=$data|@count assign="cells"}
{if $cells ne $cols}
{section name=pad loop=$cells}
<td>&nbsp;</td>
{/section}
{/if}
</tr>
{/if}
{/section}
</table>
</div>
......@@ -15,7 +15,7 @@ if(!$user) {
}
//if($tiki_p_usermenu != 'y') {
//if($tiki_p_minical != 'y') {
// $smarty->assign('msg',tra("Permission denied to use this feature"));
// $smarty->display("styles/$style_base/error.tpl");
// die;
......@@ -25,9 +25,13 @@ if(!$user) {
if(!isset($_REQUEST["eventId"])) $_REQUEST["eventId"]=0;
if(isset($_REQUEST['remove'])) {
// foreach(array_keys($_REQUEST["menu"]) as $men) {
$minicallib->minical_remove_event($user, $_REQUEST['remove']);
// }
$minicallib->minical_remove_event($user, $_REQUEST['remove']);
}
if(isset($_REQUEST['delete'])) {
foreach(array_keys($_REQUEST["event"]) as $ev) {
$minicallib->minical_remove_event($user, $ev);
}
}
if(isset($_SESSION['thedate'])) {
......@@ -35,16 +39,14 @@ if(isset($_SESSION['thedate'])) {
} else {
$pdate = date("U");
}
$yesterday = $pdate - 60*60*24;
$tomorrow = $pdate + 60*60*24;
$smarty->assign('yesterday',$yesterday);
$smarty->assign('tomorrow',$tomorrow);
$smarty->assign('day',date("d",$pdate));
$smarty->assign('mon',date("m",$pdate));
$smarty->assign('year',date("Y",$pdate));
$pdate_h = mktime(date("G"),date("i"),date("s"),date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$smarty->assign('pdate',$pdate);
$smarty->assign('pdate_h',$pdate_h);
......@@ -60,7 +62,7 @@ if($_REQUEST["eventId"]) {
$info['title']='';
$info['description']='';
$info['start']=mktime(date("H"),date("i"),date("s"),date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$info['duration']=1;
$info['duration']=60*60;
}
$smarty->assign('ev_pdate',$ev_pdate);
$smarty->assign('ev_pdate_h',$ev_pdate_h);
......@@ -68,12 +70,12 @@ $smarty->assign('ev_pdate_h',$ev_pdate_h);
if(isset($_REQUEST['save'])) {
$start = mktime($_REQUEST['Time_Hour'],$_REQUEST['Time_Minute'],0,$_REQUEST['Date_Month'],$_REQUEST['Date_Day'],$_REQUEST['Date_Year']);
$minicallib->minical_replace_event($user,$_REQUEST["eventId"],$_REQUEST["title"],$_REQUEST["description"],$start,$_REQUEST['duration']);
$minicallib->minical_replace_event($user,$_REQUEST["eventId"],$_REQUEST["title"],$_REQUEST["description"],$start,($_REQUEST['duration_hours']*60*60)+($_REQUEST['duration_minutes']*60));
$info=Array();
$info['title']='';
$info['description']='';
$info['start']=mktime(date("h"),date("i"),date("s"),date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$info['duration']=1;
$info['duration']=60*60;
$_REQUEST["eventId"]=0;
}
$smarty->assign('eventId',$_REQUEST["eventId"]);
......@@ -115,12 +117,68 @@ if($_REQUEST['view']=='weekly') {
$slot_end = $slot_start + 60*60*24*7-1;
}
$smarty->assign('slot_start',$slot_start);
$smarty->assign('slot_end',$slot_end);
if($_REQUEST['view']=='daily' || $_REQUEST['view']=='weekly') {
$smarty->assign('slot_start',$slot_start);
$smarty->assign('slot_end',$slot_end);
$events = $minicallib->minical_events_by_slot($user,$slot_start,$slot_end,$interval);
$smarty->assign_by_ref('slots',$events);
}
// List view
if($_REQUEST['view']=='list') {
if(!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'start_desc';
} else {
$sort_mode = $_REQUEST["sort_mode"];
}
if(!isset($_REQUEST["offset"])) {
$offset = 0;
} else {
$offset = $_REQUEST["offset"];
}
$smarty->assign_by_ref('offset',$offset);
if(isset($_REQUEST["find"])) {
$find = $_REQUEST["find"];
} else {
$find = '';
}
$smarty->assign('find',$find);
$smarty->assign_by_ref('sort_mode',$sort_mode);
if(isset($_SESSION['thedate'])) {
$pdate = $_SESSION['thedate'];
} else {
$pdate = date("U");
}
$channels = $minicallib->minical_list_events($user,$offset,$maxRecords,$sort_mode,$find);
$cant_pages = ceil($channels["cant"] / $maxRecords);
$smarty->assign_by_ref('cant_pages',$cant_pages);
$smarty->assign('actual_page',1+($offset/$maxRecords));
if($channels["cant"] > ($offset+$maxRecords)) {
$smarty->assign('next_offset',$offset + $maxRecords);
} else {
$smarty->assign('next_offset',-1);
}
// If offset is > 0 then prev_offset
if($offset>0) {
$smarty->assign('prev_offset',$offset - $maxRecords);
} else {
$smarty->assign('prev_offset',-1);
}
$smarty->assign_by_ref('channels',$channels["data"]);
}
$events = $minicallib->minical_events_by_slot($user,$slot_start,$slot_end,$interval);
//print_r($events);
$smarty->assign_by_ref('slots',$events);
$hours=range(0,23);
$smarty->assign('hours',$hours);
$minutes=range(0,59);
$smarty->assign('minutes',$minutes);
$duration_hours = $info['duration']/(60*60);
$duration_minutes = $info['duration']%(60*60);
$smarty->assign('duration_hours',$duration_hours);
$smarty->assign('duration_minutes',$duration_minutes);
include_once('tiki-mytiki_shared.php');
......
......@@ -15,12 +15,13 @@ if(!$user) {
}
//if($tiki_p_usermenu != 'y') {
//if($tiki_p_minical != 'y') {
// $smarty->assign('msg',tra("Permission denied to use this feature"));
// $smarty->display("styles/$style_base/error.tpl");
// die;
//}
if(isset($_REQUEST['save'])) {
$tikilib->set_user_preference($user,'minical_interval',$_REQUEST['minical_interval']);
$tikilib->set_user_preference($user,'minical_start_hour',$_REQUEST['minical_start_hour']);
......@@ -54,6 +55,35 @@ $smarty->assign('minical_end_hour',$minical_end_hour);
$hours=range(0,23);
$smarty->assign('hours',$hours);
if(isset($_REQUEST['removetopic'])) {
$minicallib->minical_remove_topic($user,$_REQUEST['removetopic']);
}
// Process upload here
if(isset($_REQUEST['addtopic'])) {
if(isset($_FILES['userfile1'])&&is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
$fp = fopen($_FILES['userfile1']['tmp_name'],"rb");
$data = '';
while(!feof($fp)) {
$data .= fread($fp,8192*16);
}
fclose($fp);
$size = $_FILES['userfile1']['size'];
$name = $_FILES['userfile1']['name'];
$type = $_FILES['userfile1']['type'];
} else {
$size=0;
$name='';
$type='';
$data='';
}
$minicallib->minical_upload_topic($user,$_REQUEST['name'],$name,$type,$size, $data,$_REQUEST['path']);
}
$topics = $minicallib->minical_list_topics($user,0,-1,'name_asc','');
$smarty->assign('topics',$topics['data']);
$smarty->assign('cols',4);
include_once('tiki-mytiki_shared.php');
$smarty->assign('mid','tiki-minical_prefs.tpl');
......
......@@ -873,7 +873,6 @@ include_once("tiki-modules.php");
$smarty->assign('beingEdited','n');
if($feature_warn_on_edit == 'y') {
// Check if the page is being edited
if(isset($_REQUEST["page"])) {
......@@ -885,9 +884,9 @@ if($feature_warn_on_edit == 'y') {
//print($GLOBALS["HTTP_REFERER"]);
// IF isset the referer and if the referer is editpage then unset taking the pagename from the
// query or homepage if not query
if(isset($GLOBALS["HTTP_REFERER"])) {
if(strstr($GLOBALS["HTTP_REFERER"],'tiki-editpage')) {
$purl = parse_url($GLOBALS["HTTP_REFERER"]);
if(isset($HTTP_SERVER_VARS["HTTP_REFERER"])) {
if(strstr($HTTP_SERVER_VARS["HTTP_REFERER"],'tiki-editpage')) {
$purl = parse_url($HTTP_SERVER_VARS["HTTP_REFERER"]);
if(!isset($purl["query"])) {
$purl["query"]='';
}
......@@ -909,7 +908,6 @@ if($feature_warn_on_edit == 'y') {
if(!isset($purlquery["page"])) {
$purlquery["page"]='HomePage';
}
$_SESSION["edit_lock"]=$tikilib->semaphore_set($purlquery["page"]);
}
......@@ -966,8 +964,8 @@ $smarty->assign('allowMsgs',$allowMsgs);
if($feature_referer_stats != 'y') {
// Referer tracking
if(isset($GLOBALS["HTTP_REFERER"])) {
$pref = parse_url($GLOBALS["HTTP_REFERER"]);
if(isset($HTTP_SERVER_VARS["HTTP_REFERER"])) {
$pref = parse_url($HTTP_SERVER_VARS["HTTP_REFERER"]);
if(!strstr($_SERVER["SERVER_NAME"],$pref["host"])) {
$tikilib->register_referer($pref["host"]);
}
......
<?php
// Initialization
require_once('tiki-setup.php');
include_once('lib/minical/minicallib.php');
if(!$user) die;
if(!isset($_REQUEST["topicId"])) {
die;
}
$info = $minicallib->minical_get_topic($user,$_REQUEST["topicId"]);
$type=&$info["filetype"];
$file=&$info["filename"];
$content=&$info["data"];
header("Content-type: $type");
header( "Content-Disposition: inline; filename=$file" );
echo "$content";
?>
\ No newline at end of file
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