commit
e5d3666280
@ -1,11 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); |
||||
?> |
@ -1,12 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); |
||||
OC_JSON::encodedPrint(array("duration" => $duration)); |
||||
?> |
@ -1,12 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
$firstdayofweek = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); |
||||
OC_JSON::encodedPrint(array("firstdayofweek" => $firstdayofweek)); |
||||
?> |
@ -0,0 +1,11 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011, 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. |
||||
*/ |
||||
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'))); |
@ -1,30 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
$weekenddays = array("Monday"=>"false", "Tuesday"=>"false", "Wednesday"=>"false", "Thursday"=>"false", "Friday"=>"false", "Saturday"=>"false", "Sunday"=>"false"); |
||||
for($i = 0;$i < count($_POST["weekend"]); $i++){ |
||||
switch ($_POST["weekend"][$i]){ |
||||
case "Monday": |
||||
case "Tuesday": |
||||
case "Wednesday": |
||||
case "Thursday": |
||||
case "Friday": |
||||
case "Saturday": |
||||
case "Sunday": |
||||
break; |
||||
default: |
||||
OC_JSON::error(); |
||||
exit; |
||||
} |
||||
$weekenddays[$_POST["weekend"][$i]] = "true"; |
||||
} |
||||
$setValue = json_encode($weekenddays); |
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'weekend', $setValue); |
||||
OC_JSON::success(); |
||||
?> |
@ -1,17 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
if(isset($_POST["duration"])){ |
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]); |
||||
OC_JSON::success(); |
||||
}else{ |
||||
OC_JSON::error(); |
||||
} |
||||
?> |
||||
|
@ -1,16 +0,0 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011 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. |
||||
*/ |
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
if(isset($_POST["firstdayofweek"])){ |
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstdayofweek', $_POST["firstdayofweek"]); |
||||
OC_JSON::success(); |
||||
}else{ |
||||
OC_JSON::error(); |
||||
} |
||||
?> |
@ -0,0 +1,17 @@ |
||||
<?php |
||||
/** |
||||
* Copyright (c) 2011, 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. |
||||
*/ |
||||
require_once ("../../../lib/base.php"); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('calendar'); |
||||
if($_POST['timezonedetection'] == 'on'){ |
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'true'); |
||||
}else{ |
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezonedetection', 'false'); |
||||
} |
||||
OC_JSON::success(); |
||||
|
@ -1,26 +1,23 @@ |
||||
<?php |
||||
$l=new OC_L10N('calendar'); |
||||
OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; |
||||
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; |
||||
OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser'); |
||||
|
||||
OC_Util::addScript('calendar','loader'); |
||||
|
||||
OC_App::register( array( |
||||
'order' => 10, |
||||
'id' => 'calendar', |
||||
'name' => 'Calendar' )); |
||||
|
||||
OC_App::addNavigationEntry( array( |
||||
'id' => 'calendar_index', |
||||
'order' => 10, |
||||
'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), |
||||
'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ), |
||||
'name' => $l->t('Calendar'))); |
||||
|
||||
OC_App::registerPersonal('calendar', 'settings'); |
||||
|
||||
require_once('apps/calendar/lib/search.php'); |
||||
if(version_compare(PHP_VERSION, '5.3.0', '>')){ |
||||
$l=new OC_L10N('calendar'); |
||||
OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php'; |
||||
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php'; |
||||
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php'; |
||||
OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser'); |
||||
OC_Util::addScript('calendar','loader'); |
||||
OC_App::register( array( |
||||
'order' => 10, |
||||
'id' => 'calendar', |
||||
'name' => 'Calendar' )); |
||||
OC_App::addNavigationEntry( array( |
||||
'id' => 'calendar_index', |
||||
'order' => 10, |
||||
'href' => OC_Helper::linkTo( 'calendar', 'index.php' ), |
||||
'icon' => OC_Helper::imagePath( 'calendar', 'icon.png' ), |
||||
'name' => $l->t('Calendar'))); |
||||
OC_App::registerPersonal('calendar', 'settings'); |
||||
require_once('apps/calendar/lib/search.php'); |
||||
} |
||||
|
@ -1,63 +1,35 @@ |
||||
$(document).ready(function(){ |
||||
$("#timezone").change( function(){ |
||||
$('#timezone').change( function(){ |
||||
OC.msg.startSaving('#calendar .msg') |
||||
// Serialize the data
|
||||
var post = $( "#timezone" ).serialize(); |
||||
var post = $( '#timezone' ).serialize(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){ |
||||
//OC.msg.finishedSaving('#calendar .msg', data);
|
||||
}); |
||||
return false; |
||||
}); |
||||
$("#timezone").chosen(); |
||||
$("#firstdayofweek").change( function(){ |
||||
var data = $("#firstdayofweek").serialize(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){ |
||||
if(data == "error"){ |
||||
console.log("saving first day of week failed"); |
||||
} |
||||
}); |
||||
}); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) { |
||||
$("#select_" + jsondata.firstdayofweek).attr('selected',true); |
||||
$("#firstdayofweek").chosen(); |
||||
}); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) { |
||||
for(day in jsondata){ |
||||
if(jsondata[day] == "true"){ |
||||
$("#selectweekend_" + day).attr('selected',true); |
||||
} |
||||
} |
||||
$("#weekend").chosen(); |
||||
}); |
||||
$("#timeformat").change( function(){ |
||||
var data = $("#timeformat").serialize(); |
||||
$('#timezone').chosen(); |
||||
$('#timeformat').change( function(){ |
||||
var data = $('#timeformat').serialize(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ |
||||
if(data == "error"){ |
||||
console.log("saving timeformat failed"); |
||||
if(data == 'error'){ |
||||
console.log('saving timeformat failed'); |
||||
} |
||||
}); |
||||
}); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { |
||||
$("#" + jsondata.timeformat).attr('selected',true); |
||||
$("#timeformat").chosen(); |
||||
}); |
||||
$("#duration").blur( function(){ |
||||
var data = $("#duration").val(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){ |
||||
if(data == "error"){ |
||||
console.log("saving duration failed"); |
||||
} |
||||
$('#timezonedetection').change( function(){ |
||||
var post = $('#timezonedetection').serialize(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){ |
||||
|
||||
}); |
||||
}); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) { |
||||
$("#duration").val(jsondata.duration); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { |
||||
$('#' + jsondata.timeformat).attr('selected',true); |
||||
$('#timeformat').chosen(); |
||||
}); |
||||
$("#weekend").change( function(){ |
||||
var data = $("#weekend").serialize(); |
||||
$.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ |
||||
if(data == "error"){ |
||||
console.log("saving days of weekend failed"); |
||||
} |
||||
}); |
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){ |
||||
if(jsondata.detection == 'true'){ |
||||
$('#timezonedetection').attr('checked', 'checked'); |
||||
} |
||||
}); |
||||
}); |
||||
|
@ -0,0 +1,4 @@ |
||||
<?php |
||||
require_once ("../../lib/base.php"); |
||||
OC_Preferences::deleteKey(OC_USER::getUser(), 'calendar', 'timezone'); |
||||
?> |
@ -0,0 +1,39 @@ |
||||
<?php |
||||
$l->t('Sunday'); |
||||
$l->t('Monday'); |
||||
$l->t('Tuesday'); |
||||
$l->t('Wednesday'); |
||||
$l->t('Thursday'); |
||||
$l->t('Friday'); |
||||
$l->t('Saturday'); |
||||
$l->t('Sun.'); |
||||
$l->t('Mon.'); |
||||
$l->t('Tue.'); |
||||
$l->t('Wed.'); |
||||
$l->t('Thu.'); |
||||
$l->t('Fri.'); |
||||
$l->t('Sat.'); |
||||
$l->t('January'); |
||||
$l->t('February'); |
||||
$l->t('March'); |
||||
$l->t('April'); |
||||
$l->t('May'); |
||||
$l->t('June'); |
||||
$l->t('July'); |
||||
$l->t('August'); |
||||
$l->t('September'); |
||||
$l->t('October'); |
||||
$l->t('November'); |
||||
$l->t('December'); |
||||
$l->t('Jan.'); |
||||
$l->t('Feb.'); |
||||
$l->t('Mar.'); |
||||
$l->t('Apr.'); |
||||
$l->t('May.'); |
||||
$l->t('Jun.'); |
||||
$l->t('Jul.'); |
||||
$l->t('Aug.'); |
||||
$l->t('Sep.'); |
||||
$l->t('Oct.'); |
||||
$l->t('Nov.'); |
||||
$l->t('Dec.'); |
@ -1,10 +1,31 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - gallery application |
||||
* |
||||
* @author Bartek Przybylski |
||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
require_once('../../../lib/base.php'); |
||||
OC_JSON::checkLoggedIn(); |
||||
OC_JSON::checkAppEnabled('gallery'); |
||||
|
||||
OC_Gallery_Scanner::cleanUp(); |
||||
OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan(''))); |
||||
OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/'))); |
||||
|
||||
?> |
||||
|
@ -0,0 +1,118 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* ownCloud - gallery application |
||||
* |
||||
* @author Bartek Przybylski |
||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com |
||||
* |
||||
* This library is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
* License as published by the Free Software Foundation; either |
||||
* version 3 of the License, or any later version. |
||||
* |
||||
* This library is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
||||
* |
||||
*/ |
||||
|
||||
OC_Hook::connect("OC_Filesystem", "post_write", "OC_Gallery_Hooks_Handlers", "addPhotoFromPath"); |
||||
OC_Hook::connect("OC_Filesystem", "delete", "OC_Gallery_Hooks_Handlers", "removePhoto"); |
||||
OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Gallery_Hooks_Handlers", "renamePhoto"); |
||||
|
||||
require_once(OC::$CLASSPATH['OC_Gallery_Album']); |
||||
require_once(OC::$CLASSPATH['OC_Gallery_Photo']); |
||||
|
||||
class OC_Gallery_Hooks_Handlers { |
||||
private static $APP_TAG = "Gallery"; |
||||
|
||||
private static function isPhoto($filename) { |
||||
OC_Log::write(self::$APP_TAG, "Checking file ".$filename." with mimetype ".OC_Filesystem::getMimeType($filename), OC_Log::DEBUG); |
||||
if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") |
||||
return 1; |
||||
return 0; |
||||
} |
||||
|
||||
private static function createAlbum($path) { |
||||
$new_album_name = trim(str_replace('/', '.', $path), '.'); |
||||
if ($new_album_name == '') |
||||
$new_album_name = 'main'; |
||||
|
||||
OC_Log::write(self::$APP_TAG, 'Creating new album '.$new_album_name, OC_Log::DEBUG); |
||||
OC_Gallery_Album::create(OC_User::getUser(), $new_album_name, $path); |
||||
|
||||
return OC_Gallery_Album::find(OC_User::getUser(), null, $path); |
||||
} |
||||
|
||||
public static function addPhotoFromPath($params) { |
||||
if (!self::isPhoto($params['path'])) return; |
||||
$fullpath = $params['path']; |
||||
OC_Log::write(self::$APP_TAG, 'Adding file with path '. $fullpath, OC_Log::DEBUG); |
||||
$path = substr($fullpath, 0, strrpos($fullpath, '/')); |
||||
if ($path == '') $path = '/'; |
||||
$album = OC_Gallery_Album::find(OC_User::getUser(), null, $path); |
||||
|
||||
if ($album->numRows() == 0) { |
||||
$album = self::createAlbum($path); |
||||
} |
||||
$album = $album->fetchRow(); |
||||
$albumId = $album['album_id']; |
||||
$photo = OC_Gallery_Photo::find($albumId, $fullpath); |
||||
if ($photo->numRows() == 0) { // don't duplicate photo entries |
||||
OC_Log::write(self::$APP_TAG, 'Adding new photo to album', OC_Log::DEBUG); |
||||
OC_Gallery_Photo::create($albumId, $fullpath); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static function removePhoto($params) { |
||||
$path = $params['path']; |
||||
if (!self::isPhoto($path)) return; |
||||
OC_Gallery_Photo::removeByPath($path); |
||||
} |
||||
|
||||
public static function renamePhoto($params) { |
||||
$olddir = substr($params['oldpath'], 0, strrpos($params['oldpath'], '/')); |
||||
$newdir = substr($params['newpath'], 0, strrpos($params['newpath'], '/')); |
||||
if ($olddir == '') $olddir = '/'; |
||||
if ($newdir == '') $newdir = '/'; |
||||
if (!self::isPhoto($params['newpath'])) return; |
||||
OC_Log::write(self::$APP_TAG, 'Moving photo from '.$params['oldpath'].' to '.$params['newpath'], OC_Log::DEBUG); |
||||
$album; |
||||
$newAlbumId; |
||||
$oldAlbumId; |
||||
if ($olddir == $newdir) { |
||||
// album changing is not needed |
||||
$album = OC_Gallery_Album::find(OC_User::getUser(), null, $olddir); |
||||
if ($album->numRows() == 0) { |
||||
$album = self::createAlbum($newdir); |
||||
} |
||||
$album = $album->fetchRow(); |
||||
$newAlbumId = $oldAlbumId = $album['album_id']; |
||||
} else { |
||||
$newalbum = OC_Gallery_Album::find(OC_User::getUser(), null, $newdir); |
||||
$oldalbum = OC_Gallery_Album::find(OC_User::getUser(), null, $olddir); |
||||
|
||||
if ($newalbum->numRows() == 0) { |
||||
$newalbum = self::createAlbum($newdir); |
||||
} |
||||
$newalbum = $newalbum->fetchRow(); |
||||
if ($oldalbum->numRows() == 0) { |
||||
OC_Gallery_Photo::create($newalbum['album_id'], $params['newpath']); |
||||
return; |
||||
} |
||||
$oldalbum = $oldalbum->fetchRow(); |
||||
$newAlbumId = $newalbum['album_id']; |
||||
$oldAlbumId = $oldalbum['album_id']; |
||||
|
||||
} |
||||
OC_Gallery_Photo::changePath($oldAlbumId, $newAlbumId, $params['oldpath'], $params['newpath']); |
||||
} |
||||
} |
||||
|
||||
?> |
Loading…
Reference in new issue