Merge branch 'master' into vcategories
Conflicts: apps/contacts/lib/vcard.php
This commit is contained in:
commit
9908adb320
222 changed files with 5698 additions and 2044 deletions
2
3rdparty/MDB2/Driver/mysql.php
vendored
2
3rdparty/MDB2/Driver/mysql.php
vendored
|
@ -794,7 +794,7 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common
|
|||
? 'mysql_query' : 'mysql_unbuffered_query';
|
||||
$result = @$function($query, $connection);
|
||||
if (!$result) {
|
||||
$err =& $this->raiseError(null, null, null,
|
||||
$err =$this->raiseError(null, null, null,
|
||||
'Could not execute statement', __FUNCTION__);
|
||||
return $err;
|
||||
}
|
||||
|
|
253
3rdparty/phpass/PasswordHash.php
vendored
Normal file
253
3rdparty/phpass/PasswordHash.php
vendored
Normal file
|
@ -0,0 +1,253 @@
|
|||
<?php
|
||||
#
|
||||
# Portable PHP password hashing framework.
|
||||
#
|
||||
# Version 0.3 / genuine.
|
||||
#
|
||||
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
|
||||
# the public domain. Revised in subsequent years, still public domain.
|
||||
#
|
||||
# There's absolutely no warranty.
|
||||
#
|
||||
# The homepage URL for this framework is:
|
||||
#
|
||||
# http://www.openwall.com/phpass/
|
||||
#
|
||||
# Please be sure to update the Version line if you edit this file in any way.
|
||||
# It is suggested that you leave the main version number intact, but indicate
|
||||
# your project name (after the slash) and add your own revision information.
|
||||
#
|
||||
# Please do not change the "private" password hashing method implemented in
|
||||
# here, thereby making your hashes incompatible. However, if you must, please
|
||||
# change the hash type identifier (the "$P$") to something different.
|
||||
#
|
||||
# Obviously, since this code is in the public domain, the above are not
|
||||
# requirements (there can be none), but merely suggestions.
|
||||
#
|
||||
class PasswordHash {
|
||||
var $itoa64;
|
||||
var $iteration_count_log2;
|
||||
var $portable_hashes;
|
||||
var $random_state;
|
||||
|
||||
function PasswordHash($iteration_count_log2, $portable_hashes)
|
||||
{
|
||||
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
|
||||
$iteration_count_log2 = 8;
|
||||
$this->iteration_count_log2 = $iteration_count_log2;
|
||||
|
||||
$this->portable_hashes = $portable_hashes;
|
||||
|
||||
$this->random_state = microtime();
|
||||
if (function_exists('getmypid'))
|
||||
$this->random_state .= getmypid();
|
||||
}
|
||||
|
||||
function get_random_bytes($count)
|
||||
{
|
||||
$output = '';
|
||||
if (is_readable('/dev/urandom') &&
|
||||
($fh = @fopen('/dev/urandom', 'rb'))) {
|
||||
$output = fread($fh, $count);
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
if (strlen($output) < $count) {
|
||||
$output = '';
|
||||
for ($i = 0; $i < $count; $i += 16) {
|
||||
$this->random_state =
|
||||
md5(microtime() . $this->random_state);
|
||||
$output .=
|
||||
pack('H*', md5($this->random_state));
|
||||
}
|
||||
$output = substr($output, 0, $count);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function encode64($input, $count)
|
||||
{
|
||||
$output = '';
|
||||
$i = 0;
|
||||
do {
|
||||
$value = ord($input[$i++]);
|
||||
$output .= $this->itoa64[$value & 0x3f];
|
||||
if ($i < $count)
|
||||
$value |= ord($input[$i]) << 8;
|
||||
$output .= $this->itoa64[($value >> 6) & 0x3f];
|
||||
if ($i++ >= $count)
|
||||
break;
|
||||
if ($i < $count)
|
||||
$value |= ord($input[$i]) << 16;
|
||||
$output .= $this->itoa64[($value >> 12) & 0x3f];
|
||||
if ($i++ >= $count)
|
||||
break;
|
||||
$output .= $this->itoa64[($value >> 18) & 0x3f];
|
||||
} while ($i < $count);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function gensalt_private($input)
|
||||
{
|
||||
$output = '$P$';
|
||||
$output .= $this->itoa64[min($this->iteration_count_log2 +
|
||||
((PHP_VERSION >= '5') ? 5 : 3), 30)];
|
||||
$output .= $this->encode64($input, 6);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function crypt_private($password, $setting)
|
||||
{
|
||||
$output = '*0';
|
||||
if (substr($setting, 0, 2) == $output)
|
||||
$output = '*1';
|
||||
|
||||
$id = substr($setting, 0, 3);
|
||||
# We use "$P$", phpBB3 uses "$H$" for the same thing
|
||||
if ($id != '$P$' && $id != '$H$')
|
||||
return $output;
|
||||
|
||||
$count_log2 = strpos($this->itoa64, $setting[3]);
|
||||
if ($count_log2 < 7 || $count_log2 > 30)
|
||||
return $output;
|
||||
|
||||
$count = 1 << $count_log2;
|
||||
|
||||
$salt = substr($setting, 4, 8);
|
||||
if (strlen($salt) != 8)
|
||||
return $output;
|
||||
|
||||
# We're kind of forced to use MD5 here since it's the only
|
||||
# cryptographic primitive available in all versions of PHP
|
||||
# currently in use. To implement our own low-level crypto
|
||||
# in PHP would result in much worse performance and
|
||||
# consequently in lower iteration counts and hashes that are
|
||||
# quicker to crack (by non-PHP code).
|
||||
if (PHP_VERSION >= '5') {
|
||||
$hash = md5($salt . $password, TRUE);
|
||||
do {
|
||||
$hash = md5($hash . $password, TRUE);
|
||||
} while (--$count);
|
||||
} else {
|
||||
$hash = pack('H*', md5($salt . $password));
|
||||
do {
|
||||
$hash = pack('H*', md5($hash . $password));
|
||||
} while (--$count);
|
||||
}
|
||||
|
||||
$output = substr($setting, 0, 12);
|
||||
$output .= $this->encode64($hash, 16);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function gensalt_extended($input)
|
||||
{
|
||||
$count_log2 = min($this->iteration_count_log2 + 8, 24);
|
||||
# This should be odd to not reveal weak DES keys, and the
|
||||
# maximum valid value is (2**24 - 1) which is odd anyway.
|
||||
$count = (1 << $count_log2) - 1;
|
||||
|
||||
$output = '_';
|
||||
$output .= $this->itoa64[$count & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 6) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 12) & 0x3f];
|
||||
$output .= $this->itoa64[($count >> 18) & 0x3f];
|
||||
|
||||
$output .= $this->encode64($input, 3);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function gensalt_blowfish($input)
|
||||
{
|
||||
# This one needs to use a different order of characters and a
|
||||
# different encoding scheme from the one in encode64() above.
|
||||
# We care because the last character in our encoded string will
|
||||
# only represent 2 bits. While two known implementations of
|
||||
# bcrypt will happily accept and correct a salt string which
|
||||
# has the 4 unused bits set to non-zero, we do not want to take
|
||||
# chances and we also do not want to waste an additional byte
|
||||
# of entropy.
|
||||
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
$output = '$2a$';
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
|
||||
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
|
||||
$output .= '$';
|
||||
|
||||
$i = 0;
|
||||
do {
|
||||
$c1 = ord($input[$i++]);
|
||||
$output .= $itoa64[$c1 >> 2];
|
||||
$c1 = ($c1 & 0x03) << 4;
|
||||
if ($i >= 16) {
|
||||
$output .= $itoa64[$c1];
|
||||
break;
|
||||
}
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 4;
|
||||
$output .= $itoa64[$c1];
|
||||
$c1 = ($c2 & 0x0f) << 2;
|
||||
|
||||
$c2 = ord($input[$i++]);
|
||||
$c1 |= $c2 >> 6;
|
||||
$output .= $itoa64[$c1];
|
||||
$output .= $itoa64[$c2 & 0x3f];
|
||||
} while (1);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function HashPassword($password)
|
||||
{
|
||||
$random = '';
|
||||
|
||||
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
|
||||
$random = $this->get_random_bytes(16);
|
||||
$hash =
|
||||
crypt($password, $this->gensalt_blowfish($random));
|
||||
if (strlen($hash) == 60)
|
||||
return $hash;
|
||||
}
|
||||
|
||||
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
|
||||
if (strlen($random) < 3)
|
||||
$random = $this->get_random_bytes(3);
|
||||
$hash =
|
||||
crypt($password, $this->gensalt_extended($random));
|
||||
if (strlen($hash) == 20)
|
||||
return $hash;
|
||||
}
|
||||
|
||||
if (strlen($random) < 6)
|
||||
$random = $this->get_random_bytes(6);
|
||||
$hash =
|
||||
$this->crypt_private($password,
|
||||
$this->gensalt_private($random));
|
||||
if (strlen($hash) == 34)
|
||||
return $hash;
|
||||
|
||||
# Returning '*' on error is safe here, but would _not_ be safe
|
||||
# in a crypt(3)-like function used _both_ for generating new
|
||||
# hashes and for validating passwords against existing hashes.
|
||||
return '*';
|
||||
}
|
||||
|
||||
function CheckPassword($password, $stored_hash)
|
||||
{
|
||||
$hash = $this->crypt_private($password, $stored_hash);
|
||||
if ($hash[0] == '*')
|
||||
$hash = crypt($password, $stored_hash);
|
||||
|
||||
return $hash == $stored_hash;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
21
3rdparty/phpass/c/Makefile
vendored
Normal file
21
3rdparty/phpass/c/Makefile
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
#
|
||||
# Written by Solar Designer and placed in the public domain.
|
||||
# See crypt_private.c for more information.
|
||||
#
|
||||
CC = gcc
|
||||
LD = $(CC)
|
||||
RM = rm -f
|
||||
CFLAGS = -Wall -O2 -fomit-frame-pointer -funroll-loops
|
||||
LDFLAGS = -s
|
||||
LIBS = -lcrypto
|
||||
|
||||
all: crypt_private-test
|
||||
|
||||
crypt_private-test: crypt_private-test.o
|
||||
$(LD) $(LDFLAGS) $(LIBS) crypt_private-test.o -o $@
|
||||
|
||||
crypt_private-test.o: crypt_private.c
|
||||
$(CC) -c $(CFLAGS) crypt_private.c -DTEST -o $@
|
||||
|
||||
clean:
|
||||
$(RM) crypt_private-test*
|
106
3rdparty/phpass/c/crypt_private.c
vendored
Normal file
106
3rdparty/phpass/c/crypt_private.c
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* This code exists for the sole purpose to serve as another implementation
|
||||
* of the "private" password hashing method implemened in PasswordHash.php
|
||||
* and thus to confirm that these password hashes are indeed calculated as
|
||||
* intended.
|
||||
*
|
||||
* Other uses of this code are discouraged. There are much better password
|
||||
* hashing algorithms available to C programmers; one of those is bcrypt:
|
||||
*
|
||||
* http://www.openwall.com/crypt/
|
||||
*
|
||||
* Written by Solar Designer <solar at openwall.com> in 2005 and placed in
|
||||
* the public domain.
|
||||
*
|
||||
* There's absolutely no warranty.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#ifdef TEST
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
static char *itoa64 =
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
static void encode64(char *dst, char *src, int count)
|
||||
{
|
||||
int i, value;
|
||||
|
||||
i = 0;
|
||||
do {
|
||||
value = (unsigned char)src[i++];
|
||||
*dst++ = itoa64[value & 0x3f];
|
||||
if (i < count)
|
||||
value |= (unsigned char)src[i] << 8;
|
||||
*dst++ = itoa64[(value >> 6) & 0x3f];
|
||||
if (i++ >= count)
|
||||
break;
|
||||
if (i < count)
|
||||
value |= (unsigned char)src[i] << 16;
|
||||
*dst++ = itoa64[(value >> 12) & 0x3f];
|
||||
if (i++ >= count)
|
||||
break;
|
||||
*dst++ = itoa64[(value >> 18) & 0x3f];
|
||||
} while (i < count);
|
||||
}
|
||||
|
||||
char *crypt_private(char *password, char *setting)
|
||||
{
|
||||
static char output[35];
|
||||
MD5_CTX ctx;
|
||||
char hash[MD5_DIGEST_LENGTH];
|
||||
char *p, *salt;
|
||||
int count_log2, length, count;
|
||||
|
||||
strcpy(output, "*0");
|
||||
if (!strncmp(setting, output, 2))
|
||||
output[1] = '1';
|
||||
|
||||
if (strncmp(setting, "$P$", 3))
|
||||
return output;
|
||||
|
||||
p = strchr(itoa64, setting[3]);
|
||||
if (!p)
|
||||
return output;
|
||||
count_log2 = p - itoa64;
|
||||
if (count_log2 < 7 || count_log2 > 30)
|
||||
return output;
|
||||
|
||||
salt = setting + 4;
|
||||
if (strlen(salt) < 8)
|
||||
return output;
|
||||
|
||||
length = strlen(password);
|
||||
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, salt, 8);
|
||||
MD5_Update(&ctx, password, length);
|
||||
MD5_Final(hash, &ctx);
|
||||
|
||||
count = 1 << count_log2;
|
||||
do {
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, hash, MD5_DIGEST_LENGTH);
|
||||
MD5_Update(&ctx, password, length);
|
||||
MD5_Final(hash, &ctx);
|
||||
} while (--count);
|
||||
|
||||
memcpy(output, setting, 12);
|
||||
encode64(&output[12], hash, MD5_DIGEST_LENGTH);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3) return 1;
|
||||
|
||||
puts(crypt_private(argv[1], argv[2]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
72
3rdparty/phpass/test.php
vendored
Normal file
72
3rdparty/phpass/test.php
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
#
|
||||
# This is a test program for the portable PHP password hashing framework.
|
||||
#
|
||||
# Written by Solar Designer and placed in the public domain.
|
||||
# See PasswordHash.php for more information.
|
||||
#
|
||||
|
||||
require 'PasswordHash.php';
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
$ok = 0;
|
||||
|
||||
# Try to use stronger but system-specific hashes, with a possible fallback to
|
||||
# the weaker portable hashes.
|
||||
$t_hasher = new PasswordHash(8, FALSE);
|
||||
|
||||
$correct = 'test12345';
|
||||
$hash = $t_hasher->HashPassword($correct);
|
||||
|
||||
print 'Hash: ' . $hash . "\n";
|
||||
|
||||
$check = $t_hasher->CheckPassword($correct, $hash);
|
||||
if ($check) $ok++;
|
||||
print "Check correct: '" . $check . "' (should be '1')\n";
|
||||
|
||||
$wrong = 'test12346';
|
||||
$check = $t_hasher->CheckPassword($wrong, $hash);
|
||||
if (!$check) $ok++;
|
||||
print "Check wrong: '" . $check . "' (should be '0' or '')\n";
|
||||
|
||||
unset($t_hasher);
|
||||
|
||||
# Force the use of weaker portable hashes.
|
||||
$t_hasher = new PasswordHash(8, TRUE);
|
||||
|
||||
$hash = $t_hasher->HashPassword($correct);
|
||||
|
||||
print 'Hash: ' . $hash . "\n";
|
||||
|
||||
$check = $t_hasher->CheckPassword($correct, $hash);
|
||||
if ($check) $ok++;
|
||||
print "Check correct: '" . $check . "' (should be '1')\n";
|
||||
|
||||
$check = $t_hasher->CheckPassword($wrong, $hash);
|
||||
if (!$check) $ok++;
|
||||
print "Check wrong: '" . $check . "' (should be '0' or '')\n";
|
||||
|
||||
# A correct portable hash for 'test12345'.
|
||||
# Please note the use of single quotes to ensure that the dollar signs will
|
||||
# be interpreted literally. Of course, a real application making use of the
|
||||
# framework won't store password hashes within a PHP source file anyway.
|
||||
# We only do this for testing.
|
||||
$hash = '$P$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0';
|
||||
|
||||
print 'Hash: ' . $hash . "\n";
|
||||
|
||||
$check = $t_hasher->CheckPassword($correct, $hash);
|
||||
if ($check) $ok++;
|
||||
print "Check correct: '" . $check . "' (should be '1')\n";
|
||||
|
||||
$check = $t_hasher->CheckPassword($wrong, $hash);
|
||||
if (!$check) $ok++;
|
||||
print "Check wrong: '" . $check . "' (should be '0' or '')\n";
|
||||
|
||||
if ($ok == 6)
|
||||
print "All tests have PASSED\n";
|
||||
else
|
||||
print "Some tests have FAILED\n";
|
||||
|
||||
?>
|
|
@ -28,19 +28,6 @@ OC_Util::checkLoggedIn();
|
|||
OC_Util::checkAppEnabled('bookmarks');
|
||||
|
||||
require_once('bookmarksHelper.php');
|
||||
addBookmark($_GET['url'], '', 'Read-Later');
|
||||
|
||||
OC_App::setActiveNavigationEntry( 'bookmarks_index' );
|
||||
|
||||
OC_Util::addScript('bookmarks','addBm');
|
||||
OC_Util::addStyle('bookmarks', 'bookmarks');
|
||||
|
||||
$tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
|
||||
|
||||
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
|
||||
$metadata = getURLMetadata($url);
|
||||
|
||||
$tmpl->assign('URL', htmlentities($metadata['url'],ENT_COMPAT,'utf-8'));
|
||||
$title = isset($metadata['title']) ? $metadata['title'] : (isset($_GET['title']) ? $_GET['title'] : '');
|
||||
$tmpl->assign('TITLE', htmlentities($title,ENT_COMPAT,'utf-8'));
|
||||
|
||||
$tmpl->printPage();
|
||||
include 'templates/addBm.php';
|
||||
|
|
|
@ -30,50 +30,6 @@ require_once('../../../lib/base.php');
|
|||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('bookmarks');
|
||||
|
||||
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
|
||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||
$_ut = "strftime('%s','now')";
|
||||
} elseif($CONFIG_DBTYPE == 'pgsql') {
|
||||
$_ut = 'date_part(\'epoch\',now())::integer';
|
||||
} else {
|
||||
$_ut = "UNIX_TIMESTAMP()";
|
||||
}
|
||||
|
||||
//FIXME: Detect when user adds a known URL
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks
|
||||
(url, title, user_id, public, added, lastmodified)
|
||||
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
||||
");
|
||||
|
||||
|
||||
$params=array(
|
||||
htmlspecialchars_decode($_GET["url"]),
|
||||
htmlspecialchars_decode($_GET["title"]),
|
||||
OC_User::getUser()
|
||||
);
|
||||
$query->execute($params);
|
||||
|
||||
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
|
||||
|
||||
|
||||
if($b_id !== false) {
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
(bookmark_id, tag)
|
||||
VALUES (?, ?)
|
||||
");
|
||||
|
||||
$tags = explode(' ', urldecode($_GET["tags"]));
|
||||
foreach ($tags as $tag) {
|
||||
if(empty($tag)) {
|
||||
//avoid saving blankspaces
|
||||
continue;
|
||||
}
|
||||
$params = array($b_id, trim($tag));
|
||||
$query->execute($params);
|
||||
}
|
||||
|
||||
OC_JSON::success(array('data' => $b_id));
|
||||
}
|
||||
|
||||
require_once('../bookmarksHelper.php');
|
||||
$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']);
|
||||
OC_JSON::success(array('data' => $id));
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - bookmarks plugin
|
||||
*
|
||||
* @author Arthur Schiwon
|
||||
* @copyright 2011 Arthur Schiwon blizzz@arthur-schiwon.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 Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//no apps or filesystem
|
||||
$RUNTIME_NOSETUPFS=true;
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('bookmarks');
|
||||
|
||||
// $metadata = array();
|
||||
|
||||
require '../bookmarksHelper.php';
|
||||
$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"]));
|
||||
|
||||
|
||||
OC_JSON::success(array('data' => $metadata));
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
|
||||
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php';
|
||||
OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php';
|
||||
|
||||
OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
|
||||
|
||||
|
@ -15,5 +16,5 @@ $l = new OC_l10n('bookmarks');
|
|||
OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OC_Helper::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
|
||||
|
||||
OC_App::registerPersonal('bookmarks', 'settings');
|
||||
require_once('apps/bookmarks/lib/search.php');
|
||||
OC_Util::addScript('bookmarks','bookmarksearch');
|
||||
OC_Search::registerProvider('OC_Search_Provider_Bookmarks');
|
||||
|
|
|
@ -75,14 +75,6 @@
|
|||
<sorting>descending</sorting>
|
||||
</field>
|
||||
</index>
|
||||
<!-- <index>
|
||||
<name>url</name>
|
||||
<unique>true</unique>
|
||||
<field>
|
||||
<name>url</name>
|
||||
<sorting>ascending</sorting>
|
||||
</field>
|
||||
</index>-->
|
||||
</declaration>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<id>bookmarks</id>
|
||||
<name>Bookmarks</name>
|
||||
<description>Bookmark manager for ownCloud</description>
|
||||
<version>0.1</version>
|
||||
<version>0.2</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Arthur Schiwon</author>
|
||||
<author>Arthur Schiwon, Marvin Thomas Rabe</author>
|
||||
<require>2</require>
|
||||
</info>
|
|
@ -70,3 +70,55 @@ function getURLMetadata($url) {
|
|||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
function addBookmark($url, $title='', $tags='') {
|
||||
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
|
||||
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
|
||||
$_ut = "strftime('%s','now')";
|
||||
} elseif($CONFIG_DBTYPE == 'pgsql') {
|
||||
$_ut = 'date_part(\'epoch\',now())::integer';
|
||||
} else {
|
||||
$_ut = "UNIX_TIMESTAMP()";
|
||||
}
|
||||
|
||||
//FIXME: Detect when user adds a known URL
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks
|
||||
(url, title, user_id, public, added, lastmodified)
|
||||
VALUES (?, ?, ?, 0, $_ut, $_ut)
|
||||
");
|
||||
|
||||
if(empty($title)) {
|
||||
$metadata = getURLMetadata($url);
|
||||
$title = $metadata['title'];
|
||||
}
|
||||
|
||||
$params=array(
|
||||
htmlspecialchars_decode($url),
|
||||
htmlspecialchars_decode($title),
|
||||
OC_User::getUser()
|
||||
);
|
||||
$query->execute($params);
|
||||
|
||||
$b_id = OC_DB::insertid('*PREFIX*bookmarks');
|
||||
|
||||
if($b_id !== false) {
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
(bookmark_id, tag)
|
||||
VALUES (?, ?)
|
||||
");
|
||||
|
||||
$tags = explode(' ', urldecode($tags));
|
||||
foreach ($tags as $tag) {
|
||||
if(empty($tag)) {
|
||||
//avoid saving blankspaces
|
||||
continue;
|
||||
}
|
||||
$params = array($b_id, trim($tag));
|
||||
$query->execute($params);
|
||||
}
|
||||
|
||||
return $b_id;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
#content { overflow: auto; }
|
||||
#content { overflow: auto; height: 100%; }
|
||||
#firstrun { width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
|
||||
#firstrun small { display: block; font-weight: normal; font-size: 0.5em; margin-bottom: 1.5em; }
|
||||
#firstrun .button { font-size: 0.7em; }
|
||||
#firstrun #selections { font-size:0.8em; font-weight: normal; width: 100%; margin: 2em auto auto auto; clear: both; }
|
||||
|
||||
.bookmarks_headline {
|
||||
font-size: large;
|
||||
|
@ -12,13 +16,10 @@
|
|||
padding: 0.5ex;
|
||||
}
|
||||
|
||||
.bookmarks_add {
|
||||
display: none;
|
||||
margin-top: 45px;
|
||||
}
|
||||
|
||||
.bookmarks_list {
|
||||
margin-top: 36px;
|
||||
overflow: auto;
|
||||
position: fixed;
|
||||
top: 6.5em;
|
||||
}
|
||||
|
||||
.bookmarks_addBml {
|
||||
|
@ -32,7 +33,7 @@
|
|||
}
|
||||
|
||||
.bookmarks_input {
|
||||
width: 20em;
|
||||
width: 8em;
|
||||
}
|
||||
|
||||
.bookmark_actions {
|
||||
|
@ -84,16 +85,3 @@
|
|||
display: none;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
color: #999;
|
||||
font-size: medium;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
visibility: visible;
|
||||
display: block
|
||||
}
|
||||
|
|
|
@ -4,13 +4,12 @@ $(document).ready(function() {
|
|||
|
||||
function addBookmark(event) {
|
||||
var url = $('#bookmark_add_url').val();
|
||||
var title = $('#bookmark_add_title').val();
|
||||
var tags = $('#bookmark_add_tags').val();
|
||||
$.ajax({
|
||||
url: 'ajax/addBookmark.php',
|
||||
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
|
||||
data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags),
|
||||
success: function(data){
|
||||
location.href='index.php';
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
}
|
|
@ -3,19 +3,16 @@ var bookmarks_loading = false;
|
|||
|
||||
var bookmarks_sorting = 'bookmarks_sorting_recent';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.bookmarks_addBtn').click(function(event){
|
||||
$('.bookmarks_add').slideToggle();
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#bookmark_add_submit').click(addOrEditBookmark);
|
||||
$(window).scroll(updateOnBottom);
|
||||
|
||||
$('#bookmark_add_url').focusout(getMetadata);
|
||||
$(window).resize(function () {
|
||||
fillWindow($('.bookmarks_list'));
|
||||
});
|
||||
$(window).resize();
|
||||
$($('.bookmarks_list')).scroll(updateOnBottom);
|
||||
|
||||
$('.bookmarks_list').empty();
|
||||
getBookmarks();
|
||||
|
||||
});
|
||||
|
||||
function getBookmarks() {
|
||||
|
@ -28,13 +25,19 @@ function getBookmarks() {
|
|||
url: 'ajax/updateList.php',
|
||||
data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
|
||||
success: function(bookmarks){
|
||||
bookmarks_page += 1;
|
||||
if (bookmarks.data.length) {
|
||||
bookmarks_page += 1;
|
||||
}
|
||||
$('.bookmark_link').unbind('click', recordClick);
|
||||
$('.bookmark_delete').unbind('click', delBookmark);
|
||||
$('.bookmark_edit').unbind('click', showBookmark);
|
||||
|
||||
for(var i in bookmarks.data) {
|
||||
updateBookmarksList(bookmarks.data[i]);
|
||||
$("#firstrun").hide();
|
||||
}
|
||||
if($('.bookmarks_list').is(':empty')) {
|
||||
$("#firstrun").show();
|
||||
}
|
||||
|
||||
$('.bookmark_link').click(recordClick);
|
||||
|
@ -42,24 +45,13 @@ function getBookmarks() {
|
|||
$('.bookmark_edit').click(showBookmark);
|
||||
|
||||
bookmarks_loading = false;
|
||||
if (bookmarks.data.length) {
|
||||
updateOnBottom()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getMetadata() {
|
||||
var url = encodeEntities($('#bookmark_add_url').val());
|
||||
$('.loading_meta').css('display','inline');
|
||||
$.ajax({
|
||||
url: 'ajax/getMeta.php',
|
||||
data: 'url=' + encodeURIComponent(url),
|
||||
success: function(pageinfo){
|
||||
$('#bookmark_add_url').val(pageinfo.data.url);
|
||||
$('#bookmark_add_title').val(pageinfo.data.title);
|
||||
$('.loading_meta').css('display','none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// function addBookmark() {
|
||||
// Instead of creating editBookmark() function, Converted the one above to
|
||||
// addOrEditBookmark() to make .js file more compact.
|
||||
|
@ -69,35 +61,17 @@ function addOrEditBookmark(event) {
|
|||
var url = encodeEntities($('#bookmark_add_url').val());
|
||||
var title = encodeEntities($('#bookmark_add_title').val());
|
||||
var tags = encodeEntities($('#bookmark_add_tags').val());
|
||||
var taglist = tags.split(' ');
|
||||
var tagshtml = '';
|
||||
for ( var i=0, len=taglist.length; i<len; ++i ){
|
||||
tagshtml += '<a class="bookmark_tag" href="?tag=' + encodeURI(taglist[i]) + '">' + taglist[i] + '</a> ';
|
||||
}
|
||||
$("#firstrun").hide();
|
||||
|
||||
if (id == 0) {
|
||||
$.ajax({
|
||||
url: 'ajax/addBookmark.php',
|
||||
data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
|
||||
success: function(response){
|
||||
var bookmark_id = response.data;
|
||||
$('.bookmarks_add').slideToggle();
|
||||
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
|
||||
$('.bookmarks_list').prepend(
|
||||
'<div class="bookmark_single" data-id="' + bookmark_id + '" >' +
|
||||
'<p class="bookmark_actions">' +
|
||||
'<span class="bookmark_delete">' +
|
||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
|
||||
'</span> ' +
|
||||
'<span class="bookmark_edit">' +
|
||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
|
||||
'</span>' +
|
||||
'</p>' +
|
||||
'<p class="bookmark_title"><a href="' + url + '" target="_blank" class="bookmark_link">' + title + '</a></p>' +
|
||||
'<p class="bookmark_tags">' + tagshtml + '</p>' +
|
||||
'<p class="bookmark_url">' + url + '</p>' +
|
||||
'</div>'
|
||||
);
|
||||
$('.bookmarks_input').val('');
|
||||
$('.bookmarks_list').empty();
|
||||
bookmarks_page = 0;
|
||||
getBookmarks();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -106,18 +80,11 @@ function addOrEditBookmark(event) {
|
|||
url: 'ajax/editBookmark.php',
|
||||
data: 'id=' + id + '&url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags),
|
||||
success: function(){
|
||||
$('.bookmarks_add').slideToggle();
|
||||
$('.bookmarks_add').children('p').children('.bookmarks_input').val('');
|
||||
$('.bookmarks_input').val('');
|
||||
$('#bookmark_add_id').val('0');
|
||||
|
||||
var record = $('.bookmark_single[data-id = "' + id + '"]');
|
||||
record.children('.bookmark_url:first').text(url);
|
||||
|
||||
var record_title = record.children('.bookmark_title:first').children('a:first');
|
||||
record_title.attr('href', url);
|
||||
record_title.text(title);
|
||||
|
||||
record.children('.bookmark_tags:first').html(tagshtml);
|
||||
$('.bookmarks_list').empty();
|
||||
bookmarks_page = 0;
|
||||
getBookmarks();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -129,7 +96,12 @@ function delBookmark(event) {
|
|||
$.ajax({
|
||||
url: 'ajax/delBookmark.php',
|
||||
data: 'url=' + encodeURI($(this).parent().parent().children('.bookmark_url:first').text()),
|
||||
success: function(data){ record.animate({ opacity: 'hide' }, 'fast'); }
|
||||
success: function(data){
|
||||
record.remove();
|
||||
if($('.bookmarks_list').is(':empty')) {
|
||||
$("#firstrun").show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -159,15 +131,16 @@ function updateBookmarksList(bookmark) {
|
|||
if(!hasProtocol(bookmark.url)) {
|
||||
bookmark.url = 'http://' + bookmark.url;
|
||||
}
|
||||
if(bookmark.title == '') bookmark.title = bookmark.url;
|
||||
$('.bookmarks_list').append(
|
||||
'<div class="bookmark_single" data-id="' + bookmark.id +'" >' +
|
||||
'<p class="bookmark_actions">' +
|
||||
'<span class="bookmark_delete">' +
|
||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
|
||||
'</span> ' +
|
||||
'<span class="bookmark_edit">' +
|
||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' +
|
||||
'</span>' +
|
||||
'<span class="bookmark_delete">' +
|
||||
'<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' +
|
||||
'</span> ' +
|
||||
'</p>' +
|
||||
'<p class="bookmark_title">'+
|
||||
'<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' +
|
||||
|
@ -182,7 +155,11 @@ function updateBookmarksList(bookmark) {
|
|||
|
||||
function updateOnBottom() {
|
||||
//check wether user is on bottom of the page
|
||||
if ($('body').height() <= ($(window).height() + $(window).scrollTop())) {
|
||||
var top = $('.bookmarks_list>:last-child').position().top;
|
||||
var height = $('.bookmarks_list').height();
|
||||
// use a bit of margin to begin loading before we are really at the
|
||||
// bottom
|
||||
if (top < height * 1.2) {
|
||||
getBookmarks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
|
||||
function search($query){
|
||||
class OC_Search_Provider_Bookmarks implements OC_Search_Provider{
|
||||
static function search($query){
|
||||
$results=array();
|
||||
|
||||
$offset = 0;
|
||||
|
@ -45,6 +45,3 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
|
|||
return $results;
|
||||
}
|
||||
}
|
||||
new OC_Search_Provider_Bookmarks();
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
|
@ -8,6 +8,4 @@
|
|||
|
||||
$tmpl = new OC_Template( 'bookmarks', 'settings');
|
||||
|
||||
//OC_Util::addScript('bookmarks','settings');
|
||||
|
||||
return $tmpl->fetchPage();
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<div class="bookmarks_addBm">
|
||||
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<?php echo $_['URL']; ?>"/></p>
|
||||
<p><label class="bookmarks_label"><?php echo $l->t('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('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
|
||||
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
|
||||
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
|
||||
</div>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Read later - ownCloud</title>
|
||||
<link rel="stylesheet" href="css/readlater.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="message"><h1>Saved!</h1></div>
|
||||
</body>
|
||||
</html>
|
8
apps/bookmarks/templates/bookmarklet.php
Normal file
8
apps/bookmarks/templates/bookmarklet.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
function createBookmarklet() {
|
||||
$l = new OC_L10N('bookmarks');
|
||||
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>'
|
||||
. '<a class="bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=230px,width=230px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
|
||||
. $l->t('Read later') . '</a>';
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
|
||||
* Copyright (c) 2011 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
|
@ -9,21 +9,18 @@
|
|||
?>
|
||||
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" />
|
||||
<div id="controls">
|
||||
<input type="button" class="bookmarks_addBtn" value="<?php echo $l->t('Add bookmark'); ?>"/>
|
||||
</div>
|
||||
<div class="bookmarks_add">
|
||||
<input type="hidden" id="bookmark_add_id" value="0" />
|
||||
<p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p>
|
||||
<p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" />
|
||||
<img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p>
|
||||
<p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p>
|
||||
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p>
|
||||
<p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p>
|
||||
<input type="text" id="bookmark_add_url" placeholder="<?php echo $l->t('Address'); ?>" class="bookmarks_input" />
|
||||
<input type="text" id="bookmark_add_title" placeholder="<?php echo $l->t('Title'); ?>" class="bookmarks_input" />
|
||||
<input type="text" id="bookmark_add_tags" placeholder="<?php echo $l->t('Tags'); ?>" class="bookmarks_input" />
|
||||
<input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" />
|
||||
</div>
|
||||
<div class="bookmarks_list">
|
||||
<?php echo $l->t('You have no bookmarks'); ?>
|
||||
</div>
|
||||
<div id="footer">
|
||||
Bookmark pages more easily. Drag this bookmarklet to the Bookmarks bar of your browser:
|
||||
<a style='background-color:#dddddd;border:1px groove #999; padding:5px;padding-top:0px;padding-bottom:2px; text-decoration:none; margin-top:5px' href='javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open("<?php echo OC_Helper::linkToAbsolute('bookmarks', 'addBm.php') ?>?output=popup&url="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=510px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)})();'>ownCloud bookmark</a>
|
||||
<div id="firstrun" style="display: none;">
|
||||
<?php
|
||||
echo $l->t('You have no bookmarks');
|
||||
require_once('bookmarklet.php');
|
||||
createBookmarklet();
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
|
||||
* Copyright (c) 2011 Marvin Thomas Rabe <mrabe@marvinrabe.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
|
@ -8,7 +8,10 @@
|
|||
?>
|
||||
<form id="bookmarks">
|
||||
<fieldset class="personalblock">
|
||||
<span class="bold"><?php echo $l->t('Bookmarklet:');?></span> <a class="bookmarks_addBml" href="javascript:(function(){url=encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkToAbsolute('bookmarks', 'addBm.php'); ?>?url='+url, 'owncloud-bookmarks') })()"><?php echo $l->t('Add page to ownCloud'); ?></a>
|
||||
<br/><em><?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?></em><br />
|
||||
<span class="bold"><?php echo $l->t('Bookmarklet <br />');?></span>
|
||||
<?php
|
||||
require_once('bookmarklet.php');
|
||||
createBookmarklet();
|
||||
?>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once ("../../../lib/base.php");
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
$calendarid = $_POST['calendarid'];
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
20
apps/calendar/ajax/calendar/edit.php
Normal file
20
apps/calendar/ajax/calendar/edit.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
||||
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
|
||||
$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
|
||||
$tmpl = new OC_Template("calendar", "part.editcalendar");
|
||||
$tmpl->assign('new', false);
|
||||
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
|
||||
$tmpl->assign('calendar', $calendar);
|
||||
$tmpl->printPage();
|
||||
?>
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
$l10n = new OC_L10N('calendar');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
$l10n = new OC_L10N('calendar');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
|
@ -25,16 +25,8 @@ foreach($calendars as $cal){
|
|||
}
|
||||
|
||||
$calendarid = $_POST['id'];
|
||||
$calendarcolor = $_POST['color'];
|
||||
if (preg_match('/^#?([0-9a-f]{6})/', $calendarcolor, $matches)) {
|
||||
$calendarcolor = '#'.$matches[1];
|
||||
}
|
||||
else {
|
||||
$calendarcolor = null;
|
||||
}
|
||||
|
||||
$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
|
||||
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $calendarcolor);
|
||||
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
|
||||
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
||||
|
||||
$calendar = OC_Calendar_App::getCalendar($calendarid);
|
|
@ -9,7 +9,16 @@
|
|||
require_once ("../../../lib/base.php");
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
$currentview = $_GET["v"];
|
||||
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
|
||||
$view = $_GET['v'];
|
||||
switch($view){
|
||||
case 'agendaWeek':
|
||||
case 'month';
|
||||
case 'list':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter: ' . $view));
|
||||
exit;
|
||||
}
|
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'currentview', $view);
|
||||
OC_JSON::success();
|
||||
?>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('calendar');
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
if(!OC_USER::isLoggedIn()) {
|
||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
||||
|
@ -243,16 +243,6 @@ if($repeat['repeat'] != 'doesnotrepeat'){
|
|||
$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
|
||||
$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
|
||||
}
|
||||
else {
|
||||
$tmpl->assign('repeat_month', 'monthday');
|
||||
$tmpl->assign('repeat_weekdays', array());
|
||||
$tmpl->assign('repeat_interval', 1);
|
||||
$tmpl->assign('repeat_end', 'never');
|
||||
$tmpl->assign('repeat_count', '10');
|
||||
$tmpl->assign('repeat_weekofmonth', 'auto');
|
||||
$tmpl->assign('repeat_date', '');
|
||||
$tmpl->assign('repeat_year', 'bydate');
|
||||
}
|
||||
$tmpl->printpage();
|
||||
|
||||
?>
|
||||
?>
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
|
||||
$id = $_POST['id'];
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
if(!OC_USER::isLoggedIn()) {
|
||||
die('<script type="text/javascript">document.location = oc_webroot;</script>');
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('calendar');
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
|
||||
$id = $_POST['id'];
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
require_once ('../../../lib/base.php');
|
||||
require_once('../../../3rdparty/when/When.php');
|
||||
require_once('when/When.php');
|
||||
|
||||
function create_return_event($event, $vevent){
|
||||
$return_event = array();
|
||||
|
@ -27,25 +27,40 @@ function create_return_event($event, $vevent){
|
|||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
||||
$start = DateTime::createFromFormat('U', $_GET['start']);
|
||||
$end = DateTime::createFromFormat('U', $_GET['end']);
|
||||
if(version_compare(PHP_VERSION, '5.3.0', '>=')){
|
||||
$start = DateTime::createFromFormat('U', $_GET['start']);
|
||||
$end = DateTime::createFromFormat('U', $_GET['end']);
|
||||
}else{
|
||||
$start = new DateTime('@' . $_GET['start']);
|
||||
$end = new DateTime('@' . $_GET['end']);
|
||||
}
|
||||
|
||||
$calendar = OC_Calendar_App::getCalendar($_GET['calendar_id']);
|
||||
OC_Response::enableCaching(0);
|
||||
OC_Response::setETagHeader($calendar['ctag']);
|
||||
$calendar_id = $_GET['calendar_id'];
|
||||
if (is_numeric($calendar_id)) {
|
||||
$calendar = OC_Calendar_App::getCalendar($calendar_id);
|
||||
OC_Response::enableCaching(0);
|
||||
OC_Response::setETagHeader($calendar['ctag']);
|
||||
$events = OC_Calendar_Object::allInPeriod($calendar_id, $start, $end);
|
||||
} else {
|
||||
$events = array();
|
||||
OC_Hook::emit('OC_Calendar', 'getEvents', array('calendar_id' => $calendar_id, 'events' => &$events));
|
||||
}
|
||||
|
||||
$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
|
||||
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
|
||||
$return = array();
|
||||
foreach($events as $event){
|
||||
$object = OC_VObject::parse($event['calendardata']);
|
||||
$vevent = $object->VEVENT;
|
||||
if (isset($event['calendardata'])) {
|
||||
$object = OC_VObject::parse($event['calendardata']);
|
||||
$vevent = $object->VEVENT;
|
||||
} else {
|
||||
$vevent = $event['vevent'];
|
||||
}
|
||||
|
||||
$return_event = create_return_event($event, $vevent);
|
||||
|
||||
$dtstart = $vevent->DTSTART;
|
||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||
$start_dt = $dtstart->getDateTime();
|
||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||
$end_dt = $dtend->getDateTime();
|
||||
if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
|
||||
$return_event['allDay'] = true;
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
function make_array_out_of_xml ($xml){
|
||||
$returnarray = array();
|
||||
$xml = (array)$xml ;
|
||||
foreach ($xml as $property => $value){
|
||||
$value = (array)$value;
|
||||
if(!isset($value[0])){
|
||||
$returnarray[$property] = make_array_out_of_xml($value);
|
||||
}else{
|
||||
$returnarray[$property] = trim($value[0]);
|
||||
}
|
||||
}
|
||||
return $returnarray;
|
||||
}
|
||||
require_once ("../../../lib/base.php");
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
$l = new OC_L10N('calendar');
|
||||
$lat = $_GET['lat'];
|
||||
$long = $_GET['long'];
|
||||
if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'position') == $lat . '-' . $long && OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone') != null){
|
||||
OC_JSON::success();
|
||||
exit;
|
||||
}
|
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'position', $lat . '-' . $long);
|
||||
$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long);
|
||||
//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
|
||||
$geoxml = simplexml_load_string($geolocation);
|
||||
$geoarray = make_array_out_of_xml($geoxml);
|
||||
if($geoarray['timezone']['timezoneId'] == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){
|
||||
OC_JSON::success();
|
||||
exit;
|
||||
}
|
||||
if(in_array($geoarray['timezone']['timezoneId'], DateTimeZone::listIdentifiers())){
|
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
|
||||
$message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']);
|
||||
OC_JSON::success($message);
|
||||
}else{
|
||||
OC_JSON::error();
|
||||
}
|
||||
|
||||
?>
|
|
@ -6,7 +6,7 @@
|
|||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
$l10n = new OC_L10N('calendar');
|
120
apps/calendar/ajax/import/import.php
Normal file
120
apps/calendar/ajax/import/import.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
//check for calendar rights or create new one
|
||||
ob_start();
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
$nl = "\n";
|
||||
$progressfile = OC::$APPSROOT . '/apps/calendar/import_tmp/' . md5(session_id()) . '.txt';
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '10');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
|
||||
if($_POST['method'] == 'new'){
|
||||
$id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']);
|
||||
OC_Calendar_Calendar::setCalendarActive($id, 1);
|
||||
}else{
|
||||
$calendar = OC_Calendar_App::getCalendar($_POST['id']);
|
||||
if($calendar['userid'] != OC_USER::getUser()){
|
||||
OC_JSON::error();
|
||||
exit();
|
||||
}
|
||||
$id = $_POST['id'];
|
||||
}
|
||||
//analyse the calendar file
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '20');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
$searchfor = array('VEVENT', 'VTODO', 'VJOURNAL');
|
||||
$parts = $searchfor;
|
||||
$filearr = explode($nl, $file);
|
||||
$inelement = false;
|
||||
$parts = array();
|
||||
$i = 0;
|
||||
foreach($filearr as $line){
|
||||
foreach($searchfor as $search){
|
||||
if(substr_count($line, $search) == 1){
|
||||
list($attr, $val) = explode(':', $line);
|
||||
if($attr == 'BEGIN'){
|
||||
$parts[]['begin'] = $i;
|
||||
$inelement = true;
|
||||
}
|
||||
if($attr == 'END'){
|
||||
$parts[count($parts) - 1]['end'] = $i;
|
||||
$inelement = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
//import the calendar
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '40');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
$start = '';
|
||||
for ($i = 0; $i < $parts[0]['begin']; $i++) {
|
||||
if($i == 0){
|
||||
$start = $filearr[0];
|
||||
}else{
|
||||
$start .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
$end = '';
|
||||
for($i = $parts[count($parts) - 1]['end'] + 1;$i <= count($filearr) - 1; $i++){
|
||||
if($i == $parts[count($parts) - 1]['end'] + 1){
|
||||
$end = $filearr[$parts[count($parts) - 1]['end'] + 1];
|
||||
}else{
|
||||
$end .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '50');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
$importready = array();
|
||||
foreach($parts as $part){
|
||||
for($i = $part['begin']; $i <= $part['end'];$i++){
|
||||
if($i == $part['begin']){
|
||||
$content = $filearr[$i];
|
||||
}else{
|
||||
$content .= $nl . $filearr[$i];
|
||||
}
|
||||
}
|
||||
$importready[] = $start . $nl . $content . $nl . $end;
|
||||
}
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '70');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
if(count($parts) == 1){
|
||||
OC_Calendar_Object::add($id, $file);
|
||||
}else{
|
||||
foreach($importready as $import){
|
||||
OC_Calendar_Object::add($id, $import);
|
||||
}
|
||||
}
|
||||
//done the import
|
||||
if(is_writable('import_tmp/')){
|
||||
$progressfopen = fopen($progressfile, 'w');
|
||||
fwrite($progressfopen, '100');
|
||||
fclose($progressfopen);
|
||||
}
|
||||
sleep(3);
|
||||
if(is_writable('import_tmp/')){
|
||||
unlink($progressfile);
|
||||
}
|
||||
OC_JSON::success();
|
12
apps/calendar/ajax/settings/getfirstday.php
Normal file
12
apps/calendar/ajax/settings/getfirstday.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
$firstday = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstday', 'mo');
|
||||
OC_JSON::encodedPrint(array('firstday' => $firstday));
|
||||
?>
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once ("../../../lib/base.php");
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
OC_JSON::success(array('detection' => OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezonedetection')));
|
27
apps/calendar/ajax/settings/guesstimezone.php
Executable file
27
apps/calendar/ajax/settings/guesstimezone.php
Executable file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
||||
$l = new OC_L10N('calendar');
|
||||
|
||||
$lat = $_GET['lat'];
|
||||
$lng = $_GET['long'];
|
||||
|
||||
$timezone = OC_Geo::timezone($lat, $lng);
|
||||
|
||||
if($timezone == OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone')){
|
||||
OC_JSON::success();
|
||||
exit;
|
||||
}
|
||||
OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $timezone);
|
||||
$message = array('message'=> $l->t('New Timezone:') . $timezone);
|
||||
OC_JSON::success($message);
|
||||
?>
|
17
apps/calendar/ajax/settings/setfirstday.php
Normal file
17
apps/calendar/ajax/settings/setfirstday.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
if(isset($_POST["firstday"])){
|
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstday', $_POST["firstday"]);
|
||||
OC_JSON::success();
|
||||
}else{
|
||||
OC_JSON::error();
|
||||
}
|
||||
?>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
if(isset($_POST["timeformat"])){
|
||||
OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
|
||||
$l=new OC_L10N('calendar');
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24");
|
||||
OC_JSON::encodedPrint(array("timeformat" => $timeformat));
|
|
@ -5,7 +5,7 @@
|
|||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once ("../../../lib/base.php");
|
||||
require_once('../../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
if($_POST['timezonedetection'] == 'on'){
|
40
apps/calendar/ajax/share/changepermission.php
Normal file
40
apps/calendar/ajax/share/changepermission.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
$id = strip_tags($_GET['id']);
|
||||
$idtype = strip_tags($_GET['idtype']);
|
||||
$permission = (int) strip_tags($_GET['permission']);
|
||||
switch($idtype){
|
||||
case 'calendar':
|
||||
case 'event':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
$sharewith = $_GET['sharewith'];
|
||||
$sharetype = strip_tags($_GET['sharetype']);
|
||||
switch($sharetype){
|
||||
case 'user':
|
||||
case 'group':
|
||||
case 'public':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'user not found'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'group not found'));
|
||||
exit;
|
||||
}
|
||||
$success = OC_Calendar_Share::changepermission($sharewith, $sharetype, $id, $permission, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
|
||||
OC_JSON::success();
|
18
apps/calendar/ajax/share/dropdown.php
Normal file
18
apps/calendar/ajax/share/dropdown.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
$user = OC_USER::getUser();
|
||||
$calid = $_GET['calid'];
|
||||
$calendar = OC_Calendar_Calendar::find($calid);
|
||||
if($calendar['userid'] != $user){
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
$tmpl = new OC_Template('calendar', 'share.dropdown');
|
||||
$tmpl->assign('calid', $calid);
|
||||
$tmpl->printPage();
|
51
apps/calendar/ajax/share/share.php
Normal file
51
apps/calendar/ajax/share/share.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
$id = strip_tags($_GET['id']);
|
||||
$idtype = strip_tags($_GET['idtype']);
|
||||
switch($idtype){
|
||||
case 'calendar':
|
||||
case 'event':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
$sharewith = $_GET['sharewith'];
|
||||
$sharetype = strip_tags($_GET['sharetype']);
|
||||
switch($sharetype){
|
||||
case 'user':
|
||||
case 'group':
|
||||
case 'public':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'user not found'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'group not found'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'user' && OC_User::getUser() == $sharewith){
|
||||
OC_JSON::error(array('meesage'=>'you can not share with yourself'));
|
||||
}
|
||||
$success = OC_Calendar_Share::share(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
|
||||
if($success){
|
||||
if($sharetype == 'public'){
|
||||
OC_JSON::success(array('message'=>$success));
|
||||
}else{
|
||||
OC_JSON::success(array('message'=>'shared'));
|
||||
}
|
||||
}else{
|
||||
OC_JSON::error(array('message'=>'can not share'));
|
||||
exit;
|
||||
}
|
44
apps/calendar/ajax/share/unshare.php
Normal file
44
apps/calendar/ajax/share/unshare.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
require_once('../../../../lib/base.php');
|
||||
$id = strip_tags($_GET['id']);
|
||||
$idtype = strip_tags($_GET['idtype']);
|
||||
switch($idtype){
|
||||
case 'calendar':
|
||||
case 'event':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
$sharewith = $_GET['sharewith'];
|
||||
$sharetype = strip_tags($_GET['sharetype']);
|
||||
switch($sharetype){
|
||||
case 'user':
|
||||
case 'group':
|
||||
case 'public':
|
||||
break;
|
||||
default:
|
||||
OC_JSON::error(array('message'=>'unexspected parameter'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'user' && !OC_User::userExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'user not found'));
|
||||
exit;
|
||||
}
|
||||
if($sharetype == 'group' && !OC_Group::groupExists($sharewith)){
|
||||
OC_JSON::error(array('message'=>'group not found'));
|
||||
exit;
|
||||
}
|
||||
$success = OC_Calendar_Share::unshare(OC_User::getUser(), $sharewith, $sharetype, $id, (($idtype=='calendar') ? OC_Calendar_Share::CALENDAR : OC_Calendar_Share::Event));
|
||||
if($success){
|
||||
OC_JSON::success();
|
||||
}else{
|
||||
OC_JSON::error(array('message'=>'can not unshare'));
|
||||
exit;
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
<?php
|
||||
if(version_compare(PHP_VERSION, '5.3.0', '>=')){
|
||||
$l=new OC_L10N('calendar');
|
||||
OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
|
||||
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
|
||||
OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
|
||||
OC_Util::addScript('calendar','loader');
|
||||
OC_App::register( array(
|
||||
'order' => 10,
|
||||
'id' => 'calendar',
|
||||
'name' => 'Calendar' ));
|
||||
OC_App::addNavigationEntry( array(
|
||||
'id' => 'calendar_index',
|
||||
'order' => 10,
|
||||
'href' => OC_Helper::linkTo( 'calendar', 'index.php' ),
|
||||
'icon' => OC_Helper::imagePath( 'calendar', 'icon.svg' ),
|
||||
'name' => $l->t('Calendar')));
|
||||
OC_App::registerPersonal('calendar', 'settings');
|
||||
require_once('apps/calendar/lib/search.php');
|
||||
}
|
||||
$l=new OC_L10N('calendar');
|
||||
OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
|
||||
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
|
||||
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
|
||||
OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
|
||||
OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
|
||||
OC_Hook::connect('OC_DAV', 'initialize', 'OC_Calendar_Hooks', 'initializeCalDAV');
|
||||
OC_Util::addScript('calendar','loader');
|
||||
OC_App::register( array(
|
||||
'order' => 10,
|
||||
'id' => 'calendar',
|
||||
'name' => 'Calendar' ));
|
||||
OC_App::addNavigationEntry( array(
|
||||
'id' => 'calendar_index',
|
||||
'order' => 10,
|
||||
'href' => OC_Helper::linkTo( 'calendar', 'index.php' ),
|
||||
'icon' => OC_Helper::imagePath( 'calendar', 'icon.svg' ),
|
||||
'name' => $l->t('Calendar')));
|
||||
OC_App::registerPersonal('calendar', 'settings');
|
||||
OC_Search::registerProvider('OC_Search_Provider_Calendar');
|
|
@ -25,7 +25,7 @@ $nodes = array(
|
|||
|
||||
// Fire up server
|
||||
$server = new Sabre_DAV_Server($nodes);
|
||||
$server->setBaseUri(OC::$WEBROOT.'/apps/calendar/caldav.php');
|
||||
$server->setBaseUri(OC::$APPSWEBROOT.'/apps/calendar/caldav.php');
|
||||
// Add plugins
|
||||
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
|
||||
$server->addPlugin(new Sabre_CalDAV_Plugin());
|
||||
|
|
|
@ -9,16 +9,20 @@
|
|||
require_once ('../../lib/base.php');
|
||||
OC_Util::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
|
||||
// Create default calendar ...
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
|
||||
if( count($calendars) == 0){
|
||||
OC_Calendar_Calendar::addCalendar(OC_User::getUser(),'Default calendar');
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
|
||||
}
|
||||
|
||||
$eventSources = array();
|
||||
foreach($calendars as $calendar){
|
||||
$eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
|
||||
}
|
||||
OC_Hook::emit('OC_Calendar', 'getSources', array('sources' => &$eventSources));
|
||||
|
||||
//Fix currentview for fullcalendar
|
||||
if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
|
||||
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek");
|
||||
|
|
|
@ -69,17 +69,20 @@ Calendar={
|
|||
$('#event').dialog('destroy').remove();
|
||||
}else{
|
||||
Calendar.UI.loading(true);
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'new.form.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
|
||||
}
|
||||
},
|
||||
editEvent:function(calEvent, jsEvent, view){
|
||||
if (calEvent.editable == false || calEvent.source.editable == false) {
|
||||
return;
|
||||
}
|
||||
var id = calEvent.id;
|
||||
if($('#event').dialog('isOpen') == true){
|
||||
// TODO: save event
|
||||
$('#event').dialog('destroy').remove();
|
||||
}else{
|
||||
Calendar.UI.loading(true);
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog);
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/event', 'edit.form.php') + '?id=' + id, Calendar.UI.startEventDialog);
|
||||
}
|
||||
},
|
||||
submitDeleteEventForm:function(url){
|
||||
|
@ -141,7 +144,7 @@ Calendar={
|
|||
moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
|
||||
$('.tipsy').remove();
|
||||
Calendar.UI.loading(true);
|
||||
$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
|
||||
$.post(OC.filePath('calendar', 'ajax/event', 'move.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
|
||||
function(data) {
|
||||
Calendar.UI.loading(false);
|
||||
if (data.status == 'success'){
|
||||
|
@ -156,7 +159,7 @@ Calendar={
|
|||
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
|
||||
$('.tipsy').remove();
|
||||
Calendar.UI.loading(true);
|
||||
$.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
|
||||
$.post(OC.filePath('calendar', 'ajax/event', 'resize.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
|
||||
function(data) {
|
||||
Calendar.UI.loading(false);
|
||||
if (data.status == 'success'){
|
||||
|
@ -214,7 +217,7 @@ Calendar={
|
|||
},
|
||||
initScroll:function(){
|
||||
if(window.addEventListener)
|
||||
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar);
|
||||
document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar, false);
|
||||
//}else{
|
||||
document.onmousewheel = Calendar.UI.scrollCalendar;
|
||||
//}
|
||||
|
@ -373,7 +376,7 @@ Calendar={
|
|||
$('#choosecalendar_dialog').dialog('moveToTop');
|
||||
}else{
|
||||
Calendar.UI.loading(true);
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){
|
||||
$('#dialog_holder').load(OC.filePath('calendar', 'ajax/calendar', 'overview.php'), function(){
|
||||
$('#choosecalendar_dialog').dialog({
|
||||
width : 600,
|
||||
close : function(event, ui) {
|
||||
|
@ -387,7 +390,7 @@ Calendar={
|
|||
activation:function(checkbox, calendarid)
|
||||
{
|
||||
Calendar.UI.loading(true);
|
||||
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
|
||||
$.post(OC.filePath('calendar', 'ajax/calendar', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
|
||||
function(data) {
|
||||
Calendar.UI.loading(false);
|
||||
if (data.status == 'success'){
|
||||
|
@ -402,13 +405,13 @@ Calendar={
|
|||
},
|
||||
newCalendar:function(object){
|
||||
var tr = $(document.createElement('tr'))
|
||||
.load(OC.filePath('calendar', 'ajax', 'newcalendar.php'),
|
||||
.load(OC.filePath('calendar', 'ajax/calendar', 'new.form.php'),
|
||||
function(){Calendar.UI.Calendar.colorPicker(this)});
|
||||
$(object).closest('tr').after(tr).hide();
|
||||
},
|
||||
edit:function(object, calendarid){
|
||||
var tr = $(document.createElement('tr'))
|
||||
.load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid,
|
||||
.load(OC.filePath('calendar', 'ajax/calendar', 'edit.form.php') + "?calendarid="+calendarid,
|
||||
function(){Calendar.UI.Calendar.colorPicker(this)});
|
||||
$(object).closest('tr').after(tr).hide();
|
||||
},
|
||||
|
@ -417,7 +420,7 @@ Calendar={
|
|||
if(check == false){
|
||||
return false;
|
||||
}else{
|
||||
$.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
|
||||
$.post(OC.filePath('calendar', 'ajax/calendar', 'delete.php'), { calendarid: calid},
|
||||
function(data) {
|
||||
if (data.status == 'success'){
|
||||
var url = 'ajax/events.php?calendar_id='+calid;
|
||||
|
@ -442,9 +445,9 @@ Calendar={
|
|||
|
||||
var url;
|
||||
if (calendarid == 'new'){
|
||||
url = OC.filePath('calendar', 'ajax', 'createcalendar.php');
|
||||
url = OC.filePath('calendar', 'ajax/calendar', 'new.php');
|
||||
}else{
|
||||
url = OC.filePath('calendar', 'ajax', 'updatecalendar.php');
|
||||
url = OC.filePath('calendar', 'ajax/calendar', 'update.php');
|
||||
}
|
||||
$.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
|
||||
function(data){
|
||||
|
@ -661,7 +664,7 @@ $(document).ready(function(){
|
|||
Calendar.UI.initScroll();
|
||||
$('#calendar_holder').fullCalendar({
|
||||
header: false,
|
||||
firstDay: 1,
|
||||
firstDay: firstDay,
|
||||
editable: true,
|
||||
defaultView: defaultView,
|
||||
timeFormat: {
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
*/
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
|
||||
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
|
||||
function(data){
|
||||
if (data.status == 'success' && typeof(data.message) != 'undefined'){
|
||||
$('#notification').html(data.message);
|
||||
$('#notification').attr('title', 'CC BY 3.0 by Geonames.org');
|
||||
$('#notification').slideDown();
|
||||
window.setTimeout(function(){$('#notification').slideUp();}, 5000);
|
||||
}else{
|
||||
|
|
|
@ -8,7 +8,7 @@ Calendar_Import={
|
|||
importdialog: function(filename){
|
||||
var path = $('#dir').val();
|
||||
$('body').append('<div id="calendar_import"></div>');
|
||||
$('#calendar_import').load(OC.filePath('calendar', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);});
|
||||
$('#calendar_import').load(OC.filePath('calendar', 'ajax/import', 'dialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);});
|
||||
},
|
||||
initdialog: function(filename){
|
||||
$('#calendar_import_dialog').dialog({
|
||||
|
@ -68,7 +68,7 @@ Calendar_Import={
|
|||
if(percent < 100){
|
||||
window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500);
|
||||
}else{
|
||||
$('#import_done').css('display', 'block');
|
||||
$('#import_done').css('display', 'block');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -78,4 +78,4 @@ $(document).ready(function(){
|
|||
FileActions.register('text/calendar','importcal', '', Calendar_Import.importdialog);
|
||||
FileActions.setDefault('text/calendar','importcal');
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ $(document).ready(function(){
|
|||
OC.msg.startSaving('#calendar .msg')
|
||||
// Serialize the data
|
||||
var post = $( '#timezone' ).serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){
|
||||
$.post( OC.filePath('calendar', 'ajax/settings', 'settimezone.php'), post, function(data){
|
||||
//OC.msg.finishedSaving('#calendar .msg', data);
|
||||
});
|
||||
return false;
|
||||
|
@ -11,25 +11,37 @@ $(document).ready(function(){
|
|||
$('#timezone').chosen();
|
||||
$('#timeformat').change( function(){
|
||||
var data = $('#timeformat').serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){
|
||||
$.post( OC.filePath('calendar', 'ajax/settings', 'settimeformat.php'), data, function(data){
|
||||
if(data == 'error'){
|
||||
console.log('saving timeformat failed');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#firstday').change( function(){
|
||||
var data = $('#firstday').serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax/settings', 'setfirstday.php'), data, function(data){
|
||||
if(data == 'error'){
|
||||
console.log('saving firstday failed');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#timezonedetection').change( function(){
|
||||
var post = $('#timezonedetection').serialize();
|
||||
$.post( OC.filePath('calendar', 'ajax', 'timezonedetection.php'), post, function(data){
|
||||
$.post( OC.filePath('calendar', 'ajax/settings', 'timezonedetection.php'), post, function(data){
|
||||
|
||||
});
|
||||
});
|
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) {
|
||||
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) {
|
||||
$('#' + jsondata.timeformat).attr('selected',true);
|
||||
$('#timeformat').chosen();
|
||||
});
|
||||
$.getJSON(OC.filePath('calendar', 'ajax', 'gettimezonedetection.php'), function(jsondata, status){
|
||||
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){
|
||||
if(jsondata.detection == 'true'){
|
||||
$('#timezonedetection').attr('checked', 'checked');
|
||||
}
|
||||
});
|
||||
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) {
|
||||
$('#' + jsondata.firstday).attr('selected',true);
|
||||
$('#firstday').chosen();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -240,9 +240,10 @@ class OC_Calendar_Calendar{
|
|||
'#9fc6e7', // "light blue"
|
||||
);
|
||||
}
|
||||
|
||||
public static function getEventSourceInfo($calendar){
|
||||
return array(
|
||||
'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
|
||||
'url' => OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id='.$calendar['id'],
|
||||
'backgroundColor' => $calendar['calendarcolor'],
|
||||
'borderColor' => '#888',
|
||||
'textColor' => 'black',
|
||||
|
|
|
@ -17,11 +17,24 @@ class OC_Calendar_Hooks{
|
|||
*/
|
||||
public static function deleteUser($parameters) {
|
||||
$calendars = OC_Calendar_Calendar::allCalendars($parameters['uid']);
|
||||
|
||||
|
||||
foreach($calendars as $calendar) {
|
||||
OC_Calendar_Calendar::deleteCalendar($calendar['id']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds the CardDAV resource to the DAV server
|
||||
* @param paramters parameters from initialize-Hook
|
||||
* @return array
|
||||
*/
|
||||
public static function initializeCalDAV($parameters){
|
||||
// We need a backend, the root node and the caldav plugin
|
||||
$parameters['backends']['caldav'] = new OC_Connector_Sabre_CalDAV();
|
||||
$parameters['nodes'][] = new Sabre_CalDAV_CalendarRootNode($parameters['backends']['principal'], $parameters['backends']['caldav']);
|
||||
$parameters['plugins'][] = new Sabre_CalDAV_Plugin();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,7 @@ class OC_Calendar_Object{
|
|||
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
|
||||
|
||||
if(is_null($uid)){
|
||||
$uid = self::createUID();
|
||||
$object->add('UID',$uid);
|
||||
$object->setUID();
|
||||
$data = $object->serialize();
|
||||
}
|
||||
|
||||
|
@ -208,14 +207,6 @@ class OC_Calendar_Object{
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a UID
|
||||
* @return string
|
||||
*/
|
||||
protected static function createUID(){
|
||||
return substr(md5(rand().time()),0,10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Extracts data from a vObject-Object
|
||||
* @param Sabre_VObject $object
|
||||
|
@ -309,6 +300,8 @@ class OC_Calendar_Object{
|
|||
$dtend = $vevent->DTEND;
|
||||
}else{
|
||||
$dtend = clone $vevent->DTSTART;
|
||||
// clone creates a shallow copy, also clone DateTime
|
||||
$dtend->setDateTime(clone $dtend->getDateTime(), $dtend->getDateType());
|
||||
if ($vevent->DURATION){
|
||||
$duration = strval($vevent->DURATION);
|
||||
$invert = 0;
|
||||
|
@ -817,4 +810,4 @@ class OC_Calendar_Object{
|
|||
|
||||
return $vcalendar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
class OC_Search_Provider_Calendar extends OC_Search_Provider{
|
||||
function search($query){
|
||||
class OC_Search_Provider_Calendar implements OC_Search_Provider{
|
||||
static function search($query){
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
|
||||
if(count($calendars)==0 || !OC_App::isEnabled('calendar')){
|
||||
//return false;
|
||||
|
@ -44,4 +44,3 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
|
|||
return $results;
|
||||
}
|
||||
}
|
||||
new OC_Search_Provider_Calendar();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
var missing_field_startsbeforeends = '<?php echo addslashes($l->t('The event ends before it starts')) ?>';
|
||||
var missing_field_dberror = '<?php echo addslashes($l->t('There was a database fail')) ?>';
|
||||
var totalurl = '<?php echo OC_Helper::linkToAbsolute('calendar', 'caldav.php'); ?>/calendars';
|
||||
var firstDay = '<?php echo (OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>';
|
||||
$(document).ready(function() {
|
||||
<?php
|
||||
if(array_key_exists('showevent', $_)){
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<?php echo $this->inc("part.eventform"); ?>
|
||||
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
|
||||
<span id="actions">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');">
|
||||
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/edit.php');">
|
||||
<input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/event/delete.php');">
|
||||
<input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';">
|
||||
</span>
|
||||
</form>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
?>
|
||||
</select>
|
||||
</td>
|
||||
<?php if(count($_['calendar_options']) > 1) { ?>
|
||||
<th width="75px"> <?php echo $l->t("Calendar");?>:</th>
|
||||
<td>
|
||||
<select style="width:140px;" name="calendar">
|
||||
|
@ -26,6 +27,12 @@
|
|||
?>
|
||||
</select>
|
||||
</td>
|
||||
<?php } else { ?>
|
||||
<th width="75px"> </th>
|
||||
<td>
|
||||
<input type="hidden" name="calendar" value="<?php echo $_['calendar_options'][0]['id'] ?>">
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<?php echo $this->inc("part.eventform"); ?>
|
||||
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
|
||||
<span id="actions">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/newevent.php');">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/event/new.php');">
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -37,6 +37,13 @@
|
|||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><label for="firstday" class="bold"><?php echo $l->t('First day of the week');?></label></td><td>
|
||||
<select style="display: none;" id="firstday" title="<?php echo "First day"; ?>" name="firstday">
|
||||
<option value="mo" id="mo"><?php echo $l->t("Monday"); ?></option>
|
||||
<option value="su" id="su"><?php echo $l->t("Sunday"); ?></option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php echo $l->t('Calendar CalDAV syncing address:');?>
|
||||
|
|
|
@ -92,7 +92,7 @@ foreach( $add as $propname){
|
|||
}
|
||||
}
|
||||
}
|
||||
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
|
||||
$id = OC_Contacts_VCard::add($aid,$vcard);
|
||||
if(!$id) {
|
||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
|
||||
OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
|
||||
|
|
|
@ -52,7 +52,7 @@ $vcard->setUID();
|
|||
$vcard->setString('FN',$fn);
|
||||
$vcard->setString('N',$n);
|
||||
|
||||
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
|
||||
$id = OC_Contacts_VCard::add($aid,$vcard);
|
||||
if(!$id) {
|
||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
|
||||
OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
|
||||
|
|
|
@ -113,7 +113,7 @@ foreach ($parameters as $key=>$element) {
|
|||
}
|
||||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard)) {
|
||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.'))));
|
||||
OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR);
|
||||
exit();
|
||||
|
|
|
@ -39,7 +39,7 @@ if(is_null($line)){
|
|||
|
||||
unset($vcard->children[$line]);
|
||||
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard)) {
|
||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.'))));
|
||||
OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR);
|
||||
exit();
|
||||
|
|
|
@ -95,7 +95,7 @@ if(file_exists($tmp_path)) {
|
|||
OC_Log::write('contacts','savecrop.php: files: Adding PHOTO property.', OC_Log::DEBUG);
|
||||
$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
|
||||
}
|
||||
if(!OC_Contacts_VCard::edit($id,$card->serialize())) {
|
||||
if(!OC_Contacts_VCard::edit($id,$card)) {
|
||||
bailOut('Error saving contact.');
|
||||
}
|
||||
unlink($tmpfname);
|
||||
|
|
|
@ -122,7 +122,7 @@ switch($element) {
|
|||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
debug('New checksum: '.$checksum);
|
||||
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard)) {
|
||||
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error updating contact property.'))));
|
||||
OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
|
||||
exit();
|
||||
|
|
|
@ -80,7 +80,7 @@ foreach($missingparameters as $i){
|
|||
// NOTE: This checksum is not used..?
|
||||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
|
||||
if(!OC_Contacts_VCard::edit($id,$vcard)) {
|
||||
OC_JSON::error(array('data' => array('message' => $l->t('Error updating contact property.'))));
|
||||
OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
|
||||
exit();
|
||||
|
|
|
@ -4,7 +4,11 @@ OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
|
|||
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
|
||||
OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
|
||||
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
|
||||
OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
|
||||
OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser');
|
||||
OC_HOOK::connect('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
|
||||
OC_HOOK::connect('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');
|
||||
OC_Hook::connect('OC_DAV', 'initialize', 'OC_Contacts_Hooks', 'initializeCardDAV');
|
||||
|
||||
OC_App::register( array(
|
||||
'order' => 10,
|
||||
|
@ -21,4 +25,4 @@ OC_App::addNavigationEntry( array(
|
|||
|
||||
OC_APP::registerPersonal('contacts','settings');
|
||||
OC_UTIL::addScript('contacts', 'loader');
|
||||
require_once('apps/contacts/lib/search.php');
|
||||
OC_Search::registerProvider('OC_Search_Provider_Contacts');
|
||||
|
|
|
@ -39,7 +39,7 @@ $nodes = array(
|
|||
|
||||
// Fire up server
|
||||
$server = new Sabre_DAV_Server($nodes);
|
||||
$server->setBaseUri(OC::$WEBROOT.'/apps/contacts/carddav.php');
|
||||
$server->setBaseUri(OC::$APPSWEBROOT.'/apps/contacts/carddav.php');
|
||||
// Add plugins
|
||||
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
|
||||
$server->addPlugin(new Sabre_CardDAV_Plugin());
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#contacts_propertymenu li a:hover { color: #fff }
|
||||
#actionbar { height: 30px; width: 200px; position: fixed; right: 0px; top: 75px; margin: 0 0 0 0; padding: 0 0 0 0;}
|
||||
#card { /*max-width: 70em; border: thin solid lightgray; display: block;*/ }
|
||||
#firstrun { /*border: thin solid lightgray;*/ width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
|
||||
#firstrun #selections { /*border: thin solid lightgray;*/ font-size:0.8em; width: 100%; margin: 2em auto auto auto; clear: both; }
|
||||
#firstrun { width: 100%; position: absolute; top: 5em; left: 0; text-align: center; font-weight:bold; font-size:1.5em; color:#777; }
|
||||
#firstrun #selections { font-size:0.8em; margin: 2em auto auto auto; clear: both; }
|
||||
|
||||
#card input[type="text"].contacts_property,input[type="email"].contacts_property { width: 16em; }
|
||||
#card input[type="text"],input[type="email"],input[type="tel"],input[type="date"], select { background-color: #f8f8f8; border: 0 !important; -webkit-appearance:none !important; -moz-appearance:none !important; -webkit-box-sizing:none !important; -moz-box-sizing:none !important; box-sizing:none !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; float: left; }
|
||||
|
|
|
@ -97,11 +97,15 @@ if(is_writable('import_tmp/')){
|
|||
fclose($progressfopen);
|
||||
}
|
||||
if(count($parts) == 1){
|
||||
OC_Contacts_VCard::add($id, $file);
|
||||
}else{
|
||||
foreach($importready as $import){
|
||||
OC_Contacts_VCard::add($id, $import);
|
||||
$importready = array($file);
|
||||
}
|
||||
foreach($importready as $import){
|
||||
$card = OC_VObject::parse($import);
|
||||
if (!$card) {
|
||||
OC_Log::write('contacts','Import: skipping card. Error parsing VCard: '.$import, OC_Log::ERROR);
|
||||
continue; // Ditch cards that can't be parsed by Sabre.
|
||||
}
|
||||
OC_Contacts_VCard::add($id, $card);
|
||||
}
|
||||
//done the import
|
||||
if(is_writable('import_tmp/')){
|
||||
|
@ -113,4 +117,4 @@ sleep(3);
|
|||
if(is_writable('import_tmp/')){
|
||||
unlink($progressfile);
|
||||
}
|
||||
OC_JSON::success();
|
||||
OC_JSON::success();
|
||||
|
|
|
@ -8,7 +8,7 @@ String.prototype.strip_tags = function(){
|
|||
tags = this;
|
||||
stripped = tags.replace(/[\<\>]/gi, "");
|
||||
return stripped;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Contacts={
|
||||
|
@ -68,7 +68,7 @@ Contacts={
|
|||
return $(obj).parents('.propertycontainer').first().data('element');
|
||||
},
|
||||
showHideContactInfo:function() {
|
||||
var show = ($('#emaillist li[class*="propertycontainer"]').length > 0 || $('#phonelist li[class*="propertycontainer"]').length > 0 || $('#addressdisplay dl[class*="propertycontainer"]').length > 0);
|
||||
var show = ($('#emaillist li.propertycontainer').length > 0 || $('#phonelist li.propertycontainer').length > 0 || $('#addressdisplay dl.propertycontainer').length > 0);
|
||||
console.log('showHideContactInfo: ' + show);
|
||||
if(show) {
|
||||
$('#contact_communication').show();
|
||||
|
@ -82,19 +82,19 @@ Contacts={
|
|||
switch (type) {
|
||||
case 'EMAIL':
|
||||
console.log('emails: '+$('#emaillist>li').length);
|
||||
if($('#emaillist li[class*="propertycontainer"]').length == 0) {
|
||||
if($('#emaillist li.propertycontainer').length == 0) {
|
||||
$('#emails').hide();
|
||||
}
|
||||
break;
|
||||
case 'TEL':
|
||||
console.log('phones: '+$('#phonelist>li').length);
|
||||
if($('#phonelist li[class*="propertycontainer"]').length == 0) {
|
||||
if($('#phonelist li.propertycontainer').length == 0) {
|
||||
$('#phones').hide();
|
||||
}
|
||||
break;
|
||||
case 'ADR':
|
||||
console.log('addresses: '+$('#addressdisplay>dl').length);
|
||||
if($('#addressdisplay dl[class*="propertycontainer"]').length == 0) {
|
||||
if($('#addressdisplay dl.propertycontainer').length == 0) {
|
||||
$('#addresses').hide();
|
||||
}
|
||||
break;
|
||||
|
@ -142,7 +142,7 @@ Contacts={
|
|||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
loadListHandlers:function() {
|
||||
//$('.add,.delete').hide();
|
||||
|
@ -183,7 +183,7 @@ Contacts={
|
|||
dateFormat : 'dd-mm-yy'
|
||||
});
|
||||
// Style phone types
|
||||
$('#phonelist').find('select[class*="contacts_property"]').multiselect({
|
||||
$('#phonelist').find('select.contacts_property').multiselect({
|
||||
noneSelectedText: t('contacts', 'Select type'),
|
||||
header: false,
|
||||
selectedList: 4,
|
||||
|
@ -323,7 +323,7 @@ Contacts={
|
|||
}
|
||||
});
|
||||
},
|
||||
delete:function() {
|
||||
delete: function() {
|
||||
$('#contacts_deletecard').tipsy('hide');
|
||||
$.getJSON('ajax/deletecard.php',{'id':this.id},function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
|
@ -373,7 +373,7 @@ Contacts={
|
|||
loadSingleProperties:function() {
|
||||
var props = ['BDAY', 'NICKNAME', 'ORG'];
|
||||
// Clear all elements
|
||||
$('#ident .propertycontainer[class*="propertycontainer"]').each(function(){
|
||||
$('#ident .propertycontainer').each(function(){
|
||||
if(props.indexOf($(this).data('element')) > -1) {
|
||||
$(this).data('checksum', '');
|
||||
$(this).find('input').val('');
|
||||
|
@ -448,6 +448,9 @@ Contacts={
|
|||
$('#fn_select option').remove();
|
||||
$('#fn_select').combobox('value', this.fn);
|
||||
var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname];
|
||||
if(this.data.ORG) {
|
||||
names[names.length]=this.data.ORG[0].value;
|
||||
}
|
||||
$.each(names, function(key, value) {
|
||||
$('#fn_select')
|
||||
.append($('<option></option>')
|
||||
|
@ -518,8 +521,8 @@ Contacts={
|
|||
var checksum = container.data('checksum');
|
||||
var name = container.data('element');
|
||||
console.log('saveProperty: ' + name);
|
||||
var fields = container.find('input[class*="contacts_property"],select[class*="contacts_property"]').serializeArray();
|
||||
var q = container.find('input[class*="contacts_property"],select[class*="contacts_property"]').serialize();
|
||||
var fields = container.find('input.contacts_property,select.contacts_property').serializeArray();
|
||||
var q = container.find('input.contacts_property,select.contacts_property').serialize();
|
||||
if(q == '' || q == undefined) {
|
||||
console.log('Couldn\'t serialize elements.');
|
||||
Contacts.UI.loading(container, false);
|
||||
|
@ -708,7 +711,7 @@ Contacts={
|
|||
},
|
||||
loadAddresses:function(){
|
||||
$('#addresses').hide();
|
||||
$('#addressdisplay dl[class*="propertycontainer"]').remove();
|
||||
$('#addressdisplay dl.propertycontainer').remove();
|
||||
for(var adr in this.data.ADR) {
|
||||
$('#addressdisplay dl').first().clone().insertAfter($('#addressdisplay dl').last()).show();
|
||||
$('#addressdisplay dl').last().removeClass('template').addClass('propertycontainer');
|
||||
|
@ -920,15 +923,15 @@ Contacts={
|
|||
},
|
||||
addMail:function() {
|
||||
//alert('addMail');
|
||||
$('#emaillist li[class*="template"]:first-child').clone().appendTo($('#emaillist')).show();
|
||||
$('#emaillist li[class*="template"]:last-child').removeClass('template').addClass('propertycontainer');
|
||||
$('#emaillist li.template:first-child').clone().appendTo($('#emaillist')).show();
|
||||
$('#emaillist li.template:last-child').removeClass('template').addClass('propertycontainer');
|
||||
$('#emaillist li:last-child').find('input[type="email"]').focus();
|
||||
Contacts.UI.loadListHandlers();
|
||||
return false;
|
||||
},
|
||||
loadMails:function() {
|
||||
$('#emails').hide();
|
||||
$('#emaillist li[class*="propertycontainer"]').remove();
|
||||
$('#emaillist li.propertycontainer').remove();
|
||||
for(var mail in this.data.EMAIL) {
|
||||
this.addMail();
|
||||
//$('#emaillist li:first-child').clone().appendTo($('#emaillist')).show();
|
||||
|
@ -950,9 +953,9 @@ Contacts={
|
|||
return false;
|
||||
},
|
||||
addPhone:function() {
|
||||
$('#phonelist li[class*="template"]:first-child').clone().appendTo($('#phonelist')); //.show();
|
||||
$('#phonelist li[class*="template"]:last-child').find('select').addClass('contacts_property');
|
||||
$('#phonelist li[class*="template"]:last-child').removeClass('template').addClass('propertycontainer');
|
||||
$('#phonelist li.template:first-child').clone().appendTo($('#phonelist')); //.show();
|
||||
$('#phonelist li.template:last-child').find('select').addClass('contacts_property');
|
||||
$('#phonelist li.template:last-child').removeClass('template').addClass('propertycontainer');
|
||||
$('#phonelist li:last-child').find('input[type="text"]').focus();
|
||||
Contacts.UI.loadListHandlers();
|
||||
$('#phonelist li:last-child').find('select').multiselect({
|
||||
|
@ -966,7 +969,7 @@ Contacts={
|
|||
},
|
||||
loadPhones:function() {
|
||||
$('#phones').hide();
|
||||
$('#phonelist li[class*="propertycontainer"]').remove();
|
||||
$('#phonelist li.propertycontainer').remove();
|
||||
for(var phone in this.data.TEL) {
|
||||
this.addPhone();
|
||||
$('#phonelist li:last-child').find('select').multiselect('destroy');
|
||||
|
|
|
@ -85,7 +85,7 @@ class OC_Contacts_App {
|
|||
$vcard = OC_VObject::parse($card['carddata']);
|
||||
// Try to fix cards with missing 'N' field from pre ownCloud 4. Hot damn, this is ugly...
|
||||
if(!is_null($vcard) && !$vcard->__isset('N')) {
|
||||
$appinfo = $info=OC_App::getAppInfo('contacts');
|
||||
$appinfo = OC_App::getAppInfo('contacts');
|
||||
if($appinfo['version'] >= 5) {
|
||||
OC_Log::write('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OC_Log::DEBUG);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class OC_Contacts_App {
|
|||
OC_Log::write('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OC_Log::DEBUG);
|
||||
$n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;';
|
||||
$vcard->setString('N', $n);
|
||||
OC_Contacts_VCard::edit( $id, $vcard->serialize());
|
||||
OC_Contacts_VCard::edit( $id, $vcard);
|
||||
} else { // Else just add an empty 'N' field :-P
|
||||
$vcard->setString('N', 'Unknown;Name;;;');
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class OC_Contacts_Hooks{
|
|||
* @param paramters parameters from postDeleteUser-Hook
|
||||
* @return array
|
||||
*/
|
||||
public function deleteUser($parameters) {
|
||||
static public function deleteUser($parameters) {
|
||||
$addressbooks = OC_Contacts_Addressbook::all($parameters['uid']);
|
||||
|
||||
foreach($addressbooks as $addressbook) {
|
||||
|
@ -38,4 +38,62 @@ class OC_Contacts_Hooks{
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds the CardDAV resource to the DAV server
|
||||
* @param paramters parameters from initialize-Hook
|
||||
* @return array
|
||||
*/
|
||||
static public function initializeCardDAV($parameters){
|
||||
// We need a backend, the root node and the carddav plugin
|
||||
$parameters['backends']['carddav'] = new OC_Connector_Sabre_CardDAV();
|
||||
$parameters['nodes'][] = new Sabre_CardDAV_AddressBookRoot($parameters['backends']['principal'], $parameters['backends']['carddav']);
|
||||
$parameters['plugins'][] = new Sabre_CardDAV_Plugin();
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function getCalenderSources($parameters) {
|
||||
$base_url = OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id=';
|
||||
foreach(OC_Contacts_Addressbook::all(OC_User::getUser()) as $addressbook) {
|
||||
$parameters['sources'][] =
|
||||
array(
|
||||
'url' => $base_url.'birthday_'. $addressbook['id'],
|
||||
'backgroundColor' => '#cccccc',
|
||||
'borderColor' => '#888',
|
||||
'textColor' => 'black',
|
||||
'cache' => true,
|
||||
'editable' => false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static public function getBirthdayEvents($parameters) {
|
||||
$name = $parameters['calendar_id'];
|
||||
if (strpos('birthday_', $name) != 0) {
|
||||
return;
|
||||
}
|
||||
$info = explode('_', $name);
|
||||
$aid = $info[1];
|
||||
OC_Contacts_App::getAddressbook($aid);
|
||||
foreach(OC_Contacts_VCard::all($aid) as $card){
|
||||
$vcard = OC_VObject::parse($card['carddata']);
|
||||
$birthday = $vcard->BDAY;
|
||||
if ($birthday) {
|
||||
$date = new DateTime($birthday);
|
||||
$vevent = new OC_VObject('VEVENT');
|
||||
$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV));
|
||||
$vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE);
|
||||
$vevent->setString('DURATION', 'P1D');
|
||||
// DESCRIPTION?
|
||||
$vevent->setString('RRULE', 'FREQ=YEARLY');
|
||||
$title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday'));
|
||||
$parameters['events'][] = array(
|
||||
'id' => 0,//$card['id'],
|
||||
'vevent' => $vevent,
|
||||
'repeating' => true,
|
||||
'summary' => $title,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
class OC_Search_Provider_Contacts extends OC_Search_Provider{
|
||||
function search($query){
|
||||
class OC_Search_Provider_Contacts implements OC_Search_Provider{
|
||||
static function search($query){
|
||||
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser(), 1);
|
||||
// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){
|
||||
// //return false;
|
||||
|
@ -26,4 +26,3 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{
|
|||
return $results;
|
||||
}
|
||||
}
|
||||
new OC_Search_Provider_Contacts();
|
||||
|
|
|
@ -174,6 +174,9 @@ class OC_Contacts_VCard{
|
|||
if($property->name == 'UID'){
|
||||
$uid = $property->value;
|
||||
}
|
||||
if($property->name == 'ORG'){
|
||||
$org = $property->value;
|
||||
}
|
||||
if($property->name == 'EMAIL' && is_null($email)){ // only use the first email as substitute for missing N or FN.
|
||||
$email = $property->value;
|
||||
}
|
||||
|
@ -184,6 +187,8 @@ class OC_Contacts_VCard{
|
|||
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
|
||||
} elseif($email) {
|
||||
$fn = $email;
|
||||
} elseif($org) {
|
||||
$fn = $org;
|
||||
} else {
|
||||
$fn = 'Unknown Name';
|
||||
}
|
||||
|
@ -217,32 +222,37 @@ class OC_Contacts_VCard{
|
|||
|
||||
/**
|
||||
* @brief Adds a card
|
||||
* @param integer $id Addressbook id
|
||||
* @param string $data vCard file
|
||||
* @return insertid on success or null if card is not parseable.
|
||||
* @param integer $aid Addressbook id
|
||||
* @param OC_VObject $card vCard file
|
||||
* @param string $uri the uri of the card, default based on the UID
|
||||
* @return insertid on success or null if no card.
|
||||
*/
|
||||
public static function add($id,$data){
|
||||
$fn = null;
|
||||
|
||||
$card = OC_VObject::parse($data);
|
||||
if(!is_null($card)){
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
self::updateValuesFromAdd($card);
|
||||
$data = $card->serialize();
|
||||
}
|
||||
else{
|
||||
OC_Log::write('contacts','OC_Contacts_VCard::add. Error parsing VCard: '.$data,OC_Log::ERROR);
|
||||
return null; // Ditch cards that can't be parsed by Sabre.
|
||||
public static function add($aid, $card, $uri=null){
|
||||
if(is_null($card)){
|
||||
OC_Log::write('contacts','OC_Contacts_VCard::add. No vCard supplied', OC_Log::ERROR);
|
||||
return null;
|
||||
};
|
||||
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
|
||||
self::updateValuesFromAdd($card);
|
||||
|
||||
$fn = $card->getAsString('FN');
|
||||
$uid = $card->getAsString('UID');
|
||||
$uri = $uid.'.vcf';
|
||||
if (empty($fn)) {
|
||||
$fn = null;
|
||||
}
|
||||
|
||||
if (!$uri) {
|
||||
$uid = $card->getAsString('UID');
|
||||
$uri = $uid.'.vcf';
|
||||
}
|
||||
|
||||
$data = $card->serialize();
|
||||
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
|
||||
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
|
||||
$result = $stmt->execute(array($aid,$fn,$data,$uri,time()));
|
||||
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
|
||||
|
||||
OC_Contacts_Addressbook::touch($id);
|
||||
OC_Contacts_Addressbook::touch($aid);
|
||||
|
||||
return $newid;
|
||||
}
|
||||
|
@ -256,51 +266,33 @@ class OC_Contacts_VCard{
|
|||
*/
|
||||
public static function addFromDAVData($id,$uri,$data){
|
||||
$card = OC_VObject::parse($data);
|
||||
if(!is_null($card)){
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
self::updateValuesFromAdd($card);
|
||||
$data = $card->serialize();
|
||||
} else {
|
||||
OC_Log::write('contacts','OC_Contacts_VCard::addFromDAVData. Error parsing VCard: '.$data, OC_Log::ERROR);
|
||||
return null; // Ditch cards that can't be parsed by Sabre.
|
||||
};
|
||||
$fn = $card->getAsString('FN');
|
||||
|
||||
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
|
||||
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
|
||||
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
|
||||
|
||||
OC_Contacts_Addressbook::touch($id);
|
||||
|
||||
return $newid;
|
||||
return self::add($id, $data, $uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief edits a card
|
||||
* @param integer $id id of card
|
||||
* @param string $data vCard file
|
||||
* @param OC_VObject $card vCard file
|
||||
* @return boolean
|
||||
*/
|
||||
public static function edit($id, $data){
|
||||
public static function edit($id, OC_VObject $card){
|
||||
$oldcard = self::find($id);
|
||||
$fn = null;
|
||||
|
||||
$card = OC_VObject::parse($data);
|
||||
if(!is_null($card)){
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
foreach($card->children as $property){
|
||||
if($property->name == 'FN'){
|
||||
$fn = $property->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(is_null($card)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
|
||||
$fn = $card->getAsString('FN');
|
||||
if (empty($fn)) {
|
||||
$fn = null;
|
||||
}
|
||||
|
||||
$now = new DateTime;
|
||||
$card->setString('REV', $now->format(DateTime::W3C));
|
||||
$data = $card->serialize();
|
||||
|
||||
$data = $card->serialize();
|
||||
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
|
||||
$result = $stmt->execute(array($fn,$data,time(),$id));
|
||||
|
||||
|
@ -318,28 +310,8 @@ class OC_Contacts_VCard{
|
|||
*/
|
||||
public static function editFromDAVData($aid,$uri,$data){
|
||||
$oldcard = self::findWhereDAVDataIs($aid,$uri);
|
||||
|
||||
$fn = null;
|
||||
$card = OC_VObject::parse($data);
|
||||
if(!is_null($card)){
|
||||
OC_Contacts_App::$categories->loadFromVObject($card);
|
||||
foreach($card->children as $property){
|
||||
if($property->name == 'FN'){
|
||||
$fn = $property->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$now = new DateTime;
|
||||
$card->setString('REV', $now->format(DateTime::W3C));
|
||||
$data = $card->serialize();
|
||||
|
||||
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
|
||||
$result = $stmt->execute(array($fn,$data,time(),$oldcard['id']));
|
||||
|
||||
OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
|
||||
|
||||
return true;
|
||||
return self::edit($oldcard['id'], $card);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,14 +327,6 @@ class OC_Contacts_VCard{
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a UID
|
||||
* @return string
|
||||
*/
|
||||
public static function createUID(){
|
||||
return substr(md5(rand().time()),0,10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief deletes a card with the data provided by sabredav
|
||||
* @param integer $aid Addressbook id
|
||||
|
|
|
@ -3,7 +3,7 @@ $id = $_['id'];
|
|||
$wattr = isset($_['width'])?'width="'.$_['width'].'"':'';
|
||||
$hattr = isset($_['height'])?'height="'.$_['height'].'"':'';
|
||||
?>
|
||||
<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id; ?>&refresh=<?php echo rand(); ?>" />
|
||||
<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id; ?>" />
|
||||
<progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
|
||||
|
||||
|
||||
|
|
25
apps/external/ajax/setsites.php
vendored
Normal file
25
apps/external/ajax/setsites.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (c) 2011, Frank Karlitschek <karlitschek@kde.org>
|
||||
* 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_Util::checkAdminUser();
|
||||
|
||||
$sites = array();
|
||||
for ($i = 0; $i < sizeof($_POST['site_name']); $i++) {
|
||||
if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) {
|
||||
array_push($sites, array($_POST['site_name'][$i], $_POST['site_url'][$i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($sites) == 0)
|
||||
OC_Appconfig::deleteKey('external', 'sites');
|
||||
else
|
||||
OC_Appconfig::setValue('external', 'sites', json_encode($sites));
|
||||
|
||||
echo 'true';
|
||||
?>
|
24
apps/external/ajax/seturls.php
vendored
24
apps/external/ajax/seturls.php
vendored
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011, Frank Karlitschek <karlitschek@kde.org>
|
||||
* 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_Util::checkAdminUser();
|
||||
|
||||
if(isset($_POST['s1name'])) OC_Appconfig::setValue( 'external','site1name', $_POST['s1name'] );
|
||||
if(isset($_POST['s1url'])) OC_Appconfig::setValue( 'external','site1url', $_POST['s1url'] );
|
||||
if(isset($_POST['s2name'])) OC_Appconfig::setValue( 'external','site2name', $_POST['s2name'] );
|
||||
if(isset($_POST['s2url'])) OC_Appconfig::setValue( 'external','site2url', $_POST['s2url'] );
|
||||
if(isset($_POST['s3name'])) OC_Appconfig::setValue( 'external','site3name', $_POST['s3name'] );
|
||||
if(isset($_POST['s3url'])) OC_Appconfig::setValue( 'external','site3url', $_POST['s3url'] );
|
||||
if(isset($_POST['s4name'])) OC_Appconfig::setValue( 'external','site4name', $_POST['s4name'] );
|
||||
if(isset($_POST['s4url'])) OC_Appconfig::setValue( 'external','site4url', $_POST['s4url'] );
|
||||
if(isset($_POST['s5name'])) OC_Appconfig::setValue( 'external','site5name', $_POST['s5name'] );
|
||||
if(isset($_POST['s5url'])) OC_Appconfig::setValue( 'external','site5url', $_POST['s5url'] );
|
||||
|
||||
echo 'true';
|
||||
|
||||
?>
|
58
apps/external/appinfo/app.php
vendored
58
apps/external/appinfo/app.php
vendored
|
@ -1,37 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - External plugin
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2011 Frank Karlitschek karlitschek@kde.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 Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
* ownCloud - External plugin
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2011 Frank Karlitschek karlitschek@kde.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 Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
OC_APP::registerAdmin('external','settings');
|
||||
OC::$CLASSPATH['OC_External'] = 'apps/external/lib/external.php';
|
||||
OC_Util::addStyle( 'external', 'style');
|
||||
|
||||
OC_App::register( array( 'order' => 70, 'id' => 'external', 'name' => 'External' ));
|
||||
OC_APP::registerAdmin('external', 'settings');
|
||||
|
||||
if(OC_Appconfig::getValue( "external","site1name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index1', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=1', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site1name", '' )));
|
||||
|
||||
if(OC_Appconfig::getValue( "external","site2name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index2', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=2', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site2name", '' )));
|
||||
|
||||
if(OC_Appconfig::getValue( "external","site3name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index3', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=3', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site3name", '' )));
|
||||
|
||||
if(OC_Appconfig::getValue( "external","site4name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index4', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=4', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site4name", '' )));
|
||||
|
||||
if(OC_Appconfig::getValue( "external","site5name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index5', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=5', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site5name", '' )));
|
||||
OC_App::register(array('order' => 70, 'id' => 'external', 'name' => 'External'));
|
||||
|
||||
$sites = OC_External::getSites();
|
||||
for ($i = 0; $i < sizeof($sites); $i++) {
|
||||
OC_App::addNavigationEntry(
|
||||
array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OC_Helper::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OC_Helper::imagePath('external', 'external.png'), 'name' => $sites[$i][0]));
|
||||
}
|
14
apps/external/css/style.css
vendored
Normal file
14
apps/external/css/style.css
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
|
||||
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
|
||||
|
||||
.site_url {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.delete_button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.external_sites {
|
||||
width: 450px;
|
||||
}
|
59
apps/external/index.php
vendored
59
apps/external/index.php
vendored
|
@ -1,42 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - External plugin
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2011 Frank Karlitschek karlitschek@kde.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 Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
* ownCloud - External plugin
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2011 Frank Karlitschek karlitschek@kde.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 Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
require_once('../../lib/base.php');
|
||||
require_once('lib/external.php');
|
||||
|
||||
OC_Util::checkLoggedIn();
|
||||
|
||||
if(isset($_GET['id'])){
|
||||
if (isset($_GET['id'])) {
|
||||
|
||||
$id=$_GET['id'];
|
||||
$id = $_GET['id'];
|
||||
$id = (int) $id;
|
||||
|
||||
$url=OC_Appconfig::getValue( "external","site".$id."url", '' );
|
||||
OC_App::setActiveNavigationEntry( 'external_index'.$id );
|
||||
|
||||
$tmpl = new OC_Template( 'external', 'frame', 'user' );
|
||||
$tmpl->assign('url',$url);
|
||||
$tmpl->printPage();
|
||||
$sites = OC_External::getSites();
|
||||
if (sizeof($sites) >= $id) {
|
||||
$url = $sites[$id - 1][1];
|
||||
OC_App::setActiveNavigationEntry('external_index' . $id);
|
||||
|
||||
$tmpl = new OC_Template('external', 'frame', 'user');
|
||||
$tmpl->assign('url', $url);
|
||||
$tmpl->printPage();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
99
apps/external/js/admin.js
vendored
99
apps/external/js/admin.js
vendored
|
@ -1,68 +1,57 @@
|
|||
$(document).ready(function(){
|
||||
newSiteHtml = '<li><input type="text" class="site_name" name="site_name[]" value="" placeholder="Name" />\n\
|
||||
<input type="text" name="site_url[]" class="site_url" value="" placeholder="URL" />\n\
|
||||
<img class="svg action delete_button" src="'+OC.imagePath("core", "actions/delete") +'" title="Remove site" /></li>';
|
||||
|
||||
|
||||
|
||||
$('#s1name').blur(function(event){
|
||||
// Handler functions
|
||||
function addSiteEventHandler(event) {
|
||||
event.preventDefault();
|
||||
var post = $( "#s1name" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s1name .msg', data); });
|
||||
});
|
||||
|
||||
saveSites();
|
||||
}
|
||||
|
||||
$('#s2name').blur(function(event){
|
||||
function deleteButtonEventHandler(event) {
|
||||
event.preventDefault();
|
||||
var post = $( "#s2name" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s2name .msg', data); });
|
||||
});
|
||||
|
||||
$('#s3name').blur(function(event){
|
||||
$(this).tipsy('hide');
|
||||
$(this).parent().remove();
|
||||
|
||||
saveSites();
|
||||
}
|
||||
|
||||
function saveSites() {
|
||||
var post = $('#external').serialize();
|
||||
$.post( OC.filePath('external','ajax','setsites.php') , post, function(data) {
|
||||
// OC.msg.finishedSaving('#site_name .msg', data);
|
||||
});
|
||||
}
|
||||
|
||||
function showDeleteButton(event) {
|
||||
$(this).find('img.delete_button').fadeIn(100);
|
||||
}
|
||||
|
||||
function hideDeleteButton(event) {
|
||||
$(this).find('img.delete_button').fadeOut(100);
|
||||
}
|
||||
|
||||
// Initialize events
|
||||
$('input[name^=site_]').change(addSiteEventHandler);
|
||||
$('img.delete_button').click(deleteButtonEventHandler);
|
||||
$('img.delete_button').tipsy();
|
||||
|
||||
$('#external li').hover(showDeleteButton, hideDeleteButton);
|
||||
|
||||
$('#add_external_site').click(function(event) {
|
||||
event.preventDefault();
|
||||
var post = $( "#s3name" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s3name .msg', data); });
|
||||
});
|
||||
$('#external ul').append(newSiteHtml);
|
||||
|
||||
$('#s4name').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s4name" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s4name .msg', data); });
|
||||
$('input.site_url:last').prev('input.site_name').andSelf().change(addSiteEventHandler);
|
||||
$('img.delete_button').click(deleteButtonEventHandler);
|
||||
$('img.delete_button:last').tipsy();
|
||||
$('#external li:last').hover(showDeleteButton, hideDeleteButton);
|
||||
|
||||
});
|
||||
|
||||
$('#s5name').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s5name" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s5name .msg', data); });
|
||||
});
|
||||
|
||||
$('#s1url').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s1url" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s1url .msg', data); });
|
||||
});
|
||||
|
||||
$('#s2url').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s2url" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s2url .msg', data); });
|
||||
});
|
||||
|
||||
$('#s3url').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s3url" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s3url .msg', data); });
|
||||
});
|
||||
|
||||
$('#s4url').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s4url" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s4url .msg', data); });
|
||||
});
|
||||
|
||||
$('#s5url').blur(function(event){
|
||||
event.preventDefault();
|
||||
var post = $( "#s5url" ).serialize();
|
||||
$.post( OC.filePath('external','ajax','seturls.php') , post, function(data){ OC.msg.finishedSaving('#s5url .msg', data); });
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
36
apps/external/lib/external.php
vendored
Normal file
36
apps/external/lib/external.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - gallery application
|
||||
*
|
||||
* @author Bartek Przybylski
|
||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
class OC_External {
|
||||
|
||||
public static function getSites() {
|
||||
if (($sites = json_decode(OC_Appconfig::getValue("external", "sites", ''))) != NULL) {
|
||||
return $sites;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
12
apps/external/settings.php
vendored
12
apps/external/settings.php
vendored
|
@ -6,17 +6,5 @@ OC_Util::addScript( "external", "admin" );
|
|||
|
||||
$tmpl = new OC_Template( 'external', 'settings');
|
||||
|
||||
$tmpl->assign('s1name',OC_Appconfig::getValue( "external","site1name", '' ));
|
||||
$tmpl->assign('s2name',OC_Appconfig::getValue( "external","site2name", '' ));
|
||||
$tmpl->assign('s3name',OC_Appconfig::getValue( "external","site3name", '' ));
|
||||
$tmpl->assign('s4name',OC_Appconfig::getValue( "external","site4name", '' ));
|
||||
$tmpl->assign('s5name',OC_Appconfig::getValue( "external","site5name", '' ));
|
||||
|
||||
$tmpl->assign('s1url',OC_Appconfig::getValue( "external","site1url", '' ));
|
||||
$tmpl->assign('s2url',OC_Appconfig::getValue( "external","site2url", '' ));
|
||||
$tmpl->assign('s3url',OC_Appconfig::getValue( "external","site3url", '' ));
|
||||
$tmpl->assign('s4url',OC_Appconfig::getValue( "external","site4url", '' ));
|
||||
$tmpl->assign('s5url',OC_Appconfig::getValue( "external","site5url", '' ));
|
||||
|
||||
return $tmpl->fetchPage();
|
||||
?>
|
||||
|
|
30
apps/external/templates/settings.php
vendored
30
apps/external/templates/settings.php
vendored
|
@ -1,23 +1,21 @@
|
|||
<form id="external">
|
||||
<fieldset class="personalblock">
|
||||
<strong>External Sites</strong><br />
|
||||
<input type="text" name="s1name" id="s1name" value="<?php echo $_['s1name']; ?>" placeholder="<?php echo $l->t('Name');?>" />
|
||||
<input type="text" name="s1url" id="s1url" value="<?php echo $_['s1url']; ?>" placeholder="<?php echo $l->t('Url');?>" />
|
||||
<br />
|
||||
<input type="text" name="s2name" id="s2name" value="<?php echo $_['s2name']; ?>" placeholder="<?php echo $l->t('Name');?>" />
|
||||
<input type="text" name="s2url" id="s2url" value="<?php echo $_['s2url']; ?>" placeholder="<?php echo $l->t('Url');?>" />
|
||||
<br />
|
||||
<input type="text" name="s3name" id="s3name" value="<?php echo $_['s3name']; ?>" placeholder="<?php echo $l->t('Name');?>" />
|
||||
<input type="text" name="s3url" id="s3url" value="<?php echo $_['s3url']; ?>" placeholder="<?php echo $l->t('Url');?>" />
|
||||
<br />
|
||||
<input type="text" name="s4name" id="s4name" value="<?php echo $_['s4name']; ?>" placeholder="<?php echo $l->t('Name');?>" />
|
||||
<input type="text" name="s4url" id="s4url" value="<?php echo $_['s4url']; ?>" placeholder="<?php echo $l->t('Url');?>" />
|
||||
<br />
|
||||
<input type="text" name="s5name" id="s5name" value="<?php echo $_['s5name']; ?>" placeholder="<?php echo $l->t('Name');?>" />
|
||||
<input type="text" name="s5url" id="s5url" value="<?php echo $_['s5url']; ?>" placeholder="<?php echo $l->t('Url');?>" />
|
||||
<br />
|
||||
<ul class="external_sites">
|
||||
|
||||
<?php
|
||||
$sites = OC_External::getSites();
|
||||
for($i = 0; $i < sizeof($sites); $i++) {
|
||||
echo '<li><input type="text" name="site_name[]" class="site_name" value="'.$sites[$i][0].'" placeholder="'.$l->t('Name').'" />
|
||||
<input type="text" class="site_url" name="site_url[]" value="'.$sites[$i][1].'" placeholder="'.$l->t('URL').'" />
|
||||
<img class="svg action delete_button" src="'.image_path("", "actions/delete.svg") .'" title="'.$l->t("Remove site").'" />
|
||||
</li>';
|
||||
}
|
||||
?>
|
||||
|
||||
<span class="msg"></span>
|
||||
</ul>
|
||||
|
||||
<input type="button" id="add_external_site" value="Add" />
|
||||
<span class="msg"></span>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
18
apps/files_archive/appinfo/app.php
Normal file
18
apps/files_archive/appinfo/app.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
OC::$CLASSPATH['OC_Archive'] = 'apps/files_archive/lib/archive.php';
|
||||
foreach(array('ZIP') as $type){
|
||||
OC::$CLASSPATH['OC_Archive_'.$type] = 'apps/files_archive/lib/'.strtolower($type).'.php';
|
||||
}
|
||||
|
||||
OC::$CLASSPATH['OC_Filestorage_Archive']='apps/files_archive/lib/storage.php';
|
||||
|
||||
OC_Hook::connect('OC_Filesystem','get_mountpoint','OC_Filestorage_Archive','autoMount');
|
||||
|
||||
OC_Util::addScript( 'files_archive', 'archive' );
|
10
apps/files_archive/appinfo/info.xml
Normal file
10
apps/files_archive/appinfo/info.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<info>
|
||||
<id>files_archive</id>
|
||||
<name>Archive support</name>
|
||||
<description>Transparent opening of archives</description>
|
||||
<version>0.1</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Robin Appelman</author>
|
||||
<require>3</require>
|
||||
</info>
|
15
apps/files_archive/js/archive.js
Normal file
15
apps/files_archive/js/archive.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
if(typeof FileActions!=='undefined'){
|
||||
FileActions.register('application/zip','Open','',function(filename){
|
||||
window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
|
||||
});
|
||||
FileActions.setDefault('application/zip','Open');
|
||||
}
|
||||
});
|
99
apps/files_archive/lib/archive.php
Normal file
99
apps/files_archive/lib/archive.php
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
abstract class OC_Archive{
|
||||
/**
|
||||
* open any of the supporeted archive types
|
||||
* @param string path
|
||||
* @return OC_Archive
|
||||
*/
|
||||
public static function open($path){
|
||||
$ext=substr($path,strrpos($path,'.'));
|
||||
switch($ext){
|
||||
case '.zip':
|
||||
return new OC_Archive_ZIP($path);
|
||||
}
|
||||
}
|
||||
|
||||
abstract function __construct($source);
|
||||
/**
|
||||
* add an empty folder to the archive
|
||||
* @param string path
|
||||
* @return bool
|
||||
*/
|
||||
abstract function addFolder($path);
|
||||
/**
|
||||
* add a file to the archive
|
||||
* @param string path
|
||||
* @param string source either a local file or string data
|
||||
* @return bool
|
||||
*/
|
||||
abstract function addFile($path,$source='');
|
||||
/**
|
||||
* rename a file or folder in the archive
|
||||
* @param string source
|
||||
* @param string dest
|
||||
* @return bool
|
||||
*/
|
||||
abstract function rename($source,$dest);
|
||||
/**
|
||||
* get the uncompressed size of a file in the archive
|
||||
* @param string path
|
||||
* @return int
|
||||
*/
|
||||
abstract function filesize($path);
|
||||
/**
|
||||
* get the last modified time of a file in the archive
|
||||
* @param string path
|
||||
* @return int
|
||||
*/
|
||||
abstract function mtime($path);
|
||||
/**
|
||||
* get the files in a folder
|
||||
* @param path
|
||||
* @return array
|
||||
*/
|
||||
abstract function getFolder($path);
|
||||
/**
|
||||
*get all files in the archive
|
||||
* @return array
|
||||
*/
|
||||
abstract function getFiles();
|
||||
/**
|
||||
* get the content of a file
|
||||
* @param string path
|
||||
* @return string
|
||||
*/
|
||||
abstract function getFile($path);
|
||||
/**
|
||||
* extract a single file from the archive
|
||||
* @param string path
|
||||
* @param string dest
|
||||
* @return bool
|
||||
*/
|
||||
abstract function extractFile($path,$dest);
|
||||
/**
|
||||
* check if a file or folder exists in the archive
|
||||
* @param string path
|
||||
* @return bool
|
||||
*/
|
||||
abstract function fileExists($path);
|
||||
/**
|
||||
* remove a file or folder from the archive
|
||||
* @param string path
|
||||
* @return bool
|
||||
*/
|
||||
abstract function remove($path);
|
||||
/**
|
||||
* get a file handler
|
||||
* @param string path
|
||||
* @param string mode
|
||||
* @return resource
|
||||
*/
|
||||
abstract function getStream($path,$mode);
|
||||
}
|
142
apps/files_archive/lib/storage.php
Normal file
142
apps/files_archive/lib/storage.php
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
class OC_Filestorage_Archive extends OC_Filestorage_Common{
|
||||
/**
|
||||
* underlying local storage used for missing functions
|
||||
* @var OC_Archive
|
||||
*/
|
||||
private $archive;
|
||||
private $path;
|
||||
private static $mounted=array();
|
||||
private static $enableAutomount=true;
|
||||
private static $rootView;
|
||||
|
||||
private function stripPath($path){//files should never start with /
|
||||
if(substr($path,0,1)=='/'){
|
||||
$path=substr($path,1);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function __construct($params){
|
||||
$this->archive=OC_Archive::open($params['archive']);
|
||||
$this->path=$params['archive'];
|
||||
}
|
||||
|
||||
public function mkdir($path){
|
||||
$path=$this->stripPath($path);
|
||||
return $this->archive->addFolder($path);
|
||||
}
|
||||
public function rmdir($path){
|
||||
$path=$this->stripPath($path);
|
||||
return $this->archive->remove($path.'/');
|
||||
}
|
||||
public function opendir($path){
|
||||
$path=$this->stripPath($path);
|
||||
$content=$this->archive->getFolder($path);
|
||||
foreach($content as &$file){
|
||||
if(substr($file,-1)=='/'){
|
||||
$file=substr($file,0,-1);
|
||||
}
|
||||
}
|
||||
$id=md5($this->path.$path);
|
||||
OC_FakeDirStream::$dirs[$id]=$content;
|
||||
return opendir('fakedir://'.$id);
|
||||
}
|
||||
public function stat($path){
|
||||
$ctime=filectime($this->path);
|
||||
$path=$this->stripPath($path);
|
||||
if($path==''){
|
||||
$stat=stat($this->path);
|
||||
}else{
|
||||
if($this->is_dir($path)){
|
||||
$stat=array('size'=>0);
|
||||
$stat['mtime']=filemtime($this->path);
|
||||
}else{
|
||||
$stat=array();
|
||||
$stat['mtime']=$this->archive->mtime($path);
|
||||
$stat['size']=$this->archive->filesize($path);
|
||||
}
|
||||
}
|
||||
$stat['ctime']=$ctime;
|
||||
return $stat;
|
||||
}
|
||||
public function filetype($path){
|
||||
$path=$this->stripPath($path);
|
||||
if($path==''){
|
||||
return 'dir';
|
||||
}
|
||||
if(substr($path,-1)=='/'){
|
||||
return $this->archive->fileExists($path)?'dir':'file';
|
||||
}else{
|
||||
return $this->archive->fileExists($path.'/')?'dir':'file';
|
||||
}
|
||||
}
|
||||
public function is_readable($path){
|
||||
return is_readable($this->path);
|
||||
}
|
||||
public function is_writable($path){
|
||||
return is_writable($this->path);
|
||||
}
|
||||
public function file_exists($path){
|
||||
$path=$this->stripPath($path);
|
||||
if($path==''){
|
||||
return file_exists($this->path);
|
||||
}
|
||||
return $this->archive->fileExists($path) or $this->archive->fileExists($path.'/');
|
||||
}
|
||||
public function unlink($path){
|
||||
$path=$this->stripPath($path);
|
||||
return $this->archive->remove($path);
|
||||
}
|
||||
public function fopen($path,$mode){
|
||||
$path=$this->stripPath($path);
|
||||
return $this->archive->getStream($path,$mode);
|
||||
}
|
||||
public function free_space($path){
|
||||
return 0;
|
||||
}
|
||||
public function touch($path, $mtime=null){
|
||||
if(is_null($mtime)){
|
||||
$tmpFile=OC_Helper::tmpFile();
|
||||
$this->archive->extractFile($path,$tmpFile);
|
||||
$this->archive->addfile($path,$tmpFile);
|
||||
}else{
|
||||
return false;//not supported
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* automount paths from file hooks
|
||||
* @param aray params
|
||||
*/
|
||||
public static function autoMount($params){
|
||||
if(!self::$enableAutomount){
|
||||
return;
|
||||
}
|
||||
$path=$params['path'];
|
||||
if(!self::$rootView){
|
||||
self::$rootView=new OC_FilesystemView('');
|
||||
}
|
||||
self::$enableAutomount=false;//prevent recursion
|
||||
$supported=array('zip');
|
||||
foreach($supported as $type){
|
||||
$ext='.'.$type.'/';
|
||||
if(($pos=strpos(strtolower($path),$ext))!==false){
|
||||
$archive=substr($path,0,$pos+strlen($ext)-1);
|
||||
if(self::$rootView->file_exists($archive) and array_search($archive,self::$mounted)===false){
|
||||
$localArchive=self::$rootView->getLocalFile($archive);
|
||||
OC_Filesystem::mount('OC_Filestorage_Archive',array('archive'=>$localArchive),$archive.'/');
|
||||
self::$mounted[]=$archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
self::$enableAutomount=true;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue