aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/admin_export/appinfo/app.php33
-rw-r--r--apps/admin_export/appinfo/info.xml10
-rw-r--r--apps/admin_export/settings.php96
-rw-r--r--apps/admin_export/templates/settings.php13
-rw-r--r--apps/bookmarks/addBm.php1
-rw-r--r--apps/bookmarks/ajax/addBookmark.php1
-rw-r--r--apps/bookmarks/ajax/delBookmark.php1
-rw-r--r--apps/bookmarks/ajax/editBookmark.php1
-rw-r--r--apps/bookmarks/ajax/getMeta.php1
-rw-r--r--apps/bookmarks/ajax/recordClick.php1
-rw-r--r--apps/bookmarks/ajax/updateList.php1
-rw-r--r--apps/bookmarks/index.php1
-rw-r--r--apps/bookmarks/templates/addBm.php14
-rw-r--r--apps/bookmarks/templates/list.php27
-rw-r--r--apps/calendar/ajax/activation.php1
-rw-r--r--apps/calendar/ajax/changeview.php1
-rw-r--r--apps/calendar/ajax/choosecalendar.php1
-rw-r--r--apps/calendar/ajax/createcalendar.php1
-rwxr-xr-xapps/calendar/ajax/daysofweekend.php11
-rw-r--r--apps/calendar/ajax/deletecalendar.php1
-rw-r--r--apps/calendar/ajax/deleteevent.php1
-rw-r--r--apps/calendar/ajax/duration.php12
-rw-r--r--apps/calendar/ajax/editcalendar.php12
-rw-r--r--apps/calendar/ajax/editevent.php1
-rw-r--r--apps/calendar/ajax/editeventform.php9
-rwxr-xr-xapps/calendar/ajax/firstdayofweek.php12
-rw-r--r--apps/calendar/ajax/getcal.php61
-rw-r--r--apps/calendar/ajax/geteventinfo.php9
-rw-r--r--apps/calendar/ajax/moveevent.php103
-rw-r--r--apps/calendar/ajax/newcalendar.php7
-rw-r--r--apps/calendar/ajax/newevent.php1
-rw-r--r--apps/calendar/ajax/neweventform.php25
-rwxr-xr-xapps/calendar/ajax/setdaysofweekend.php30
-rw-r--r--apps/calendar/ajax/setduration.php17
-rwxr-xr-xapps/calendar/ajax/setfirstdayofweek.php16
-rw-r--r--apps/calendar/ajax/settimeformat.php17
-rw-r--r--apps/calendar/ajax/settimezone.php1
-rw-r--r--apps/calendar/ajax/timeformat.php12
-rw-r--r--apps/calendar/ajax/updatecalendar.php1
-rw-r--r--apps/calendar/caldav.php1
-rw-r--r--apps/calendar/css/style.css4
-rw-r--r--apps/calendar/export.php35
-rw-r--r--apps/calendar/index.php1
-rw-r--r--apps/calendar/js/calendar.js136
-rw-r--r--apps/calendar/js/settings.js56
-rw-r--r--apps/calendar/lib/object.php25
-rw-r--r--apps/calendar/templates/calendar.php62
-rw-r--r--apps/calendar/templates/part.choosecalendar.php4
-rw-r--r--apps/calendar/templates/part.editcalendar.php11
-rw-r--r--apps/calendar/templates/part.editevent.php1
-rw-r--r--apps/calendar/templates/part.eventform.php4
-rw-r--r--apps/calendar/templates/part.getcal.php57
-rw-r--r--apps/calendar/templates/settings.php35
-rw-r--r--apps/contacts/ajax/addcard.php1
-rw-r--r--apps/contacts/ajax/addproperty.php1
-rw-r--r--apps/contacts/ajax/deletebook.php1
-rw-r--r--apps/contacts/ajax/deletecard.php1
-rw-r--r--apps/contacts/ajax/deleteproperty.php1
-rw-r--r--apps/contacts/ajax/getdetails.php1
-rw-r--r--apps/contacts/ajax/setproperty.php1
-rw-r--r--apps/contacts/ajax/showaddcard.php1
-rw-r--r--apps/contacts/ajax/showaddproperty.php1
-rw-r--r--apps/contacts/ajax/showsetproperty.php1
-rw-r--r--apps/contacts/appinfo/app.php3
-rw-r--r--apps/contacts/carddav.php1
-rw-r--r--apps/contacts/index.php1
-rw-r--r--apps/contacts/js/interface.js2
-rw-r--r--apps/contacts/photo.php9
-rw-r--r--apps/contacts/settings.php6
-rw-r--r--apps/contacts/templates/settings.php7
-rw-r--r--apps/files_sharing/ajax/getitem.php1
-rw-r--r--apps/files_sharing/ajax/setpermissions.php3
-rw-r--r--apps/files_sharing/ajax/share.php3
-rw-r--r--apps/files_sharing/ajax/unshare.php3
-rw-r--r--apps/files_sharing/ajax/userautocomplete.php1
-rw-r--r--apps/files_sharing/get.php1
-rw-r--r--apps/files_sharing/list.php1
-rw-r--r--apps/files_sharing/templates/list.php12
-rw-r--r--apps/files_texteditor/css/style.css6
-rw-r--r--apps/files_texteditor/js/editor.js83
-rw-r--r--apps/gallery/ajax/cover.php62
-rw-r--r--apps/gallery/ajax/createAlbum.php14
-rw-r--r--apps/gallery/ajax/getAlbums.php22
-rw-r--r--apps/gallery/ajax/getCovers.php66
-rw-r--r--apps/gallery/ajax/scanForAlbums.php14
-rw-r--r--apps/gallery/ajax/thumbnail.php58
-rw-r--r--apps/gallery/appinfo/app.php27
-rw-r--r--apps/gallery/appinfo/database.xml58
-rw-r--r--apps/gallery/appinfo/info.xml11
-rw-r--r--apps/gallery/css/styles.css23
-rw-r--r--apps/gallery/index.php33
-rw-r--r--apps/gallery/js/album_cover.js41
-rw-r--r--apps/gallery/js/albums.js80
-rw-r--r--apps/gallery/lib_scanner.php57
-rw-r--r--apps/gallery/templates/index.php12
-rw-r--r--apps/gallery/templates/view_album.php20
-rw-r--r--apps/media/ajax/api.php1
-rw-r--r--apps/media/ajax/autoupdate.php1
-rw-r--r--apps/media/appinfo/app.php1
-rw-r--r--apps/media/css/music.css8
-rw-r--r--apps/media/css/player.css23
-rw-r--r--apps/media/index.php1
-rw-r--r--apps/media/js/collection.js157
-rw-r--r--apps/media/js/loader.js9
-rw-r--r--apps/media/js/music.js3
-rw-r--r--apps/media/js/player.js38
-rw-r--r--apps/media/js/playlist.js3
-rw-r--r--apps/media/server/xml.server.php1
-rw-r--r--apps/media/settings.php6
-rw-r--r--apps/media/templates/music.php3
-rw-r--r--apps/media/templates/player.php17
-rw-r--r--apps/media/templates/settings.php7
-rw-r--r--apps/media/tomahawk.php1
-rw-r--r--apps/unhosted/compat.php1
-rw-r--r--apps/user_openid/user.php1
115 files changed, 1740 insertions, 289 deletions
diff --git a/apps/admin_export/appinfo/app.php b/apps/admin_export/appinfo/app.php
new file mode 100644
index 00000000000..beebb4864e9
--- /dev/null
+++ b/apps/admin_export/appinfo/app.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+* ownCloud - user_ldap
+*
+* @author Dominik Schmidt
+* @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de
+*
+* 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 Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+
+OC_APP::registerAdmin('admin_export','settings');
+
+// add settings page to navigation
+$entry = array(
+ 'id' => "admin_export_settings",
+ 'order'=>1,
+ 'href' => OC_Helper::linkTo( "admin_export", "settings.php" ),
+ 'name' => 'Export'
+);
diff --git a/apps/admin_export/appinfo/info.xml b/apps/admin_export/appinfo/info.xml
new file mode 100644
index 00000000000..c4a2a9b398c
--- /dev/null
+++ b/apps/admin_export/appinfo/info.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<info>
+ <id>admin_export</id>
+ <name>Import/Export</name>
+ <description>Import/Export your owncloud data</description>
+ <version>0.1</version>
+ <licence>AGPL</licence>
+ <author>Thomas Schmidt</author>
+ <require>2</require>
+</info>
diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php
new file mode 100644
index 00000000000..8308a2b89b5
--- /dev/null
+++ b/apps/admin_export/settings.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * ownCloud - admin export
+ *
+ * @author Thomas Schmidt
+ * @copyright 2011 Thomas Schmidt tom@opensuse.org
+ *
+ * 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 Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+OC_Util::checkAdminUser();
+OC_Util::checkAppEnabled('admin_export');
+if (isset($_POST['admin_export'])) {
+ $root = OC::$SERVERROOT . "/";
+ $zip = new ZipArchive();
+ $filename = sys_get_temp_dir() . "/owncloud_export_" . date("y-m-d_H-i-s") . ".zip";
+ error_log("Creating export file at: " . $filename);
+ if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
+ exit("Cannot open <$filename>\n");
+ }
+
+ if (isset($_POST['owncloud_system'])) {
+ // adding owncloud system files
+ error_log("Adding owncloud system files to export");
+ zipAddDir($root, $zip, false);
+ foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dirname) {
+ zipAddDir($root . $dirname, $zip, true, basename($root) . "/");
+ }
+ }
+
+ if (isset($_POST['owncloud_config'])) {
+ // adding owncloud config
+ // todo: add database export
+ error_log("Adding owncloud config to export");
+ zipAddDir($root . "config/", $zip, true, basename($root) . "/");
+ $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/owncloud.db");
+ }
+
+ if (isset($_POST['user_files'])) {
+ // adding user files
+ $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/.htaccess");
+ $zip->addFile($root . '/data/index.html', basename($root) . "/data/index.html");
+ foreach (OC_User::getUsers() as $i) {
+ error_log("Adding owncloud user files of $i to export");
+ zipAddDir($root . "data/" . $i, $zip, true, basename($root) . "/data/");
+ }
+ }
+
+ $zip->close();
+
+ header("Content-Type: application/zip");
+ header("Content-Disposition: attachment; filename=" . basename($filename));
+ header("Content-Length: " . filesize($filename));
+ ob_end_clean();
+ readfile($filename);
+ unlink($filename);
+} else {
+// fill template
+ $tmpl = new OC_Template('admin_export', 'settings');
+ return $tmpl->fetchPage();
+}
+
+function zipAddDir($dir, $zip, $recursive=true, $internalDir='') {
+ $dirname = basename($dir);
+ $zip->addEmptyDir($internalDir . $dirname);
+ $internalDir.=$dirname.='/';
+
+ if ($dirhandle = opendir($dir)) {
+ while (false !== ( $file = readdir($dirhandle))) {
+
+ if (( $file != '.' ) && ( $file != '..' )) {
+
+ if (is_dir($dir . '/' . $file) && $recursive) {
+ zipAddDir($dir . '/' . $file, $zip, $recursive, $internalDir);
+ } elseif (is_file($dir . '/' . $file)) {
+ $zip->addFile($dir . '/' . $file, $internalDir . $file);
+ }
+ }
+ }
+ closedir($dirhandle);
+ } else {
+ error_log("Was not able to open directory: " . $dir);
+ }
+}
diff --git a/apps/admin_export/templates/settings.php b/apps/admin_export/templates/settings.php
new file mode 100644
index 00000000000..47689facbbc
--- /dev/null
+++ b/apps/admin_export/templates/settings.php
@@ -0,0 +1,13 @@
+<form id="export" action="#" method="post">
+ <fieldset class="personalblock">
+ <legend><strong><?php echo $l->t('Export this ownCloud instance');?></strong></legend>
+ <p><?php echo $l->t('This will create a compressed file that contains the data of this owncloud instance.
+ Please choose which components should be included:');?>
+ </p>
+ <p><input type="checkbox" id="user_files" name="user_files" value="true"><label for="user_files"><?php echo $l->t('User files');?></label><br/>
+ <input type="checkbox" id="owncloud_system" name="owncloud_system" value="true"><label for="owncloud_system"><?php echo $l->t('ownCloud system files');?></label><br/>
+ <input type="checkbox" id="owncloud_config" name="owncloud_config" value="true"><label for="owncloud_config"><?php echo $l->t('ownCloud configuration');?></label>
+ </p>
+ <input type="submit" name="admin_export" value="Export" />
+ </fieldset>
+</form>
diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php
index b62fcdfbeb0..a2a39134eab 100644
--- a/apps/bookmarks/addBm.php
+++ b/apps/bookmarks/addBm.php
@@ -25,6 +25,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php
index 9b0beb388a0..0dc83d9014d 100644
--- a/apps/bookmarks/ajax/addBookmark.php
+++ b/apps/bookmarks/ajax/addBookmark.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php
index afe60f7d1bf..4aef86e771b 100644
--- a/apps/bookmarks/ajax/delBookmark.php
+++ b/apps/bookmarks/ajax/delBookmark.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
$params=array(
htmlspecialchars_decode($_GET["url"]),
diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php
index 5125f9ce898..b427a175e5f 100644
--- a/apps/bookmarks/ajax/editBookmark.php
+++ b/apps/bookmarks/ajax/editBookmark.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
diff --git a/apps/bookmarks/ajax/getMeta.php b/apps/bookmarks/ajax/getMeta.php
index 4583ef204b4..ca797315ef4 100644
--- a/apps/bookmarks/ajax/getMeta.php
+++ b/apps/bookmarks/ajax/getMeta.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
// $metadata = array();
diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php
index f5f7c20c6a0..e6fdfe043e1 100644
--- a/apps/bookmarks/ajax/recordClick.php
+++ b/apps/bookmarks/ajax/recordClick.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
$query = OC_DB::prepare("
UPDATE *PREFIX*bookmarks
diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php
index de3480d6c3a..8e9bda0bc20 100644
--- a/apps/bookmarks/ajax/updateList.php
+++ b/apps/bookmarks/ajax/updateList.php
@@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('bookmarks');
$params=array(OC_User::getUser());
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
diff --git a/apps/bookmarks/index.php b/apps/bookmarks/index.php
index 45c9a52f557..50fea3fddbd 100644
--- a/apps/bookmarks/index.php
+++ b/apps/bookmarks/index.php
@@ -25,6 +25,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('bookmarks');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php
index cbc4910e1ae..36f04e135b6 100644
--- a/apps/bookmarks/templates/addBm.php
+++ b/apps/bookmarks/templates/addBm.php
@@ -1,8 +1,8 @@
<div class="bookmarks_addBm">
- <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<? echo $_['URL']; ?>"/></p>
- <p><label class="bookmarks_label">Title</label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<? echo $_['TITLE']; ?>" /></p>
- <p><label class="bookmarks_label">Description</label><input type="text" id="bookmark_add_description" class="bookmarks_input" value="<? echo $_['DESCRIPTION']; ?>" /></p>
- <p><label class="bookmarks_label">Tags</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
- <p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
- <p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p>
-</div> \ No newline at end of file
+ <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('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<?php echo $_['TITLE']; ?>" /></p>
+ <p><label class="bookmarks_label"><?php echo $l->t('Description'); ?></label><input type="text" id="bookmark_add_description" class="bookmarks_input" value="<?php echo $_['DESCRIPTION']; ?>" /></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>
diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php
index 2aa5093c82b..d73657b36ac 100644
--- a/apps/bookmarks/templates/list.php
+++ b/apps/bookmarks/templates/list.php
@@ -1,30 +1,27 @@
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />
-<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? 'Bookmarks with tag: ' . urldecode($_GET["tag"]) : 'All bookmarks'; ?></h2>
+<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? $l->t('Bookmarks with tag: ') . urldecode($_GET["tag"]) : $l->t('All bookmarks'); ?></h2>
<div class="bookmarks_menu">
- <input type="button" class="bookmarks_addBtn" value="Add Bookmark"/>&nbsp;
- <a class="bookmarks_addBml" href="javascript:var url = encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks');" title="Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.">Add page to ownCloud</a>
+ <input type="button" class="bookmarks_addBtn" value="<?php echo $l->t('Add bookmark'); ?>"/>&nbsp;
+ <a class="bookmarks_addBml" href="javascript:var url = encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks');" title="<?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?>"><?php echo $l->t('Add page to ownCloud'); ?></a>
</div>
<div class="bookmarks_add">
<input type="hidden" id="bookmark_add_id" value="0" />
- <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p>
- <p><label class="bookmarks_label">Title</label><input type="text" id="bookmark_add_title" class="bookmarks_input" />
+ <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">Description</label><input type="text" id="bookmark_add_description" class="bookmarks_input" />
+ <p><label class="bookmarks_label"><?php echo $l->t('Description'); ?></label><input type="text" id="bookmark_add_description" class="bookmarks_input" />
<img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p>
- <p><label class="bookmarks_label">Tags</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
- <p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
- <p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></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>
<div class="bookmarks_sorting pager">
<ul>
- <li class="bookmarks_sorting_recent">Recent Bookmarks</li>
- <li class="bookmarks_sorting_clicks">Most clicks</li>
+ <li class="bookmarks_sorting_recent"><?php echo $l->t('Recent Bookmarks'); ?></li>
+ <li class="bookmarks_sorting_clicks"><?php echo $l->t('Most clicks'); ?></li>
</ul>
</div>
<div class="clear"></div>
<div class="bookmarks_list">
- <noscript>
- JavaScript is needed to display your Bookmarks
- </noscript>
- You have no bookmarks
+ <?php echo $l->t('You have no bookmarks'); ?>
</div>
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 38f727e9488..89239f21759 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -10,6 +10,7 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$cal = OC_Calendar_Calendar::findCalendar($calendarid);
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php
index d19a11585a0..b396ff4945b 100644
--- a/apps/calendar/ajax/changeview.php
+++ b/apps/calendar/ajax/changeview.php
@@ -10,6 +10,7 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+OC_JSON::checkAppEnabled('calendar');
$currentview = $_GET["v"];
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
?>
diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/choosecalendar.php
index 44ff22906f1..0935a4c42ad 100644
--- a/apps/calendar/ajax/choosecalendar.php
+++ b/apps/calendar/ajax/choosecalendar.php
@@ -11,6 +11,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+OC_JSON::checkAppEnabled('calendar');
$output = new OC_TEMPLATE("calendar", "part.choosecalendar");
$output -> printpage();
?>
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php
index 7d80333b258..82176d4368a 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/createcalendar.php
@@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
$userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], $_POST['description'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
diff --git a/apps/calendar/ajax/daysofweekend.php b/apps/calendar/ajax/daysofweekend.php
new file mode 100755
index 00000000000..606d13b1e1c
--- /dev/null
+++ b/apps/calendar/ajax/daysofweekend.php
@@ -0,0 +1,11 @@
+<?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"}');
+?>
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php
index 30607b92e6f..e8ffe0d0598 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/deletecalendar.php
@@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
+OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
$calendar = OC_Calendar_Calendar::findCalendar($cal);
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php
index a6750267bd2..9e3c7dd87dd 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/deleteevent.php
@@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
+OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
$data = OC_Calendar_Object::find($id);
diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php
new file mode 100644
index 00000000000..cdc41388abd
--- /dev/null
+++ b/apps/calendar/ajax/duration.php
@@ -0,0 +1,12 @@
+<?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));
+?>
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
index 8f798d1bbf2..5f61cf50135 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/editcalendar.php
@@ -11,9 +11,21 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+$calendarcolor_options = array(
+ 'ff0000', // "Red"
+ '00ff00', // "Green"
+ 'ffff00', // "Yellow"
+ '808000', // "Olive"
+ 'ffa500', // "Orange"
+ 'ff7f50', // "Coral"
+ 'ee82ee', // "Violet"
+ 'ecc255', // dark yellow
+);
+OC_JSON::checkAppEnabled('calendar');
$calendar = OC_Calendar_Calendar::findCalendar($_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();
?>
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index 7187e05d56f..3abf4de98b3 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
+OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 47008e02e90..34d6c657cec 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
+OC_JSON::checkAppEnabled('calendar');
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
@@ -28,9 +29,10 @@ if($calendar['userid'] != OC_User::getUser()){
$object = Sabre_VObject_Reader::read($data['calendardata']);
$vevent = $object->VEVENT;
$dtstart = $vevent->DTSTART;
-$dtend = $vevent->DTEND;
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch($dtstart->getDateType()) {
case Sabre_VObject_Element_DateTime::LOCALTZ:
+ case Sabre_VObject_Element_DateTime::LOCAL:
$startdate = $dtstart->getDateTime()->format('d-m-Y');
$starttime = $dtstart->getDateTime()->format('H:i');
$enddate = $dtend->getDateTime()->format('d-m-Y');
@@ -54,6 +56,11 @@ if (isset($vevent->CATEGORIES)){
$categories = explode(',', $vevent->CATEGORIES->value);
$categories = array_map('trim', $categories);
}
+foreach($categories as $category){
+ if (!in_array($category, $category_options)){
+ array_unshift($category_options, $category);
+ }
+}
$repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
$description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
diff --git a/apps/calendar/ajax/firstdayofweek.php b/apps/calendar/ajax/firstdayofweek.php
new file mode 100755
index 00000000000..eff82cece1d
--- /dev/null
+++ b/apps/calendar/ajax/firstdayofweek.php
@@ -0,0 +1,12 @@
+<?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));
+?> \ No newline at end of file
diff --git a/apps/calendar/ajax/getcal.php b/apps/calendar/ajax/getcal.php
index 9794a83ce49..a65c6cf2602 100644
--- a/apps/calendar/ajax/getcal.php
+++ b/apps/calendar/ajax/getcal.php
@@ -10,6 +10,61 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
-$output = new OC_TEMPLATE("calendar", "part.getcal");
-$output -> printpage();
-?>
+OC_JSON::checkAppEnabled('calendar');
+
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
+$events = array();
+$return = array('calendars'=>array());
+foreach($calendars as $calendar) {
+ $tmp = OC_Calendar_Object::all($calendar['id']);
+ $events = array_merge($events, $tmp);
+ $return['calendars'][$calendar['id']] = array(
+ 'displayname' => $calendar['displayname'],
+ 'color' => '#'.$calendar['calendarcolor']
+ );
+}
+
+$select_year = $_GET["year"];
+$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
+foreach($events as $event)
+{
+ if ($select_year != substr($event['startdate'], 0, 4))
+ continue;
+ $object = Sabre_VObject_Reader::read($event['calendardata']);
+ $vevent = $object->VEVENT;
+ $dtstart = $vevent->DTSTART;
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+ $start_dt = $dtstart->getDateTime();
+ $start_dt->setTimezone(new DateTimeZone($user_timezone));
+ $end_dt = $dtend->getDateTime();
+ $end_dt->setTimezone(new DateTimeZone($user_timezone));
+ $year = $start_dt->format('Y');
+ $month = $start_dt->format('n') - 1; // return is 0 based
+ $day = $start_dt->format('j');
+ $hour = $start_dt->format('G');
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE) {
+ $hour = 'allday';
+ }
+
+ $return_event = array();
+ foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop)
+ {
+ $return_event[$prop] = $event[$prop];
+ }
+ $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i'));
+ $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i'));
+ $return_event['description'] = $event['summary'];
+ if ($hour == 'allday')
+ {
+ $return_event['allday'] = true;
+ }
+ if (isset($return[$year][$month][$day][$hour]))
+ {
+ $return[$year][$month][$day][$hour][] = $return_event;
+ }
+ else
+ {
+ $return[$year][$month][$day][$hour] = array(1 => $return_event);
+ }
+}
+OC_JSON::encodedPrint($return);
diff --git a/apps/calendar/ajax/geteventinfo.php b/apps/calendar/ajax/geteventinfo.php
deleted file mode 100644
index 2e5e713c197..00000000000
--- a/apps/calendar/ajax/geteventinfo.php
+++ /dev/null
@@ -1,9 +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.
- */
-
-?>
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
new file mode 100644
index 00000000000..e2b777969da
--- /dev/null
+++ b/apps/calendar/ajax/moveevent.php
@@ -0,0 +1,103 @@
+<?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.
+ */
+error_reporting(E_ALL);
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+$data = OC_Calendar_Object::find($_POST["id"]);
+$calendarid = $data["calendarid"];
+$cal = $calendarid;
+$id = $_POST["id"];
+$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+if(OC_User::getUser() != $calendar["userid"]){
+ OC_JSON::error();
+ exit;
+}
+$newdate = $_POST["newdate"];
+$caldata = array();
+//modified part of editeventform.php
+$object = Sabre_VObject_Reader::read($data['calendardata']);
+$vevent = $object->VEVENT;
+$dtstart = $vevent->DTSTART;
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+switch($dtstart->getDateType()) {
+ case Sabre_VObject_Element_DateTime::LOCALTZ:
+ case Sabre_VObject_Element_DateTime::LOCAL:
+ $startdate = $dtstart->getDateTime()->format('d-m-Y');
+ $starttime = $dtstart->getDateTime()->format('H:i');
+ $enddate = $dtend->getDateTime()->format('d-m-Y');
+ $endtime = $dtend->getDateTime()->format('H:i');
+ $allday = false;
+ break;
+ case Sabre_VObject_Element_DateTime::DATE:
+ $startdate = $dtstart->getDateTime()->format('d-m-Y');
+ $starttime = '00:00';
+ $dtend->getDateTime()->modify('-1 day');
+ $enddate = $dtend->getDateTime()->format('d-m-Y');
+ $endtime = '23:59';
+ $allday = true;
+ break;
+}
+$caldata["title"] = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
+$caldata["location"] = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
+$caldata["categories"] = array();
+if (isset($vevent->CATEGORIES)){
+ $caldata["categories"] = explode(',', $vevent->CATEGORIES->value);
+ $caldata["categories"] = array_map('trim', $categories);
+}
+foreach($caldata["categories"] as $category){
+ if (!in_array($category, $category_options)){
+ array_unshift($category_options, $category);
+ }
+}
+$caldata["repeat"] = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
+$caldata["description"] = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
+//end part of editeventform.php
+$startdatearray = explode("-", $startdate);
+$starttimearray = explode(":", $starttime);
+$startunix = mktime($starttimearray[0], $starttimearray[1], 0, $startdatearray[1], $startdatearray[0], $startdatearray[2]);
+$enddatearray = explode("-", $enddate);
+$endtimearray = explode(":", $endtime);
+$endunix = mktime($endtimearray[0], $endtimearray[1], 0, $enddatearray[1], $enddatearray[0], $enddatearray[2]);
+$difference = $endunix - $startunix;
+if(strlen($newdate) > 10){
+ $newdatestringarray = explode("-", $newdate);
+ if($newdatestringarray[1] == "allday"){
+ $allday = true;
+ $newdatestringarray[1] = "00:00";
+ }else{
+ if($allday == true){
+ $difference = 3600;
+ }
+ $allday = false;
+ }
+}else{
+ $newdatestringarray = array();
+ $newdatestringarray[0] = $newdate;
+ $newdatestringarray[1] = $starttime;
+}
+$newdatearray = explode(".", $newdatestringarray[0]);
+$newtimearray = explode(":", $newdatestringarray[1]);
+$newstartunix = mktime($newtimearray[0], $newtimearray[1], 0, $newdatearray[1], $newdatearray[0], $newdatearray[2]);
+$newendunix = $newstartunix + $difference;
+if($allday == true){
+ $caldata["allday"] = true;
+}else{
+ unset($caldata["allday"]);
+}
+$caldata["from"] = date("d-m-Y", $newstartunix);
+$caldata["fromtime"] = date("H:i", $newstartunix);
+$caldata["to"] = date("d-m-Y", $newendunix);
+$caldata["totime"] = date("H:i", $newendunix);
+//modified part of editevent.php
+$vcalendar = Sabre_VObject_Reader::read($data["calendardata"]);
+OC_Calendar_Object::updateVCalendarFromRequest($caldata, $vcalendar);
+
+$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+OC_JSON::success();
+//end part of editevent.php
+?> \ No newline at end of file
diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/newcalendar.php
index ffcffb8afd7..e01ae01ee8a 100644
--- a/apps/calendar/ajax/newcalendar.php
+++ b/apps/calendar/ajax/newcalendar.php
@@ -11,11 +11,12 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+OC_JSON::checkAppEnabled('calendar');
$calendar = array(
'id' => 'new',
- 'displayname' => 'Test',
- 'description' => 'Test calendar',
- 'calendarcolor' => 'black',
+ 'displayname' => '',
+ 'description' => '',
+ 'calendarcolor' => '',
);
$tmpl = new OC_Template('calendar', 'part.editcalendar');
$tmpl->assign('new', true);
diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php
index 9ac3b0aaff6..1a696cf7780 100644
--- a/apps/calendar/ajax/newevent.php
+++ b/apps/calendar/ajax/newevent.php
@@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 7a4c6f469e5..9d4dcfa2e13 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
+OC_JSON::checkAppEnabled('calendar');
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
@@ -28,21 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
$starttime = '0';
$startminutes = '00';
}else{
- $starttime = date('H');
+ $starttime = date('G');
+
$startminutes = date('i');
}
-$endday = $startday;
-$endmonth = $startmonth;
-$endyear = $startyear;
-$endtime = $starttime;
-$endminutes = $startminutes;
-if($endtime == 23) {
- $endday++;
- $endtime = 0;
-} else {
- $endtime++;
-}
+$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
+$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
+$datetimestamp = $datetimestamp + ($duration * 60);
+$endmonth = date("m", $datetimestamp);
+$endday = date("d", $datetimestamp);
+$endyear = date("Y", $datetimestamp);
+$endtime = date("G", $datetimestamp);
+$endminutes = date("i", $datetimestamp);
+
+
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
diff --git a/apps/calendar/ajax/setdaysofweekend.php b/apps/calendar/ajax/setdaysofweekend.php
new file mode 100755
index 00000000000..b5ef5f8573f
--- /dev/null
+++ b/apps/calendar/ajax/setdaysofweekend.php
@@ -0,0 +1,30 @@
+<?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();
+?>
diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php
new file mode 100644
index 00000000000..a75c8faea42
--- /dev/null
+++ b/apps/calendar/ajax/setduration.php
@@ -0,0 +1,17 @@
+<?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();
+}
+?>
+
diff --git a/apps/calendar/ajax/setfirstdayofweek.php b/apps/calendar/ajax/setfirstdayofweek.php
new file mode 100755
index 00000000000..571b95af0e3
--- /dev/null
+++ b/apps/calendar/ajax/setfirstdayofweek.php
@@ -0,0 +1,16 @@
+<?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();
+}
+?>
diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php
new file mode 100644
index 00000000000..7805120ba5e
--- /dev/null
+++ b/apps/calendar/ajax/settimeformat.php
@@ -0,0 +1,17 @@
+<?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["timeformat"])){
+ OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
+ OC_JSON::success();
+}else{
+ OC_JSON::error();
+}
+?>
+
diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php
index 2b82bc8e4bc..c726a11471d 100644
--- a/apps/calendar/ajax/settimezone.php
+++ b/apps/calendar/ajax/settimezone.php
@@ -13,6 +13,7 @@ $l=new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
// Get data
if( isset( $_POST['timezone'] ) ){
diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/timeformat.php
new file mode 100644
index 00000000000..3533adcf8e0
--- /dev/null
+++ b/apps/calendar/ajax/timeformat.php
@@ -0,0 +1,12 @@
+<?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();
+$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
+OC_JSON::encodedPrint(array("timeformat" => $timeformat));
+?>
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php
index d53515d0deb..5cf48d50ea1 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['id'];
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']);
diff --git a/apps/calendar/caldav.php b/apps/calendar/caldav.php
index 83f6a5ab51d..b581274398d 100644
--- a/apps/calendar/caldav.php
+++ b/apps/calendar/caldav.php
@@ -10,6 +10,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('calendar');
// Backends
$authBackend = new OC_Connector_Sabre_Auth();
diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css
index f1bd0f9a9c4..5e19b88f55a 100644
--- a/apps/calendar/css/style.css
+++ b/apps/calendar/css/style.css
@@ -45,6 +45,7 @@
.weekend_thead, .weekend_row{height: 20px;text-align: center;text-align: center;background: #F3F3F3;}
.thisday{background: #FFFABC;}
.event {position:relative;}
+.event.colored {border-bottom: 1px solid white;}
.popup {display: none; position: absolute; z-index: 1000; background: #eeeeee; color: #000000; border: 1px solid #1a1a1a; font-size: 90%;}
.event_popup {width: 280px; height: 40px; padding: 10px;}
@@ -57,3 +58,6 @@ color:#A9A9A9;
}
select#category{width:140px;}
button.category{margin:0 3px;}
+
+.calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;}
+.calendar-colorpicker-color.active{background-image:url("../../../core/img/jquery-ui/ui-icons_222222_256x240.png");background-position:-62px -143px;}
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index a6fdaba1d2f..b3e5ecd6834 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -8,16 +8,31 @@
require_once ("../../lib/base.php");
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('calendar');
$cal = $_GET["calid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
- header( 'Location: '.OC_Helper::linkTo('', 'index.php'));
- exit;
-}
-$calobjects = OC_Calendar_Object::all($cal);
-header("Content-Type: text/Calendar");
-header("Content-Disposition: inline; filename=calendar.ics");
-for($i = 0;$i <= count($calobjects); $i++){
- echo $calobjects[$i]["calendardata"] . "\n";
+$event = $_GET["eventid"];
+if(isset($cal)){
+ $calendar = OC_Calendar_Calendar::findCalendar($cal);
+ if($calendar["userid"] != OC_User::getUser()){
+ OC_JSON::error();
+ exit;
+ }
+ $calobjects = OC_Calendar_Object::all($cal);
+ header("Content-Type: text/Calendar");
+ header("Content-Disposition: inline; filename=calendar.ics");
+ for($i = 0;$i <= count($calobjects); $i++){
+ echo $calobjects[$i]["calendardata"] . "\n";
+ }
+}elseif(isset($event)){
+ $data = OC_Calendar_Object::find($_GET["eventid"]);
+ $calendarid = $data["calendarid"];
+ $calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+ if($calendar["userid"] != OC_User::getUser()){
+ OC_JSON::error();
+ exit;
+ }
+ header("Content-Type: text/Calendar");
+ header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
+ echo $data["calendardata"];
}
?>
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index 39f961d1bb9..1e4d724b307 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -8,6 +8,7 @@
require_once ('../../lib/base.php');
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('calendar');
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if( count($calendars) == 0){
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 1b345452912..131325007a0 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -8,6 +8,8 @@
Calendar={
space:' ',
+ firstdayofweek: '',
+ weekend: '',
Date:{
normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
@@ -79,7 +81,7 @@ Calendar={
},
UI:{
- weekdays: ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"],
+ weekdays: '',
formatDayShort:function(day){
if (typeof(day) == 'undefined'){
day = Calendar.Date.current.getDay();
@@ -124,7 +126,7 @@ Calendar={
$('#'+this.currentview + "_radio").removeClass('active');
this.currentview = view;
//sending ajax request on every change view
- $("#sysbox").load(oc_webroot + "/apps/calendar/ajax/changeview.php?v="+view);
+ $("#sysbox").load(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view);
//not necessary to check whether the response is true or not
switch(view) {
case "onedayview":
@@ -153,6 +155,7 @@ Calendar={
Calendar.UI.updateView()
});
},
+ drageventid: '',
updateDate:function(direction){
if(direction == 'forward' && this.current.forward) {
this.current.forward();
@@ -178,18 +181,19 @@ Calendar={
if( typeof (this.events[year]) == "undefined") {
this.events[year] = []
}
- $.getJSON(oc_webroot + "/apps/calendar/ajax/getcal.php?year=" + year, function(newevents, status) {
+ $.getJSON(OC.filePath('calendar', 'ajax', 'getcal.php') + "?year=" + year, function(jsondata, status) {
if(status == "nosession") {
alert("You are not logged in. That can happen if you don't use owncloud for a long time.");
document.location(oc_webroot);
}
- if(status == "parsingfail" || typeof (newevents) == "undefined") {
+ if(status == "parsingfail" || typeof (jsondata) == "undefined") {
$.ready(function() {
$( "#parsingfail_dialog" ).dialog();
});
} else {
- if (typeof(newevents[year]) != 'undefined'){
- Calendar.UI.events[year] = newevents[year];
+ if (typeof(jsondata[year]) != 'undefined'){
+ Calendar.UI.calendars = jsondata['calendars'];
+ Calendar.UI.events[year] = jsondata[year];
}
$(document).ready(function() {
Calendar.UI.updateView();
@@ -218,7 +222,7 @@ Calendar={
if (!events) {
return;
}
- var weekday = (date.getDay()+6)%7;
+ var weekday = (date.getDay()+7-Calendar.firstdayofweek)%7;
if( typeof (events["allday"]) != "undefined") {
var eventnumber = 1;
var eventcontainer = this.current.getEventContainer(week, weekday, "allday");
@@ -244,7 +248,17 @@ Calendar={
.data('event_info', event)
.hover(this.createEventPopup,
this.hideEventPopup)
+ .draggable({
+ drag: function() {
+ Calendar.UI.drageventid = event.id;
+ }
+ })
.click(this.editEvent);
+ var color = this.calendars[event['calendarid']]['color'];
+ if (color){
+ event_holder.css('background-color', color)
+ .addClass('colored');
+ }
eventcontainer.append(event_holder);
},
startEventDialog:function(){
@@ -286,7 +300,7 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
- $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
+ $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php') + '?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
}
},
editEvent:function(event){
@@ -297,12 +311,12 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
- $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, Calendar.UI.startEventDialog);
+ $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog);
}
},
submitDeleteEventForm:function(url){
var post = $( "#event_form" ).serialize();
- $("#errorbox").html("");
+ $("#errorbox").empty();
$.post(url, post, function(data){
if(data.status == 'success'){
$('#event').dialog('destroy').remove();
@@ -315,7 +329,7 @@ Calendar={
},
validateEventForm:function(url){
var post = $( "#event_form" ).serialize();
- $("#errorbox").html("");
+ $("#errorbox").empty();
$.post(url, post,
function(data){
if(data.status == "error"){
@@ -352,6 +366,12 @@ Calendar={
}
},"json");
},
+ moveevent:function(eventid, newstartdate){
+ $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate},
+ function(data) {
+ console.log("Event moved successfully");
+ });
+ },
showadvancedoptions:function(){
$("#advanced_options").css("display", "block");
$("#advanced_options_button").css("display", "none");
@@ -425,7 +445,7 @@ Calendar={
if(check == false){
return false;
}else{
- $.post(oc_webroot + "/apps/calendar/ajax/deletecalendar.php", { calendarid: calid},
+ $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
function(data) {
Calendar.UI.loadEvents();
$('#choosecalendar_dialog').dialog('destroy').remove();
@@ -438,7 +458,7 @@ Calendar={
if($('#choosecalendar_dialog').dialog('isOpen') == true){
$('#choosecalendar_dialog').dialog('moveToTop');
}else{
- $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/choosecalendar.php', function(){
+ $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){
$('#choosecalendar_dialog').dialog({
width : 600,
close : function(event, ui) {
@@ -450,7 +470,7 @@ Calendar={
},
activation:function(checkbox, calendarid)
{
- $.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 },
+ $.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
checkbox.checked = data == 1;
Calendar.UI.loadEvents();
@@ -458,14 +478,43 @@ Calendar={
},
newCalendar:function(object){
var tr = $(document.createElement('tr'))
- .load(oc_webroot + "/apps/calendar/ajax/newcalendar.php");
+ .load(OC.filePath('calendar', 'ajax', 'newcalendar.php'));
$(object).closest('tr').after(tr).hide();
},
edit:function(object, calendarid){
var tr = $(document.createElement('tr'))
- .load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid);
+ .load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid,
+ function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
+ colorPicker:function(container){
+ // based on jquery-colorpicker at jquery.webspirited.com
+ var obj = $('.colorpicker', container);
+ var picker = $('<div class="calendar-colorpicker"></div>');
+ var size = 20;
+
+ //build an array of colors
+ var colors = {};
+ $(obj).children('option').each(function(i, elm) {
+ colors[i] = {};
+ colors[i].color = $(elm).val();
+ colors[i].label = $(elm).text();
+ });
+ for (var i in colors) {
+ picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + '; width: ' + size + 'px; height: ' + size + 'px;"></span>');
+ }
+ picker.delegate(".calendar-colorpicker-color", "click", function() {
+ $(obj).val($(this).attr('rel'));
+ $(obj).change();
+ picker.children('.calendar-colorpicker-color.active').removeClass('active');
+ $(this).addClass('active');
+ });
+ $(obj).after(picker);
+ $(obj).css({
+ position: 'absolute',
+ left: -10000
+ });
+ },
submit:function(button, calendarid){
var displayname = $("#displayname_"+calendarid).val();
var active = $("#edit_active_"+calendarid+":checked").length;
@@ -490,7 +539,7 @@ Calendar={
cancel:function(button, calendarid){
$(button).closest('tr').prev().show().next().remove();
},
- },
+ },/*
OneDay:{
forward:function(){
Calendar.Date.forward_day();
@@ -499,7 +548,7 @@ Calendar={
Calendar.Date.backward_day();
},
removeEvents:function(){
- $("#onedayview .calendar_row").html("");
+ $("#onedayview .calendar_row").empty();
},
renderCal:function(){
$("#datecontrol_date").val(Calendar.UI.formatDayShort() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort() + Calendar.space + Calendar.Date.current.getFullYear());
@@ -520,7 +569,7 @@ Calendar={
return $(document.createElement('p'))
.html(time + event['description'])
},
- },
+ },*/
OneWeek:{
forward:function(){
Calendar.Date.forward_week();
@@ -530,7 +579,7 @@ Calendar={
},
removeEvents:function(){
for( i = 0; i <= 6; i++) {
- $("#oneweekview ." + Calendar.UI.weekdays[i]).html("");
+ $("#oneweekview ." + Calendar.UI.weekdays[i]).empty();
}
$("#oneweekview .thisday").removeClass("thisday");
},
@@ -539,7 +588,23 @@ Calendar={
var dates = this.generateDates();
var today = new Date();
for(var i = 0; i <= 6; i++){
- $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+1)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
+ $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
+ $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + "allday");
+ $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").droppable({
+ drop: function() {
+ Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+ Calendar.UI.loadEvents();
+ }
+ });
+ for(var ii = 0;ii <= 23; ii++){
+ $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + String(ii) + ":00");
+ $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).droppable({
+ drop: function() {
+ Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+ Calendar.UI.loadEvents();
+ }
+ });
+ }
if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
$("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
}
@@ -570,14 +635,18 @@ Calendar={
if(dayofweek == 0) {
dayofweek = 7;
}
- date.setDate(date.getDate() - dayofweek + 1);
+ if(Calendar.firstdayofweek > dayofweek){
+ date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
+ }else{
+ date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
+ }
for(var i = 0; i <= 6; i++) {
dates[i] = new Date(date)
date.setDate(date.getDate() + 1);
}
return dates;
},
- },
+ },/*
FourWeeks:{
forward:function(){
Calendar.Date.forward_week();
@@ -587,7 +656,7 @@ Calendar={
},
removeEvents:function(){
$('#fourweeksview .day.thisday').removeClass('thisday');
- $('#fourweeksview .day .events').html('');
+ $('#fourweeksview .day .events').empty();
},
renderCal:function(){
var calw1 = Calendar.Date.calw();
@@ -674,7 +743,7 @@ Calendar={
}
return dates;
},
- },
+ },*/
OneMonth:{
forward:function(){
Calendar.Date.forward_month();
@@ -684,7 +753,7 @@ Calendar={
},
removeEvents:function(){
$('#onemonthview .day.thisday').removeClass('thisday');
- $('#onemonthview .day .events').html('');
+ $('#onemonthview .day .events').empty();
},
renderCal:function(){
$("#datecontrol_date").val(Calendar.UI.formatMonthLong() + Calendar.space + Calendar.Date.current.getFullYear());
@@ -712,6 +781,13 @@ Calendar={
var month = dates[i].getMonth();
var year = dates[i].getFullYear();
$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
+ $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).attr('title', dayofmonth + "." + String(parseInt(month) + 1) + "." + year);
+ $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).droppable({
+ drop: function() {
+ Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
+ Calendar.UI.loadEvents();
+ }
+ });
if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
$("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
}
@@ -776,7 +852,11 @@ Calendar={
dayofweek = 7;
this.rows++;
}
- date.setDate(date.getDate() - dayofweek + 1);
+ if(Calendar.firstdayofweek > dayofweek){
+ date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
+ }else{
+ date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
+ }
for(var i = 0; i <= 41; i++) {
dates[i] = new Date(date)
date.setDate(date.getDate() + 1);
@@ -786,7 +866,7 @@ Calendar={
},
List:{
removeEvents:function(){
- this.eventContainer = $('#listview #events').html('');
+ this.eventContainer = $('#listview #events').empty();
this.startdate = new Date();
this.enddate = new Date();
this.enddate.setDate(this.enddate.getDate());
diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js
index 90876389858..6c00be06b39 100644
--- a/apps/calendar/js/settings.js
+++ b/apps/calendar/js/settings.js
@@ -3,9 +3,61 @@ $(document).ready(function(){
OC.msg.startSaving('#calendar .msg')
// Serialize the data
var post = $( "#timezone" ).serialize();
- $.post( oc_webroot + '/apps/calendar/ajax/settimezone.php', post, function(data){
- OC.msg.finishedSaving('#calendar .msg', data);
+ $.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();
+ $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
+ 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");
+ }
+ });
+ });
+ $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) {
+ $("#duration").val(jsondata.duration);
+ });
+ $("#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");
+ }
+ });
+ });
});
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 0c7649776d5..0c3e497d4f2 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -286,6 +286,30 @@ class OC_Calendar_Object{
}
}
+ public static function getDTEndFromVEvent($vevent)
+ {
+ if ($vevent->DTEND) {
+ $dtend = $vevent->DTEND;
+ }else{
+ $dtend = clone $vevent->DTSTART;
+ if ($vevent->DURATION){
+ $duration = strval($vevent->DURATION);
+ $invert = 0;
+ if ($duration[0] == '-'){
+ $duration = substr($duration, 1);
+ $invert = 1;
+ }
+ if ($duration[0] == '+'){
+ $duration = substr($duration, 1);
+ }
+ $interval = new DateInterval($duration);
+ $interval->invert = $invert;
+ $dtend->getDateTime()->add($interval);
+ }
+ }
+ return $dtend;
+ }
+
public static function getCategoryOptions($l10n)
{
return array(
@@ -482,6 +506,7 @@ class OC_Calendar_Object{
}
$vevent->DTSTART = $dtstart;
$vevent->DTEND = $dtend;
+ unset($vevent->DURATION);
if($location != ""){
$vevent->LOCATION = $location;
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index a185d3e7087..317bb17ddbc 100644
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -1,5 +1,5 @@
<?php
-$hours = array(
+$hours24 = array(
'allday' => $l->t('All day'),
0 => '0',
1 => '1',
@@ -26,9 +26,58 @@ $hours = array(
22 => '22',
23 => '23',
);
-$weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
+$hoursampm = array(
+ 'allday' => $l->t('All day'),
+ 0 => '12 a.m.',
+ 1 => '1 a.m.',
+ 2 => '2 a.m.',
+ 3 => '3 a.m.',
+ 4 => '4 a.m.',
+ 5 => '5 a.m.',
+ 6 => '6 a.m.',
+ 7 => '7 a.m.',
+ 8 => '8 a.m.',
+ 9 => '9 a.m.',
+ 10 => '10 a.m.',
+ 11 => '11 a.m.',
+ 12 => '12 p.m.',
+ 13 => '1 p.m.',
+ 14 => '2 p.m.',
+ 15 => '3 p.m.',
+ 16 => '4 p.m.',
+ 17 => '5 p.m.',
+ 18 => '6 p.m.',
+ 19 => '7 p.m.',
+ 20 => '8 p.m.',
+ 21 => '9 p.m.',
+ 22 => '10 p.m.',
+ 23 => '11 p.m.',
+);
+if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){
+ $hours = $hours24;
+}else{
+ $hours = $hoursampm;
+}
+$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
+$weekdays = array();
+for($i = 0;$i <= 6; $i++){
+ $weekdays[$i] = $weekdaynames[$dayforgenerator];
+ if($dayforgenerator == 6){
+ $dayforgenerator = 0;
+ }else{
+ $dayforgenerator++;
+ }
+}
+$weekendjson = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}');
+$weekend = json_decode($weekendjson, true);
+$weekenddays = array("sunday"=>$weekend["Sunday"], "monday"=>$weekend["Monday"], "tuesday"=>$weekend["Tuesday"], "wednesday"=>$weekend["Wednesday"], "thursday"=>$weekend["Thursday"], "friday"=>$weekend["Friday"], "saturday"=>$weekend["Saturday"]);
?>
<script type="text/javascript">
+ <?php
+ echo "var weekdays = new Array('".$weekdays[0]."','".$weekdays[1]."','".$weekdays[2]."','".$weekdays[3]."','".$weekdays[4]."','".$weekdays[5]."','".$weekdays[6]."');\n";
+ ?>
+ Calendar.UI.weekdays = weekdays;
Calendar.UI.daylong = new Array("<?php echo $l -> t("Sunday");?>", "<?php echo $l -> t("Monday");?>", "<?php echo $l -> t("Tuesday");?>", "<?php echo $l -> t("Wednesday");?>", "<?php echo $l -> t("Thursday");?>", "<?php echo $l -> t("Friday");?>", "<?php echo $l -> t("Saturday");?>");
Calendar.UI.dayshort = new Array("<?php echo $l -> t("Sun.");?>", "<?php echo $l -> t("Mon.");?>", "<?php echo $l -> t("Tue.");?>", "<?php echo $l -> t("Wed.");?>", "<?php echo $l -> t("Thu.");?>", "<?php echo $l -> t("Fri.");?>", "<?php echo $l -> t("Sat.");?>");
Calendar.UI.monthlong = new Array("<?php echo $l -> t("January");?>", "<?php echo $l -> t("February");?>", "<?php echo $l -> t("March");?>", "<?php echo $l -> t("April");?>", "<?php echo $l -> t("May");?>", "<?php echo $l -> t("June");?>", "<?php echo $l -> t("July");?>", "<?php echo $l -> t("August");?>", "<?php echo $l -> t("September");?>", "<?php echo $l -> t("October");?>", "<?php echo $l -> t("November");?>", "<?php echo $l -> t("December");?>");
@@ -37,6 +86,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
Calendar.UI.cws_label = "<?php echo $l->t("Weeks");?>";
Calendar.UI.more_before = String('<?php echo $l->t('More before {startdate}') ?>');
Calendar.UI.more_after = String('<?php echo $l->t('More after {enddate}') ?>');
+ Calendar.firstdayofweek = parseInt("<?php echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); ?>");
//use last view as default on the next
Calendar.UI.setCurrentView("<?php echo OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") ?>");
var totalurl = "<?php echo OC_Helper::linkTo('calendar', 'caldav.php', null, true) . '/calendars'; ?>";
@@ -93,7 +143,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
<tr>
<th class="calendar_time"><?php echo $l->t("Time");?></th>
<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <th class="calendar_row <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th>
+ <th class="calendar_row <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th>
<?php endforeach; ?>
</tr>
</thead>
@@ -102,7 +152,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
<tr>
<td class="calendar_time"><?php echo $time_label?></td>
<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekdaynr > 4 ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td>
+ <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
@@ -139,7 +189,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
<thead>
<tr>
<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <th class="calendar_row <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th>
+ <th class="calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th>
<?php endforeach; ?>
</tr>
</thead>
@@ -147,7 +197,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur
<?php foreach(range(1, 6) as $week): ?>
<tr class="week_<?php echo $week ?>">
<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <td class="day <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')">
+ <td class="day <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')">
<div class="dateinfo"></div>
<div class="events"></div>
</td>
diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php
index 9495e7192bb..65eb39cbfdf 100644
--- a/apps/calendar/templates/part.choosecalendar.php
+++ b/apps/calendar/templates/part.choosecalendar.php
@@ -11,12 +11,12 @@ for($i = 0; $i < count($option_calendars); $i++){
}
?>
<tr>
- <td colspan="4">
+ <td colspan="6">
<a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><?php echo $l->t('New Calendar') ?></a>
</td>
</tr>
<tr>
- <td colspan="4">
+ <td colspan="6">
<p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="caldav_url" onmouseover="$('#caldav_url').select();" title="<?php echo $l->t("CalDav Link"); ?>"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#caldav_url').hide();$('#caldav_url_close').hide();"/></p>
</td>
</tr>
diff --git a/apps/calendar/templates/part.editcalendar.php b/apps/calendar/templates/part.editcalendar.php
index b5c786f63c1..c2c22913bee 100644
--- a/apps/calendar/templates/part.editcalendar.php
+++ b/apps/calendar/templates/part.editcalendar.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
?>
-<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>calendar_dialog" title="<?php echo $_['new'] ? $l->t("New calendar") : $l->t("Edit calendar"); ?>" colspan="4">
+<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>calendar_dialog" title="<?php echo $_['new'] ? $l->t("New calendar") : $l->t("Edit calendar"); ?>" colspan="6">
<table width="100%" style="border: 0;">
<tr>
<th><?php echo $l->t('Displayname') ?></th>
@@ -34,7 +34,14 @@
<tr>
<th><?php echo $l->t('Calendar color') ?></th>
<td>
- <input id="calendarcolor_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['calendarcolor'] ?>">
+ <select id="calendarcolor_<?php echo $_['calendar']['id'] ?>" class="colorpicker">
+ <?php
+ if (!isset($_['calendar']['calendarcolor'])) {$_['calendar']['calendarcolor'] = false;}
+ foreach($_['calendarcolor_options'] as $color){
+ echo '<option value="' . $color . '"' . ($_['calendar']['calendarcolor'] == $color ? ' selected="selected"' : '') . '>' . $color . '</option>';
+ }
+ ?>
+ </select>
</td>
</tr>
</table>
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index be637aeae55..ae969f2dc3b 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -6,6 +6,7 @@
<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: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
</span>
</form>
</div>
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index 4c34b3e1fcc..8588b9168f7 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -12,8 +12,8 @@
<td>
<select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
<?php
+ if (!isset($_['categories'])) {$_['categories'] = array();}
foreach($_['category_options'] as $category){
- if (!isset($_['categories'])) {$_['categories'] = array();}
echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>';
}
?>
@@ -22,8 +22,8 @@
<td>
<select style="width:140px;" name="calendar">
<?php
+ if (!isset($_['calendar'])) {$_['calendar'] = false;}
foreach($_['calendar_options'] as $calendar){
- if (!isset($_['calendar'])) {$_['calendar'] = false;}
echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>';
}
?>
diff --git a/apps/calendar/templates/part.getcal.php b/apps/calendar/templates/part.getcal.php
deleted file mode 100644
index 900a43b3df2..00000000000
--- a/apps/calendar/templates/part.getcal.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?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.
- */
-
-$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
-$events = array();
-foreach($calendars as $calendar) {
- $tmp = OC_Calendar_Object::all($calendar['id']);
- $events = array_merge($events, $tmp);
-}
-$select_year = $_GET["year"];
-$return_events = array();
-$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
-foreach($events as $event)
-{
- if ($select_year != substr($event['startdate'], 0, 4))
- continue;
- $start_dt = new DateTime($event['startdate'], new DateTimeZone('UTC'));
- $start_dt->setTimezone(new DateTimeZone($user_timezone));
- $end_dt = new DateTime($event['enddate'], new DateTimeZone('UTC'));
- $end_dt->setTimezone(new DateTimeZone($user_timezone));
- $year = $start_dt->format('Y');
- $month = $start_dt->format('n') - 1; // return is 0 based
- $day = $start_dt->format('j');
- $hour = $start_dt->format('G');
-
- // hack
- if (strstr($event['calendardata'], 'DTSTART;VALUE=DATE:')) {
- $hour = 'allday';
- }
- $return_event = array();
- foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop)
- {
- $return_event[$prop] = $event[$prop];
- }
- $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i'));
- $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i'));
- $return_event['description'] = $event['summary'];
- if ($hour == 'allday')
- {
- $return_event['allday'] = true;
- }
- if (isset($return_events[$year][$month][$day][$hour]))
- {
- $return_events[$year][$month][$day][$hour][] = $return_event;
- }
- else
- {
- $return_events[$year][$month][$day][$hour] = array(1 => $return_event);
- }
-}
-OC_JSON::encodedPrint($return_events);
-?>
diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php
index ac13b2aa402..44fbb230a43 100644
--- a/apps/calendar/templates/settings.php
+++ b/apps/calendar/templates/settings.php
@@ -1,15 +1,18 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
+ * 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.
*/
+OC_UTIL::addScript('', 'jquery.multiselect');
+OC_UTIL::addStyle('', 'jquery.multiselect');
?>
<form id="calendar">
<fieldset class="personalblock">
<label for="timezone"><strong><?php echo $l->t('Timezone');?></strong></label>
- <select id="timezone" name="timezone">
+ <select style="display: none;" id="timezone" name="timezone">
<?php
$continent = '';
foreach($_['timezones'] as $timezone):
@@ -24,6 +27,34 @@
echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>';
endif;
endforeach;?>
- </select><span class="msg"></span>
+ </select>&nbsp;&nbsp;
+ <label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label>
+ <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat">
+ <option value="24" id="24h"><?php echo $l->t("24h"); ?></option>
+ <option value="ampm" id="ampm"><?php echo $l->t("12h"); ?></option>
+ </select><br />
+ <label for="firstdayofweek"><strong><?php echo $l->t('First day of the week');?></strong></label>
+ <select style="display: none;" id="firstdayofweek" name="firstdayofweek">
+ <?php
+ $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+ for($i = 0;$i <= 6;$i++){
+ echo '<option value="'.$i.'" id="select_'.$i.'">' . $l->t($weekdays[$i]) . '</option>';
+ }
+ ?>
+ </select><br />
+ <label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label>
+ <select id="weekend" name="weekend[]" style="width: 50%;" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>">
+ <?php
+ $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+ for($i = 0;$i <= 6;$i++){
+ echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>';
+ }
+ ?>
+ </select><br />
+ <label for="duration"><strong><?php echo $l->t('Event duration');?></strong></label>
+ <input type="text" maxlength="3" size="3" style="width: 2em;" id="duration" name="duration" /> <?php echo $l->t("Minutes");?>
+ <br />
+ <?php echo $l->t('Calendar CalDAV syncing address:');?>
+ <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br />
</fieldset>
</form>
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index cfae3327f56..ee95513732d 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_Addressbook::find( $aid );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 5a37f77f858..0b218c6298f 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php
index 13be33eb5a9..c13217ef2e2 100644
--- a/apps/contacts/ajax/deletebook.php
+++ b/apps/contacts/ajax/deletebook.php
@@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_Addressbook::find( $id );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index c69638320ed..a0a6b8c3ea8 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 40b765cf845..0a3a3c293a0 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -31,6 +31,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php
index 47d88a771e6..0e76de61afb 100644
--- a/apps/contacts/ajax/getdetails.php
+++ b/apps/contacts/ajax/getdetails.php
@@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index b4fc2162d90..18e00872473 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 58567392d7c..2f534f0fe2d 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -27,6 +27,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php
index 0d01b37d8ef..f87cd05359b 100644
--- a/apps/contacts/ajax/showaddproperty.php
+++ b/apps/contacts/ajax/showaddproperty.php
@@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php
index 0b30a8e68ec..6188f4773c3 100644
--- a/apps/contacts/ajax/showsetproperty.php
+++ b/apps/contacts/ajax/showsetproperty.php
@@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 98416ead2fc..fc7b3769c53 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -17,3 +17,6 @@ OC_App::addNavigationEntry( array(
'href' => OC_Helper::linkTo( 'contacts', 'index.php' ),
'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ),
'name' => 'Contacts' ));
+
+
+OC_APP::registerPersonal('contacts','settings');
diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php
index b17a9395355..df7c858b1a0 100644
--- a/apps/contacts/carddav.php
+++ b/apps/contacts/carddav.php
@@ -24,6 +24,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('contacts');
// Backends
$authBackend = new OC_Connector_Sabre_Auth();
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index c9cf348dfd7..7e8eb8e6951 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -29,6 +29,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('contacts');
// Check if the user has an addressbook
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js
index 66ee6772198..3ec84a3c8ba 100644
--- a/apps/contacts/js/interface.js
+++ b/apps/contacts/js/interface.js
@@ -34,7 +34,7 @@ $(document).ready(function(){
if(jsondata.status == 'success'){
$('#leftcontent [data-id="'+jsondata.data.id+'"]').remove();
$('#rightcontent').data('id','');
- $('#rightcontent').html('');
+ $('#rightcontent').empty();
}
else{
alert(jsondata.data.message);
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 7ba2002b13d..5178fe7a078 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -22,18 +22,13 @@
// Init owncloud
require_once('../../lib/base.php');
+OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('contacts');
$id = $_GET['id'];
$l10n = new OC_L10N('contacts');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo $l10n->t('You need to log in.');
- exit();
-}
-
-
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
echo $l10n->t('Contact could not be found.');
diff --git a/apps/contacts/settings.php b/apps/contacts/settings.php
new file mode 100644
index 00000000000..b88128823a7
--- /dev/null
+++ b/apps/contacts/settings.php
@@ -0,0 +1,6 @@
+<?php
+
+$tmpl = new OC_Template( 'contacts', 'settings');
+
+return $tmpl->fetchPage();
+?>
diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php
new file mode 100644
index 00000000000..f5c37c5a044
--- /dev/null
+++ b/apps/contacts/templates/settings.php
@@ -0,0 +1,7 @@
+<form id="mediaform">
+ <fieldset class="personalblock">
+ <strong>Contacts</strong><br />
+ CardDAV syncing address:
+ <?php echo OC_Helper::linkTo('apps/contacts', 'carddav.php', null, true); ?><br />
+ </fieldset>
+</form>
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index e7bda0f6144..8d51c146523 100644
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";
diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php
index 8e0bac0b06f..7ee8f0e57bd 100644
--- a/apps/files_sharing/ajax/setpermissions.php
+++ b/apps/files_sharing/ajax/setpermissions.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];
@@ -9,4 +10,4 @@ $uid_shared_with = $_GET['uid_shared_with'];
$permissions = $_GET['permissions'];
OC_Share::setPermissions($source, $uid_shared_with, $permissions);
-?> \ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index e672cf02403..6a2b45b3a7d 100644
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";
@@ -26,4 +27,4 @@ foreach ($sources as $source) {
}
}
-?> \ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php
index b9230d257b7..a19a85cfda3 100644
--- a/apps/files_sharing/ajax/unshare.php
+++ b/apps/files_sharing/ajax/unshare.php
@@ -2,10 +2,11 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];
$uid_shared_with = $_GET['uid_shared_with'];
OC_Share::unshare($source, $uid_shared_with);
-?> \ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index a3158cf72d6..21516c3d091 100644
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -4,6 +4,7 @@ $RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('files_sharing');
$users = array();
$ocusers = OC_User::getUsers();
diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php
index 33918bf9e7d..083f48e1127 100644
--- a/apps/files_sharing/get.php
+++ b/apps/files_sharing/get.php
@@ -3,6 +3,7 @@ $RUNTIME_NOAPPS=true; //no need to load the apps
$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
require_once '../../lib/base.php';
+OC_JSON::checkAppEnabled('files_sharing');
require_once 'lib_share.php';
//get the path of the shared file
diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php
index a5f99f38041..721620dc922 100644
--- a/apps/files_sharing/list.php
+++ b/apps/files_sharing/list.php
@@ -24,6 +24,7 @@ require_once('../../lib/base.php');
require_once('lib_share.php');
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('files_sharing');
OC_App::setActiveNavigationEntry("files_sharing_list");
diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php
index 7faf2cf4ba6..d46ff818ac1 100644
--- a/apps/files_sharing/templates/list.php
+++ b/apps/files_sharing/templates/list.php
@@ -1,11 +1,11 @@
<fieldset>
- <legend>Your Shared Files</legend>
+ <legend><?php echo $l->t('Your Shared Files');?></legend>
<table id="itemlist">
<thead>
<tr>
- <th>Item</th>
- <th>Shared With</th>
- <th>Permissions</th>
+ <th><?php echo $l->t('Item');?></th>
+ <th><?php echo $l->t('Shared With');?></th>
+ <th><?php echo $l->t('Permissions');?></th>
</tr>
</thead>
<tbody>
@@ -13,8 +13,8 @@
<tr class="item">
<td class="source"><?php echo substr($item['source'], strlen("/".$_SESSION['user_id']."/files/"));?></td>
<td class="uid_shared_with"><?php echo $item['uid_shared_with'];?></td>
- <td class="permissions"><?php echo "Read"; echo($item['permissions'] & OC_SHARE::WRITE ? ", Edit" : ""); echo($item['permissions'] & OC_SHARE::DELETE ? ", Delete" : "");?></td>
- <td><button class="delete" data-source="<?php echo $item['source'];?>" data-uid_shared_with="<?php echo $item['uid_shared_with'];?>">Delete</button></td>
+ <td class="permissions"><?php echo $l->t('Read'); echo($item['permissions'] & OC_SHARE::WRITE ? ", ".$l->t('Edit') : ""); echo($item['permissions'] & OC_SHARE::DELETE ? ", ".$l->t('Delete') : "");?></td>
+ <td><button class="delete" data-source="<?php echo $item['source'];?>" data-uid_shared_with="<?php echo $item['uid_shared_with'];?>"><?php echo $l->t('Delete');?></button></td>
</tr>
<?php endforeach;?>
<tr id="share_item_row">
diff --git a/apps/files_texteditor/css/style.css b/apps/files_texteditor/css/style.css
index cfad02100ab..3555119dffc 100644
--- a/apps/files_texteditor/css/style.css
+++ b/apps/files_texteditor/css/style.css
@@ -14,3 +14,9 @@
left: 160px;
display: none;
}
+#editorbar{
+ margin-left: auto;
+ margin-right: 10px;
+ display: block;
+ width: 300px;
+} \ No newline at end of file
diff --git a/apps/files_texteditor/js/editor.js b/apps/files_texteditor/js/editor.js
index b912b448586..d4c5bca51f2 100644
--- a/apps/files_texteditor/js/editor.js
+++ b/apps/files_texteditor/js/editor.js
@@ -1,7 +1,7 @@
function setEditorSize(){
// Sets the size of the text editor window.
- $('#editor').css('height', $(window).height()-90);
- $('#editor').css('width', $(window).width()-180);
+ $('#editor').css('height', $(window).height()-81);
+ $('#editor').css('width', $(window).width()-160);
$('#editor').css('padding-top', '40px');
}
@@ -33,31 +33,54 @@ function setSyntaxMode(ext){
}
}
-function showControlBar(){
+function showControlBar(filename){
// Loads the control bar at the top.
- $('.actions,#file_action_panel').fadeOut('slow', function(){
+ $('.actions,#file_action_panel').fadeOut('slow').promise().done(function() {
// Load the new toolbar.
- var html = '<div id="editorbar"><input type="button" id="editor_save" value="'+t('files_texteditor','Save')+'"><input type="button" id="editor_close" value="Close"></div>';
+ var html = '<div id="editorbar"><input type="button" id="editor_save" value="'+t('files_texteditor','Save')+'"><input type="button" id="editor_close" value="'+t('files_texteditor','Close Editor')+'"></div>';
if($('#editorbar').length==0){
- $('#controls').append(html).fadeIn('slow');
+ $('#controls').append(html);
+ $('#editorbar').fadeIn('slow');
}
- bindControlEvents();
+ var breadcrumbhtml = '<div class="crumb svg" style="background-image:url(&quot;/core/img/breadcrumb.png&quot;)"><a href="#">'+filename+'</a></div>';
+ $('.actions').before(breadcrumbhtml);
});
}
-
+
function bindControlEvents(){
- $('#editor_save').bind('click', function() {
- $(this).val('Saving...');
+ $("#editor_save").live('click',function() {
+ doFileSave();
+ });
+
+ $('#editor_close').live('click',function() {
+ hideFileEditor();
+ });
+
+ $(document).bind('keydown', 'Ctrl+s', doFileSave);
+}
+
+function editorIsShown(){
+ if($('#editor').length!=0){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function doFileSave(){
+ if(editorIsShown()){
+ $('#editor_save').val(t('files_texteditor','Saving')+'...');
var filecontents = window.aceEditor.getSession().getValue();
var dir = $('#editor').attr('data-dir');
- var file = $('#editor').attr('data-file');
+ var file = $('#editor').attr('data-filename');
$.post('http://cloud.tomneedham.com/apps/files_texteditor/ajax/savefile.php', { filecontents: filecontents, file: file, dir: dir },function(jsondata){
+
if(jsondata.status == 'failure'){
var answer = confirm(jsondata.data.message);
if(answer){
$.post(OC.filePath('apps','files_texteditor','ajax','savefile.php'),{ filecontents: filecontents, file: file, dir: dir, force: 'true' },function(jsondata){
if(jsondata.status =='success'){
- $('#editor_save').val('Save');
+ $('#editor_save').val(t('files_texteditor','Save'));
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
}
else {
@@ -69,23 +92,24 @@ function bindControlEvents(){
else {
// Don't save!
$('#editor_save').effect("highlight", {color:'#FF5757'}, 3000);
- $('#editor_save').val('Save');
+ $('#editor_save').val(t('files_texteditor','Save'));
}
}
else if(jsondata.status == 'success'){
// Success
- $('#editor_save').val('Save');
+ $('#editor_save').val(t('files_texteditor','Save'));
$('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000);
}
}, 'json');
- // TODO give focus back to the editor
- // window.aceEditor.focus();
- });
-
- $('#editor_close').bind('click', function() {
- hideFileEditor();
- });
-}
+ giveEditorFocus();
+ } else {
+ return;
+ }
+};
+
+function giveEditorFocus(){
+ window.aceEditor.focus();
+};
function showFileEditor(dir,filename){
// Loads the file editor and display it.
@@ -94,7 +118,7 @@ function showFileEditor(dir,filename){
complete: function(data){
var data = data.responseText;
// Initialise the editor
- showControlBar();
+ showControlBar(filename);
$('table').fadeOut('slow', function() {
$('#editor').html(data);
// encodeURIComponenet?
@@ -106,8 +130,8 @@ function showFileEditor(dir,filename){
OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){
window.aceEditor.setTheme("ace/theme/clouds");
});
- showControlBar();
});
+ bindControlEvents();
// End success
}
// End ajax
@@ -116,10 +140,17 @@ function showFileEditor(dir,filename){
}
function hideFileEditor(){
+ // Fade out controls
$('#editorbar').fadeOut('slow');
+ // Fade out breadcrumb
+ $('.actions').prev().fadeOut('slow');
+ // Fade out editor
$('#editor').fadeOut('slow', function(){
- $('#editorbar').html('');
- $('#editor').html('');
+ $('#editorbar').remove();
+ $('#editor').remove();
+ $('.actions').prev().remove();
+ var editorhtml = '<div id="editor"></div>';
+ $('table').after(editorhtml);
$('.actions,#file_access_panel').fadeIn('slow');
$('table').fadeIn('slow');
});
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php
new file mode 100644
index 00000000000..375905ec520
--- /dev/null
+++ b/apps/gallery/ajax/cover.php
@@ -0,0 +1,62 @@
+<?php
+require_once('../../../lib/base.php');
+
+function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource.
+ //getting the image dimensions
+ list($width_orig, $height_orig) = getimagesize($imgSrc);
+ switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) {
+ case "jpeg":
+ case "jpg":
+ $myImage = imagecreatefromjpeg($imgSrc);
+ break;
+ default:
+ exit();
+ }
+ $ratio_orig = $width_orig/$height_orig;
+
+ if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
+ imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+ return $thumb;
+}
+
+// Check if we are a user
+if( !OC_User::isLoggedIn()){
+ echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.')));
+ exit();
+}
+$box_size = 200;
+$album_name = $_GET['album'];
+$x = $_GET['x'];
+
+$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id');
+$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+$x = min((int)($x/($box_size/$result->numRows())), $result->numRows()-1); // get image to display
+$result->seek($x); // never throws
+$path = $result->fetchRow();
+$path = $path['file_path'];
+$tmp = OC::$CONFIG_DATADIRECTORY . $path;
+$imagesize = getimagesize($tmp);
+
+header('Content-Type: image/png');
+$image = CroppedThumbnail($tmp, $box_size, $box_size);
+
+imagepng($image);
+imagedestroy($image);
+?>
diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php
new file mode 100644
index 00000000000..3a490bdc3bd
--- /dev/null
+++ b/apps/gallery/ajax/createAlbum.php
@@ -0,0 +1,14 @@
+<?php
+require_once('../../../lib/base.php');
+
+if( !OC_User::isLoggedIn()){
+ echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.')));
+ exit();
+}
+
+$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")');
+$stmt->execute(array());
+
+echo json_encode(array( 'status' => 'success', 'name' => $_GET['album_name']));
+
+?>
diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php
new file mode 100644
index 00000000000..6b551ac49d5
--- /dev/null
+++ b/apps/gallery/ajax/getAlbums.php
@@ -0,0 +1,22 @@
+<?php
+require_once('../../../lib/base.php');
+
+if (!OC_User::IsLoggedIn()) {
+ echo json_encode(array('status' => 'error', 'message' => 'You need to log in'));
+ exit();
+}
+
+$a = array();
+$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?');
+$result = $stmt->execute(array(OC_User::getUser()));
+
+while ($r = $result->fetchRow()) {
+ $album_name = $r['album_name'];
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?');
+ $tmp_res = $stmt->execute(array($r['album_id']));
+ $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10));
+}
+
+echo json_encode(array('status'=>'success', 'albums'=>$a));
+
+?>
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
new file mode 100644
index 00000000000..d56bf6fa4b7
--- /dev/null
+++ b/apps/gallery/ajax/getCovers.php
@@ -0,0 +1,66 @@
+<?php
+require_once('../../../lib/base.php');
+
+function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $shift) {
+ //getting the image dimensions
+ list($width_orig, $height_orig) = getimagesize($imgSrc);
+ switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) {
+ case "jpeg":
+ case "jpg":
+ case "tiff":
+ $myImage = imagecreatefromjpeg($imgSrc);
+ break;
+ case "png":
+ $myImage = imagecreatefrompng($imgSrc);
+ break;
+ default:
+ exit();
+ }
+ $ratio_orig = $width_orig/$height_orig;
+
+ if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ imagecopyresampled($tgtImg, $process, $shift, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+}
+
+// Check if we are a user
+if( !OC_User::isLoggedIn()){
+ echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.')));
+ exit();
+}
+$box_size = 200;
+$album_name= $_GET['album_name'];
+
+$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id');
+$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+
+$numOfItems = min($result->numRows(),10);
+
+$targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+$counter = 0;
+while (($i = $result->fetchRow()) && $counter < $numOfItems) {
+ $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path'];
+ CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
+ $counter++;
+}
+
+header('Content-Type: image/png');
+
+imagepng($targetImg);
+imagedestroy($targetImg);
+?>
diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php
new file mode 100644
index 00000000000..a04ad62b1bf
--- /dev/null
+++ b/apps/gallery/ajax/scanForAlbums.php
@@ -0,0 +1,14 @@
+<?php
+
+require_once('../../../lib/base.php');
+require_once('../lib_scanner.php');
+
+if (!OC_User::IsLoggedIn()) {
+ echo json_encode(array('status' => 'error', 'message' => 'You need to log in'));
+ exit();
+}
+
+echo json_encode(array( 'status' => 'success', 'albums' => OC_GALLERY_SCANNER::scan('')));
+//echo json_encode(array('status' => 'success', 'albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa')))));
+
+?>
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
new file mode 100644
index 00000000000..db428eeff34
--- /dev/null
+++ b/apps/gallery/ajax/thumbnail.php
@@ -0,0 +1,58 @@
+<?php
+require_once('../../../lib/base.php');
+
+function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource.
+ //getting the image dimensions
+ list($width_orig, $height_orig) = getimagesize($imgSrc);
+ switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) {
+ case "jpeg":
+ case "jpg":
+ case "tiff":
+ $myImage = imagecreatefromjpeg($imgSrc);
+ break;
+ case "png":
+ $myImage = imagecreatefrompng($imgSrc);
+ break;
+ default:
+ exit();
+ }
+ $ratio_orig = $width_orig/$height_orig;
+
+ if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
+ imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+ return $thumb;
+}
+
+// Check if we are a user
+if( !OC_User::isLoggedIn()){
+ echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.')));
+ exit();
+}
+$box_size = 200;
+$img = $_GET['img'];
+
+$tmp = OC::$CONFIG_DATADIRECTORY . $img;
+
+header('Content-Type: image/png');
+$image = CroppedThumbnail($tmp, $box_size, $box_size);
+
+imagepng($image);
+imagedestroy($image);
+?>
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
new file mode 100644
index 00000000000..5760bb149d8
--- /dev/null
+++ b/apps/gallery/appinfo/app.php
@@ -0,0 +1,27 @@
+<?php
+OC_App::register(array(
+ 'order' => 20,
+ 'id' => 'gallery',
+ 'name' => 'Gallery'));
+
+OC_App::addNavigationEntry( array(
+ 'id' => 'gallery_index',
+ 'order' => 20,
+ 'href' => OC_Helper::linkTo('gallery', 'index.php'),
+ 'icon' => OC_Helper::linkTo('', 'core/img/filetypes/image.png'),
+ 'name' => 'Gallery'));
+
+ class OC_GallerySearchProvider extends OC_Search_Provider{
+ function search($query){
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?');
+ $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%'));
+ $results=array();
+ while($row=$result->fetchRow()){
+ $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo( 'apps/gallery', 'index.php?view='.$row['album_name']),'Galleries');
+ }
+ return $results;
+ }
+}
+
+new OC_GallerySearchProvider();
+?>
diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml
new file mode 100644
index 00000000000..fd55b3a6fb4
--- /dev/null
+++ b/apps/gallery/appinfo/database.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<database>
+ <name>*dbname*</name>
+ <create>true</create>
+ <overwrite>false</overwrite>
+ <charset>latin1</charset>
+ <table>
+ <name>*dbprefix*gallery_albums</name>
+ <declaration>
+ <field>
+ <name>album_id</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <autoincrement>1</autoincrement>
+ <length>4</length>
+ </field>
+ <field>
+ <name>uid_owner</name>
+ <type>text</type>
+ <notnull>true</notnull>
+ <length>64</length>
+ </field>
+ <field>
+ <name>album_name</name>
+ <type>text</type>
+ <notnull>true</notnull>
+ <length>100</length>
+ </field>
+ </declaration>
+ </table>
+ <table>
+ <name>*dbprefix*gallery_photos</name>
+ <declaration>
+ <field>
+ <name>photo_id</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <autoincrement>1</autoincrement>
+ <length>4</length>
+ </field>
+ <field>
+ <name>album_id</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <length>4</length>
+ </field>
+ <field>
+ <name>file_path</name>
+ <type>text</type>
+ <notnull>true</notnull>
+ <length>100</length>
+ </field>
+ </declaration>
+ </table>
+</database>
diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml
new file mode 100644
index 00000000000..154b5fcf7ae
--- /dev/null
+++ b/apps/gallery/appinfo/info.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<info>
+ <id>gallery</id>
+ <name>Gallery</name>
+ <version>0.1</version>
+ <licence>AGPL</licence>
+ <author>Bartosz Przybylski</author>
+ <require>2</require>
+ <description></description>
+ <default_enable/>
+</info>
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css
new file mode 100644
index 00000000000..03b179138e6
--- /dev/null
+++ b/apps/gallery/css/styles.css
@@ -0,0 +1,23 @@
+div#gallery_list {
+ margin: 90pt 20pt;
+}
+
+div#gallery_album_box {
+ width: 200px;
+ text-align: center;
+ border: 0;
+ float: left;
+ margin: 5pt;
+}
+
+div#gallery_album_box h1 {
+ font-size: 12pt;
+ font-family: Arial;
+}
+
+div#gallery_album_cover {
+ width: 199px;
+ height: 199px;
+ border: solid 1px black;
+}
+
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
new file mode 100644
index 00000000000..c8d5892e555
--- /dev/null
+++ b/apps/gallery/index.php
@@ -0,0 +1,33 @@
+<?php
+require_once('../../lib/base.php');
+
+OC_Util::checkLoggedIn();
+OC_App::setActiveNavigationEntry( 'gallery_index' );
+
+
+if (!isset($_GET['view'])) {
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?');
+ $result = $stmt->execute(array(OC_User::getUser()));
+
+ $r = array();
+ while ($row = $result->fetchRow())
+ $r[] = $row;
+
+ $tmpl = new OC_Template( 'gallery', 'index', 'user' );
+ $tmpl->assign('r', $r);
+ $tmpl->printPage();
+} else {
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id');
+
+ $result = $stmt->execute(array(OC_User::getUser(), $_GET['view']));
+
+ $photos = array();
+ while ($p = $result->fetchRow())
+ $photos[] = $p['file_path'];
+
+ $tmpl = new OC_Template( 'gallery', 'view_album', 'user' );
+ $tmpl->assign('photos', $photos);
+ $tmpl->assign('albumName', $_GET['view']);
+ $tmpl->printPage();
+}
+?>
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
new file mode 100644
index 00000000000..776feae32cc
--- /dev/null
+++ b/apps/gallery/js/album_cover.js
@@ -0,0 +1,41 @@
+var actual_cover;
+$(document).ready(function() {
+ $.getJSON('ajax/getAlbums.php', function(r) {
+ if (r.status == 'success') {
+ for (var i in r.albums) {
+ var a = r.albums[i];
+ Albums.add(a.name, a.numOfItems);
+ }
+ var targetDiv = document.getElementById('gallery_list');
+ if (targetDiv) {
+ Albums.display(targetDiv);
+ } else {
+ alert('Error occured: no such layer `gallery_list`');
+ }
+ } else {
+ alert('Error occured: ' + r.message);
+ }
+ });
+});
+
+function createNewAlbum() {
+ var name = prompt("album name", "");
+ if (name != null && name != "") {
+ $.getJSON("ajax/createAlbum.php", {album_name: name}, function(r) {
+ if (r.status == "success") {
+ var v = '<div class="gallery_album_box"><a href="?view='+r.name+'"><img class="gallery_album_cover"/></a><h1>'+r.name+'</h1></div>';
+ $('div#gallery_list').append(v);
+ }
+ });
+ }
+}
+
+function scanForAlbums() {
+ $.getJSON('ajax/scanForAlbums.php', function(r) {
+ if (r.status == 'success') {
+ window.location.reload(true);
+ } else {
+ alert('Error occured: ' + r.message);
+ }
+ });
+}
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
new file mode 100644
index 00000000000..7ab243ededf
--- /dev/null
+++ b/apps/gallery/js/albums.js
@@ -0,0 +1,80 @@
+Albums={
+ // album item in this array should look as follow
+ // {name: string,
+ // numOfCovers: int}
+ //
+ // previews array should be an array of base64 decoded images
+ // to display to user as preview picture when scrolling throught
+ // the album cover
+ albums:new Array(),
+ // add simply adds new album to internal structure
+ // however albums names must be unique so other
+ // album with the same name wont be insered,
+ // and false will be returned
+ // true on success
+ add: function(album_name, num) {
+ for (var a in Albums.albums) {
+ if (a.name == album_name) {
+ return false;
+ }
+ }
+ Albums.albums.push({name: album_name, numOfCovers: num});
+ return true;
+ },
+ // remove element with given name
+ // returns remove element or undefined if no such element was present
+ remove: function(name) {
+ var i = -1, tmp = 0;
+ for (var a in Albums.albums) {
+ if (a.name == name) {
+ i = tmp;
+ break;
+ }
+ tmp++;
+ }
+ if (i != -1) {
+ return Albums.albums.splice(i,1);
+ }
+ return undefined;
+ },
+ // return element which match given name
+ // of undefined if such element do not exist
+ find: function(name) {
+ var i = -1, tmp = 0;
+ for (var k in Albums.albums) {
+ var a = Albums.albums[k];
+ if (a.name == name) {
+ i = tmp;
+ break;
+ }
+ tmp++;
+ }
+ if (i != -1) {
+ return Albums.albums[i];
+ }
+ return undefined;
+ },
+ // displays gallery in linear representation
+ // on given element, and apply default styles for gallery
+ display: function(element) {
+ var displayTemplate = '<div id="gallery_album_box" title="*NAME*"><a href="?view=*NAME*"><div id="gallery_album_cover"></div></a><h1>*NAME*</h1></div></div>';
+ for (var i in Albums.albums) {
+ var a = Albums.albums[i];
+ var local = $(displayTemplate.replace(/\*NAME\*/g, a.name));
+ local.css('background-repeat', 'no-repeat');
+ local.css('background-position', '0 0');
+ local.css('background-image','url("ajax/getCovers.php?album_name='+a.name+'")');
+ local.mousemove(function(e) {
+ var albumMetadata = Albums.find(this.title);
+ if (albumMetadata == undefined) {
+ return;
+ }
+ var x = Math.min(Math.floor((e.clientX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
+ x *= this.offsetWidth;
+ $(this).css('background-position', -x+'px 0');
+ });
+ $(element).append(local);
+ }
+ }
+
+}
diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php
new file mode 100644
index 00000000000..fe14b68add1
--- /dev/null
+++ b/apps/gallery/lib_scanner.php
@@ -0,0 +1,57 @@
+<?php
+
+require_once('base.php'); // base lib
+
+class OC_GALLERY_SCANNER {
+
+ public static function scan($root) {
+ $albums = array();
+ self::scanDir($root, $albums);
+ return $albums;
+ }
+
+ public static function scanDir($path, &$albums) {
+ $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array());
+ $current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name']));
+ $current_album['name'] = ($current_album['name']==='')?'main':$current_album['name'];
+
+ if ($dh = OC_Filesystem::opendir($path)) {
+ while (($filename = readdir($dh)) !== false) {
+ $filepath = $path.'/'.$filename;
+ if (substr($filename, 0, 1) == '.') continue;
+ if (OC_Filesystem::is_dir($filepath)) {
+ self::scanDir($filepath, $albums);
+ } elseif (self::isPhoto($path.'/'.$filename)) {
+ $current_album['images'][] = $filepath;
+ }
+ }
+ }
+ $current_album['imagesCount'] = count($current_album['images']);
+ $albums[] = $current_album;
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?');
+ $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ if ($result->numRows() == 0 && count($current_album['images'])) {
+ $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES (?, ?)');
+ $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ }
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?');
+ $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ $albumId = $result->fetchRow();
+ $albumId = $albumId['album_id'];
+ foreach ($current_album['images'] as $img) {
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE "album_id" = ? AND "file_path" = ?');
+ $result = $stmt->execute(array($albumId, $img));
+ if ($result->numRows() == 0) {
+ $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_photos ("album_id", "file_path") VALUES (?, ?)');
+ $stmt->execute(array($albumId, $img));
+ }
+ }
+ }
+
+ public static function isPhoto($filename) {
+ if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/")
+ return 1;
+ return 0;
+ }
+}
+?>
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
new file mode 100644
index 00000000000..0e89e448768
--- /dev/null
+++ b/apps/gallery/templates/index.php
@@ -0,0 +1,12 @@
+<?php
+OC_Util::addStyle('gallery', 'styles');
+OC_Util::addScript('gallery', 'albums');
+OC_Util::addScript('gallery', 'album_cover');
+?>
+
+<div id="controls">
+ <!-- <input type="button" value="New album" onclick="javascript:createNewAlbum();" />-->
+ <input type="button" value="Rescan" onclick="javascript:scanForAlbums();" /><br/>
+</div>
+<div id="gallery_list">
+</div>
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php
new file mode 100644
index 00000000000..ea2969e0110
--- /dev/null
+++ b/apps/gallery/templates/view_album.php
@@ -0,0 +1,20 @@
+<?php
+OC_Util::addStyle('gallery', 'styles');
+OC_Util::addScript('gallery', 'album_cover');
+OC_Util::addScript( 'files_imageviewer', 'lightbox' );
+OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
+?>
+
+<div id="controls">
+ <a href="?"><input type="button" value="Back" /></a><br/>
+</div>
+<div id="gallery_list">
+<?php
+foreach ($_['photos'] as $a) {
+?>
+<a onclick="javascript:viewImage('/','<?php echo $a; ?>');"><img src="ajax/thumbnail.php?img=<?php echo $a ?>"></a>
+<?php
+ }
+?>
+
+</div>
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index 84ee6334463..29f61a2207f 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -27,6 +27,7 @@ header('Content-type: text/html; charset=UTF-8') ;
$RUNTIME_NOAPPS=true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_scanner.php');
diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php
index ad103d1c39b..ff0923ca032 100644
--- a/apps/media/ajax/autoupdate.php
+++ b/apps/media/ajax/autoupdate.php
@@ -28,6 +28,7 @@ $RUNTIME_NOAPPS=true;
$RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);}
$autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true');
diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php
index 0d36217bd4d..dd1a830a94b 100644
--- a/apps/media/appinfo/app.php
+++ b/apps/media/appinfo/app.php
@@ -25,6 +25,7 @@ $l=new OC_L10N('media');
require_once('apps/media/lib_media.php');
OC_Util::addScript('media','loader');
+OC_APP::registerPersonal('media','settings');
OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index ddfe3429830..c4db4e05855 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -9,8 +9,9 @@ div.jp-progress { position:absolute; overflow:hidden; top:.5em; left:8em; width:
div.jp-seek-bar { background:#eee; width:0; height:100%; cursor:pointer; }
div.jp-play-bar { background:#ccc; width:0; height:100%; }
div.jp-seeking-bg { background:url("../img/pbar-ani.gif"); }
-div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:1em; left:13.5em; }
-div.jp-duration { left:33em; }
+div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:0.9em; left:13.5em; }
+div.jp-duration { display: none }
+div.jp-current-song { left: 33em; position: absolute; top: 0.9em; }
div.jp-duration { text-align:right; }
a.jp-mute,a.jp-unmute { left:24em; }
@@ -21,9 +22,11 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection li.album,#collection li.song { margin-left:3em; }
#leftcontent img.remove { display:none; float:right; cursor:pointer; }
#leftcontent li:hover img.remove { display:inline; }
+#leftcontent li {white-space: normal; }
#collection li button { float:right; }
#collection li,#playlist li { list-style-type:none; }
.template { display:none; }
+.collection_playing { background:#eee; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
@@ -34,6 +37,7 @@ tr td { border-top:1px solid #eee; height:2.2em; }
tr .artist img { vertical-align:middle; }
tr.album td.artist { padding-left:1em; }
tr.song td.artist { padding-left:2em; }
+.add {margin: 0 0.5em 0 0; }
#scan { position:absolute; right:13em; top:0em; }
#scan .start { position:relative; display:inline; float:right; }
diff --git a/apps/media/css/player.css b/apps/media/css/player.css
new file mode 100644
index 00000000000..c4a098543d1
--- /dev/null
+++ b/apps/media/css/player.css
@@ -0,0 +1,23 @@
+#playercontrols{
+ display:inline;
+ margin-left:1em;
+ width:7em;
+ height:1em;
+ position:fixed;
+ top:auto;
+ left:auto;
+ background:transparent;
+ box-shadow:none;
+ -webkit-box-shadow:none;
+}
+#playercontrols li{
+ float:left;
+}
+#playercontrols a, #playercontrols li{
+ margin:0px;
+ padding:0;
+ left:0;
+ background:transparent !important;
+ border:none !important;
+ text-shadow:none;
+} \ No newline at end of file
diff --git a/apps/media/index.php b/apps/media/index.php
index d5273ae45cb..419d4ae0bde 100644
--- a/apps/media/index.php
+++ b/apps/media/index.php
@@ -26,6 +26,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('media');
require_once('lib_collection.php');
require_once('lib_scanner.php');
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js
index 7eb027348ce..29ba45919cf 100644
--- a/apps/media/js/collection.js
+++ b/apps/media/js/collection.js
@@ -50,6 +50,10 @@ Collection={
}
}
+ Collection.artists.sort(function(a,b){
+ return a.name.localeCompare(b.name);
+ });
+
Collection.loaded=true;
Collection.loading=false;
for(var i=0;i<Collection.loadedListeners.length;i++){
@@ -79,8 +83,13 @@ Collection={
$.each(Collection.artists,function(i,artist){
if(artist.name && artist.songs.length>0){
var tr=template.clone().removeClass('template');
- tr.find('td.title a').text(artist.songs.length+' '+t('media','songs'));
- tr.find('td.album a').text(artist.albums.length+' '+t('media','albums'));
+ if(artist.songs.length>1){
+ tr.find('td.title a').text(artist.songs.length+' '+t('media','songs'));
+ tr.find('td.album a').text(artist.albums.length+' '+t('media','albums'));
+ }else{
+ tr.find('td.title a').text(artist.songs[0].name);
+ tr.find('td.album a').text(artist.albums[0].name);
+ }
tr.find('td.artist a').text(artist.name);
tr.data('artistData',artist);
tr.find('td.artist a').click(function(event){
@@ -90,18 +99,20 @@ Collection={
Collection.parent.find('tr').removeClass('active');
$('tr[data-artist="'+artist.name+'"]').addClass('active');
});
- var expander=$('<a class="expander">&gt;</a>');
- expander.data('expanded',false);
- expander.click(function(event){
- var tr=$(this).parent().parent();
- if(expander.data('expanded')){
- Collection.hideArtist(tr.data('artist'));
- }else{
- Collection.showArtist(tr.data('artist'));
- }
- });
- tr.find('td.artist').addClass('buttons');
- Collection.addButtons(tr,artist);
+ if(artist.songs.length>1){
+ var expander=$('<a class="expander">&gt;</a>');
+ expander.data('expanded',false);
+ expander.click(function(event){
+ var tr=$(this).parent().parent();
+ if(expander.data('expanded')){
+ Collection.hideArtist(tr.data('artist'));
+ }else{
+ Collection.showArtist(tr.data('artist'));
+ }
+ });
+ }
+ tr.find('td.artist').addClass('buttons');
+ Collection.addButtons(tr,artist);
tr.children('td.artist').append(expander);
tr.attr('data-artist',artist.name);
Collection.parent.find('tbody').append(tr);
@@ -115,14 +126,16 @@ Collection={
var nextRow=tr.next();
var artist=tr.data('artistData');
var first=true;
- $.each(artist.albums,function(foo,album){
+ $.each(artist.albums,function(j,album){
$.each(album.songs,function(i,song){
if(first){
newRow=tr;
}else{
var newRow=tr.clone();
+ newRow.find('td.artist').text('');
+ newRow.find('.expander').remove();
}
- newRow.find('.expander').remove();
+ newRow.find('td.album .expander').remove();
if(i==0){
newRow.find('td.album a').text(album.name);
newRow.find('td.album a').click(function(event){
@@ -132,21 +145,23 @@ Collection={
Collection.parent.find('tr').removeClass('active');
$('tr[data-album="'+album.name+'"]').addClass('active');
});
- var expander=$('<a class="expander">v </a>');
- expander.data('expanded',true);
- expander.click(function(event){
- var tr=$(this).parent().parent();
- if(expander.data('expanded')) {
- Collection.hideAlbum(tr.data('artist'),tr.data('album'));
- } else {
- Collection.showAlbum(tr.data('artist'),tr.data('album'));
- }
- });
- newRow.children('td.artist').append(expander);
- Collection.addButtons(newRow,album);
+ if(album.songs.length>1){
+ var expander=$('<a class="expander">v </a>');
+ expander.data('expanded',true);
+ expander.click(function(event){
+ var tr=$(this).parent().parent();
+ if(expander.data('expanded')) {
+ Collection.hideAlbum(tr.data('artist'),tr.data('album'));
+ } else {
+ Collection.showAlbum(tr.data('artist'),tr.data('album'));
+ }
+ });
+ newRow.children('td.album').append(expander);
+ }
+ Collection.addButtons(newRow,album);
} else {
newRow.find('td.album a').text('');
- Collection.addButtons(newRow,song);
+ Collection.addButtons(newRow,song);
}
newRow.find('td.title a').text(song.name);
newRow.find('td.title a').click(function(event){
@@ -159,6 +174,7 @@ Collection={
newRow.attr('data-album',album.name);
newRow.attr('data-title',song.name);
newRow.attr('data-artist',artist.name);
+ newRow.data('albumData',album);
if(!first){
nextRow.before(newRow);
}
@@ -166,43 +182,62 @@ Collection={
});
});
tr.removeClass('collapsed');
- tr.find('a.expander').data('expanded',true);
- tr.find('a.expander').addClass('expanded');
- tr.find('a.expander').text('v');
+ tr.find('td.artist a.expander').data('expanded',true);
+ tr.find('td.artist a.expander').addClass('expanded');
+ tr.find('td.artist a.expander').text('v');
},
hideArtist:function(artist){
var tr=Collection.parent.find('tr[data-artist="'+artist+'"]');
- if(tr.length>1){
- var artist=tr.first().data('artistData');
- tr.first().find('td.album a').text(artist.albums.length+' '+t('media','albums'));
- tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs'));
- tr.first().find('td.album a').unbind('click');
- tr.first().find('td.title a').unbind('click');
- tr.each(function(i,row){
- if(i>0){
- $(row).remove();
- }
- });
- tr.find('a.expander').data('expanded',false);
- tr.find('a.expander').removeClass('expanded');
- tr.find('a.expander').text('>');
- Collection.addButtons(tr,artist);
- }
+ var artist=tr.first().data('artistData');
+ tr.first().find('td.album a').first().text(artist.albums.length+' '+t('media','albums'));
+ tr.first().find('td.album a.expander').remove();
+ tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs'));
+ tr.first().find('td.album a').unbind('click');
+ tr.first().find('td.title a').unbind('click');
+ tr.each(function(i,row){
+ if(i>0){
+ $(row).remove();
+ }
+ });
+ tr.find('td.artist a.expander').data('expanded',false);
+ tr.find('td.artist a.expander').removeClass('expanded');
+ tr.find('td.artist a.expander').text('>');
+ Collection.addButtons(tr,artist);
},
showAlbum:function(artist,album){
- var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
- tr.find('a.expander').data('expanded',true);
- tr.find('a.expander').addClass('expanded');
- tr.find('a.expander').text('v ');
- tr.show();
+ var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
+ var albumData=tr.data('albumData');
+ tr.find('td.album a.expander').data('expanded',true);
+ tr.find('td.album a.expander').addClass('expanded');
+ tr.find('td.album a.expander').text('v');
+ var nextRow=tr.next();
+ $.each(albumData.songs,function(i,song){
+ if(i>0){
+ var newRow=tr.clone();
+ newRow.find('a.expander').remove();
+ newRow.find('td.album a').text('');
+ newRow.find('td.artist a').text('');
+ }else{
+ var newRow=tr;
+ }
+ newRow.find('td.title a').text(song.name);
+ if(i>0){
+ nextRow.before(newRow);
+ }
+ });
},
hideAlbum:function(artist,album){
var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
- tr.find('a.expander').data('expanded',false);
- tr.find('a.expander').removeClass('expanded');
- tr.find('a.expander').text('> ');
- tr.hide();
- tr.first().show();
+ var albumData=tr.data('albumData');
+ tr.first().find('td.title a').text(albumData.songs.length+' '+t('media','songs'));
+ tr.find('td.album a.expander').data('expanded',false);
+ tr.find('td.album a.expander').removeClass('expanded');
+ tr.find('td.album a.expander').text('> ');
+ tr.each(function(i,row){
+ if(i>0){
+ $(row).remove();
+ }
+ });
},
parent:null,
hide:function(){
@@ -239,7 +274,7 @@ Collection={
},
findArtist:function(name){
for(var i=0;i<Collection.artists.length;i++){
- if(Collection.artists[i].artist_name==name){
+ if(Collection.artists[i].name==name){
return Collection.artists[i];
}
}
@@ -248,7 +283,7 @@ Collection={
var artist=Collection.findArtist(artistName);
if(artist){
for(var i=0;i<artist.albums.length;i++){
- if(artist.albums[i].album_name==albumName){
+ if(artist.albums[i].name==albumName){
return artist.albums[i];
}
}
@@ -258,7 +293,7 @@ Collection={
var album=Collection.findAlbum(artistName,albumName);
if(album){
for(var i=0;i<album.songs.length;i++){
- if(album.songs[i].song_name==songName){
+ if(album.songs[i].name==songName){
return album.songs[i];
}
}
diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js
index c6c834d3a31..dff4163897f 100644
--- a/apps/media/js/loader.js
+++ b/apps/media/js/loader.js
@@ -22,16 +22,17 @@ function addAudio(filename){
function loadPlayer(type,ready){
if(!loadPlayer.done){
+ loadPlayer.done=true;
+ OC.addStyle('media','player');
OC.addScript('media','jquery.jplayer.min',function(){
OC.addScript('media','player',function(){
- $('body').append($('<div id="playerPlaceholder"/>'))
- $('#playerPlaceholder').append($('<div/>')).load(OC.filePath('media','templates','player.php'),function(){
- loadPlayer.done=true;
+ var navItem=$('#apps a[href="'+OC.linkTo('media','index.php')+'"]');
+ navItem.height(navItem.height());
+ navItem.load(OC.filePath('media','templates','player.php'),function(){
PlayList.init(type,ready);
});
});
});
- OC.addStyle('media','player');
}else{
ready();
}
diff --git a/apps/media/js/music.js b/apps/media/js/music.js
index c04c579d1ca..bf082207829 100644
--- a/apps/media/js/music.js
+++ b/apps/media/js/music.js
@@ -15,7 +15,7 @@ $(document).ready(function(){
PlayList.play(oldSize);
PlayList.render();
});
- var button=$('<input type="button" title="'+t('media','Add to playlist')+'" class="add"></input>');
+ var button=$('<input type="button" title="'+t('media','Add album to playlist')+'" class="add"></input>');
button.css('background-image','url('+OC.imagePath('core','actions/play-add')+')')
button.click(function(event){
event.stopPropagation();
@@ -23,6 +23,7 @@ $(document).ready(function(){
PlayList.render();
});
row.find('div.name').append(button);
+ button.tipsy({gravity:'n', fade:true, delayIn: 400, live:true});
}
Collection.display();
});
diff --git a/apps/media/js/player.js b/apps/media/js/player.js
index f696b87bbde..3c022e9f8c4 100644
--- a/apps/media/js/player.js
+++ b/apps/media/js/player.js
@@ -28,17 +28,19 @@ var PlayList={
if(index==null){
index=PlayList.current;
}
+ PlayList.save();
if(index>-1 && index<items.length){
PlayList.current=index;
if(PlayList.player){
if(PlayList.player.data('jPlayer').options.supplied!=items[index].type){//the the audio type changes we need to reinitialize jplayer
PlayList.player.jPlayer("play",time);
- localStorage.setItem(oc_current_user+'oc_playlist_time',time);
+ localStorage.setItem(oc_current_user+'oc_playlist_time',time);
PlayList.player.jPlayer("destroy");
- PlayList.save(); // so that the init don't lose the playlist
+// PlayList.save(); // so that the init don't lose the playlist
PlayList.init(items[index].type,null); // init calls load that calls play
}else{
PlayList.player.jPlayer("setMedia", items[PlayList.current]);
+ $(".jp-current-song").text(items[PlayList.current].name);
items[index].playcount++;
PlayList.player.jPlayer("play",time);
if(index>0){
@@ -56,6 +58,7 @@ var PlayList={
if (typeof Collection !== 'undefined') {
Collection.registerPlay();
}
+ PlayList.render();
if(ready){
ready();
}
@@ -63,10 +66,12 @@ var PlayList={
}else{
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
- PlayList.save(); // so that the init don't lose the playlist
+// PlayList.save(); // so that the init don't lose the playlist
PlayList.init(items[index].type,null); // init calls load that calls play
}
}
+ $(".song").removeClass("collection_playing");
+ $(".jp-playlist-" + index).addClass("collection_playing");
},
init:function(type,ready){
if(!PlayList.player){
@@ -82,7 +87,7 @@ var PlayList={
PlayList.render();
return false;
});
- PlayList.player=$('#controls div.player');
+ PlayList.player=$('#jp-player');
}
$(PlayList.player).jPlayer({
ended:PlayList.next,
@@ -100,7 +105,7 @@ var PlayList={
}
},
volume:PlayList.volume,
- cssSelectorAncestor:'#controls',
+ cssSelectorAncestor:'.player-controls',
swfPath:OC.linkTo('media','js'),
});
},
@@ -127,7 +132,7 @@ var PlayList={
var type=musicTypeFromFile(song.path);
var item={name:song.name,type:type,artist:song.artist,album:song.album,length:song.length,playcount:song.playCount};
item[type]=PlayList.urlBase+encodeURIComponent(song.path);
- PlayList.items.push(item);
+ PlayList.items.push(item);
}
},
addFile:function(path){
@@ -157,17 +162,15 @@ var PlayList={
if(typeof localStorage !== 'undefined' && localStorage){
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current);
- if(PlayList.player) {
- if(PlayList.player.data('jPlayer')) {
- var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
- localStorage.setItem(oc_current_user+'oc_playlist_time',time);
- var volume=PlayList.player.data('jPlayer').options.volume*100;
- localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
- }
- }
- if(PlayList.active){
- localStorage.setItem(oc_current_user+'oc_playlist_active','false');
+ if(PlayList.player) {
+ if(PlayList.player.data('jPlayer')) {
+ var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
+ localStorage.setItem(oc_current_user+'oc_playlist_time',time);
+ var volume=PlayList.player.data('jPlayer').options.volume*100;
+ localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
+ }
}
+ localStorage.setItem(oc_current_user+'oc_playlist_active','true');
}
},
load:function(){
@@ -204,6 +207,9 @@ var PlayList={
$(document).ready(function(){
$(window).bind('beforeunload', function (){
PlayList.save();
+ if(PlayList.active){
+ localStorage.setItem(oc_current_user+'oc_playlist_active','false');
+ }
});
$('jp-previous').tipsy({gravity:'n', fade:true, live:true});
diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js
index cb7f24522a4..57180b3be7b 100644
--- a/apps/media/js/playlist.js
+++ b/apps/media/js/playlist.js
@@ -5,6 +5,7 @@ PlayList.render=function(){
var item=PlayList.items[i];
var li=$('<li/>');
li.append(item.name);
+ li.attr('class', 'jp-playlist-' + i);
var img=$('<img class="remove svg action" src="'+OC.imagePath('core','actions/delete')+'"/>');
img.click(function(event){
event.stopPropagation();
@@ -18,6 +19,7 @@ PlayList.render=function(){
li.addClass('song');
PlayList.parent.append(li);
}
+ $(".jp-playlist-" + PlayList.current).addClass("collection_playing");
}
PlayList.getSelected=function(){
return $('tbody td.name input:checkbox:checked').parent().parent();
@@ -28,6 +30,7 @@ PlayList.hide=function(){
$(document).ready(function(){
PlayList.parent=$('#leftcontent');
+ PlayList.init();
$('#selectAll').click(function(){
if($(this).attr('checked')){
// Check all
diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php
index 387c3480047..44a16793bf2 100644
--- a/apps/media/server/xml.server.php
+++ b/apps/media/server/xml.server.php
@@ -23,6 +23,7 @@
require_once('../../../lib/base.php');
+OC_Util::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_ampache.php');
diff --git a/apps/media/settings.php b/apps/media/settings.php
new file mode 100644
index 00000000000..133440a9af6
--- /dev/null
+++ b/apps/media/settings.php
@@ -0,0 +1,6 @@
+<?php
+
+$tmpl = new OC_Template( 'media', 'settings');
+
+return $tmpl->fetchPage();
+?>
diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php
index 6c8d740cc13..7764a315a8f 100644
--- a/apps/media/templates/music.php
+++ b/apps/media/templates/music.php
@@ -1,4 +1,4 @@
-<div id="controls">
+<div class='player-controls' id="controls">
<ul class="jp-controls">
<li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play-big.svg'); ?>" /></a></li>
<li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause-big.svg'); ?>" /></a></li>
@@ -17,6 +17,7 @@
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
+ <div class="jp-current-song"></div>
<div class="player" id="jp-player"></div>
diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php
new file mode 100644
index 00000000000..295f33ab9e0
--- /dev/null
+++ b/apps/media/templates/player.php
@@ -0,0 +1,17 @@
+<?php
+if(!isset($_)){//allow the template to be loaded standalone
+ require_once '../../../lib/base.php';
+ $tmpl = new OC_Template( 'media', 'player');
+ $tmpl->printPage();
+ exit;
+}
+?>
+Music
+<div class='player-controls' id="playercontrols">
+ <div class="player" id="jp-player"></div>
+ <ul class="jp-controls">
+ <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play.svg'); ?>" /></a></li>
+ <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause.svg'); ?>" /></a></li>
+ <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo image_path('core', 'actions/play-next.svg'); ?>" /></a></li>
+ </ul>
+</div> \ No newline at end of file
diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php
new file mode 100644
index 00000000000..da9346166e4
--- /dev/null
+++ b/apps/media/templates/settings.php
@@ -0,0 +1,7 @@
+<form id="mediaform">
+ <fieldset class="personalblock">
+ <strong>Media</strong><br />
+ Ampache address:
+ <?php echo OC_Helper::linkTo('apps/media', 'tomahawk.php', null, true); ?><br />
+ </fieldset>
+</form>
diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php
index 1db982a3504..68401db67ae 100644
--- a/apps/media/tomahawk.php
+++ b/apps/media/tomahawk.php
@@ -24,6 +24,7 @@
$_POST=$_GET; //debug
require_once('../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
require_once('lib_collection.php');
$user=isset($_POST['user'])?$_POST['user']:'';
diff --git a/apps/unhosted/compat.php b/apps/unhosted/compat.php
index 00d6a7c2eeb..a514018f71a 100644
--- a/apps/unhosted/compat.php
+++ b/apps/unhosted/compat.php
@@ -30,6 +30,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('unhosted');
require_once('Sabre/autoload.php');
require_once('lib_unhosted.php');
require_once('oauth_ro_auth.php');
diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php
index d90e0b71900..3cbc38491ca 100644
--- a/apps/user_openid/user.php
+++ b/apps/user_openid/user.php
@@ -37,6 +37,7 @@ if($USERNAME=='' and isset($_SERVER['PHP_AUTH_USER'])){
$RUNTIME_NOAPPS=true;
$RUNTIME_NOAPPS=false;
require_once '../../lib/base.php';
+OC_Util::checkAppEnabled('user_openid');
if(!OC_User::userExists($USERNAME)){
if(defined("DEBUG") && DEBUG) {error_log($USERNAME.' doesn\'t exist');}