Commit 62e7dc91 authored by lrargerich's avatar lrargerich

New feature: MyTiki-User Menus

parent a4352a39
......@@ -1073,6 +1073,7 @@ tiki/lib/mailin/mailinlib.php -text
tiki/lib/md5.js -text
tiki/lib/menubuilder/menulib.php -text
tiki/lib/messu/messulib.php -text
tiki/lib/minical/minicallib.php -text
tiki/lib/newsletters/nllib.php -text
tiki/lib/newsreader/newslib.php -text
tiki/lib/notepad/notepadlib.php -text
......@@ -1103,6 +1104,7 @@ tiki/lib/tiki-js.js -text
tiki/lib/tikilib.php -text
tiki/lib/trackers/trackerlib.php -text
tiki/lib/userfiles/userfileslib.php -text
tiki/lib/usermenu/usermenulib.php -text
tiki/lib/usermodules/usermoduleslib.php -text
tiki/lib/userprefs/userprefslib.php -text
tiki/lib/userslib.php -text
......@@ -1492,6 +1494,7 @@ tiki/templates/tiki-list_surveys.tpl -text
tiki/templates/tiki-list_trackers.tpl -text
tiki/templates/tiki-listpages.tpl -text
tiki/templates/tiki-login.tpl -text
tiki/templates/tiki-minical.php -text
tiki/templates/tiki-my_tiki.tpl -text
tiki/templates/tiki-mytiki_bar.tpl -text
tiki/templates/tiki-newsletters.tpl -text
......@@ -1560,6 +1563,7 @@ tiki/templates/tiki-user_menu.tpl -text
tiki/templates/tiki-user_preferences.tpl -text
tiki/templates/tiki-user_tasks.tpl -text
tiki/templates/tiki-userfiles.tpl -text
tiki/templates/tiki-usermenu.tpl -text
tiki/templates/tiki-userversions.tpl -text
tiki/templates/tiki-view_articles.tpl -text
tiki/templates/tiki-view_banner.tpl -text
......@@ -1746,6 +1750,7 @@ tiki/tiki-login_scr.php -text
tiki/tiki-login_validate.php -text
tiki/tiki-logout.php -text
tiki/tiki-mailin.php -text
tiki/tiki-minical.php -text
tiki/tiki-modules.php -text
tiki/tiki-my_tiki.php -text
tiki/tiki-mytiki_shared.php -text
......@@ -1820,6 +1825,7 @@ tiki/tiki-user_information.php -text
tiki/tiki-user_preferences.php -text
tiki/tiki-user_tasks.php -text
tiki/tiki-userfiles.php -text
tiki/tiki-usermenu.php -text
tiki/tiki-userversions.php -text
tiki/tiki-view_articles.php -text
tiki/tiki-view_banner.php -text
......
Version 1.6 -Tau Ceti-
* [NEW] User menus, the user can add items to the application menu, an option to
automatically add top-level bookmarks to the menu is provided.
* [NEW] Theme control center: if activated you can control the theme
by section, by category or by specific object.
* [NEW] Ephemerides feature: admin can set up images/texts for specific
......
## THIS FILE IS JUST A HELP FOR DEVELOPERS IT SHOULDNT BE USED IN A 1.5 DISTRIBUTION
INSERT INTO users_permissions(permName,type,permDesc,level) VALUES ('tiki_p_usermenu','user','Can create items in personal menu','registered');
INSERT INTO users_permissions(permName,type,permDesc,level) VALUES ('tiki_p_minical','user','Can use the mini event calendar','registered');
drop table if exists tiki_user_menus;
create table tiki_user_menus(
user varchar(200) not null,
menuId integer(12) not null auto_increment,
url varchar(250),
name varchar(40),
position integer(4),
mode char(1),
primary key(menuId)
);
drop table if exists tiki_theme_control_sections;
create table tiki_theme_control_sections(
section varchar(250) not null,
......
......@@ -82,7 +82,4 @@ class NotepadLib extends TikiLib {
}
$notepadlib= new NotepadLib($dbTiki);
?>
?>
\ No newline at end of file
<?php
class UserMenuLib extends TikiLib {
function UserMenuLib($db)
{
# this is probably uneeded now
if(!$db) {
die("Invalid db object passed to UserMenuLib constructor");
}
$this->db = $db;
}
function add_bk($user)
{
$query = "select tubu.name,url from tiki_user_bookmarks_urls tubu, tiki_user_bookmarks_folders tubf where tubu.folderId=tubf.folderId and tubf.parentId=0 and tubu.user='$user'";
$result = $this->query($query);
$start = $this->get_max_position($user)+1;
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
// Check for duplicate URL
if(!$this->getOne("select count(*) from tiki_user_menus where url='".$res['url']."'")) {
$this->replace_usermenu($user,0,$res['name'],$res['url'],$start,'w');
$start++;
} else {
}
}
$query = "select tubu.name,url from tiki_user_bookmarks_urls tubu where tubu.folderId=0 and tubu.user='$user'";
$result = $this->query($query);
$start = $this->get_max_position($user)+1;
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
// Check for duplicate URL
if(!$this->getOne("select count(*) from tiki_user_menus where url='".$res['url']."'")) {
$this->replace_usermenu($user,0,$res['name'],$res['url'],$start,'w');
$start++;
} else {
}
}
}
function list_usermenus($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."%')";
} else {
$mid=" ";
}
$query = "select * from tiki_user_menus where
user='$user' $mid order by $sort_mode limit $offset,$maxRecords";
$query_cant = "select count(*) from tiki_user_menus 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 get_usermenu($user,$menuId)
{
$query = "select * from tiki_user_menus where
user='$user' and menuId='$menuId'";
$result = $this->query($query);
$res = $result->fetchRow(DB_FETCHMODE_ASSOC);
return $res;
}
function get_max_position($user)
{
return $this->getOne("select max(position) from tiki_user_menus where user='$user'");
}
function replace_usermenu($user,$menuId,$name,$url,$position,$mode)
{
$name = addslashes($name);
$url = addslashes($url);
$now = date("U");
if($menuId) {
$query = "update tiki_user_menus set
name='$name', position=$position, url='$url', mode='$mode'
where user='$user' and
menuId=$menuId";
$this->query($query);
return $menuId;
} else {
$query = "insert into tiki_user_menus(user,name,url,position,mode)
values('$user','$name','$url',$position,'$mode')";
$this->query($query);
$Id = $this->getOne("select max(menuId) from
tiki_user_menus where user='$user' and url='$url' and name='$name'");
return $Id;
}
}
function remove_usermenu($user,$menuId)
{
$query = "delete from tiki_user_menus where user='$user'
and menuId=$menuId";
$this->query($query);
}
}
$usermenulib= new UserMenuLib($dbTiki);
?>
\ No newline at end of file
......@@ -59,6 +59,9 @@
{if $feature_userfiles eq 'y' and $tiki_p_userfiles eq 'y'}
&nbsp;<a href="tiki-userfiles.php" class="linkmenu">{tr}My files{/tr}</a><br/>
{/if}
{if $feature_usermenu eq 'y'}
&nbsp;<a href="tiki-usermenu.php" class="linkmenu">{tr}User menu{/tr}</a><br/>
{/if}
</div>
{/if}
......@@ -381,6 +384,17 @@
&nbsp;<a href="tiki-phpinfo.php" class="linkmenu">{tr}phpinfo{/tr}</a><br/>
</div>
{/if}
{if $feature_usermenu eq 'y'}
<div class="separator"><a class='separator' href="javascript:setCookie('usrmenu','c');hide('usrmenu');">[-]</a>
<a href="tiki-usermenu.php" class="separator">{tr}User Menu{/tr}</a>
<a class='separator' href="javascript:setCookie('usrmenu','o');show('usrmenu');">[+]</a></div>
<div id='usrmenu' style="{$mnu_usrmenu}">
{section name=ix loop=$usr_user_menus}
&nbsp;<a {if $usr_user_menus[ix].mode eq 'n'}target='_new'{/if} href="{$usr_user_menus[ix].url}" class="linkmenu">{$usr_user_menus[ix].name}</a><br/>
{/section}
</div>
{/if}
</div>
</div>
......@@ -72,6 +72,8 @@
<tr><td class="form">{tr}Contact{/tr}:</td><td><input type="checkbox" name="feature_contact" {if $feature_contact eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}User Notepad{/tr}:</td><td><input type="checkbox" name="feature_notepad" {if $feature_notepad eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}User files{/tr}:</td><td><input type="checkbox" name="feature_userfiles" {if $feature_userfiles eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}User menu{/tr}:</td><td><input type="checkbox" name="feature_usermenu" {if $feature_usermenu eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}Mini calendar{/tr}:</td><td><input type="checkbox" name="feature_minical" {if $feature_minical eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}Ephemerides{/tr}:</td><td><input type="checkbox" name="feature_eph" {if $feature_eph eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td class="form">{tr}Theme control{/tr}:</td><td><input type="checkbox" name="feature_theme_control" {if $feature_theme_control eq 'y'}checked="checked"{/if}/></td></tr>
<tr><td align="center" class="form" colspan="2"><input type="submit" name="features" value="{tr}Set features{/tr}" /></td></tr>
......
{*Smarty template*}
<a class="pagetitle" href="tiki-usermenu.php">{tr}User Menu{/tr}</a><br/><br/>
{include file=tiki-mytiki_bar.tpl}
<br/>
{if $feature_user_bookmarks eq 'y' and $tiki_p_create_bookmarks eq 'y'}
<a title="({tr}May need to refresh twice to see changes{/tr})" class="link" href="tiki-usermenu.php?addbk=1">{tr}Add top level bookmarks to menu{/tr}</a>
{/if}
<br/><br/>
<table class="findtable">
<tr><td class="findtable">{tr}Find{/tr}</td>
<td class="findtable">
<form method="get" action="tiki-usermenu.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}" />
</form>
</td>
</tr>
</table>
<form action="tiki-usermenu.php" method="post">
<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-usermenu.php?tasks_useDates={$tasks_useDates}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'position_desc'}position_asc{else}position_desc{/if}">{tr}Pos{/tr}</a></td>
<td class="heading" ><a class="tableheading" href="tiki-usermenu.php?tasks_useDates={$tasks_useDates}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'name_desc'}name_asc{else}name_desc{/if}">{tr}Name{/tr}</a></td>
<td class="heading" ><a class="tableheading" href="tiki-usermenu.php?tasks_useDates={$tasks_useDates}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'url_desc'}url_asc{else}url_desc{/if}">{tr}URL{/tr}</a></td>
<td class="heading" ><a class="tableheading" href="tiki-usermenu.php?tasks_useDates={$tasks_useDates}&amp;offset={$offset}&amp;sort_mode={if $sort_mode eq 'mode_desc'}mode_asc{else}mode_desc{/if}">{tr}Mode{/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="menu[{$channels[user].menuId}]" />
</td>
<td class="{cycle advance=false}">{$channels[user].position}</td>
<td class="{cycle advance=false}"><a class="link" href="tiki-usermenu.php?menuId={$channels[user].menuId}&amp;offset={$offset}&amp;sort_mode={$sort_mode}&amp;find={$find}">{$channels[user].name}</a></td>
<td class="{cycle advance=false}">{$channels[user].url|truncate:40:"...":true}</td>
<td class="{cycle advance=false}">{$channels[user].mode}</td>
</tr>
{/section}
</table>
</form>
<div class="mini">
<div align="center">
{if $prev_offset >= 0}
[<a class="prevnext" href="tiki-usermenu.php?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-usermenu.php?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-usermenu.php?find={$find}&amp;offset={$selector_offset}&amp;sort_mode={$sort_mode}">
{$smarty.section.foo.index_next}</a>&nbsp;
{/section}
{/if}
</div>
</div>
<h3>{tr}Add or edit an item{/tr}</h3>
<form action="tiki-usermenu.php" method="post">
<input type="hidden" name="menuId" value="{$menuId}" />
<table class="normal">
<tr><td class="formcolor">{tr}Name{/tr}</td>
<td class="formcolor"><input type="text" name="name" value="{$info.name}" /></td>
</tr>
<tr><td class="formcolor">{tr}URL{/tr}</td>
<td class="formcolor"><input type="text" name="url" value="{$info.url}" /></td> </tr>
<tr><td class="formcolor">{tr}Position{/tr}</td>
<td class="formcolor"><input type="text" name="position" value="{$info.position}" /></td>
</tr>
<tr><td class="formcolor">{tr}Mode{/tr}</td>
<td class="formcolor">
<select name="mode">
<option value="n" {if $info.status eq 'n'}selected="selected"{/if}>{tr}new window{/tr}</option>
<option value="w" {if $info.status eq 'w'}selected="selected"{/if}>{tr}replace window{/tr}</option>
</select>
</td>
</tr>
<tr>
<td class="formcolor">&nbsp;</td>
<td class="formcolor"><input type="submit" name="save" value="{tr}save{/tr}" /></td>
</tr>
</table>
</form>
......@@ -3,6 +3,7 @@
require_once('tiki-setup.php');
include_once('lib/wiki/exportlib.php');
include_once('lib/admin/adminlib.php');
include_once('lib/imagegals/imagegallib.php');
include_once ("lib/webmail/htmlMimeMail.php");
include_once ("lib/ziplib.php");
......@@ -1105,6 +1106,24 @@ if(isset($_REQUEST["features"])) {
$smarty->assign("feature_userfiles",'n');
}
if(isset($_REQUEST["feature_usermenu"]) && $_REQUEST["feature_usermenu"]=="on") {
$tikilib->set_preference("feature_usermenu",'y');
$smarty->assign("feature_usermenu",'y');
} else {
$tikilib->set_preference("feature_usermenu",'n');
$smarty->assign("feature_usermenu",'n');
}
if(isset($_REQUEST["feature_minical"]) && $_REQUEST["feature_minical"]=="on") {
$tikilib->set_preference("feature_minical",'y');
$smarty->assign("feature_minical",'y');
} else {
$tikilib->set_preference("feature_minical",'n');
$smarty->assign("feature_minical",'n');
}
if(isset($_REQUEST["feature_theme_control"]) && $_REQUEST["feature_theme_control"]=="on") {
$tikilib->set_preference("feature_theme_control",'y');
$smarty->assign("feature_theme_control",'y');
......@@ -1525,11 +1544,11 @@ if($home_blog) {
$smarty->assign('home_blog_name',substr($hbloginfo["title"],0,20));
}
if($home_gallery) {
$hgalinfo = $tikilib->get_gallery($home_gallery);
$hgalinfo = $imagegallib->get_gallery($home_gallery);
$smarty->assign('home_gal_name',substr($hgalinfo["name"],0,20));
}
if($home_file_gallery) {
$hgalinfo = $tikilib->get_gallery($home_file_gallery);
$hgalinfo = $imagegallib->get_gallery($home_file_gallery);
$smarty->assign('home_fil_name',substr($hgalinfo["name"],0,20));
}
$anonCanEdit = $tikilib->get_preference("anonCanEdit",'n');
......
......@@ -327,6 +327,11 @@ $smarty->assign('feature_trackers',$feature_trackers);
$feature_directory = 'n';
$smarty->assign('feature_directory',$feature_directory);
$feature_usermenu = 'n';
$smarty->assign('feature_usermenu',$feature_usermenu);
$feature_minical = 'n';
$smarty->assign('feature_minical',$feature_minical);
$feature_notepad = 'n';
$smarty->assign('feature_notepad',$feature_notepad);
$feature_userfiles = 'n';
......@@ -767,6 +772,13 @@ if(isset($_COOKIE["mymenu"])) {
}
}
$smarty->assign('mnu_usrmenu','display:none;');
if(isset($_COOKIE["usrmenu"])) {
if($_COOKIE["usrmenu"]=='o') {
$smarty->assign('mnu_usrmenu','display:block;');
}
}
$smarty->assign('mnu_wikimenu','display:none;');
if(isset($_COOKIE["wikimenu"])) {
......@@ -839,9 +851,18 @@ if(isset($_COOKIE["filegalmenu"])) {
if($user && $feature_usermenu == 'y') {
$smarty->assign('foo_usr','hsah');
if(!isset($_SESSION['usermenu'])) {
include_once('lib/usermenu/usermenulib.php');
$user_menus = $usermenulib->list_usermenus($user,0,-1,'position_asc','');
$smarty->assign('usr_user_menus',$user_menus['data']);
$_SESSION['usermenu']=$user_menus['data'];
} else {
$user_menus = $_SESSION['usermenu'];
$smarty->assign('usr_user_menus',$user_menus);
}
}
include_once("tiki-modules.php");
......@@ -958,6 +979,8 @@ if($feature_stats == 'y') {
}
}
if($feature_obzip == 'y') {
ob_start("ob_gzhandler");
}
......
<?php
require_once('tiki-setup.php');
include_once('lib/usermenu/usermenulib.php');
if($feature_usermenu != 'y') {
$smarty->assign('msg',tra("This feature is disabled"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if(!$user) {
$smarty->assign('msg',tra("Must be logged to use this feature"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if($tiki_p_usermenu != 'y') {
$smarty->assign('msg',tra("Permission denied to use this feature"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if(!isset($_REQUEST["menuId"])) $_REQUEST["menuId"]=0;
if(isset($_REQUEST["delete"])) {
foreach(array_keys($_REQUEST["menu"]) as $men) {
$usermenulib->remove_usermenu($user, $men);
}
}
if(isset($_REQUEST['addbk'])) {
$usermenulib->add_bk($user);
unset($_SESSION['usermenu']);
}
if($_REQUEST["menuId"]) {
$info = $usermenulib->get_usermenu($user,$_REQUEST["menuId"]);
} else {
$info=Array();
$info['name']='';
$info['url']='';
$info['position']=$usermenulib->get_max_position($user)+1;
}
if(isset($_REQUEST['save'])) {
$usermenulib->replace_usermenu($user,$_REQUEST["menuId"],$_REQUEST["name"],$_REQUEST["url"],$_REQUEST['position'],$_REQUEST['mode']);
$info=Array();
$info['name']='';
$info['url']='';
$info['position']=1;
$_REQUEST["menuId"]=0;
unset($_SESSION['usermenu']);
}
$smarty->assign('menuId',$_REQUEST["menuId"]);
$smarty->assign('info',$info);
if(!isset($_REQUEST["sort_mode"])) {
$sort_mode = 'position_asc';
} 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 = $usermenulib->list_usermenus($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"]);
include_once('tiki-mytiki_shared.php');
$smarty->assign('mid','tiki-usermenu.tpl');
$smarty->display("styles/$style_base/tiki.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