Merge branch 'master' of gitorious.org:owncloud/owncloud

This commit is contained in:
Michiel de Jong 2012-02-25 21:58:59 +00:00
commit a1d03de666
75 changed files with 887 additions and 294 deletions

View File

@ -794,7 +794,7 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common
? 'mysql_query' : 'mysql_unbuffered_query';
$result = @$function($query, $connection);
if (!$result) {
$err =& $this->raiseError(null, null, null,
$err =$this->raiseError(null, null, null,
'Could not execute statement', __FUNCTION__);
return $err;
}

View File

@ -27,14 +27,7 @@ require_once('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
require_once('bookmarksHelper.php');
addBookmark($_GET['url'], '', 'Read-Later');
OC_Util::addScript('bookmarks','addBm');
OC_Util::addStyle('bookmarks', 'bookmarks');
$tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
$tmpl->assign('URL', htmlentities($url,ENT_COMPAT,'utf-8'));
$tmpl->printPage();
include 'templates/addBm.php';

View File

@ -30,53 +30,6 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_ut = "strftime('%s','now')";
} elseif($CONFIG_DBTYPE == 'pgsql') {
$_ut = 'date_part(\'epoch\',now())::integer';
} else {
$_ut = "UNIX_TIMESTAMP()";
}
//FIXME: Detect when user adds a known URL
$query = OC_DB::prepare("
INSERT INTO *PREFIX*bookmarks
(url, title, user_id, public, added, lastmodified)
VALUES (?, ?, ?, 0, $_ut, $_ut)
");
if(empty($_GET["title"])) {
require_once('../bookmarksHelper.php');
$metadata = getURLMetadata($_GET["url"]);
$_GET["title"] = $metadata['title'];
}
$params=array(
htmlspecialchars_decode($_GET["url"]),
htmlspecialchars_decode($_GET["title"]),
OC_User::getUser()
);
$query->execute($params);
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
$query = OC_DB::prepare("
INSERT INTO *PREFIX*bookmarks_tags
(bookmark_id, tag)
VALUES (?, ?)
");
$tags = explode(' ', urldecode($_GET["tags"]));
foreach ($tags as $tag) {
if(empty($tag)) {
//avoid saving blankspaces
continue;
}
$params = array($b_id, trim($tag));
$query->execute($params);
}
OC_JSON::success(array('data' => $b_id));
}
require_once('../bookmarksHelper.php');
$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']);
OC_JSON::success(array('data' => $id));

View File

@ -70,3 +70,55 @@ function getURLMetadata($url) {
return $metadata;
}
function addBookmark($url, $title='', $tags='') {
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_ut = "strftime('%s','now')";
} elseif($CONFIG_DBTYPE == 'pgsql') {
$_ut = 'date_part(\'epoch\',now())::integer';
} else {
$_ut = "UNIX_TIMESTAMP()";
}
//FIXME: Detect when user adds a known URL
$query = OC_DB::prepare("
INSERT INTO *PREFIX*bookmarks
(url, title, user_id, public, added, lastmodified)
VALUES (?, ?, ?, 0, $_ut, $_ut)
");
if(empty($title)) {
$metadata = getURLMetadata($url);
$title = $metadata['title'];
}
$params=array(
htmlspecialchars_decode($url),
htmlspecialchars_decode($title),
OC_User::getUser()
);
$query->execute($params);
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
$query = OC_DB::prepare("
INSERT INTO *PREFIX*bookmarks_tags
(bookmark_id, tag)
VALUES (?, ?)
");
$tags = explode(' ', urldecode($tags));
foreach ($tags as $tag) {
if(empty($tag)) {
//avoid saving blankspaces
continue;
}
$params = array($b_id, trim($tag));
$query->execute($params);
}
return $b_id;
}
}

View File

@ -1,7 +1,8 @@
#content { overflow: auto; height: 100%; }
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; }
#firstrun #selections { font-size:0.8em; width: 100%; margin: 2em auto auto auto; clear: both; }
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
#firstrun .button { font-size: 0.7em; }
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }
.bookmarks_headline {
font-size: large;
@ -15,11 +16,6 @@
padding: 0.5ex;
}
.bookmarks_add {
display: none;
margin-top: 45px;
}
.bookmarks_list {
margin-top: 36px;
}
@ -35,7 +31,7 @@
}
.bookmarks_input {
width: 20em;
width: 8em;
}
.bookmark_actions {
@ -87,16 +83,3 @@
display: none;
margin-left: 5px;
}
#footer {
color: #999;
font-size: medium;
text-align: center;
position: absolute;
bottom: 10px;
left: 0px;
width: 100%;
height: 20px;
visibility: visible;
display: block
}

View File

@ -3,17 +3,12 @@ var bookmarks_loading = false;
var bookmarks_sorting = 'bookmarks_sorting_recent';
$(document).ready(function() {
$('.bookmarks_addBtn').click(function(event){
$('.bookmarks_add').slideToggle();
});
$(document).ready(function() {
$('#bookmark_add_submit').click(addOrEditBookmark);
$(window).scroll(updateOnBottom);
$('.bookmarks_list').empty();
getBookmarks();
});
function getBookmarks() {
@ -35,6 +30,9 @@ function getBookmarks() {
updateBookmarksList(bookmarks.data[i]);
$("#firstrun").hide();
}
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
$('.bookmark_link').click(recordClick);
$('.bookmark_delete').click(delBookmark);
@ -54,22 +52,14 @@ function addOrEditBookmark(event) {
var url = encodeEntities($('#bookmark_add_url').val());
var title = encodeEntities($('#bookmark_add_title').val());
var tags = encodeEntities($('#bookmark_add_tags').val());
var taglist = tags.split(' ');
var tagshtml = '';
$("#firstrun").hide();
for ( var i=0, len=taglist.length; i<len; ++i ){
tagshtml += '<a class="bookmark_tag" href="?tag=' + encodeURI(taglist[i]) + '">' + taglist[i] + '</a> ';
}
if (id == 0) {
$.ajax({
url: 'ajax/addBookmark.php',
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
success: function(response){
var bookmark_id = response.data;
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_input').val('');
$('.bookmarks_list').empty();
bookmarks_page = 0;
getBookmarks();
@ -81,8 +71,7 @@ function addOrEditBookmark(event) {
url: 'ajax/editBookmark.php',
data: 'id=' + id + '&url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
success: function(){
$('.bookmarks_add').slideToggle();
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
$('.bookmarks_input').val('');
$('#bookmark_add_id').val('0');
$('.bookmarks_list').empty();
bookmarks_page = 0;
@ -98,7 +87,12 @@ function delBookmark(event) {
$.ajax({
url: 'ajax/delBookmark.php',
data: 'url=' + encodeURI($(this).parent().parent().children('.bookmark_url:first').text()),
success: function(data){ record.animate({ opacity: 'hide' }, 'fast'); }
success: function(data){
record.remove();
if($('.bookmarks_list').is(':empty')) {
$("#firstrun").show();
}
}
});
}
@ -132,12 +126,12 @@ function updateBookmarksList(bookmark) {
$('.bookmarks_list').append(
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
'<p class="bookmark_actions">' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'<span class="bookmark_edit">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
'</span>' +
'<span class="bookmark_delete">' +
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
'</span>&nbsp;' +
'</p>' +
'<p class="bookmark_title">'+
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +

View File

@ -1,6 +1,11 @@
<div class="bookmarks_addBm">
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<?php echo $_['URL']; ?>"/></p>
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Read later - ownCloud</title>
<link rel="stylesheet" href="css/readlater.css">
</head>
<body>
<div class="message"><h1>Saved!</h1></div>
</body>
</html>

View File

@ -0,0 +1,8 @@
<?php
function createBookmarklet() {
$l = new OC_L10N('bookmarks');
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>'
. '<a class="button" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
. $l->t('Read later') . '</a>';
}

View File

@ -9,23 +9,18 @@
?>
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />
<div id="controls">
<input type="button" class="bookmarks_addBtn" value="<?php echo $l->t('Add bookmark'); ?>"/>
</div>
<div class="bookmarks_add">
<input type="hidden" id="bookmark_add_id" value="0" />
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" />
<img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p>
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />
</div>
<div class="bookmarks_list">
</div>
<div id="firstrun">
<?php echo $l->t('You have no bookmarks'); ?>
<small><?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?></small>
<div id="selections">
<a class="button" href='javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open("<?php echo OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') ?>?output=popup&url="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=510px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)})();'><?php echo $l->t('Add page to ownCloud'); ?></a>
</div>
<div id="firstrun" style="display: none;">
<?php
echo $l->t('You have no bookmarks');
require_once('bookmarklet.php');
createBookmarklet();
?>
</div>

View File

@ -8,7 +8,10 @@
?>
<form id="bookmarks">
<fieldset class="personalblock">
<span class="bold"><?php echo $l->t('Bookmarklet:');?></span>&nbsp;<a class="bookmarks_addBml" href='javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open("<?php echo OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') ?>?output=popup&url="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=510px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)})();'><?php echo $l->t('Add page to ownCloud'); ?></a>
<br/><em><?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?></em><br />
<span class="bold"><?php echo $l->t('Bookmarklet <br />');?></span>
<?php
require_once('bookmarklet.php');
createBookmarklet();
?>
</fieldset>
</form>

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once ("../../../lib/base.php");
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

View File

@ -0,0 +1,20 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
$tmpl->assign('calendar', $calendar);
$tmpl->printPage();
?>

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
@ -25,16 +25,8 @@ foreach($calendars as $cal){
}
$calendarid = $_POST['id'];
$calendarcolor = $_POST['color'];
if (preg_match('/^#?([0-9a-f]{6})/', $calendarcolor, $matches)) {
$calendarcolor = '#'.$matches[1];
}
else {
$calendarcolor = null;
}
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $calendarcolor);
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$calendar = OC_Calendar_App::getCalendar($calendarid);

View File

@ -9,7 +9,16 @@
require_once ("../../../lib/base.php");
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$currentview = $_GET["v"];
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
$view = $_GET['v'];
switch($view){
case 'agendaWeek':
case 'month';
case 'list':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter: ' . $view));
exit;
}
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view);
OC_JSON::success();
?>

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
@ -243,16 +243,6 @@ if($repeat['repeat'] != 'doesnotrepeat'){
$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
}
else {
$tmpl->assign('repeat_month', 'monthday');
$tmpl->assign('repeat_weekdays', array());
$tmpl->assign('repeat_interval', 1);
$tmpl->assign('repeat_end', 'never');
$tmpl->assign('repeat_count', '10');
$tmpl->assign('repeat_weekofmonth', 'auto');
$tmpl->assign('repeat_date', '');
$tmpl->assign('repeat_year', 'bydate');
}
$tmpl->printpage();
?>
?>

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$id = $_POST['id'];

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
$l10n = new OC_L10N('calendar');

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$id = $_POST['id'];

View File

@ -7,7 +7,7 @@
*/
require_once ('../../../lib/base.php');
require_once('../../../3rdparty/when/When.php');
require_once('when/When.php');
function create_return_event($event, $vevent){
$return_event = array();

View File

@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$l10n = new OC_L10N('calendar');

View File

@ -0,0 +1,120 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
//check for calendar rights or create new one
ob_start();
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$nl = "\n";
$progressfile = OC::$SERVERROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '10');
fclose($progressfopen);
}
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
if($_POST['method'] == 'new'){
$id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']);
OC_Calendar_Calendar::setCalendarActive($id, 1);
}else{
$calendar = OC_Calendar_App::getCalendar($_POST['id']);
if($calendar['userid'] != OC_USER::getUser()){
OC_JSON::error();
exit();
}
$id = $_POST['id'];
}
//analyse the calendar file
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '20');
fclose($progressfopen);
}
$searchfor = array('VEVENT', 'VTODO', 'VJOURNAL');
$parts = $searchfor;
$filearr = explode($nl, $file);
$inelement = false;
$parts = array();
$i = 0;
foreach($filearr as $line){
foreach($searchfor as $search){
if(substr_count($line, $search) == 1){
list($attr, $val) = explode(':', $line);
if($attr == 'BEGIN'){
$parts[]['begin'] = $i;
$inelement = true;
}
if($attr == 'END'){
$parts[count($parts) - 1]['end'] = $i;
$inelement = false;
}
}
}
$i++;
}
//import the calendar
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '40');
fclose($progressfopen);
}
$start = '';
for ($i = 0; $i < $parts[0]['begin']; $i++) {
if($i == 0){
$start = $filearr[0];
}else{
$start .= $nl . $filearr[$i];
}
}
$end = '';
for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){
if($i == $parts[count($parts) - 1]['end'] + 1){
$end = $filearr[$parts[count($parts) - 1]['end'] + 1];
}else{
$end .= $nl . $filearr[$i];
}
}
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '50');
fclose($progressfopen);
}
$importready = array();
foreach($parts as $part){
for($i = $part['begin']; $i <= $part['end'];$i++){
if($i == $part['begin']){
$content = $filearr[$i];
}else{
$content .= $nl . $filearr[$i];
}
}
$importready[] = $start . $nl . $content . $nl . $end;
}
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '70');
fclose($progressfopen);
}
if(count($parts) == 1){
OC_Calendar_Object::add($id, $file);
}else{
foreach($importready as $import){
OC_Calendar_Object::add($id, $import);
}
}
//done the import
if(is_writable('import_tmp/')){
$progressfopen = fopen($progressfile, 'w');
fwrite($progressfopen, '100');
fclose($progressfopen);
}
sleep(3);
if(is_writable('import_tmp/')){
unlink($progressfile);
}
OC_JSON::success();

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once ("../../../lib/base.php");
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection')));

View File

@ -18,7 +18,7 @@ function make_array_out_of_xml ($xml){
}
return $returnarray;
}
require_once ("../../../lib/base.php");
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$l = new OC_L10N('calendar');

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
if(isset($_POST["timeformat"])){
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);

View File

@ -7,7 +7,7 @@
*/
// Init owncloud
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
$l=new OC_L10N('calendar');

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
OC_JSON::encodedPrint(array("timeformat" => $timeformat));

View File

@ -5,7 +5,7 @@
* later.
* See the COPYING-README file.
*/
require_once ("../../../lib/base.php");
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
if($_POST['timezonedetection'] == 'on'){

View File

@ -0,0 +1,40 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
$permission = (int) strip_tags($_GET['permission']);
switch($idtype){
case 'calendar':
case 'event':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch($sharetype){
case 'user':
case 'group':
case 'public':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
OC_JSON::error(array('message'=>'user not found'));
exit;
}
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
OC_JSON::error(array('message'=>'group not found'));
exit;
}
$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
OC_JSON::success();

View File

@ -0,0 +1,18 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
$user = OC_USER::getUser();
$calid = $_GET['calid'];
$calendar = OC_Calendar_Calendar::find($calid);
if($calendar['userid'] != $user){
OC_JSON::error();
exit;
}
$tmpl = new OC_Template('calendar', 'share.dropdown');
$tmpl->assign('calid', $calid);
$tmpl->printPage();

View File

@ -0,0 +1,51 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
switch($idtype){
case 'calendar':
case 'event':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch($sharetype){
case 'user':
case 'group':
case 'public':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
OC_JSON::error(array('message'=>'user not found'));
exit;
}
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
OC_JSON::error(array('message'=>'group not found'));
exit;
}
if($sharetype == 'user' && OC_User::getUser() == $sharewith){
OC_JSON::error(array('meesage'=>'you can not share with yourself'));
}
$success = OC_Calendar_Share::share(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
if($success){
if($sharetype == 'public'){
OC_JSON::success(array('message'=>$success));
}else{
OC_JSON::success(array('message'=>'shared'));
}
}else{
OC_JSON::error(array('message'=>'can not share'));
exit;
}

View File

@ -0,0 +1,44 @@
<?php
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
switch($idtype){
case 'calendar':
case 'event':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch($sharetype){
case 'user':
case 'group':
case 'public':
break;
default:
OC_JSON::error(array('message'=>'unexspected parameter'));
exit;
}
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
OC_JSON::error(array('message'=>'user not found'));
exit;
}
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
OC_JSON::error(array('message'=>'group not found'));
exit;
}
$success = OC_Calendar_Share::unshare(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
if($success){
OC_JSON::success();
}else{
OC_JSON::error(array('message'=>'can not unshare'));
exit;
}

View File

@ -69,7 +69,7 @@ Calendar={
$('#event').dialog('destroy').remove();
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'new.form.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
}
},
editEvent:function(calEvent, jsEvent, view){
@ -79,7 +79,7 @@ Calendar={
$('#event').dialog('destroy').remove();
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.php') + '?id=' + id, Calendar.UI.startEventDialog);
}
},
submitDeleteEventForm:function(url){
@ -141,7 +141,7 @@ Calendar={
moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
$('.tipsy').remove();
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
$.post(OC.filePath('calendar', 'ajax/event', 'move.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
@ -156,7 +156,7 @@ Calendar={
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
$('.tipsy').remove();
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
$.post(OC.filePath('calendar', 'ajax/event', 'resize.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
@ -373,7 +373,7 @@ Calendar={
$('#choosecalendar_dialog').dialog('moveToTop');
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/calendar', 'overview.php'), function(){
$('#choosecalendar_dialog').dialog({
width : 600,
close : function(event, ui) {
@ -387,7 +387,7 @@ Calendar={
activation:function(checkbox, calendarid)
{
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
$.post(OC.filePath('calendar', 'ajax/calendar', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
@ -402,13 +402,13 @@ Calendar={
},
newCalendar:function(object){
var tr = $(document.createElement('tr'))
.load(OC.filePath('calendar', 'ajax', 'newcalendar.php'),
.load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'),
function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
edit:function(object, calendarid){
var tr = $(document.createElement('tr'))
.load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid,
.load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php') + "?calendarid="+calendarid,
function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
@ -417,7 +417,7 @@ Calendar={
if(check == false){
return false;
}else{
$.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
$.post(OC.filePath('calendar', 'ajax/calendar', 'delete.php'), { calendarid: calid},
function(data) {
if (data.status == 'success'){
var url = 'ajax/events.php?calendar_id='+calid;
@ -442,9 +442,9 @@ Calendar={
var url;
if (calendarid == 'new'){
url = OC.filePath('calendar', 'ajax', 'createcalendar.php');
url = OC.filePath('calendar', 'ajax/calendar', 'new.php');
}else{
url = OC.filePath('calendar', 'ajax', 'updatecalendar.php');
url = OC.filePath('calendar', 'ajax/calendar', 'update.php');
}
$.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
function(data){

View File

@ -6,7 +6,7 @@
*/
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
function(data){
if (data.status == 'success' && typeof(data.message) != 'undefined'){
$('#notification').html(data.message);

View File

@ -8,7 +8,7 @@ Calendar_Import={
importdialog: function(filename){
var path = $('#dir').val();
$('body').append('<div id="calendar_import"></div>');
$('#calendar_import').load(OC.filePath('calendar', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);});
$('#calendar_import').load(OC.filePath('calendar', 'ajax/import', 'dialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);});
},
initdialog: function(filename){
$('#calendar_import_dialog').dialog({
@ -68,7 +68,7 @@ Calendar_Import={
if(percent < 100){
window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500);
}else{
$('#import_done').css('display', 'block');
$('#import_done').css('display', 'block');
}
});
}
@ -78,4 +78,4 @@ $(document).ready(function(){
FileActions.register('text/calendar','importcal', '', Calendar_Import.importdialog);
FileActions.setDefault('text/calendar','importcal');
};
});
});

View File

@ -3,7 +3,7 @@ $(document).ready(function(){
OC.msg.startSaving('#calendar .msg')
// Serialize the data
var post = $( '#timezone' ).serialize();
$.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){
$.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){
//OC.msg.finishedSaving('#calendar .msg', data);
});
return false;
@ -11,7 +11,7 @@ $(document).ready(function(){
$('#timezone').chosen();
$('#timeformat').change( function(){
var data = $('#timeformat').serialize();
$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
$.post( OC.filePath('calendar', 'ajax/settings', 'settimeformat.php'), data, function(data){
if(data == 'error'){
console.log('saving timeformat failed');
}
@ -19,15 +19,15 @@ $(document).ready(function(){
});
$('#timezonedetection').change( function(){
var post = $('#timezonedetection').serialize();
$.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){
$.post( OC.filePath('calendar', 'ajax/settings', 'timezonedetection.php'), post, function(data){
});
});
$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) {
$('#' + jsondata.timeformat).attr('selected',true);
$('#timeformat').chosen();
});
$.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){
if(jsondata.detection == 'true'){
$('#timezonedetection').attr('checked', 'checked');
}

View File

@ -5,8 +5,8 @@
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');">
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');">
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');">
<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
</span>
</form>

View File

@ -17,6 +17,7 @@
?>
</select>
</td>
<?php if(count($_['calendar_options']) > 1) { ?>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
<td>
<select style="width:140px;" name="calendar">
@ -26,6 +27,12 @@
?>
</select>
</td>
<?php } else { ?>
<th width="75px">&nbsp;</th>
<td>
<input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id'] ?>">
</td>
<?php } ?>
</tr>
</table>
<hr>

View File

@ -3,7 +3,7 @@
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/newevent.php');">
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/new.php');">
</span>
</form>
</div>

View File

@ -1,7 +1,8 @@
<?xml version="1.0"?>
<info>
<id>files_pdfviewer</id>
<name>PDF viewer (pdfjs-based)</name>
<name>PDF Viewer</name>
<description>Inline PDF viewer (pdfjs-based)</description>
<version>0.1</version>
<licence>GPL</licence>
<author>Joan Creus</author>

View File

@ -5,4 +5,5 @@
#shared_list { padding:0.5em; list-style-type: none; }
#public { border-top:1px solid #ddd; padding-top:0.5em; }
a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; opacity:.5; }
a.unshare:hover { opacity:1; }
a.unshare:hover { opacity:1; }
#share_with { width: 16em; }

View File

@ -174,7 +174,7 @@ $(document).ready(function() {
function createDropdown(filename, files) {
var html = '<div id="dropdown" class="drop" data-file="'+files+'">';
html += '<div id="private">';
html += '<select data-placeholder="User or Group" style="width:220px;" id="share_with" class="chzen-select">';
html += '<select data-placeholder="User or Group" id="share_with" class="chzen-select">';
html += '<option value=""></option>';
html += '</select>';
html += '<ul id="shared_list"></ul>';

View File

@ -1,7 +1,8 @@
#editor{
position: absoloute;
position: fixed;
display: block;
top: 2em;
top: 6.5em;
left: 12.5em;
}
#editorwrapper{
position: absoloute;

View File

@ -172,6 +172,7 @@ function giveEditorFocus(){
function showFileEditor(dir,filename){
if(!editorIsShown()){
// Loads the file editor and display it.
$('#content').append('<div id="editor"></div>');
var data = $.getJSON(
OC.filePath('files_texteditor','ajax','loadfile.php'),
{file:filename,dir:dir},
@ -273,10 +274,10 @@ $(document).ready(function(){
var dir=text.substr(0,text.length-file.length-1);
showFileEditor(dir,file);
});
}
};
// Binds the file save and close editor events, and gotoline button
bindControlEvents();
$('#editor').remove();
// Binds the save keyboard shortcut events
//$(document).unbind('keydown').bind('keydown',checkForSaveKeyPress);
});

View File

@ -41,7 +41,8 @@ function handleRemove($name) {
function handleGetThumbnails($albumname) {
OC_Response::enableCaching(3600 * 24); // 24 hour
$thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.$albumname.'.png';
error_log(htmlentities($albumname));
$thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png';
header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail));
OC_Response::sendFile($thumbnail);
}

View File

@ -33,7 +33,7 @@ while ($r = $result->fetchRow()) {
$album_name = $r['album_name'];
$tmp_res = OC_Gallery_Photo::find($r['album_id']);
$a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
$a[] = array('name' => utf8_encode($album_name), 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
}
OC_JSON::success(array('albums'=>$a));

View File

@ -54,9 +54,9 @@ Albums={
event.preventDefault();
galleryRemove(event.data.name);
});
$("a.view", local).attr('href','?view='+escape(a.name));
$('h1',local).text(a.name);
$(".gallery_album_cover", local).attr('title',a.name);
$("a.view", local).attr('href','?view='+decodeURIComponent(escape(a.name)));
$('h1',local).text(decodeURIComponent(escape(a.name)));
$(".gallery_album_cover", local).attr('title',decodeURIComponent(escape(a.name)));
$(".gallery_album_cover", local).css('background-repeat', 'no-repeat');
$(".gallery_album_cover", local).css('background-position', '0');
$(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+escape(a.name)+'")');

View File

@ -69,7 +69,6 @@ class OC_Gallery_Photo {
public static function getThumbnail($image_name) {
$save_dir = OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/';
$save_dir .= dirname($image_name). '/';
$image_name = basename($image_name);
$thumb_file = $save_dir . $image_name;
if (file_exists($thumb_file)) {
$image = new OC_Image($thumb_file);

View File

@ -13,6 +13,8 @@ $CONFIG = array(
"forcessl" => false,
"enablebackup" => false,
"theme" => "",
"3rdpartyroot" => "",
"3rdpartyurl" => "",
// "datadirectory" => ""
);
?>

35
core/ajax/appconfig.php Normal file
View File

@ -0,0 +1,35 @@
<?php
/**
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
require_once ("../../lib/base.php");
OC_JSON::checkLoggedIn();
$action=isset($_POST['action'])?$_POST['action']:$_GET['action'];
$result=false;
switch($action){
case 'getValue':
$result=OC_Appconfig::getValue($_GET['app'],$_GET['key'],$_GET['default']);
break;
case 'setValue':
$result=OC_Appconfig::setValue($_POST['app'],$_POST['key'],$_POST['value']);
break;
case 'getApps':
$result=OC_Appconfig::getApps();
break;
case 'getKeys':
$result=OC_Appconfig::getKeys($_GET['app']);
break;
case 'hasKey':
$result=OC_Appconfig::hasKey($_GET['app'],$_GET['key']);
break;
case 'deleteKey':
$result=OC_Appconfig::deleteKey($_POST['app'],$_POST['key']);
break;
case 'deleteApp':
$result=OC_Appconfig::deleteApp($_POST['app']);
break;
}
OC_JSON::success(array('data'=>$result));

View File

@ -40,8 +40,8 @@ input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,
input[type="password"]:hover, input[type="password"]:focus, input[type="password"]:active,
.searchbox input[type="search"]:hover, .searchbox input[type="search"]:focus, .searchbox input[type="search"]:active { background-color:#fff; color:#333; opacity:1; }
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, select, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, select:hover, select:focus, select:active, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="checkbox"] { width:auto; }
#quota { cursor:default; }

55
core/js/config.js Normal file
View File

@ -0,0 +1,55 @@
/**
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
OC.AppConfig={
url:OC.filePath('core','ajax','appconfig.php'),
getCall:function(action,data,callback){
data.action=action;
$.getJSON(OC.AppConfig.url,data,function(result){
if(result.status='success'){
if(callback){
callback(result.data);
}
}
});
},
postCall:function(action,data,callback){
data.action=action;
$.post(OC.AppConfig.url,data,function(result){
if(result.status='success'){
if(callback){
callback(result.data);
}
}
},'json');
},
getValue:function(app,key,defaultValue,callback){
if(typeof defaultValue=='function'){
callback=defaultValue;
defaultValue=null;
}
OC.AppConfig.getCall('getValue',{app:app,key:key,default:defaultValue},callback);
},
setValue:function(app,key,value){
OC.AppConfig.postCall('setValue',{app:app,key:key,value:value});
},
getApps:function(callback){
OC.AppConfig.getCall('getApps',{},callback);
},
getKeys:function(app,callback){
OC.AppConfig.getCall('getKeys',{app:app},callback);
},
hasKey:function(app,key,callback){
OC.AppConfig.getCall('hasKey',{app:app,key:key},callback);
},
deleteKey:function(app,key){
OC.AppConfig.postCall('deleteKey',{app:app,key:key});
},
deleteApp:function(app){
OC.AppConfig.postCall('deleteApp',{app:app});
},
}
//TODO OC.Preferences

View File

@ -12,6 +12,11 @@
'minWidth': 'default;',
};
$.extend(settings,options);
$.each(this.children(),function(i,option){
if($(option).attr('selected') && settings.checked.indexOf($(option).val())==-1){
settings.checked.push($(option).val());
}
});
var button=$('<div class="multiselect button"><span>'+settings.title+'</span><span>▾</span></div>');
var span=$('<span/>');
span.append(button);
@ -46,9 +51,11 @@
});
button.addClass('active');
event.stopPropagation();
var options=$(this).parent().next().children().map(function(){return $(this).val();});
var options=$(this).parent().next().children();
var list=$('<ul class="multiselectoptions"/>').hide().appendTo($(this).parent());
function createItem(item,checked){
function createItem(element,checked){
element=$(element);
var item=element.val();
var id='ms'+multiSelectId+'-option-'+item;
var input=$('<input id="'+id+'" type="checkbox"/>');
var label=$('<label for="'+id+'">'+item+'</label>');
@ -61,6 +68,7 @@
input.change(function(){
var groupname=$(this).next().text();
if($(this).is(':checked')){
element.attr('selected','selected');
if(settings.oncheck){
if(settings.oncheck(groupname)===false){
$(this).attr('checked', false);
@ -70,6 +78,7 @@
settings.checked.push(groupname);
}else{
var index=settings.checked.indexOf(groupname);
element.attr('selected',null);
if(settings.onuncheck){
if(settings.onuncheck(groupname)===false){
$(this).attr('checked',true);
@ -119,11 +128,11 @@
var li=$(this).parent();
$(this).remove();
li.text('+ '+settings.createText);
li.before(createItem($(this).val()));
li.before(createItem(this));
var select=button.parent().next();
select.append($('<option selected="selected" value="'+$(this).val()+'">'+$(this).val()+'</option>'));
li.prev().children('input').trigger('click');
button.parent().data('preventHide',false);
var select=button.parent().next();
select.append($('<option value="'+$(this).val()+'">'+$(this).val()+'</option>'));
if(settings.createCallback){
settings.createCallback();
}

View File

@ -31,12 +31,12 @@
<field>
<name>configvalue</name>
<type>text</type>
<default></default>
<type>clob</type>
<notnull>true</notnull>
<length>255</length>
</field>
</declaration>
</table>
@ -53,9 +53,9 @@
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
<name>path</name>
<type>text</type>
@ -70,7 +70,7 @@
<default>
</default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
@ -90,13 +90,13 @@
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>size</name>
<type>integer</type>
<default></default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
@ -105,7 +105,7 @@
<default>
</default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
@ -114,7 +114,7 @@
<default>
</default>
<notnull>true</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
@ -291,7 +291,7 @@
<type>integer</type>
<default></default>
<notnull>false</notnull>
<length>4</length>
<length>8</length>
</field>
<field>
@ -522,7 +522,7 @@
</declaration>
</table>
<table>
<name>*dbprefix*properties</name>

View File

@ -166,6 +166,7 @@ $(document).ready(function() {
$('.file_upload_start').live('change',function(){
var form=$(this).closest('form');
var that=this;
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
@ -173,6 +174,12 @@ $(document).ready(function() {
if(files){
for(var i=0;i<files.length;i++){
totalSize+=files[i].size;
if(FileList.deleteFiles && FileList.deleteFiles.indexOf(files[i].name)!=-1){//finish delete if we are uploading a deleted file
FileList.finishDelete(function(){
$(that).change();
});
return;
}
}
}
if(totalSize>$('#max_upload').val()){

View File

@ -54,6 +54,14 @@ class OC{
* the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data)
*/
public static $CONFIG_DATADIRECTORY_ROOT = '';
/**
* The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty)
*/
public static $THIRDPARTYROOT = '';
/**
* the root path of the 3rdparty folder for http requests (e.g. owncloud/3rdparty)
*/
public static $THIRDPARTYWEBROOT = '';
/**
* SPL autoload
@ -138,12 +146,35 @@ class OC{
}
OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI));
if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){
OC::$WEBROOT='/'.OC::$WEBROOT;
}
// search the 3rdparty folder
if(OC_Config::getValue('3rdpartyroot', '')<>'' and OC_Config::getValue('3rdpartyurl', '')<>''){
OC::$THIRDPARTYROOT=OC_Config::getValue('3rdpartyroot', '');
OC::$THIRDPARTYWEBROOT=OC_Config::getValue('3rdpartyurl', '');
}elseif(file_exists(OC::$SERVERROOT.'/3rdparty')){
OC::$THIRDPARTYROOT=OC::$SERVERROOT;
OC::$THIRDPARTYWEBROOT=OC::$WEBROOT;
}elseif(file_exists(OC::$SERVERROOT.'/../3rdparty')){
$url_tmp=explode('/',OC::$WEBROOT);
$length=count($url_tmp);
unset($url_tmp[$length-1]);
OC::$THIRDPARTYWEBROOT=implode('/',$url_tmp);
$root_tmp=explode('/',OC::$SERVERROOT);
$length=count($root_tmp);
unset($root_tmp[$length-1]);
OC::$THIRDPARTYROOT=implode('/',$root_tmp);
}else{
echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file.");
exit;
}
// set the right include path
set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$SERVERROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
set_include_path(OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.OC::$SERVERROOT.'/config'.PATH_SEPARATOR.OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.get_include_path().PATH_SEPARATOR.OC::$SERVERROOT);
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
@ -205,6 +236,7 @@ class OC{
OC_Util::addScript( "jquery-tipsy" );
OC_Util::addScript( "js" );
OC_Util::addScript( "eventsource" );
OC_Util::addScript( "config" );
//OC_Util::addScript( "multiselect" );
OC_Util::addScript('search','result');
OC_Util::addStyle( "styles" );

View File

@ -318,6 +318,9 @@ class OC_DB {
// Make changes and save them to a temporary file
$file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
if($file2 == ''){
die('could not create tempfile in get_temp_dir() - aborting');
}
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't
@ -505,6 +508,21 @@ class OC_DB {
self::$connection->commit();
self::$inTransaction=false;
}
/**
* check if a result is an error, works with MDB2 and PDOException
* @param mixed $result
* @return bool
*/
public static function isError($result){
if(!$result){
return true;
}elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)){
return true;
}else{
return false;
}
}
}
/**
@ -524,11 +542,15 @@ class PDOStatementWrapper{
public function execute($input=array()){
$this->lastArguments=$input;
if(count($input)>0){
$this->statement->execute($input);
$result=$this->statement->execute($input);
}else{
$this->statement->execute();
$result=$this->statement->execute();
}
if($result){
return $this;
}else{
return false;
}
return $this;
}
/**

View File

@ -102,8 +102,10 @@ class OC_FileCache{
$mimePart=dirname($data['mimetype']);
$user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart,user,writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable']));
$result=$query->execute(array($parent,basename($path),$path,$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable']));
if(OC_DB::isError($result)){
OC_Log::write('files','error while writing file('.$path.') to cache',OC_Log::ERROR);
}
}
/**
@ -128,7 +130,10 @@ class OC_FileCache{
$sql = 'UPDATE *PREFIX*fscache SET '.implode(' , ',$queryParts).' WHERE id=?';
$query=OC_DB::prepare($sql);
$query->execute($arguments);
$result=$query->execute($arguments);
if(OC_DB::isError($result)){
OC_Log::write('files','error while updating file('.$path.') in cache',OC_Log::ERROR);
}
}
/**
@ -262,11 +267,20 @@ class OC_FileCache{
*/
private static function getFileId($path){
$query=OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
$result=$query->execute(array($path))->fetchRow();
if(OC_DB::isError($query)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1;
}
$result=$query->execute(array($path));
if(OC_DB::isError($result)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1;
}
$result=$result->fetchRow();
if(is_array($result)){
return $result['id'];
}else{
OC_Log::write('getFieldId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG);
OC_Log::write('getFileId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG);
return -1;
}
}

View File

@ -26,11 +26,37 @@
*/
class OC_FileProxy_Quota extends OC_FileProxy{
private $userQuota=-1;
/**
* get the quota for the current user
* @return int
*/
private function getQuota(){
if($this->userQuota!=-1){
return $this->userQuota;
}
$userQuota=OC_Preferences::getValue(OC_User::getUser(),'files','quota','default');
if($userQuota=='default'){
$userQuota=OC_AppConfig::getValue('files','default_quota','none');
}
if($userQuota=='none'){
$this->userQuota=0;
}else{
$this->userQuota=OC_Helper::computerFileSize($userQuota);
}
return $this->userQuota;
}
/**
* get the free space in the users home folder
* @return int
*/
private function getFreeSpace(){
$rootInfo=OC_FileCache::get('');
$usedSpace=$rootInfo['size'];
$totalSpace=OC_Preferences::getValue(OC_User::getUser(),'files','quota',0);
$totalSpace=OC_Helper::computerFileSize($totalSpace);
$totalSpace=$this->getQuota();
if($totalSpace==0){
return 0;
}

View File

@ -130,7 +130,7 @@ class OC_Group_Database extends OC_Group_Backend {
* removes the user from a group.
*/
public static function removeFromGroup( $uid, $gid ){
$query = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `uid` = ? AND `gid` = ?" );
$query = OC_DB::prepare( "DELETE FROM *PREFIX*group_user WHERE uid = ? AND gid = ?" );
$result = $query->execute( array( $uid, $gid ));
return true;

View File

@ -346,31 +346,41 @@ class OC_Template{
// Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){
if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){
// Is it in 3rd party?
if(is_file(OC::$THIRDPARTYROOT."/$script.js" )){
$page->append( "jsfiles", OC::$THIRDPARTYWEBROOT."/$script.js" );
// Is it in apps and overwritten by the theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" );
// Is it part of an app?
}elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
// Is it in the owncloud root but overwritten by the theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script.js" );
// Is it in the owncloud root ?
}elseif(is_file(OC::$SERVERROOT."/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script.js" );
// Is in core but overwritten by a theme?
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script$fext.js" );
}elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script.js" );
// Is it in core?
}elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" );
}else{
@ -380,14 +390,20 @@ class OC_Template{
}
// Add the css files
foreach(OC_Util::$styles as $style){
if(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
// is it in 3rdparty?
if(is_file(OC::$THIRDPARTYROOT."/$style.css" )){
$page->append( "cssfiles", OC::$THIRDPARTYWEBROOT."/$style.css" );
// or in apps?
}elseif(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
// or in the owncloud root?
}elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" );
}elseif(is_file(OC::$SERVERROOT."/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style.css" );
// or in core ?
}elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" );
}else{

View File

@ -321,7 +321,10 @@ class OC_User {
$users=array();
foreach(self::$_usedBackends as $backend){
if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){
$users=array_merge($users,$backend->getUsers());
$backendUsers=$backend->getUsers();
if(is_array($backendUsers)){
$users=array_merge($users,$backendUsers);
}
}
}
return $users;

View File

@ -62,7 +62,7 @@ class OC_Util {
* @return array
*/
public static function getVersion(){
return array(3,00,1);
return array(3,00,3);
}
/**

View File

@ -5,14 +5,28 @@ require_once('../../lib/base.php');
OC_JSON::checkAdminUser();
$username = $_POST["username"];
$username = isset($_POST["username"])?$_POST["username"]:'';
//make sure the quota is in the expected format
$quota= OC_Helper::computerFileSize($_POST["quota"]);
$quota=OC_Helper::humanFileSize($quota);
$quota=$_POST["quota"];
if($quota!='none' and $quota!='default'){
$quota= OC_Helper::computerFileSize($quota);
if($quota==0){
$quota='default';
}else{
$quota=OC_Helper::humanFileSize($quota);
}
}
// Return Success story
OC_Preferences::setValue($username,'files','quota',$quota);
if($username){
OC_Preferences::setValue($username,'files','quota',$quota);
}else{//set the default quota when no username is specified
if($quota=='default'){//'default' as default quota makes no sense
$quota='none';
}
OC_Appconfig::setValue('files','default_quota',$quota);
}
OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
?>

View File

@ -29,6 +29,12 @@ li.selected { background-color:#ddd; }
#content>table:not(.nostyle) { margin-top:3em; }
table:not(.nostyle) { width:100%; }
#rightcontent { padding-left: 1em; }
td.quota { position:relative }
div.quota { float:right; display:block; position:absolute; right:25em; top:0; }
select.quota { position:absolute; left:0; top:0; width:10em; }
input.quota-other { display:none; position:absolute; left:0.1em; top:0.1em; width:7em; border:none; -webkit-box-shadow: none -mox-box-shadow:none ; box-shadow:none; }
div.quota>span { position:absolute; right:0em; white-space:nowrap; top: 0.7em }
select.quota.active { background: #fff; }
/* APPS */
li { color:#888; }

View File

@ -5,6 +5,18 @@
*/
$(document).ready(function(){
function setQuota(uid,quota,ready){
$.post(
OC.filePath('settings','ajax','setquota.php'),
{username:uid,quota:quota},
function(result){
if(ready){
ready(result.data.quota);
}
}
);
}
function applyMultiplySelect(element){
var checked=[];
var user=element.data('username');
@ -82,48 +94,66 @@ $(document).ready(function(){
$('td.password').live('click',function(event){
$(this).children('img').click();
});
$('td.quota>img').live('click',function(event){
event.stopPropagation();
var img=$(this);
var uid=img.parent().parent().data('uid');
var input=$('<input>');
var quota=img.parent().children('span').text();
if(quota=='None'){
quota='';
$('select.quota').live('change',function(){
var select=$(this);
var uid=$(this).parent().parent().data('uid');
var quota=$(this).val();
var other=$(this).next();
if(quota!='other'){
other.hide();
select.data('previous',quota);
setQuota(uid,quota);
}else{
other.show();
select.addClass('active');
other.focus();
}
input.val(quota);
img.css('display','none');
img.parent().children('span').replaceWith(input);
input.focus();
input.keypress(function(event) {
if(event.keyCode == 13) {
$(this).parent().attr('data-quota',$(this).val());
if($(this).val().length>0){
$.post(
OC.filePath('settings','ajax','setquota.php'),
{username:uid,quota:$(this).val()},
function(result){
img.parent().children('span').text(result.data.quota)
$(this).parent().attr('data-quota',result.data.quota);
}
);
input.blur();
});
$('select.quota').each(function(i,select){
$(select).data('previous',$(select).val());
})
$('input.quota-other').live('change',function(){
var uid=$(this).parent().parent().data('uid');
var quota=$(this).val();
var select=$(this).prev();
var other=$(this);
if(quota){
setQuota(uid,quota,function(quota){
select.children().attr('selected',null);
var existingOption=select.children().filter(function(i,option){
return ($(option).val()==quota);
});
if(existingOption.length){
existingOption.attr('selected','selected');
}else{
input.blur();
var option=$('<option/>');
option.attr('selected','selected').attr('value',quota).text(quota);
select.children().last().before(option);
}
}
});
input.blur(function(){
var quota=$(this).parent().attr('data-quota');
$(this).replaceWith($('<span>'+quota+'</span>'));
img.css('display','');
});
});
$('td.quota').live('click',function(event){
$(this).children('img').click();
select.val(quota);
select.removeClass('active');
other.val(null);
other.hide();
});
}else{
var previous=select.data('previous');
select.children().attr('selected',null);
select.children().each(function(i,option){
if($(option).val()==previous){
$(option).attr('selected','selected');
}
});
select.removeClass('active');
other.hide();
}
});
$('input.quota-other').live('blur',function(){
$(this).change();
})
$('#newuser').submit(function(event){
event.preventDefault();
var username=$('#newusername').val();
@ -157,7 +187,13 @@ $(document).ready(function(){
select.data('username',username);
select.data('userGroups',groups.join(', '));
tr.find('td.groups').empty();
$.each($('#content table').data('groups').split(', '),function(i,group){
var allGroups=$('#content table').data('groups').split(', ');
for(var i=0;i<groups.length;i++){
if(allGroups.indexOf(groups[i])==-1){
allGroups.push(groups[i]);
}
}
$.each(allGroups,function(i,group){
select.append($('<option value="'+group+'">'+group+'</option>'));
});
tr.find('td.groups').append(select);
@ -166,5 +202,9 @@ $(document).ready(function(){
}
applyMultiplySelect(select);
$('#content table tbody').last().after(tr);
tr.find('select.quota option').attr('selected',null);
tr.find('select.quota option').first().attr('selected','selected');
tr.find('select.quota').data('previous','default');
});
});

View File

@ -12,16 +12,30 @@ foreach($_["groups"] as $group) {
<div id="controls">
<form id="newuser">
<th class="name"><input id="newusername" placeholder="<?php echo $l->t('Name')?>" /></th>
<th class="password"><input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" /></th>
<th class="groups"><select id="newusergroups" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple">
<input id="newusername" placeholder="<?php echo $l->t('Name')?>" />
<input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" />
<select id="newusergroups" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple">
<?php foreach($_["groups"] as $group): ?>
<option value="<?php echo $group['name'];?>"><?php echo $group['name'];?></option>
<?php endforeach;?>
</select></th>
<th class="quota"></th>
<th><input type="submit" value="<?php echo $l->t('Create')?>" /></th>
</select>
<input type="submit" value="<?php echo $l->t('Create')?>" />
</form>
<div class="quota">
<span><?php echo $l->t('Default Quota');?>:</span>
<select class='quota'>
<?php foreach($_['quota_preset'] as $preset):?>
<?php if($preset!='default'):?>
<option <?php if($_['default_quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
<?php endif;?>
<?php endforeach;?>
<?php if(array_search($_['default_quota'],$_['quota_preset'])===false):?>
<option selected="selected" value='<?php echo $_['default_quota'];?>'><?php echo $_['default_quota'];?></option>
<?php endif;?>
<option value='other'><?php echo $l->t('Other');?>...</option>
</select>
<input class='quota-other'></input>
</div>
</div>
<table data-groups="<?php echo implode(', ',$allGroups);?>">
@ -49,9 +63,17 @@ foreach($_["groups"] as $group) {
<?php endforeach;?>
</select>
</td>
<td class="quota" data-quota="<?php echo $user['quota']?>">
<span><?php echo ($user['quota']>0)?$user['quota']:'None';?></span>
<img class="svg action" src="<?php echo image_path('core','actions/rename.svg')?>" alt="set new password" title="set quota" />
<td class="quota">
<select class='quota'>
<?php foreach($_['quota_preset'] as $preset):?>
<option <?php if($user['quota']==$preset) echo 'selected="selected"';?> value='<?php echo $preset;?>'><?php echo $preset;?></option>
<?php endforeach;?>
<?php if(array_search($user['quota'],$_['quota_preset'])===false):?>
<option selected="selected" value='<?php echo $user['quota'];?>'><?php echo $user['quota'];?></option>
<?php endif;?>
<option value='other'><?php echo $l->t('Other');?>...</option>
</select>
<input class='quota-other'></input>
</td>
<td class="remove">
<?php if($user['name']!=OC_User::getUser()):?>

View File

@ -18,17 +18,26 @@ $users = array();
$groups = array();
foreach( OC_User::getUsers() as $i ){
$users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota',0));
$users[] = array( "name" => $i, "groups" => join( ", ", OC_Group::getUserGroups( $i ) ),'quota'=>OC_Preferences::getValue($i,'files','quota','default'));
}
foreach( OC_Group::getGroups() as $i ){
// Do some more work here soon
$groups[] = array( "name" => $i );
}
$quotaPreset=OC_Appconfig::getValue('files','quota_preset','default,none,1 GB, 5 GB, 10 GB');
$quotaPreset=explode(',',$quotaPreset);
foreach($quotaPreset as &$preset){
$preset=trim($preset);
}
$defaultQuota=OC_Appconfig::getValue('files','default_quota','none');
$tmpl = new OC_Template( "settings", "users", "user" );
$tmpl->assign( "users", $users );
$tmpl->assign( "groups", $groups );
$tmpl->assign( 'quota_preset', $quotaPreset);
$tmpl->assign( 'default_quota', $defaultQuota);
$tmpl->printPage();
?>