summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/calendar/ajax/calendar/activation.php2
-rw-r--r--apps/calendar/ajax/calendar/delete.php1
-rw-r--r--apps/calendar/ajax/calendar/new.php3
-rw-r--r--apps/calendar/ajax/calendar/update.php1
-rw-r--r--apps/calendar/ajax/categories/rescan.php1
-rw-r--r--apps/calendar/ajax/event/delete.php1
-rw-r--r--apps/calendar/ajax/event/edit.php1
-rw-r--r--apps/calendar/ajax/event/move.php1
-rw-r--r--apps/calendar/ajax/event/new.form.php2
-rw-r--r--apps/calendar/ajax/event/new.php1
-rw-r--r--apps/calendar/ajax/event/resize.php1
-rw-r--r--apps/calendar/ajax/import/import.php3
-rw-r--r--apps/calendar/ajax/settings/setfirstday.php1
-rw-r--r--apps/calendar/ajax/settings/settimeformat.php1
-rw-r--r--apps/calendar/ajax/settings/settimezone.php1
-rw-r--r--apps/calendar/ajax/share/changepermission.php4
-rw-r--r--apps/calendar/ajax/share/share.php2
-rw-r--r--apps/calendar/ajax/share/unshare.php4
-rw-r--r--apps/calendar/appinfo/app.php1
-rw-r--r--apps/calendar/js/settings.js4
-rw-r--r--apps/calendar/lib/app.php14
-rw-r--r--apps/calendar/lib/hooks.php13
-rw-r--r--apps/calendar/lib/object.php2
-rw-r--r--apps/calendar/lib/search.php2
-rw-r--r--apps/calendar/templates/calendar.php8
-rw-r--r--apps/contacts/ajax/activation.php8
-rw-r--r--apps/contacts/ajax/addaddressbook.php6
-rw-r--r--apps/contacts/ajax/addcontact.php10
-rw-r--r--apps/contacts/ajax/addproperty.php42
-rw-r--r--apps/contacts/ajax/categories/categoriesfor.php15
-rw-r--r--apps/contacts/ajax/categories/delete.php3
-rw-r--r--apps/contacts/ajax/categories/rescan.php1
-rw-r--r--apps/contacts/ajax/contactdetails.php5
-rw-r--r--apps/contacts/ajax/createaddressbook.php2
-rw-r--r--apps/contacts/ajax/currentphoto.php2
-rw-r--r--apps/contacts/ajax/deletecard.php12
-rw-r--r--apps/contacts/ajax/deleteproperty.php11
-rw-r--r--apps/contacts/ajax/editaddress.php4
-rw-r--r--apps/contacts/ajax/editname.php6
-rw-r--r--apps/contacts/ajax/loadcard.php14
-rw-r--r--apps/contacts/ajax/loadintro.php2
-rw-r--r--apps/contacts/ajax/loadphoto.php2
-rw-r--r--apps/contacts/ajax/loghandler.php10
-rw-r--r--apps/contacts/ajax/oc_photo.php6
-rw-r--r--apps/contacts/ajax/savecrop.php22
-rw-r--r--apps/contacts/ajax/saveproperty.php21
-rw-r--r--apps/contacts/ajax/updateaddressbook.php2
-rw-r--r--apps/contacts/ajax/uploadimport.php28
-rw-r--r--apps/contacts/ajax/uploadphoto.php46
-rw-r--r--apps/contacts/appinfo/app.php2
-rw-r--r--apps/contacts/appinfo/database.xml4
-rw-r--r--apps/contacts/appinfo/migrate.php15
-rw-r--r--apps/contacts/appinfo/remote.php4
-rw-r--r--apps/contacts/appinfo/update.php2
-rw-r--r--apps/contacts/appinfo/version2
-rw-r--r--apps/contacts/carddav.php6
-rw-r--r--apps/contacts/css/contacts.css8
-rw-r--r--apps/contacts/export.php18
-rw-r--r--apps/contacts/import.php61
-rw-r--r--apps/contacts/index.php45
-rw-r--r--apps/contacts/js/contacts.js398
-rw-r--r--apps/contacts/lib/VCFExportPlugin.php8
-rw-r--r--apps/contacts/lib/addressbook.php80
-rw-r--r--apps/contacts/lib/app.php10
-rw-r--r--apps/contacts/lib/connector_sabre.php6
-rw-r--r--apps/contacts/lib/hooks.php24
-rw-r--r--apps/contacts/lib/search.php6
-rw-r--r--apps/contacts/lib/vcard.php130
-rw-r--r--apps/contacts/photo.php23
-rw-r--r--apps/contacts/templates/index.php2
-rw-r--r--apps/contacts/templates/part.cropphoto.php1
-rw-r--r--apps/contacts/templates/part.edit_categories_dialog.php16
-rw-r--r--apps/contacts/thumbnail.php27
-rw-r--r--apps/contacts/tmpphoto.php2
-rw-r--r--apps/files_encryption/lib/cryptstream.php3
-rwxr-xr-xapps/files_external/lib/dropbox.php2
-rw-r--r--apps/files_external/lib/google.php9
-rw-r--r--apps/files_external/lib/smb.php2
-rw-r--r--apps/files_external/lib/webdav.php15
-rw-r--r--apps/files_external/tests/ftp.php1
-rw-r--r--apps/files_external/tests/google.php1
-rw-r--r--apps/files_external/tests/smb.php1
-rw-r--r--apps/files_external/tests/swift.php1
-rw-r--r--apps/files_external/tests/webdav.php1
-rw-r--r--apps/files_sharing/sharedstorage.php66
-rw-r--r--apps/files_sharing_log/appinfo/database.xml2
-rw-r--r--apps/files_versions/ajax/expireAll.php1
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php1
-rw-r--r--apps/files_versions/ajax/togglesettings.php1
-rw-r--r--apps/files_versions/lib/versions.php6
-rw-r--r--apps/gallery/lib/album.php2
-rw-r--r--apps/gallery/lib/managers.php1
-rw-r--r--apps/gallery/lib/tiles.php2
-rw-r--r--apps/media/lib_ampache.php1
-rw-r--r--apps/media/lib_collection.php3
-rw-r--r--apps/media/lib_media.php6
-rw-r--r--apps/remoteStorage/appinfo/info.xml3
-rw-r--r--apps/remoteStorage/appinfo/version2
-rw-r--r--apps/remoteStorage/appinfo/webfinger.php6
-rw-r--r--apps/remoteStorage/lib_remoteStorage.php13
-rw-r--r--apps/remoteStorage/oauth_ro_auth.php20
-rw-r--r--apps/remoteStorage/webdav.php (renamed from apps/remoteStorage/WebDAV.php)36
-rw-r--r--apps/tasks/ajax/addtask.php3
-rw-r--r--apps/tasks/ajax/addtaskform.php20
-rw-r--r--apps/tasks/ajax/delete.php1
-rw-r--r--apps/tasks/ajax/edittask.php31
-rw-r--r--apps/tasks/ajax/edittaskform.php24
-rw-r--r--apps/tasks/ajax/getdetails.php24
-rw-r--r--apps/tasks/ajax/gettasks.php2
-rw-r--r--apps/tasks/ajax/update_property.php5
-rw-r--r--apps/tasks/index.php4
-rw-r--r--apps/tasks/js/tasks.js62
-rw-r--r--apps/tasks/lib/app.php18
-rw-r--r--apps/tasks/templates/part.addtaskform.php15
-rw-r--r--apps/tasks/templates/part.details.php42
-rw-r--r--apps/tasks/templates/part.edittaskform.php5
-rw-r--r--apps/tasks/templates/part.property.php22
-rw-r--r--apps/tasks/templates/part.taskform.php36
-rw-r--r--apps/tasks/templates/part.tasks.php3
-rw-r--r--apps/user_external/appinfo/app.php4
-rw-r--r--apps/user_external/appinfo/info.xml13
-rw-r--r--apps/user_external/appinfo/version1
-rw-r--r--apps/user_external/lib/ftp.php45
-rw-r--r--apps/user_external/lib/imap.php40
-rw-r--r--apps/user_external/lib/smb.php43
-rw-r--r--apps/user_external/tests/config.php28
-rw-r--r--apps/user_external/tests/ftp.php34
-rw-r--r--apps/user_external/tests/imap.php34
-rw-r--r--apps/user_external/tests/smb.php34
-rw-r--r--apps/user_webfinger/.htaccess5
-rw-r--r--apps/user_webfinger/host-meta.php19
131 files changed, 1127 insertions, 953 deletions
diff --git a/apps/calendar/ajax/calendar/activation.php b/apps/calendar/ajax/calendar/activation.php
index e31908beb14..f4aadc5b017 100644
--- a/apps/calendar/ajax/calendar/activation.php
+++ b/apps/calendar/ajax/calendar/activation.php
@@ -9,6 +9,8 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
+
$calendarid = $_POST['calendarid'];
$calendar = OC_Calendar_App::getCalendar($calendarid, true);
if(!$calendar){
diff --git a/apps/calendar/ajax/calendar/delete.php b/apps/calendar/ajax/calendar/delete.php
index 4d6706f6002..089255cae39 100644
--- a/apps/calendar/ajax/calendar/delete.php
+++ b/apps/calendar/ajax/calendar/delete.php
@@ -9,6 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
$cal = $_POST["calendarid"];
$calendar = OC_Calendar_App::getCalendar($cal, true);
diff --git a/apps/calendar/ajax/calendar/new.php b/apps/calendar/ajax/calendar/new.php
index e77d4ebff03..67d12822378 100644
--- a/apps/calendar/ajax/calendar/new.php
+++ b/apps/calendar/ajax/calendar/new.php
@@ -6,11 +6,10 @@
* See the COPYING-README file.
*/
-
-
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
if(trim($_POST['name']) == ''){
OCP\JSON::error(array('message'=>'empty'));
diff --git a/apps/calendar/ajax/calendar/update.php b/apps/calendar/ajax/calendar/update.php
index a2c898c8075..c09b1008c9c 100644
--- a/apps/calendar/ajax/calendar/update.php
+++ b/apps/calendar/ajax/calendar/update.php
@@ -11,6 +11,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
if(trim($_POST['name']) == ''){
OCP\JSON::error(array('message'=>'empty'));
diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php
index f0060cb23b2..08c32865b6f 100644
--- a/apps/calendar/ajax/categories/rescan.php
+++ b/apps/calendar/ajax/categories/rescan.php
@@ -9,6 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
foreach ($_POST as $key=>$element) {
debug('_POST: '.$key.'=>'.print_r($element, true));
diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php
index f183d431afa..17e45c001e8 100644
--- a/apps/calendar/ajax/event/delete.php
+++ b/apps/calendar/ajax/event/delete.php
@@ -9,6 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
$id = $_POST['id'];
$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
diff --git a/apps/calendar/ajax/event/edit.php b/apps/calendar/ajax/event/edit.php
index 1c3babc3d90..db78bf6e5e0 100644
--- a/apps/calendar/ajax/event/edit.php
+++ b/apps/calendar/ajax/event/edit.php
@@ -9,6 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
$id = $_POST['id'];
diff --git a/apps/calendar/ajax/event/move.php b/apps/calendar/ajax/event/move.php
index 04cf2fb0513..f4e2b36376d 100644
--- a/apps/calendar/ajax/event/move.php
+++ b/apps/calendar/ajax/event/move.php
@@ -7,6 +7,7 @@
*/
OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
$id = $_POST['id'];
$access = OC_Calendar_App::getaccess($id, OC_Calendar_App::EVENT);
diff --git a/apps/calendar/ajax/event/new.form.php b/apps/calendar/ajax/event/new.form.php
index 0b19e7e92f9..db04cdf2d49 100644
--- a/apps/calendar/ajax/event/new.form.php
+++ b/apps/calendar/ajax/event/new.form.php
@@ -27,7 +27,7 @@ if (!$end){
}
$start = new DateTime('@'.$start);
$end = new DateTime('@'.$end);
-$timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$timezone = OC_Calendar_App::getTimezone();
$start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php
index 30e2b0cae36..bc0439cc315 100644
--- a/apps/calendar/ajax/event/new.php
+++ b/apps/calendar/ajax/event/new.php
@@ -10,6 +10,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
diff --git a/apps/calendar/ajax/event/resize.php b/apps/calendar/ajax/event/resize.php
index 56b83205e85..15b687b55da 100644
--- a/apps/calendar/ajax/event/resize.php
+++ b/apps/calendar/ajax/event/resize.php
@@ -7,6 +7,7 @@
*/
OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
$id = $_POST['id'];
diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php
index cbb4b550569..b1dfc464d00 100644
--- a/apps/calendar/ajax/import/import.php
+++ b/apps/calendar/ajax/import/import.php
@@ -7,6 +7,7 @@
*/
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
session_write_close();
if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) {
echo OCP\JSON::success(array('percent'=>OC_Cache::get($_POST['progresskey'])));
@@ -147,4 +148,4 @@ foreach($uids as $uid) {
writeProgress('100');
sleep(3);
OC_Cache::remove($progresskey);
-OCP\JSON::success();*/ \ No newline at end of file
+OCP\JSON::success();*/
diff --git a/apps/calendar/ajax/settings/setfirstday.php b/apps/calendar/ajax/settings/setfirstday.php
index 056a6037524..73cf0c19b78 100644
--- a/apps/calendar/ajax/settings/setfirstday.php
+++ b/apps/calendar/ajax/settings/setfirstday.php
@@ -7,6 +7,7 @@
*/
OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
if(isset($_POST["firstday"])){
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]);
OCP\JSON::success();
diff --git a/apps/calendar/ajax/settings/settimeformat.php b/apps/calendar/ajax/settings/settimeformat.php
index 8e95f6f3bf5..6136857e2fe 100644
--- a/apps/calendar/ajax/settings/settimeformat.php
+++ b/apps/calendar/ajax/settings/settimeformat.php
@@ -7,6 +7,7 @@
*/
OCP\JSON::checkLoggedIn();
+OCP\JSON::callCheck();
if(isset($_POST["timeformat"])){
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
OCP\JSON::success();
diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php
index 6d029a6643a..06db66d578e 100644
--- a/apps/calendar/ajax/settings/settimezone.php
+++ b/apps/calendar/ajax/settings/settimezone.php
@@ -14,6 +14,7 @@ $l=OC_L10N::get('calendar');
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
+OCP\JSON::callCheck();
// Get data
if( isset( $_POST['timezone'] ) ){
diff --git a/apps/calendar/ajax/share/changepermission.php b/apps/calendar/ajax/share/changepermission.php
index e807c164a23..5aff7666f79 100644
--- a/apps/calendar/ajax/share/changepermission.php
+++ b/apps/calendar/ajax/share/changepermission.php
@@ -5,7 +5,9 @@
* later.
* See the COPYING-README file.
*/
-
+
+OCP\JSON::callCheck();
+
$id = strip_tags($_POST['id']);
$idtype = strip_tags($_POST['idtype']);
$permission = (int) strip_tags($_POST['permission']);
diff --git a/apps/calendar/ajax/share/share.php b/apps/calendar/ajax/share/share.php
index 838db619f62..77e1ab9d657 100644
--- a/apps/calendar/ajax/share/share.php
+++ b/apps/calendar/ajax/share/share.php
@@ -6,6 +6,8 @@
* See the COPYING-README file.
*/
+OCP\JSON::callCheck();
+
$id = strip_tags($_POST['id']);
$idtype = strip_tags($_POST['idtype']);
switch($idtype){
diff --git a/apps/calendar/ajax/share/unshare.php b/apps/calendar/ajax/share/unshare.php
index 1ce04677fb1..c7c06113189 100644
--- a/apps/calendar/ajax/share/unshare.php
+++ b/apps/calendar/ajax/share/unshare.php
@@ -5,7 +5,9 @@
* later.
* See the COPYING-README file.
*/
-
+
+OCP\JSON::callCheck();
+
$id = strip_tags($_POST['id']);
$idtype = strip_tags($_POST['idtype']);
switch($idtype){
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 09b18ed397b..4fdba291262 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -11,6 +11,7 @@ OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
OC::$CLASSPATH['OC_Calendar_Export'] = 'apps/calendar/lib/export.php';
OC::$CLASSPATH['OC_Calendar_Import'] = 'apps/calendar/lib/import.php';
//General Hooks
+OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
//Repeating Events Hooks
OCP\Util::connectHook('OC_Calendar', 'addEvent', 'OC_Calendar_Repeat', 'generate');
diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js
index 03e4217573d..60741f2b6fc 100644
--- a/apps/calendar/js/settings.js
+++ b/apps/calendar/js/settings.js
@@ -34,6 +34,7 @@ $(document).ready(function(){
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'timeformat.php'), function(jsondata, status) {
$('#' + jsondata.timeformat).attr('selected',true);
$('#timeformat').chosen();
+ $('#timeformat_chzn').css('width', '100px');
});
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'gettimezonedetection.php'), function(jsondata, status){
if(jsondata.detection == 'true'){
@@ -43,6 +44,7 @@ $(document).ready(function(){
$.getJSON(OC.filePath('calendar', 'ajax/settings', 'getfirstday.php'), function(jsondata, status) {
$('#' + jsondata.firstday).attr('selected',true);
$('#firstday').chosen();
+ $('#firstday_chzn').css('width', '100px');
});
$('#cleancalendarcache').click(function(){
$.getJSON(OC.filePath('calendar', 'ajax/cache', 'rescan.php'), function(){
@@ -55,7 +57,7 @@ function calendarcachecheck(){
$.getJSON(OC.filePath('calendar', 'ajax/cache', 'status.php'), function(jsondata, status) {
$('#cleancalendarcache').attr('title', jsondata.l10n.text);
if(jsondata.status == 'success'){
- $('#cleancalendarcache').css('background', '#90EE90');
+ $('#cleancalendarcache').css('background', '#F8F8F8');
$('#cleancalendarcache').css('color', '#333');
$('#cleancalendarcache').css('text-shadow', '#fff 0 1px 0');
}else{
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index 1a13f2958c0..29e5ab5b0c8 100644
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -9,7 +9,7 @@
* This class manages our app actions
*/
OC_Calendar_App::$l10n = new OC_L10N('calendar');
-OC_Calendar_App::$tz = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+OC_Calendar_App::$tz = OC_Calendar_App::getTimezone();
class OC_Calendar_App{
const CALENDAR = 'calendar';
const EVENT = 'event';
@@ -282,7 +282,17 @@ class OC_Calendar_App{
public static function getWeekofMonth(){
return OC_Calendar_Object::getWeekofMonth(self::$l10n);
}
-
+
+ /**
+ * @return (string) $timezone as set by user or the default timezone
+ */
+ public static function getTimezone() {
+ return OCP\Config::getUserValue(OCP\User::getUser(),
+ 'calendar',
+ 'timezone',
+ date_default_timezone_get());
+ }
+
/**
* @brief checks the access for a calendar / an event
* @param (int) $id - id of the calendar / event
diff --git a/apps/calendar/lib/hooks.php b/apps/calendar/lib/hooks.php
index 328d2951d23..bc0b02c62b8 100644
--- a/apps/calendar/lib/hooks.php
+++ b/apps/calendar/lib/hooks.php
@@ -11,7 +11,18 @@
*/
class OC_Calendar_Hooks{
/**
- * @brief Deletes all Addressbooks of a certain user
+ * @brief Creates default calendar for a user
+ * @param paramters parameters from postCreateUser-Hook
+ * @return array
+ */
+ public static function createUser($parameters) {
+ OC_Calendar_Calendar::addCalendar($parameters['uid'],'Default calendar');
+
+ return true;
+ }
+
+ /**
+ * @brief Deletes all calendars of a certain user
* @param paramters parameters from postDeleteUser-Hook
* @return array
*/
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 140542bf4fb..34676830205 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -856,7 +856,7 @@ class OC_Calendar_Object{
$vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::DATE);
$vevent->setDateTime('DTEND', $end, Sabre_VObject_Property_DateTime::DATE);
}else{
- $timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
$start = new DateTime($from.' '.$fromtime, $timezone);
$end = new DateTime($to.' '.$totime, $timezone);
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
index 560330f65e9..551489672b9 100644
--- a/apps/calendar/lib/search.php
+++ b/apps/calendar/lib/search.php
@@ -12,7 +12,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
}else{
$searchquery[] = $query;
}
- $user_timezone = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $user_timezone = OC_Calendar_App::getTimezone();
$l = new OC_l10n('calendar');
foreach($calendars as $calendar){
$objects = OC_Calendar_Object::all($calendar['id']);
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 2246a0178e3..29b9bf6bc54 100644
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -2,10 +2,10 @@
var defaultView = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') ?>';
var eventSources = <?php echo json_encode($_['eventSources']) ?>;
var categories = <?php echo json_encode($_['categories']); ?>;
- var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>;
- var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>;
- var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>;
- var monthNamesShort = <?php echo json_encode($l->tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>;
+ var dayNames = new Array("<?php echo $l -> t("Sunday");?>", "<?php echo $l -> t("Monday");?>", "<?php echo $l -> t("Tuesday");?>", "<?php echo $l -> t("Wednesday");?>", "<?php echo $l -> t("Thursday");?>", "<?php echo $l -> t("Friday");?>", "<?php echo $l -> t("Saturday");?>");
+ var dayNamesShort = new Array("<?php echo $l -> t("Sun.");?>", "<?php echo $l -> t("Mon.");?>", "<?php echo $l -> t("Tue.");?>", "<?php echo $l -> t("Wed.");?>", "<?php echo $l -> t("Thu.");?>", "<?php echo $l -> t("Fri.");?>", "<?php echo $l -> t("Sat.");?>");
+ var monthNames = new Array("<?php echo $l -> t("January");?>", "<?php echo $l -> t("February");?>", "<?php echo $l -> t("March");?>", "<?php echo $l -> t("April");?>", "<?php echo $l -> t("May");?>", "<?php echo $l -> t("June");?>", "<?php echo $l -> t("July");?>", "<?php echo $l -> t("August");?>", "<?php echo $l -> t("September");?>", "<?php echo $l -> t("October");?>", "<?php echo $l -> t("November");?>", "<?php echo $l -> t("December");?>");
+ var monthNamesShort = new Array("<?php echo $l -> t("Jan.");?>", "<?php echo $l -> t("Feb.");?>", "<?php echo $l -> t("Mar.");?>", "<?php echo $l -> t("Apr.");?>", "<?php echo $l -> t("May.");?>", "<?php echo $l -> t("Jun.");?>", "<?php echo $l -> t("Jul.");?>", "<?php echo $l -> t("Aug.");?>", "<?php echo $l -> t("Sep.");?>", "<?php echo $l -> t("Oct.");?>", "<?php echo $l -> t("Nov.");?>", "<?php echo $l -> t("Dec.");?>");
var agendatime = '<?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>{ - <?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>}';
var defaulttime = '<?php echo ((int) OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>';
var allDayText = '<?php echo addslashes($l->t('All day')) ?>';
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php
index 74cb738ab8f..69173c54c44 100644
--- a/apps/contacts/ajax/activation.php
+++ b/apps/contacts/ajax/activation.php
@@ -16,8 +16,12 @@ $bookid = $_POST['bookid'];
$book = OC_Contacts_App::getAddressbook($bookid);// is owner access check
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
- OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
+ OCP\Util::writeLog('contacts',
+ 'ajax/activation.php: Error activating addressbook: '. $bookid,
+ OCP\Util::ERROR);
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
exit();
}
diff --git a/apps/contacts/ajax/addaddressbook.php b/apps/contacts/ajax/addaddressbook.php
index 3d7885fe468..40773704bb4 100644
--- a/apps/contacts/ajax/addaddressbook.php
+++ b/apps/contacts/ajax/addaddressbook.php
@@ -12,13 +12,15 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
debug('name: '.$_POST['name']);
$userid = OCP\USER::getUser();
$name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null;
-$description = isset($_POST['description'])?trim(strip_tags($_POST['description'])):null;
+$description = isset($_POST['description'])
+ ? trim(strip_tags($_POST['description']))
+ : null;
if(is_null($name)) {
bailOut('Cannot add addressbook with an empty name.');
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index 12f7bb9db96..6aaf5a9df35 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -37,13 +37,15 @@ $n = trim($_POST['n']);
$vcard = new OC_VObject('VCARD');
$vcard->setUID();
-$vcard->setString('FN',$fn);
-$vcard->setString('N',$n);
+$vcard->setString('FN', $fn);
+$vcard->setString('N', $n);
$id = OC_Contacts_VCard::add($aid, $vcard, null, $isnew);
if(!$id) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
- OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
+ OCP\Util::writeLog('contacts', 'ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
exit();
}
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 1b6db0c8f81..58b857547fb 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null;
@@ -33,22 +33,27 @@ $value = isset($_POST['value'])?$_POST['value']:null;
$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
$vcard = OC_Contacts_App::getContactVCard($id);
+$l10n = OC_Contacts_App::$l10n;
if(!$name) {
- bailOut(OC_Contacts_App::$l10n->t('element name is not set.'));
+ bailOut($l10n->t('element name is not set.'));
}
if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
+ bailOut($l10n->t('id is not set.'));
}
if(!$vcard) {
- bailOut(OC_Contacts_App::$l10n->t('Could not parse contact: ').$id);
+ bailOut($l10n->t('Could not parse contact: ').$id);
}
-if(!is_array($value)){
+if(!is_array($value)) {
$value = trim($value);
- if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))) {
- bailOut(OC_Contacts_App::$l10n->t('Cannot add empty property.'));
+ if(!$value
+ && in_array(
+ $name,
+ array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))
+ ) {
+ bailOut($l10n->t('Cannot add empty property.'));
}
} elseif($name === 'ADR') { // only add if non-empty elements.
$empty = true;
@@ -59,7 +64,7 @@ if(!is_array($value)){
}
}
if($empty) {
- bailOut(OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.'));
+ bailOut($l10n->t('At least one of the address fields has to be filled out.'));
}
}
@@ -68,12 +73,14 @@ $current = $vcard->select($name);
foreach($current as $item) {
$tmpvalue = (is_array($value)?implode(';', $value):$value);
if($tmpvalue == $item->value) {
- bailOut(OC_Contacts_App::$l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
+ bailOut($l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
}
}
if(is_array($value)) {
- ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+ // NOTE: Important, otherwise the compound value will
+ // be set in the order the fields appear in the form!
+ ksort($value);
$value = array_map('strip_tags', $value);
} else {
$value = strip_tags($value);
@@ -116,24 +123,25 @@ switch($name) {
$line = count($vcard->children) - 1;
-// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
+// Apparently Sabre_VObject_Parameter doesn't do well with
+// multiple values or I don't know how to do it. Tanghus.
foreach ($parameters as $key=>$element) {
if(is_array($element) && strtoupper($key) == 'TYPE') {
// NOTE: Maybe this doesn't only apply for TYPE?
// And it probably shouldn't be done here anyways :-/
- foreach($element as $e){
- if($e != '' && !is_null($e)){
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e);
+ foreach($element as $e) {
+ if($e != '' && !is_null($e)) {
+ $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e);
}
}
} else {
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element);
+ $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element);
}
}
$checksum = md5($vcard->children[$line]->serialize());
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error adding contact property: '.$name));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+ bailOut($l10n->t('Error adding contact property: '.$name));
}
OCP\JSON::success(array('data' => array( 'checksum' => $checksum )));
diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php
index 6b6fcad0ebb..8391b14b545 100644
--- a/apps/contacts/ajax/categories/categoriesfor.php
+++ b/apps/contacts/ajax/categories/categoriesfor.php
@@ -12,16 +12,23 @@ OCP\JSON::checkAppEnabled('contacts');
$id = isset($_GET['id'])?$_GET['id']:null;
if(is_null($id)) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided'))));
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('No ID provided'))));
exit();
}
$vcard = OC_Contacts_App::getContactVCard( $id );
foreach($vcard->children as $property){
- //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
if($property->name == 'CATEGORIES') {
$checksum = md5($property->serialize());
- OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'value' => $property->value,
+ 'checksum' => $checksum,
+ )));
exit();
}
}
-OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
+OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
index 7c3261446bb..bc9f3e14e87 100644
--- a/apps/contacts/ajax/categories/delete.php
+++ b/apps/contacts/ajax/categories/delete.php
@@ -9,8 +9,9 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
+OCP\JSON::callCheck();
-require_once('../loghandler.php');
+require_once __DIR__.'/../loghandler.php';
$categories = isset($_POST['categories'])?$_POST['categories']:null;
diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php
index fd875a965dc..a06e7803955 100644
--- a/apps/contacts/ajax/categories/rescan.php
+++ b/apps/contacts/ajax/categories/rescan.php
@@ -9,6 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
+OCP\JSON::callCheck();
OC_Contacts_App::scanCategories();
$categories = OC_Contacts_App::getCategories();
diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
index b697b1a8e5b..27d7611ade9 100644
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -20,7 +20,7 @@
*
*/
-require_once('loghandler.php');
+require_once 'loghandler.php';
// Check if we are a user
OCP\JSON::checkLoggedIn();
@@ -30,6 +30,7 @@ $id = isset($_GET['id'])?$_GET['id']:null;
if(is_null($id)) {
bailOut(OC_Contacts_App::$l10n->t('Missing ID'));
}
+$card = OC_Contacts_VCard::find($id);
$vcard = OC_Contacts_App::getContactVCard( $id );
if(is_null($vcard)) {
bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "'.$id.'"'));
@@ -50,5 +51,7 @@ if(isset($details['PHOTO'])) {
$details['PHOTO'] = false;
}
$details['id'] = $id;
+$details['displayname'] = $card['fullname'];
+$details['addressbookid'] = $card['addressbookid'];
OC_Contacts_App::setLastModifiedHeader($vcard);
OCP\JSON::success(array('data' => $details));
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index 2ec5f542bb3..8dbd63f6425 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -12,7 +12,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$userid = OCP\USER::getUser();
$name = trim(strip_tags($_POST['name']));
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
index 8f60eca08ec..96080e661ef 100644
--- a/apps/contacts/ajax/currentphoto.php
+++ b/apps/contacts/ajax/currentphoto.php
@@ -24,7 +24,7 @@
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
if (!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 1161c18abda..9777046fc82 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -23,17 +23,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
-
-// foreach($_SERVER as $key=>$value) {
-// OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG);
-// }
-// foreach($_POST as $key=>$value) {
-// debug($key.'=>'.print_r($value, true));
-// }
-// foreach($_GET as $key=>$value) {
-// debug($key.'=>'.print_r($value, true));
-// }
+require_once 'loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null;
if(!$id) {
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 90e5e64903e..205df8bc184 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -24,22 +24,23 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = $_POST['id'];
$checksum = $_POST['checksum'];
+$l10n = OC_Contacts_App::$l10n;
$vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
-if(is_null($line)){
- bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'));
+if(is_null($line)) {
+ bailOut($l10n->t('Information about vCard is incorrect. Please reload the page.'));
exit();
}
unset($vcard->children[$line]);
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.'));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+ bailOut($l10n->t('Error deleting contact property.'));
}
OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php
index 1eb9429d79c..b5e4b72ed57 100644
--- a/apps/contacts/ajax/editaddress.php
+++ b/apps/contacts/ajax/editaddress.php
@@ -34,8 +34,8 @@ if($checksum) {
$tmpl->assign('adr', $adr, false);
}
-$tmpl->assign('id',$id);
-$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('id', $id);
+$tmpl->assign('adr_types', $adr_types);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
index 9e7c090eeed..eb55634011d 100644
--- a/apps/contacts/ajax/editname.php
+++ b/apps/contacts/ajax/editname.php
@@ -9,7 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
@@ -25,8 +25,8 @@ if($id) {
}
}
$name = array_map('htmlspecialchars', $name['value']);
- $tmpl->assign('name',$name, false);
- $tmpl->assign('id',$id, false);
+ $tmpl->assign('name', $name, false);
+ $tmpl->assign('id', $id, false);
} else {
bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
}
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
index 1309faaa7a2..75fe33ada6f 100644
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -30,20 +30,20 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$requesttoken = $_GET['requesttoken'];
$freeSpace=OC_Filesystem::free_space('/');
-$freeSpace=max($freeSpace,0);
-$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
+$freeSpace=max($freeSpace, 0);
+$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
-$tmpl = new OCP\Template('contacts','part.contact');
+$tmpl = new OCP\Template('contacts', 'part.contact');
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
-$tmpl->assign('adr_types',$adr_types);
-$tmpl->assign('phone_types',$phone_types);
-$tmpl->assign('email_types',$email_types);
+$tmpl->assign('adr_types', $adr_types);
+$tmpl->assign('phone_types', $phone_types);
+$tmpl->assign('email_types', $email_types);
$tmpl->assign('requesttoken', $requesttoken);
-$tmpl->assign('id','');
+$tmpl->assign('id', '');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php
index 6e8fcc4b049..1da08950ca0 100644
--- a/apps/contacts/ajax/loadintro.php
+++ b/apps/contacts/ajax/loadintro.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-$tmpl = new OCP\Template('contacts','part.no_contacts');
+$tmpl = new OCP\Template('contacts', 'part.no_contacts');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
index a35631055eb..be924b5db4d 100644
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -24,7 +24,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = isset($_GET['id']) ? $_GET['id'] : '';
$refresh = isset($_GET['refresh']) ? true : false;
diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php
index 831b2e50c1e..be4b98c1112 100644
--- a/apps/contacts/ajax/loghandler.php
+++ b/apps/contacts/ajax/loghandler.php
@@ -20,13 +20,15 @@
*
*/
-function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) {
+function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR)
+{
OCP\JSON::error(array('data' => array('message' => $msg)));
debug($msg, $tracelevel, $debuglevel);
exit();
}
-function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
+function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG)
+{
if(PHP_VERSION >= "5.4") {
$call = debug_backtrace(false, $tracelevel+1);
} else {
@@ -35,6 +37,8 @@ function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
error_log('trace: '.print_r($call, true));
$call = $call[$tracelevel];
if($debuglevel !== false) {
- OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel);
+ OCP\Util::writeLog('contacts',
+ $call['file'].'. Line: '.$call['line'].': '.$msg,
+ $debuglevel);
}
}
diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php
index 710179fffcc..fe37b530f82 100644
--- a/apps/contacts/ajax/oc_photo.php
+++ b/apps/contacts/ajax/oc_photo.php
@@ -22,7 +22,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
if(!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
@@ -50,7 +50,9 @@ if($image->width() > 400 || $image->height() > 400) {
$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
}
if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
- OCP\Util::writeLog('contacts','ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath,
+ OCP\Util::DEBUG);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index adce6be3b39..8ee2e46bf0c 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -27,7 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$image = null;
@@ -48,7 +48,7 @@ if($id == '') {
bailOut('Missing contact id.');
}
-OCP\Util::writeLog('contacts','savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
+OCP\Util::writeLog('contacts', 'savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
$data = OC_Cache::get($tmpkey);
if($data) {
@@ -56,7 +56,9 @@ if($data) {
if($image->loadFromdata($data)) {
$w = ($w != -1 ? $w : $image->width());
$h = ($h != -1 ? $h : $image->height());
- OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h,
+ OCP\Util::DEBUG);
if($image->crop($x1, $y1, $w, $h)) {
if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) {
$card = OC_Contacts_App::getContactVCard($id);
@@ -65,7 +67,9 @@ if($data) {
bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.'));
}
if($card->__isset('PHOTO')) {
- OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php: PHOTO property exists.',
+ OCP\Util::DEBUG);
$property = $card->__get('PHOTO');
if(!$property) {
OC_Cache::remove($tmpkey);
@@ -76,12 +80,16 @@ if($data) {
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
$card->__set('PHOTO', $property);
} else {
- OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
- $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php: files: Adding PHOTO property.',
+ OCP\Util::DEBUG);
+ $card->addProperty('PHOTO',
+ $image->__toString(), array('ENCODING' => 'b',
+ 'TYPE' => $image->mimeType()));
}
$now = new DateTime;
$card->setString('REV', $now->format(DateTime::W3C));
- if(!OC_Contacts_VCard::edit($id,$card)) {
+ if(!OC_Contacts_VCard::edit($id, $card)) {
bailOut(OC_Contacts_App::$l10n->t('Error saving contact.'));
}
$tmpl = new OCP\Template("contacts", "part.contactphoto");
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 34fc3cc5351..5d743c99df4 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -19,7 +19,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-require_once('loghandler.php');
+require_once 'loghandler.php';
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
@@ -39,9 +39,11 @@ if(!$id) {
if(!$checksum) {
bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
}
-if(is_array($value)){
+if(is_array($value)) {
$value = array_map('strip_tags', $value);
- ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+ // NOTE: Important, otherwise the compound value will be
+ // set in the order the fields appear in the form!
+ ksort($value);
//if($name == 'CATEGORIES') {
// $value = OC_Contacts_VCard::escapeDelimiters($value, ',');
//} else {
@@ -66,8 +68,7 @@ if($element != $name) {
switch($element) {
case 'BDAY':
$date = New DateTime($value);
- //$vcard->setDateTime('BDAY', $date, Sabre_VObject_Element_DateTime::DATE);
- $value = $date->format(DateTime::ATOM);
+ $value = $date->format('Y-m-d');
break;
case 'FN':
if(!$value) {
@@ -89,6 +90,14 @@ if(!$value) {
} else {
/* setting value */
switch($element) {
+ case 'BDAY':
+ // I don't use setDateTime() because that formats it as YYYYMMDD instead of YYYY-MM-DD
+ // which is what the RFC recommends.
+ $vcard->children[$line]->setValue($value);
+ $vcard->children[$line]->parameters = array();
+ $vcard->children[$line]->add(new Sabre_VObject_Parameter('VALUE', 'DATE'));
+ debug('Setting value:'.$name.' '.$vcard->children[$line]);
+ break;
case 'CATEGORIES':
debug('Setting string:'.$name.' '.$value);
$vcard->children[$line]->setValue($value);
@@ -120,7 +129,7 @@ if(!$value) {
}
//debug('New checksum: '.$checksum);
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));
exit();
}
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index d3a772c727f..a14b2158431 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -11,7 +11,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$bookid = $_POST['id'];
OC_Contacts_App::getAddressbook($bookid); // is owner access check
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
index 3c5a2d750ed..87032b731a5 100644
--- a/apps/contacts/ajax/uploadimport.php
+++ b/apps/contacts/ajax/uploadimport.php
@@ -24,7 +24,9 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
+
+$l10n = OC_Contacts_App::$l10n;
$view = OCP\Files::getStorage('contacts');
if(!$view->file_exists('imports')) {
@@ -39,25 +41,29 @@ if($fn) {
OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn)));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+ bailOut($l10n->t('Error uploading contacts to storage.'));
}
}
// File input transfers are handled here
if (!isset($_FILES['importfile'])) {
- OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
- OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
+ OCP\Util::writeLog('contacts',
+ 'ajax/uploadphoto.php: No file was uploaded. Unknown error.',
+ OCP\Util::DEBUG);
+ OCP\JSON::error(array('
+ data' => array(
+ 'message' => 'No file was uploaded. Unknown error' )));
exit();
}
$error = $_FILES['importfile']['error'];
if($error !== UPLOAD_ERR_OK) {
$errors = array(
- 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
- 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
- 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
- 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
- 4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
- 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
+ 0=>$l10n->t("There is no error, the file uploaded with success"),
+ 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+ 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+ 3=>$l10n->t("The uploaded file was only partially uploaded"),
+ 4=>$l10n->t("No file was uploaded"),
+ 6=>$l10n->t("Missing a temporary folder")
);
bailOut($errors[$error]);
}
@@ -67,7 +73,7 @@ if(file_exists($file['tmp_name'])) {
if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) {
OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name'])));
} else {
- bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+ bailOut($l10n->t('Error uploading contacts to storage.'));
}
} else {
bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
index 6bb3fe8a5e0..4cd38db8c72 100644
--- a/apps/contacts/ajax/uploadphoto.php
+++ b/apps/contacts/ajax/uploadphoto.php
@@ -27,13 +27,13 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-require_once('loghandler.php');
-
+require_once 'loghandler.php';
+$l10n = OC_Contacts_App::$l10n;
// If it is a Drag'n'Drop transfer it's handled here.
$fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
if ($fn) {
if (!isset($_GET['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+ bailOut($l10n->t('No contact ID was submitted.'));
}
$id = $_GET['id'];
$tmpkey = 'contact-photo-'.md5($fn);
@@ -48,33 +48,38 @@ if ($fn) {
debug('Couldn\'t save correct image orientation: '.$tmpkey);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpkey)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'mime'=>$_SERVER['CONTENT_TYPE'],
+ 'name'=>$fn,
+ 'id'=>$id,
+ 'tmp'=>$tmpkey)));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
}
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey);
}
}
// Uploads from file dialog are handled here.
if (!isset($_POST['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+ bailOut($l10n->t('No contact ID was submitted.'));
}
if (!isset($_FILES['imagefile'])) {
- bailOut(OC_Contacts_App::$l10n->t('No file was uploaded. Unknown error'));
+ bailOut($l10n->t('No file was uploaded. Unknown error'));
}
$error = $_FILES['imagefile']['error'];
if($error !== UPLOAD_ERR_OK) {
$errors = array(
- 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
- 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
- 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
- 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
- 4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
- 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
+ 0=>$l10n->t("There is no error, the file uploaded with success"),
+ 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+ 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+ 3=>$l10n->t("The uploaded file was only partially uploaded"),
+ 4=>$l10n->t("No file was uploaded"),
+ 6=>$l10n->t("Missing a temporary folder")
);
bailOut($errors[$error]);
}
@@ -91,13 +96,20 @@ if(file_exists($file['tmp_name'])) {
debug('Couldn\'t save correct image orientation: '.$tmpkey);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpkey)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'mime'=>$file['type'],
+ 'size'=>$file['size'],
+ 'name'=>$file['name'],
+ 'id'=>$_POST['id'],
+ 'tmp'=>$tmpkey,
+ )));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
}
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
+ bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
}
} else {
bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 33e89c3e9be..cbbbbc79e58 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -19,6 +19,6 @@ OCP\App::addNavigationEntry( array(
'name' => OC_L10N::get('contacts')->t('Contacts') ));
-OCP\App::registerPersonal('contacts','settings');
+OCP\App::registerPersonal('contacts', 'settings');
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OC_Search_Provider_Contacts');
diff --git a/apps/contacts/appinfo/database.xml b/apps/contacts/appinfo/database.xml
index 9b269d765dc..b814b0f1516 100644
--- a/apps/contacts/appinfo/database.xml
+++ b/apps/contacts/appinfo/database.xml
@@ -44,7 +44,7 @@
<type>text</type>
<default></default>
<notnull>false</notnull>
- <length>100</length>
+ <length>200</length>
</field>
<field>
@@ -118,7 +118,7 @@
<type>text</type>
<default></default>
<notnull>false</notnull>
- <length>100</length>
+ <length>200</length>
</field>
<field>
diff --git a/apps/contacts/appinfo/migrate.php b/apps/contacts/appinfo/migrate.php
index 02026c5979c..2559b4ea456 100644
--- a/apps/contacts/appinfo/migrate.php
+++ b/apps/contacts/appinfo/migrate.php
@@ -2,7 +2,7 @@
class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
// Create the xml for the user supplied
- function export( ){
+ function export( ) {
$options = array(
'table'=>'contacts_addressbooks',
'matchcol'=>'userid',
@@ -21,9 +21,8 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
$ids2 = $this->content->copyRows( $options );
// If both returned some ids then they worked
- if( is_array( $ids ) && is_array( $ids2 ) )
- {
- return true;
+ if(is_array($ids) && is_array($ids2)) {
+ return true;
} else {
return false;
}
@@ -31,14 +30,14 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
}
// Import function for contacts
- function import( ){
- switch( $this->appinfo->version ){
+ function import( ) {
+ switch( $this->appinfo->version ) {
default:
// All versions of the app have had the same db structure, so all can use the same import function
$query = $this->content->prepare( "SELECT * FROM contacts_addressbooks WHERE userid LIKE ?" );
$results = $query->execute( array( $this->olduid ) );
$idmap = array();
- while( $row = $results->fetchRow() ){
+ while( $row = $results->fetchRow() ) {
// Import each addressbook
$addressbookquery = OCP\DB::prepare( "INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)" );
$addressbookquery->execute( array( $this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag'] ) );
@@ -48,7 +47,7 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
OC_Contacts_Addressbook::setActive($idmap[$row['id']], true);
}
// Now tags
- foreach($idmap as $oldid => $newid){
+ foreach($idmap as $oldid => $newid) {
$query = $this->content->prepare( "SELECT * FROM contacts_cards WHERE addressbookid LIKE ?" );
$results = $query->execute( array( $oldid ) );
diff --git a/apps/contacts/appinfo/remote.php b/apps/contacts/appinfo/remote.php
index 09c2de17990..fd5604aec6f 100644
--- a/apps/contacts/appinfo/remote.php
+++ b/apps/contacts/appinfo/remote.php
@@ -22,7 +22,7 @@
OCP\App::checkAppEnabled('contacts');
-if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php'){
+if(substr($_SERVER["REQUEST_URI"], 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php')) == OC_App::getAppWebPath('contacts').'/carddav.php') {
$baseuri = OC_App::getAppWebPath('contacts').'/carddav.php';
}
@@ -45,7 +45,7 @@ $nodes = array(
$server = new Sabre_DAV_Server($nodes);
$server->setBaseUri($baseuri);
// Add plugins
-$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
+$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new Sabre_CardDAV_Plugin());
$server->addPlugin(new Sabre_DAVACL_Plugin());
$server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload
diff --git a/apps/contacts/appinfo/update.php b/apps/contacts/appinfo/update.php
index 873899f578b..21e736bb446 100644
--- a/apps/contacts/appinfo/update.php
+++ b/apps/contacts/appinfo/update.php
@@ -1,7 +1,7 @@
<?php
$installedVersion=OCP\Config::getAppValue('contacts', 'installed_version');
-if (version_compare($installedVersion, '0.2.90', '<')) {
+if (version_compare($installedVersion, '0.2.3', '<')) {
// First set all address books in-active.
$stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET active=0' );
$result = $stmt->execute(array());
diff --git a/apps/contacts/appinfo/version b/apps/contacts/appinfo/version
index 373f8c6f073..72f9fa82020 100644
--- a/apps/contacts/appinfo/version
+++ b/apps/contacts/appinfo/version
@@ -1 +1 @@
-0.2.3 \ No newline at end of file
+0.2.4 \ No newline at end of file
diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php
index e0579e625d7..264eb30836b 100644
--- a/apps/contacts/carddav.php
+++ b/apps/contacts/carddav.php
@@ -1,6 +1,6 @@
<?php
-if(!file_exists('../../lib/base.php')){
+if(!file_exists('../../lib/base.php')) {
die('Please update the path to /lib/base.php in carddav.php or make use of /remote.php/carddav/');
}
-require_once('../../lib/base.php');
-require_once('appinfo/remote.php'); \ No newline at end of file
+require_once '../../lib/base.php';
+require_once 'appinfo/remote.php'; \ No newline at end of file
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index de7950ecc61..927e7309807 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -5,18 +5,18 @@
#leftcontent a { padding: 0 0 0 25px; }
#rightcontent { top: 3.5em !important; padding-top: 5px; }
#leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; }
-#leftcontent h3:hover,#leftcontent h3:active,#leftcontent h3.active { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
+#leftcontent h3:hover,#leftcontent h3:active,#leftcontent h3.active { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; font-weight: bold; }
#contacts { position: fixed; background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom: 3em; overflow: auto; padding: 0; margin: 0; }
.contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; }
.contacts li.ui-draggable { height: 23px; }
-.ui-draggable-dragging { width: 16em; }
+.ui-draggable-dragging { width: 17em; cursor: move; }
.ui-state-hover { border: 1px solid dashed; }
#bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
#bottomcontrols img { margin-top: 0.35em; }
#uploadprogressbar { display: none; padding: 0; bottom: 3em; height:2em; width: 20em; margin:0; background:#eee; border:1px solid #ccc; position:fixed; }
#contacts_newcontact, #contacts_import, #chooseaddressbook { float: left; margin: 0.2em 0 0 1em; border: 0 none; border-radius: 0; -moz-box-shadow: none; box-shadow: none; outline: 0 none; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }
-#actionbar { position: relative; clear: both; height: 30px;}
+#actionbar { clear: both; height: 30px;}
#contacts_deletecard {position:relative; float:left; background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; }
#contacts_downloadcard {position:relative; float:left; background:url('%webroot%/core/img/actions/download.svg') no-repeat center; }
#contacts_propertymenu { clear: left; float:left; max-width: 15em; margin: 2em; }
@@ -72,7 +72,7 @@ label:hover, dt:hover { color: #333; }
#identityprops { /*position: absolute; top: 2.5em; left: 0px;*/ }
/*#contact_photo { max-width: 250px; }*/
#contact_identity { min-width: 30em; }
-.contactsection { position: relative; float: left; /*max-width: 40em;*/ padding: 0.5em; height: auto: border: thin solid lightgray;/* -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; border-radius: 0.5em; background-color: #f8f8f8;*/ }
+.contactsection { position: relative; float: left; padding: 0.5em; height: auto; }
#cropbox { margin: auto; }
#contacts_details_photo_wrapper { width: 200px; }
diff --git a/apps/contacts/export.php b/apps/contacts/export.php
index eb506506c42..161ca8047ac 100644
--- a/apps/contacts/export.php
+++ b/apps/contacts/export.php
@@ -9,26 +9,30 @@
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
-$bookid = isset($_GET['bookid']) ? $_GET['bookid'] : NULL;
-$contactid = isset($_GET['contactid']) ? $_GET['contactid'] : NULL;
+$bookid = isset($_GET['bookid']) ? $_GET['bookid'] : null;
+$contactid = isset($_GET['contactid']) ? $_GET['contactid'] : null;
$nl = "\n";
-if(isset($bookid)){
+if(isset($bookid)) {
$addressbook = OC_Contacts_App::getAddressbook($bookid);
//$cardobjects = OC_Contacts_VCard::all($bookid);
header('Content-Type: text/directory');
- header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
+ header('Content-Disposition: inline; filename='
+ . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
$start = 0;
- $batchsize = OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'export_batch_size', 20);
+ $batchsize = OCP\Config::getUserValue(OCP\User::getUser(),
+ 'contacts',
+ 'export_batch_size', 20);
while($cardobjects = OC_Contacts_VCard::all($bookid, $start, $batchsize)){
foreach($cardobjects as $card) {
echo $card['carddata'] . $nl;
}
$start += $batchsize;
}
-}elseif(isset($contactid)){
+}elseif(isset($contactid)) {
$data = OC_Contacts_App::getContactObject($contactid);
header('Content-Type: text/vcard');
- header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $data['fullname']) . '.vcf');
+ header('Content-Disposition: inline; filename='
+ . str_replace(' ', '_', $data['fullname']) . '.vcf');
echo $data['carddata'];
}
diff --git a/apps/contacts/import.php b/apps/contacts/import.php
index ed1b80e132a..1986d79f6d6 100644
--- a/apps/contacts/import.php
+++ b/apps/contacts/import.php
@@ -38,17 +38,29 @@ if(!$file) {
OCP\JSON::error(array('data' => array('message' => 'Import file was empty.')));
exit();
}
-if(isset($_POST['method']) && $_POST['method'] == 'new'){
- $id = OC_Contacts_Addressbook::add(OCP\USER::getUser(), $_POST['addressbookname']);
+if(isset($_POST['method']) && $_POST['method'] == 'new') {
+ $id = OC_Contacts_Addressbook::add(OCP\USER::getUser(),
+ $_POST['addressbookname']);
if(!$id) {
- OCP\JSON::error(array('data' => array('message' => 'Error creating address book.')));
+ OCP\JSON::error(
+ array(
+ 'data' => array('message' => 'Error creating address book.')
+ )
+ );
exit();
}
OC_Contacts_Addressbook::setActive($id, 1);
}else{
$id = $_POST['id'];
if(!$id) {
- OCP\JSON::error(array('data' => array('message' => 'Error getting the ID of the address book.', 'file'=>$_POST['file'])));
+ OCP\JSON::error(
+ array(
+ 'data' => array(
+ 'message' => 'Error getting the ID of the address book.',
+ 'file'=>$_POST['file']
+ )
+ )
+ );
exit();
}
OC_Contacts_App::getAddressbook($id); // is owner access check
@@ -62,7 +74,7 @@ $inelement = false;
$parts = array();
$card = array();
foreach($lines as $line){
- if(strtoupper(trim($line)) == 'BEGIN:VCARD'){
+ if(strtoupper(trim($line)) == 'BEGIN:VCARD') {
$inelement = true;
} elseif (strtoupper(trim($line)) == 'END:VCARD') {
$card[] = $line;
@@ -79,21 +91,40 @@ writeProgress('70');
$imported = 0;
$failed = 0;
if(!count($parts) > 0) {
- OCP\JSON::error(array('data' => array('message' => 'No contacts to import in '.$_POST['file'].'. Please check if the file is corrupted.', 'file'=>$_POST['file'])));
+ OCP\JSON::error(
+ array(
+ 'data' => array(
+ 'message' => 'No contacts to import in '
+ . $_POST['file'].'. Please check if the file is corrupted.',
+ 'file'=>$_POST['file']
+ )
+ )
+ );
+ if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
+ if(!$view->unlink('/imports/' . $_POST['file'])) {
+ OCP\Util::writeLog('contacts',
+ 'Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'],
+ OCP\Util::ERROR);
+ }
+ }
exit();
}
foreach($parts as $part){
$card = OC_VObject::parse($part);
if (!$card) {
$failed += 1;
- OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$part, OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'Import: skipping card. Error parsing VCard: ' . $part,
+ OCP\Util::ERROR);
continue; // Ditch cards that can't be parsed by Sabre.
}
try {
OC_Contacts_VCard::add($id, $card);
$imported += 1;
} catch (Exception $e) {
- OCP\Util::writeLog('contacts', 'Error importing vcard: '.$e->getMessage().$nl.$card, OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'Error importing vcard: ' . $e->getMessage() . $nl . $card,
+ OCP\Util::ERROR);
$failed += 1;
}
}
@@ -103,7 +134,17 @@ sleep(3);
OC_Cache::remove($progresskey);
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
if(!$view->unlink('/imports/' . $_POST['file'])) {
- OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'],
+ OCP\Util::ERROR);
}
}
-OCP\JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed, 'file'=>$_POST['file'])));
+OCP\JSON::success(
+ array(
+ 'data' => array(
+ 'imported'=>$imported,
+ 'failed'=>$failed,
+ 'file'=>$_POST['file'],
+ )
+ )
+);
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 00b1b4f7a95..c35e1b85d4e 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -14,13 +14,17 @@ OCP\App::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
-$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0 ? true : false); // just to check if there are any contacts.
+$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0
+ ? true
+ : false); // just to check if there are any contacts.
if($has_contacts === false) {
- OCP\Util::writeLog('contacts','index.html: No contacts found.',OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'index.html: No contacts found.',
+ OCP\Util::DEBUG);
}
// Load the files we need
-OCP\App::setActiveNavigationEntry( 'contacts_index' );
+OCP\App::setActiveNavigationEntry('contacts_index');
// Load a specific user?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
@@ -34,30 +38,31 @@ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace=OC_Filesystem::free_space('/');
-$freeSpace=max($freeSpace,0);
-$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
-
-OCP\Util::addscript('','jquery.multiselect');
-OCP\Util::addscript('','oc-vcategories');
-OCP\Util::addscript('contacts','contacts');
-OCP\Util::addscript('contacts','expanding');
-OCP\Util::addscript('contacts','jquery.combobox');
+$freeSpace=max($freeSpace, 0);
+$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
+
+OCP\Util::addscript('', 'jquery.multiselect');
+OCP\Util::addscript('', 'oc-vcategories');
+OCP\Util::addscript('contacts', 'contacts');
+OCP\Util::addscript('contacts', 'expanding');
+OCP\Util::addscript('contacts', 'jquery.combobox');
OCP\Util::addscript('files', 'jquery.fileupload');
-OCP\Util::addscript('contacts','jquery.inview');
-OCP\Util::addscript('contacts','jquery.Jcrop');
-OCP\Util::addscript('contacts','jquery.multi-autocomplete');
-OCP\Util::addStyle('','jquery.multiselect');
-OCP\Util::addStyle('contacts','jquery.combobox');
-OCP\Util::addStyle('contacts','jquery.Jcrop');
-OCP\Util::addStyle('contacts','contacts');
+OCP\Util::addscript('contacts', 'jquery.inview');
+OCP\Util::addscript('contacts', 'jquery.Jcrop');
+OCP\Util::addscript('contacts', 'jquery.multi-autocomplete');
+OCP\Util::addStyle('', 'jquery.multiselect');
+OCP\Util::addStyle('contacts', 'jquery.combobox');
+OCP\Util::addStyle('contacts', 'jquery.Jcrop');
+OCP\Util::addStyle('contacts', 'contacts');
$tmpl = new OCP\Template( "contacts", "index", "user" );
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize, false);
-$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize), false);
+$tmpl->assign('uploadMaxHumanFilesize',
+ OCP\Util::humanFileSize($maxUploadFilesize), false);
$tmpl->assign('property_types', $property_types, false);
$tmpl->assign('phone_types', $phone_types, false);
$tmpl->assign('email_types', $email_types, false);
$tmpl->assign('categories', $categories, false);
$tmpl->assign('has_contacts', $has_contacts, false);
-$tmpl->assign('id',$id, false);
+$tmpl->assign('id', $id, false);
$tmpl->printPage();
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index b4e7cdba444..337f51839dc 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -12,10 +12,38 @@ String.prototype.strip_tags = function(){
Contacts={
UI:{
+ /**
+ * Arguments:
+ * message: The text message to show. The only mandatory parameter.
+ * timeout: The timeout in seconds before the notification disappears. Default 10.
+ * timeouthandler: A function to run on timeout.
+ * clickhandler: A function to run on click. If a timeouthandler is given it will be cancelled.
+ * data: An object that will be passed as argument to the timeouthandler and clickhandler functions.
+ */
notify:function(params) {
- $('#notification').text(params.message);
- $('#notification').fadeIn();
- setTimeout(function() {$('#notification').fadeOut();}, 10000);
+ var notifier = $('#notification');
+ notifier.text(params.message);
+ notifier.fadeIn();
+ var timer = setTimeout(function() {
+ notifier.fadeOut();
+ if(params.timeouthandler && $.isFunction(params.timeouthandler)) {
+ params.timeouthandler(notifier.data(dataid));
+ notifier.off('click');
+ notifier.data(dataid, null);
+ }
+ }, params.timeout && $.isNumeric(params.timeout) ? parseInt(params.timeout)*1000 : 10000);
+ var dataid = timer.toString();
+ if(params.data) {
+ notifier.data(dataid, params.data);
+ }
+ if(params.clickhandler && $.isFunction(params.clickhandler)) {
+ notifier.on('click', function() {
+ clearTimeout(timer);
+ notifier.off('click');
+ params.clickhandler(notifier.data(dataid));
+ notifier.data(dataid, null);
+ });
+ }
},
notImplemented:function() {
OC.dialogs.alert(t('contacts', 'Sorry, this functionality has not been implemented yet'), t('contacts', 'Not implemented'));
@@ -96,7 +124,7 @@ Contacts={
$('.addresscard,.propertylist li,.propertycontainer').hover(
function () {
$(this).find('.globe,.mail,.delete,.edit').animate({ opacity: 1.0 }, 200, function() {});
- },
+ },
function () {
$(this).find('.globe,.mail,.delete,.edit').animate({ opacity: 0.1 }, 200, function() {});
}
@@ -107,7 +135,7 @@ Contacts={
obj.tipsy('hide');
Contacts.UI.Card.deleteProperty(obj, 'single');
}
-
+
var goToUrl = function(obj) {
var url = Contacts.UI.propertyContainerFor(obj).find('#url').val();
if(url != '') {
@@ -115,7 +143,7 @@ Contacts={
newWindow.focus();
}
}
-
+
$('#identityprops a.delete').click( function() { deleteItem($(this)) });
$('#identityprops a.delete').keydown( function() { deleteItem($(this)) });
$('#categories_value a.edit').click( function() { $(this).tipsy('hide');OCCategories.edit(); } );
@@ -140,7 +168,7 @@ Contacts={
});
$('#edit_name').click(function(){Contacts.UI.Card.editName()});
$('#edit_name').keydown(function(){Contacts.UI.Card.editName()});
-
+
$('#phototools li a').click(function() {
$(this).tipsy('hide');
});
@@ -167,13 +195,13 @@ Contacts={
OC.dialogs.filepicker(t('contacts', 'Select photo'), Contacts.UI.Card.cloudPhotoSelected, false, 'image', true);
});
/* Initialize the photo edit dialog */
- $('#edit_photo_dialog').dialog({
+ $('#edit_photo_dialog').dialog({
autoOpen: false, modal: true, height: 'auto', width: 'auto'
});
$('#edit_photo_dialog' ).dialog( 'option', 'buttons', [
{
text: "Ok",
- click: function() {
+ click: function() {
Contacts.UI.Card.savePhoto(this);
$(this).dialog('close');
}
@@ -183,37 +211,31 @@ Contacts={
click: function() { $(this).dialog('close'); }
}
] );
-
+
// Name has changed. Update it and reorder.
$('#fn').change(function(){
var name = $('#fn').val().strip_tags();
- var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]');
+ var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]').detach();
$(item).find('a').html(name);
Contacts.UI.Card.fn = name;
- var added = false;
- $('.contacts li[data-bookid="'+Contacts.UI.Card.bookid+'"]').each(function(){
- if ($(this).text().toLowerCase() > name.toLowerCase()) {
- $(this).before(item).fadeIn('fast');
- added = true;
- return false;
- }
+ Contacts.UI.Contacts.insertContact({
+ contactlist:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]'),
+ contacts:$('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"] li'),
+ contact:item,
});
- if(!added) {
- $('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item);
- }
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
});
- $('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
- $('#contacts_deletecard').keydown( function(event) {
+ $('#contacts_deletecard').click( function() { Contacts.UI.Card.delayedDelete();return false;} );
+ $('#contacts_deletecard').keydown( function(event) {
if(event.which == 13 || event.which == 32) {
- Contacts.UI.Card.doDelete();
+ Contacts.UI.Card.delayedDelete();
}
return false;
});
$('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} );
- $('#contacts_downloadcard').keydown( function(event) {
+ $('#contacts_downloadcard').keydown( function(event) {
if(event.which == 13 || event.which == 32) {
Contacts.UI.Card.doExport();
}
@@ -228,12 +250,12 @@ Contacts={
$('#contacts_details_photo_wrapper').bind('dragover',function(event){
$(event.target).addClass('droppable');
event.stopPropagation();
- event.preventDefault();
+ event.preventDefault();
});
$('#contacts_details_photo_wrapper').bind('dragleave',function(event){
$(event.target).removeClass('droppable');
//event.stopPropagation();
- //event.preventDefault();
+ //event.preventDefault();
});
$('#contacts_details_photo_wrapper').bind('drop',function(event){
event.stopPropagation();
@@ -285,7 +307,7 @@ Contacts={
data:undefined,
update:function(params) { // params {cid:int, aid:int}
if(!params) { params = {}; }
- $('#contacts li').removeClass('active');
+ $('#contacts li,#contacts h3').removeClass('active');
console.log('Card, cid: ' + params.cid + ' aid: ' + params.aid);
var newid, bookid, firstitem;
if(!parseInt(params.cid) && !parseInt(params.aid)) {
@@ -299,7 +321,13 @@ Contacts={
newid = parseInt($('#contacts').find('li[data-bookid="'+bookid+'"]').first().data('id'));
} else if(parseInt(params.cid) && !parseInt(params.aid)) {
newid = parseInt(params.cid);
- bookid = parseInt($('#contacts li[data-id="'+newid+'"]').data('bookid'));
+ var listitem = $('#contacts li[data-id="'+newid+'"]');
+ console.log('Is contact in list? ' + listitem.length);
+ if(listitem.length) {
+ bookid = parseInt($('#contacts li[data-id="'+newid+'"]').data('bookid'));
+ } else { // contact isn't in list yet.
+ bookid = 'unknown';
+ }
} else {
newid = parseInt(params.cid);
bookid = parseInt(params.aid);
@@ -311,18 +339,26 @@ Contacts={
console.log('newid: ' + newid + ' bookid: ' +bookid);
var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) {
- $('#contacts li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
+ if(bookid == 'unknown') {
+ bookid = jsondata.data.addressbookid;
+ var contact = Contacts.UI.Contacts.insertContact({
+ contactlist:$('#contacts ul[data-id="'+bookid+'"]'),
+ data:jsondata.data
+ });
+ }
+ $('#contacts li[data-id="'+newid+'"],#contacts h3[data-id="'+bookid+'"]').addClass('active');
$('#contacts ul[data-id="'+bookid+'"]').slideDown(300);
Contacts.UI.Card.loadContact(jsondata.data, bookid);
+ Contacts.UI.Contacts.scrollTo(newid);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
}
-
+
// Make sure proper DOM is loaded.
if(!$('#card').length && newid) {
console.log('Loading card DOM');
@@ -363,9 +399,6 @@ Contacts={
Contacts.UI.Card.add(';;;;;', '', '', true);
return false;
},
- createEntry:function(data) {
- return $('<li data-id="'+data.id+'" data-bookid="'+data.addressbookid+'" role="button"><a href="'+OC.linkTo('contacts', 'index.php')+'&id='+data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+data.id+') no-repeat scroll 0% 0% transparent;">'+data.displayname+'</a></li>');
- },
add:function(n, fn, aid, isnew){ // add a new contact
console.log('Adding ' + fn);
aid = aid?aid:$('#contacts h3.active').first().data('id');
@@ -410,7 +443,7 @@ Contacts={
}
});
}
-
+
if(!$('#card').length) {
console.log('Loading card DOM');
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{'requesttoken': requesttoken},function(jsondata){
@@ -427,47 +460,56 @@ Contacts={
localAddcontact(n, fn, aid, isnew);
}
},
- doDelete:function() {
+ delayedDelete:function() {
$('#contacts_deletecard').tipsy('hide');
- OC.dialogs.confirm(t('contacts', 'Are you sure you want to delete this contact?'), t('contacts', 'Warning'), function(answer) {
- if(answer == true) {
- $.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){
- if(jsondata.status == 'success'){
- var newid = '', bookid;
- var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]');
- var newlistitem = curlistitem.prev('li');
- if(!newlistitem) {
- newlistitem = curlistitem.next('li');
- }
- curlistitem.remove();
- if($(newlistitem).is('li')) {
- newid = newlistitem.data('id');
- bookid = newlistitem.data('bookid');
- }
- $('#rightcontent').data('id',newid);
- this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
- this.data = undefined;
-
- if($('.contacts li').length > 0) { // Load first in list.
- Contacts.UI.Card.update({cid:newid, aid:bookid});
- } else {
- // load intro page
- $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
- if(jsondata.status == 'success'){
- id = '';
- $('#rightcontent').data('id','');
- $('#rightcontent').html(jsondata.data.page);
- }
- else{
- OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
- }
- });
- }
- }
- else{
- OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
- }
- });
+ var newid = '', bookid;
+ var curlistitem = $('#contacts li[data-id="'+Contacts.UI.Card.id+'"]');
+ curlistitem.removeClass('active');
+ var newlistitem = curlistitem.prev('li');
+ if(!newlistitem) {
+ newlistitem = curlistitem.next('li');
+ }
+ curlistitem.detach();
+ if($(newlistitem).is('li')) {
+ newid = newlistitem.data('id');
+ bookid = newlistitem.data('bookid');
+ }
+ $('#rightcontent').data('id',newid);
+ this.id = this.fn = this.fullname = this.shortname = this.famname = this.givname = this.addname = this.honpre = this.honsuf = '';
+ this.data = undefined;
+
+ if($('.contacts li').length > 0) { // Load first in list.
+ Contacts.UI.Card.update({cid:newid, aid:bookid});
+ } else {
+ // load intro page
+ $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
+ if(jsondata.status == 'success'){
+ id = '';
+ $('#rightcontent').data('id','');
+ $('#rightcontent').html(jsondata.data.page);
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ }
+ Contacts.UI.notify({
+ data:curlistitem,
+ message:t('contacts','Click to undo deletion of "') + curlistitem.find('a').text() + '"',
+ timeouthandler:function(contact) {
+ Contacts.UI.Card.doDelete(contact.data('id'));
+ delete contact;
+ },
+ clickhandler:function(contact) {
+ Contacts.UI.Contacts.insertContact({contact:contact});
+ Contacts.UI.notify({message:t('contacts', 'Cancelled deletion of: "') + curlistitem.find('a').text() + '"'});
+ }
+ });
+ },
+ doDelete:function(id) {
+ $.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':id},function(jsondata) {
+ if(jsondata.status == 'error'){
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
return false;
@@ -519,7 +561,7 @@ Contacts={
$('#contacts_propertymenu_dropdown a[data-type="'+propname+'"]').parent().hide();
var property = this.data[propname][0];
var value = property['value'], checksum = property['checksum'];
-
+
if(propname == 'BDAY') {
var val = $.datepicker.parseDate('yy-mm-dd', value.substring(0, 10));
value = $.datepicker.formatDate('dd-mm-yy', val);
@@ -584,7 +626,7 @@ Contacts={
$.each(names, function(key, value) {
$('#fn_select')
.append($('<option></option>')
- .text(value));
+ .text(value));
});
$('#fn_select').combobox('value', this.fn);
$('#contact_identity').find('*[data-element="N"]').data('checksum', this.data.N[0]['checksum']);
@@ -835,7 +877,7 @@ Contacts={
title: t('contacts', 'Edit name'),
height: 'auto', width: 'auto',
buttons: {
- 'Ok':function() {
+ 'Ok':function() {
Contacts.UI.Card.saveName(this);
$(this).dialog('close');
},
@@ -886,9 +928,9 @@ Contacts={
$.each(names, function(key, value) {
$('#fn_select')
.append($('<option></option>')
- .text(value));
+ .text(value));
});
-
+
if(this.id == '') {
var aid = $(dlg).find('#aid').val();
Contacts.UI.Card.add(n.join(';'), $('#short').text(), aid);
@@ -952,7 +994,7 @@ Contacts={
container = $('#addressdisplay dl').last();
container.removeClass('template').addClass('propertycontainer');
} else {
- params['checksum'] = Contacts.UI.checksumFor(obj);
+ params['checksum'] = Contacts.UI.checksumFor(obj);
}
/* Initialize the address edit dialog */
if($('#edit_address_dialog').dialog('isOpen') == true){
@@ -1168,7 +1210,7 @@ Contacts={
$('#phototools li a').tipsy('hide');
var wrapper = $('#contacts_details_photo_wrapper');
wrapper.addClass('loading').addClass('wait');
-
+
var img = new Image();
$(img).load(function () {
$('img.contacts_details_photo').remove()
@@ -1177,9 +1219,9 @@ Contacts={
$(this).insertAfter($('#phototools')).fadeIn();
}).error(function () {
// notify the user that the image could not be loaded
- $(t('contacts','something went wrong.')).insertAfter($('#phototools'));
+ Contacts.UI.notify({message:t('contacts','Error loading profile picture.')});
}).attr('src', OC.linkTo('contacts', 'photo.php')+'?id='+self.id+refreshstr);
-
+
$.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum);
@@ -1334,8 +1376,6 @@ Contacts={
},
},
Addressbooks:{
- droptarget:undefined,
- droptext:t('contacts', 'Drop a VCF file<br />to import contacts.'),
overview:function(){
if($('#chooseaddressbook_dialog').dialog('isOpen') == true){
$('#chooseaddressbook_dialog').dialog('moveToTop');
@@ -1427,7 +1467,7 @@ Contacts={
var displayname = $("#displayname_"+bookid).val().trim();
var active = $("#edit_active_"+bookid+":checked").length;
var description = $("#description_"+bookid).val();
-
+
if(displayname.length == 0) {
OC.dialogs.alert(t('contacts', 'Displayname cannot be empty.'), t('contacts', 'Error'));
return false;
@@ -1456,12 +1496,18 @@ Contacts={
batchnum:50,
drop:function(event, ui) {
var dragitem = ui.draggable, droptarget = $(this);
- //console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id'));
+ if(dragitem.is('li')) {
+ Contacts.UI.Contacts.dropContact(event, dragitem, droptarget);
+ } else {
+ Contacts.UI.Contacts.dropAddressbook(event, dragitem, droptarget);
+ }
+ },
+ dropContact:function(event, dragitem, droptarget) {
if(dragitem.data('bookid') == droptarget.data('id')) {
return false;
}
var droplist = (droptarget.is('ul'))?droptarget:droptarget.next();
- $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') },
+ $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: droptarget.data('id') },
function(jsondata){
if(jsondata.status == 'success'){
// Do some inserting/removing/sorting magic
@@ -1485,6 +1531,44 @@ Contacts={
}
});
},
+ dropAddressbook:function(event, dragitem, droptarget) {
+ alert('Dropping address books not implemented yet');
+ },
+ /**
+ * @params params An object with the properties 'contactlist':a jquery object of the ul to insert into,
+ * 'contacts':a jquery object of all items in the list and either 'data': an object with the properties
+ * id, addressbookid and displayname or 'contact': a listitem to be inserted directly.
+ * If 'contactlist' or 'contacts' aren't defined they will be search for based in the properties in 'data'.
+ */
+ insertContact:function(params) {
+ if(!params.contactlist) {
+ // FIXME: Check if contact really exists.
+ var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid');
+ params.contactlist = $('#contacts ul[data-id="'+bookid+'"]');
+ }
+ if(!params.contacts) {
+ var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid');
+ params.contacts = $('#contacts ul[data-id="'+bookid+'"] li');
+ }
+ var contact = params.data
+ ? $('<li data-id="'+params.data.id+'" data-bookid="'+params.data.addressbookid+'" role="button"><a href="'+OC.linkTo('contacts', 'index.php')+'&id='+params.data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+params.data.id+') no-repeat scroll 0% 0% transparent;">'+params.data.displayname+'</a></li>')
+ : params.contact;
+ var added = false;
+ var name = params.data ? params.data.displayname.toLowerCase() : contact.find('a').text().toLowerCase();
+ if(params.contacts) {
+ params.contacts.each(function() {
+ if ($(this).text().toLowerCase() > name) {
+ $(this).before(contact);
+ added = true;
+ return false;
+ }
+ });
+ }
+ if(!added || !params.contacts) {
+ params.contactlist.append(contact);
+ }
+ return contact;
+ },
// Reload the contacts list.
update:function(params){
if(!params) { params = {}; }
@@ -1506,7 +1590,7 @@ Contacts={
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),opts,function(jsondata){
if(jsondata.status == 'success'){
var books = jsondata.data.entries;
- $.each(books, function(b, book) {
+ $.each(books, function(b, book) {
if($('#contacts h3[data-id="'+b+'"]').length == 0) {
firstrun = true;
if($('#contacts h3').length == 0) {
@@ -1525,7 +1609,7 @@ Contacts={
if(!added) {
$('#contacts').append(item);
}
-
+
}
}
$('#contacts h3[data-id="'+b+'"]').on('click', function(event) {
@@ -1534,7 +1618,7 @@ Contacts={
$('#contacts ul[data-id="'+b+'"]').slideToggle(300);
return false;
});
- var accept = 'li:not([data-bookid="'+b+'"])';
+ var accept = 'li:not([data-bookid="'+b+'"]),h3:not([data-id="'+b+'"])';
$('#contacts h3[data-id="'+b+'"],#contacts ul[data-id="'+b+'"]').droppable({
drop: Contacts.UI.Contacts.drop,
activeClass: 'ui-state-hover',
@@ -1542,11 +1626,12 @@ Contacts={
});
}
var contactlist = $('#contacts ul[data-id="'+b+'"]');
+ var contacts = $('#contacts ul[data-id="'+b+'"] li');
for(var c in book.contacts) {
if(book.contacts[c].id == undefined) { continue; }
- if($('#contacts li[data-id="'+book.contacts[c]['id']+'"][data-id="'+book.contacts[c]['bookid']+'"]').length == 0) {
- var contact = Contacts.UI.Card.createEntry(book.contacts[c]);
- if(c == self.batchnum-5) {
+ if(!$('#contacts li[data-id="'+book.contacts[c]['id']+'"]').length) {
+ var contact = Contacts.UI.Contacts.insertContact({contactlist:contactlist, contacts:contacts, data:book.contacts[c]});
+ if(c == self.batchnum-10) {
contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
$(this).unbind(event);
var bookid = $(this).data('bookid');
@@ -1557,15 +1642,15 @@ Contacts={
}
});
}
- contactlist.append(contact);
}
}
});
if($('#contacts h3').length > 1) {
- $('#contacts li').draggable({
+ $('#contacts li,#contacts h3').draggable({
+ distance: 10,
revert: 'invalid',
axis: 'y', containment: '#contacts',
- scroll: true, scrollSensitivity: 100,
+ scroll: true, scrollSensitivity: 40,
opacity: 0.7, helper: 'clone'
});
} else {
@@ -1587,9 +1672,10 @@ Contacts={
},
scrollTo:function(id){
var item = $('#contacts li[data-id="'+id+'"]');
+ console.log('scrollTo, found item '+id+'? ' + item.length);
if(item) {
- $('.contacts').animate({
- scrollTop: $('#contacts li[data-id="'+id+'"]').offset().top-20}, 'slow','swing');
+ $('#contacts').animate({
+ scrollTop: item.offset().top-40}, 'slow','swing');
}
}
}
@@ -1603,13 +1689,13 @@ $(document).ready(function(){
$('#notification').click(function(){
$('#notification').fadeOut();
});
-
+
$('#chooseaddressbook').click(Contacts.UI.Addressbooks.overview);
$('#chooseaddressbook').keydown(Contacts.UI.Addressbooks.overview);
$('#contacts_newcontact').click(Contacts.UI.Card.editNew);
$('#contacts_newcontact').keydown(Contacts.UI.Card.editNew);
-
+
// Load a contact.
$('.contacts').keydown(function(event) {
if(event.which == 13 || event.which == 32) {
@@ -1625,7 +1711,13 @@ $(document).ready(function(){
item.addClass('active');
var oldid = $('#rightcontent').data('id');
if(oldid != 0){
- $('.contacts li[data-id="'+oldid+'"]').removeClass('active');
+ var olditem = $('.contacts li[data-id="'+oldid+'"]');
+ var oldbookid = olditem.data('bookid');
+ olditem.removeClass('active');
+ if(oldbookid != bookid) {
+ $('#contacts h3[data-id="'+oldbookid+'"]').removeClass('active');
+ $('#contacts h3[data-id="'+bookid+'"]').addClass('active');
+ }
}
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
if(jsondata.status == 'success'){
@@ -1643,53 +1735,55 @@ $(document).ready(function(){
Contacts.UI.Card.saveProperty(this);
});
- // Upload function for dropped contact photos files. Should go in the Contacts class/object.
- $.fileUpload = function(files){
- var file = files[0];
- if(file.size > $('#max_upload').val()){
- OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large'));
- return;
- }
- if (file.type.indexOf("image") != 0) {
- OC.dialogs.alert(t('contacts','Only image files can be used as profile picture.'), t('contacts','Wrong file type'));
- return;
- }
- var xhr = new XMLHttpRequest();
+ $(function() {
+ // Upload function for dropped contact photos files. Should go in the Contacts class/object.
+ $.fileUpload = function(files){
+ var file = files[0];
+ if(file.size > $('#max_upload').val()){
+ OC.dialogs.alert(t('contacts','The file you are trying to upload exceed the maximum size for file uploads on this server.'), t('contacts','Upload too large'));
+ return;
+ }
+ if (file.type.indexOf("image") != 0) {
+ OC.dialogs.alert(t('contacts','Only image files can be used as profile picture.'), t('contacts','Wrong file type'));
+ return;
+ }
+ var xhr = new XMLHttpRequest();
- if (!xhr.upload) {
- OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please click on the profile picture to select a photo to upload.'), t('contacts', 'Error'))
- }
- fileUpload = xhr.upload,
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4){
- response = $.parseJSON(xhr.responseText);
- if(response.status == 'success') {
- if(xhr.status == 200) {
- Contacts.UI.Card.editPhoto(response.data.id, response.data.tmp);
+ if (!xhr.upload) {
+ OC.dialogs.alert(t('contacts', 'Your browser doesn\'t support AJAX upload. Please click on the profile picture to select a photo to upload.'), t('contacts', 'Error'))
+ }
+ fileUpload = xhr.upload,
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4){
+ response = $.parseJSON(xhr.responseText);
+ if(response.status == 'success') {
+ if(xhr.status == 200) {
+ Contacts.UI.Card.editPhoto(response.data.id, response.data.tmp);
+ } else {
+ OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error'));
+ }
} else {
- OC.dialogs.alert(xhr.status + ': ' + xhr.responseText, t('contacts', 'Error'));
+ OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
}
- } else {
- OC.dialogs.alert(response.data.message, t('contacts', 'Error'));
}
- }
- };
-
- fileUpload.onprogress = function(e){
- if (e.lengthComputable){
- var _progress = Math.round((e.loaded * 100) / e.total);
- //if (_progress != 100){
- //}
- }
- };
- xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&requesttoken='+requesttoken+'&imagefile='+encodeURIComponent(file.name), true);
- xhr.setRequestHeader('Cache-Control', 'no-cache');
- xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
- xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name));
- xhr.setRequestHeader('X-File-Size', file.size);
- xhr.setRequestHeader('Content-Type', file.type);
- xhr.send(file);
- }
+ };
+
+ fileUpload.onprogress = function(e){
+ if (e.lengthComputable){
+ var _progress = Math.round((e.loaded * 100) / e.total);
+ //if (_progress != 100){
+ //}
+ }
+ };
+ xhr.open('POST', OC.filePath('contacts', 'ajax', 'uploadphoto.php')+'?id='+Contacts.UI.Card.id+'&requesttoken='+requesttoken+'&imagefile='+encodeURIComponent(file.name), true);
+ xhr.setRequestHeader('Cache-Control', 'no-cache');
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ xhr.setRequestHeader('X_FILE_NAME', encodeURIComponent(file.name));
+ xhr.setRequestHeader('X-File-Size', file.size);
+ xhr.setRequestHeader('Content-Type', file.type);
+ xhr.send(file);
+ }
+ });
$(document).bind('drop dragover', function (e) {
e.preventDefault(); // prevent browser from doing anything, if file isn't dropped in dropZone
@@ -1703,7 +1797,7 @@ $(document).ready(function(){
$(function() {
var uploadingFiles = {}, numfiles = 0, uploadedfiles = 0, retries = 0;
var aid;
-
+
$('#import_upload_start').fileupload({
dropZone: $('#contacts'), // restrict dropZone to contacts list.
acceptFileTypes: /^text\/(directory|vcard|x-vcard)$/i,
@@ -1803,9 +1897,10 @@ $(document).ready(function(){
if(numfiles != uploadedfiles) {
Contacts.UI.notify({message:t('contacts', 'Not all files uploaded. Retrying...')});
retries += 1;
- if(retries > 0) {
+ if(retries > 3) {
numfiles = uploadedfiles = retries = aid = 0;
uploadingFiles = {};
+ $('#uploadprogressbar').fadeOut();
OC.dialogs.alert(t('contacts', 'Something went wrong with the upload, please retry.'), t('contacts', 'Error'));
return;
}
@@ -1864,7 +1959,7 @@ $(document).ready(function(){
$(this).dialog('close');
}
},
- 'Cancel':function() {
+ 'Cancel':function() {
$(this).dialog('close');
numfiles = uploadedfiles = retries = aid = 0;
uploadingFiles = {};
@@ -1879,6 +1974,7 @@ $(document).ready(function(){
});
}
} else {
+ $('#uploadprogressbar').fadeOut();
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
@@ -1890,11 +1986,11 @@ $(document).ready(function(){
}
if(data.dataType != 'iframe ') {
$('#upload input.stop').hide();
- }
+ }
}
})
});
-
+
Contacts.UI.loadHandlers();
Contacts.UI.Contacts.update({cid:id});
});
diff --git a/apps/contacts/lib/VCFExportPlugin.php b/apps/contacts/lib/VCFExportPlugin.php
index 6554cb258e8..9a64c964b06 100644
--- a/apps/contacts/lib/VCFExportPlugin.php
+++ b/apps/contacts/lib/VCFExportPlugin.php
@@ -31,7 +31,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin {
public function initialize(Sabre_DAV_Server $server) {
$this->server = $server;
- $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90);
+ $this->server->subscribeEvent('beforeMethod', array($this,'beforeMethod'), 90);
}
@@ -49,7 +49,7 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin {
if ($this->server->httpRequest->getQueryString()!='export') return;
// splitting uri
- list($uri) = explode('?',$uri,2);
+ list($uri) = explode('?', $uri, 2);
$node = $this->server->tree->getNodeForPath($uri);
@@ -60,12 +60,12 @@ class Sabre_CardDAV_VCFExportPlugin extends Sabre_DAV_ServerPlugin {
$aclPlugin->checkPrivileges($uri, '{DAV:}read');
}
- $this->server->httpResponse->setHeader('Content-Type','text/directory');
+ $this->server->httpResponse->setHeader('Content-Type', 'text/directory');
$this->server->httpResponse->sendStatus(200);
$nodes = $this->server->getPropertiesForPath($uri, array(
'{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}address-data',
- ),1);
+ ), 1);
$this->server->httpResponse->sendBody($this->generateVCF($nodes));
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 9d584ff6d61..eb61b6dbced 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -37,17 +37,17 @@
/**
* This class manages our addressbooks.
*/
-class OC_Contacts_Addressbook{
+class OC_Contacts_Addressbook {
/**
* @brief Returns the list of addressbooks for a specific user.
* @param string $uid
* @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care
* @return array or false.
*/
- public static function all($uid, $active=false){
+ public static function all($uid, $active=false) {
$values = array($uid);
$active_where = '';
- if ($active){
+ if ($active) {
$active_where = ' AND active = ?';
$values[] = 1;
}
@@ -55,13 +55,13 @@ class OC_Contacts_Addressbook{
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' . $active_where . ' ORDER BY displayname' );
$result = $stmt->execute($values);
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG);
return false;
}
$addressbooks = array();
- while( $row = $result->fetchRow()){
+ while( $row = $result->fetchRow()) {
$addressbooks[] = $row;
}
if(!$active && !count($addressbooks)) {
@@ -76,8 +76,8 @@ class OC_Contacts_Addressbook{
* @param integer $uid User id. If null current user will be used.
* @return array
*/
- public static function activeIds($uid = null){
- if(is_null($uid)){
+ public static function activeIds($uid = null) {
+ if(is_null($uid)) {
$uid = OCP\USER::getUser();
}
$activeaddressbooks = self::all($uid, true);
@@ -93,7 +93,7 @@ class OC_Contacts_Addressbook{
* @param string $uid
* @return array
*/
- public static function active($uid){
+ public static function active($uid) {
return self::all($uid, true);
}
@@ -112,13 +112,13 @@ class OC_Contacts_Addressbook{
* @param integer $id
* @return associative array or false.
*/
- public static function find($id){
+ public static function find($id) {
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
$result = $stmt->execute(array($id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
return false;
}
@@ -129,11 +129,11 @@ class OC_Contacts_Addressbook{
* @brief Adds default address book
* @return $id ID of the newly created addressbook or false on error.
*/
- public static function addDefault($uid = null){
+ public static function addDefault($uid = null) {
if(is_null($uid)) {
$uid = OCP\USER::getUser();
}
- $id = self::add($uid,'Contacts','Default Address Book');
+ $id = self::add($uid, 'Contacts', 'Default Address Book');
if($id !== false) {
self::setActive($id, true);
}
@@ -147,13 +147,13 @@ class OC_Contacts_Addressbook{
* @param string $description
* @return insertid
*/
- public static function add($uid,$name,$description=''){
+ public static function add($uid,$name,$description='') {
try {
$stmt = OCP\DB::prepare( 'SELECT uri FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' );
$result = $stmt->execute(array($uid));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG);
return false;
}
$uris = array();
@@ -166,8 +166,8 @@ class OC_Contacts_Addressbook{
$stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($uid,$name,$uri,$description,1));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG);
return false;
}
@@ -182,16 +182,16 @@ class OC_Contacts_Addressbook{
* @param string $description
* @return insertid or false
*/
- public static function addFromDAVData($principaluri,$uri,$name,$description){
+ public static function addFromDAVData($principaluri,$uri,$name,$description) {
$uid = self::extractUserID($principaluri);
try {
$stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)');
$result = $stmt->execute(array($uid,$name,$uri,$description,1));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uri: '.$uri,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uri: '.$uri, OCP\Util::DEBUG);
return false;
}
@@ -205,14 +205,14 @@ class OC_Contacts_Addressbook{
* @param string $description
* @return boolean
*/
- public static function edit($id,$name,$description){
+ public static function edit($id,$name,$description) {
// Need these ones for checking uri
$addressbook = self::find($id);
- if(is_null($name)){
+ if(is_null($name)) {
$name = $addressbook['name'];
}
- if(is_null($description)){
+ if(is_null($description)) {
$description = $addressbook['description'];
}
@@ -220,8 +220,8 @@ class OC_Contacts_Addressbook{
$stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_addressbooks SET displayname=?,description=?, ctag=ctag+1 WHERE id=?');
$result = $stmt->execute(array($name,$description,$id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
return false;
}
@@ -234,15 +234,15 @@ class OC_Contacts_Addressbook{
* @param boolean $active
* @return boolean
*/
- public static function setActive($id,$active){
+ public static function setActive($id,$active) {
$sql = 'UPDATE *PREFIX*contacts_addressbooks SET active = ? WHERE id = ?';
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active),OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active), OCP\Util::ERROR);
try {
$stmt = OCP\DB::prepare($sql);
$stmt->execute(array(intval($active), $id));
return true;
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR);
return false;
}
}
@@ -252,7 +252,7 @@ class OC_Contacts_Addressbook{
* @param integer $id ID of the address book.
* @return boolean
*/
- public static function isActive($id){
+ public static function isActive($id) {
$sql = 'SELECT active FROM *PREFIX*contacts_addressbooks WHERE id = ?';
try {
$stmt = OCP\DB::prepare( $sql );
@@ -260,7 +260,7 @@ class OC_Contacts_Addressbook{
$row = $result->fetchRow();
return (bool)$row['active'];
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
}
}
@@ -269,13 +269,13 @@ class OC_Contacts_Addressbook{
* @param integer $id
* @return boolean
*/
- public static function delete($id){
+ public static function delete($id) {
self::setActive($id, false);
try {
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
$stmt->execute(array($id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR);
return false;
}
@@ -292,7 +292,7 @@ class OC_Contacts_Addressbook{
* @param integer $id
* @return boolean
*/
- public static function touch($id){
+ public static function touch($id) {
$stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' );
$stmt->execute(array($id));
@@ -305,11 +305,11 @@ class OC_Contacts_Addressbook{
* @param array $existing existing addressbook URIs
* @return string new name
*/
- public static function createURI($name,$existing){
+ public static function createURI($name,$existing) {
$name = str_replace(' ', '_', strtolower($name));
$newname = $name;
$i = 1;
- while(in_array($newname,$existing)){
+ while(in_array($newname, $existing)) {
$newname = $name.$i;
$i = $i + 1;
}
@@ -320,8 +320,8 @@ class OC_Contacts_Addressbook{
* @brief gets the userid from a principal path
* @return string
*/
- public static function extractUserID($principaluri){
- list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri);
+ public static function extractUserID($principaluri) {
+ list($prefix, $userid) = Sabre_DAV_URLUtil::splitPath($principaluri);
return $userid;
}
}
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index 046ceb0bf00..689149367fa 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -61,11 +61,11 @@ class OC_Contacts_App {
if(!is_null($vcard) && !$vcard->__isset('N')) {
$version = OCP\App::getAppVersion('contacts');
if($version >= 5) {
- OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG);
}
- OCP\Util::writeLog('contacts','getContactVCard, Missing N field', OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'getContactVCard, Missing N field', OCP\Util::DEBUG);
if($vcard->__isset('FN')) {
- OCP\Util::writeLog('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG);
$n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;';
$vcard->setString('N', $n);
OC_Contacts_VCard::edit( $id, $vcard);
@@ -203,9 +203,9 @@ class OC_Contacts_App {
foreach($vccontacts as $vccontact) {
$cards[] = $vccontact['carddata'];
}
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start, OCP\Util::DEBUG);
// only reset on first batch.
- self::getVCategories()->rescan($cards, true, ($start==0?true:false));
+ self::getVCategories()->rescan($cards, true, ($start == 0 ? true : false));
$start += $batchsize;
}
}
diff --git a/apps/contacts/lib/connector_sabre.php b/apps/contacts/lib/connector_sabre.php
index 99b94fc767e..9fcfff08fa8 100644
--- a/apps/contacts/lib/connector_sabre.php
+++ b/apps/contacts/lib/connector_sabre.php
@@ -79,7 +79,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
}
}
- OC_Contacts_Addressbook::edit($addressbookid,$name,$description);
+ OC_Contacts_Addressbook::edit($addressbookid, $name, $description);
return true;
@@ -113,7 +113,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
}
- OC_Contacts_Addressbook::addFromDAVData($principaluri,$url,$name,$description);
+ OC_Contacts_Addressbook::addFromDAVData($principaluri, $url, $name, $description);
}
/**
@@ -156,7 +156,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
* @return array
*/
public function getCard($addressbookid, $carduri) {
- return OC_Contacts_VCard::findWhereDAVDataIs($addressbookid,$carduri);
+ return OC_Contacts_VCard::findWhereDAVDataIs($addressbookid, $carduri);
}
diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php
index d91d3c565b5..3344e3d6939 100644
--- a/apps/contacts/lib/hooks.php
+++ b/apps/contacts/lib/hooks.php
@@ -34,12 +34,12 @@
*/
class OC_Contacts_Hooks{
/**
- * @brief Add default Addressbooks of a certain user
- * @param paramters parameters from postDeleteUser-Hook
+ * @brief Add default Addressbook for a certain user
+ * @param paramters parameters from postCreateUser-Hook
* @return array
*/
static public function createUser($parameters) {
- OC_Contacts_Addressbook::addDefault($parameters['uid'],'default','Default Address Book');
+ OC_Contacts_Addressbook::addDefault($parameters['uid']);
return true;
}
@@ -61,8 +61,8 @@ class OC_Contacts_Hooks{
static public function getCalenderSources($parameters) {
$base_url = OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id=';
foreach(OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) {
- $parameters['sources'][] =
- array(
+ $parameters['sources'][]
+ = array(
'url' => $base_url.'birthday_'. $addressbook['id'],
'backgroundColor' => '#cccccc',
'borderColor' => '#888',
@@ -91,18 +91,24 @@ class OC_Contacts_Hooks{
$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->setDateTime('DTSTART', $date,
+ Sabre_VObject_Element_DateTime::DATE);
$vevent->setString('DURATION', 'P1D');
- $vevent->setString('UID', substr(md5(rand().time()),0,10));
+ $vevent->setString('UID', substr(md5(rand().time()), 0, 10));
// DESCRIPTION?
$vevent->setString('RRULE', 'FREQ=YEARLY');
- $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday'));
+ $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,
- 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Contacts " . OCP\App::getAppVersion('contacts') . "\n" . $vevent->serialize() . "END:VCALENDAR"
+ 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\n"
+ . "PRODID:ownCloud Contacts "
+ . OCP\App::getAppVersion('contacts') . "\n"
+ . $vevent->serialize() . "END:VCALENDAR"
);
}
}
diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php
index 5d9ca97e761..53aa2b48496 100644
--- a/apps/contacts/lib/search.php
+++ b/apps/contacts/lib/search.php
@@ -2,7 +2,7 @@
class OC_Search_Provider_Contacts extends OC_Search_Provider{
function search($query){
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
- if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')){
+ if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')) {
return array();
}
$results=array();
@@ -10,9 +10,9 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{
foreach($addressbooks as $addressbook){
$vcards = OC_Contacts_VCard::all($addressbook['id']);
foreach($vcards as $vcard){
- if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){
+ if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
$link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']);
- $results[]=new OC_Search_Result($vcard['fullname'],'', $link,(string)$l->t('Contact'));//$name,$text,$link,$type
+ $results[]=new OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
}
}
}
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index e3b65605624..ca171e792fc 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -63,9 +63,9 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( $prep );
$result = $stmt->execute($id);
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $id),OCP\Util::DEBUG);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'SQL:'.$prep,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $id), OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'SQL:'.$prep, OCP\Util::DEBUG);
return false;
}
} elseif(is_int($id) || is_string($id)) {
@@ -74,12 +74,12 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( $sql );
$result = $stmt->execute(array($id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '. $id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '. $id, OCP\Util::DEBUG);
return false;
}
} else {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id, OCP\Util::DEBUG);
return false;
}
$cards = array();
@@ -102,8 +102,8 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' );
$result = $stmt->execute(array($id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '. $id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '. $id, OCP\Util::DEBUG);
return false;
}
@@ -121,8 +121,8 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
$result = $stmt->execute(array($aid,$uri));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
return false;
}
@@ -177,16 +177,16 @@ class OC_Contacts_VCard{
try {
$result = $stmt->execute(array($aid,$uri));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG);
return false;
}
- if($result->numRows() > 0){
+ if($result->numRows() > 0) {
while(true) {
- $tmpuid = substr(md5(rand().time()),0,10);
+ $tmpuid = substr(md5(rand().time()), 0, 10);
$uri = $tmpuid.'.vcf';
- $result = $stmt->execute(array($aid,$uri));
- if($result->numRows() > 0){
+ $result = $stmt->execute(array($aid, $uri));
+ if($result->numRows() > 0) {
continue;
} else {
$uid = $tmpuid;
@@ -212,7 +212,7 @@ class OC_Contacts_VCard{
// Add version if needed
if($version && $version < '3.0') {
$upgrade = true;
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version, OCP\Util::DEBUG);
}
foreach($vcard->children as &$property){
// Decode string properties and remove obsolete properties.
@@ -225,29 +225,29 @@ class OC_Contacts_VCard{
}
// Fix format of type parameters.
if($upgrade && in_array($property->name, $typeprops)) {
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(), OCP\Util::DEBUG);
self::formatPropertyTypes($property);
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(), OCP\Util::DEBUG);
}
- if($property->name == 'FN'){
+ if($property->name == 'FN') {
$fn = $property->value;
}
- if($property->name == 'N'){
+ if($property->name == 'N') {
$n = $property->value;
}
- if($property->name == 'UID'){
+ if($property->name == 'UID') {
$uid = $property->value;
}
- if($property->name == 'ORG'){
+ 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.
+ if($property->name == 'EMAIL' && is_null($email)) { // only use the first email as substitute for missing N or FN.
$email = $property->value;
}
}
// Check for missing 'N', 'FN' and 'UID' properties
if(!$fn) {
- if($n && $n != ';;;;'){
+ if($n && $n != ';;;;') {
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
} elseif($email) {
$fn = $email;
@@ -257,21 +257,21 @@ class OC_Contacts_VCard{
$fn = 'Unknown Name';
}
$vcard->setString('FN', $fn);
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn, OCP\Util::DEBUG);
}
- if(!$n || $n == ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-)
+ if(!$n || $n == ';;;;') { // Fix missing 'N' field. Ugly hack ahead ;-)
$slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse.
if(count($slice) < 2) { // If not enought, add one more...
$slice[] = "";
}
$n = implode(';', $slice).';;;';
$vcard->setString('N', $n);
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n, OCP\Util::DEBUG);
}
if(!$uid) {
$vcard->setUID();
$uid = $vcard->getAsString('UID');
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid, OCP\Util::DEBUG);
}
if(self::trueUID($aid, $uid)) {
$vcard->setString('UID', $uid);
@@ -288,8 +288,8 @@ class OC_Contacts_VCard{
* @return insertid on success or false.
*/
public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){
- if(is_null($card)){
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
+ if(is_null($card)) {
+ OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
return null;
};
@@ -298,7 +298,7 @@ class OC_Contacts_VCard{
self::updateValuesFromAdd($aid, $card);
}
- $card->setString('VERSION','3.0');
+ $card->setString('VERSION', '3.0');
// Add product ID is missing.
$prodid = trim($card->getAsString('PRODID'));
if(!$prodid) {
@@ -323,8 +323,8 @@ class OC_Contacts_VCard{
try {
$result = $stmt->execute(array($aid,$fn,$data,$uri,time()));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG);
return false;
}
$newid = OCP\DB::insertid('*PREFIX*contacts_cards');
@@ -355,15 +355,15 @@ class OC_Contacts_VCard{
$now = new DateTime;
foreach($objects as $object) {
$vcard = OC_VObject::parse($object[1]);
- if(!is_null($vcard)){
+ if(!is_null($vcard)) {
$vcard->setString('REV', $now->format(DateTime::W3C));
$data = $vcard->serialize();
try {
$result = $stmt->execute(array($data,time(),$object[0]));
//OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG);
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$object[0],OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$object[0], OCP\Util::DEBUG);
}
}
}
@@ -397,8 +397,8 @@ class OC_Contacts_VCard{
try {
$result = $stmt->execute(array($fn,$data,time(),$id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG);
return false;
}
@@ -414,11 +414,11 @@ class OC_Contacts_VCard{
* @param string $data vCard file
* @return boolean
*/
- public static function editFromDAVData($aid,$uri,$data){
- $oldcard = self::findWhereDAVDataIs($aid,$uri);
+ public static function editFromDAVData($aid, $uri, $data){
+ $oldcard = self::findWhereDAVDataIs($aid, $uri);
$card = OC_VObject::parse($data);
if(!$card) {
- OCP\Util::writeLog('contacts','OC_Contacts_VCard::editFromDAVData. Unable to parse VCARD, uri: '.$uri,OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', Unable to parse VCARD, uri: '.$uri, OCP\Util::ERROR);
return false;
}
return self::edit($oldcard['id'], $card);
@@ -430,14 +430,13 @@ class OC_Contacts_VCard{
* @return boolean
*/
public static function delete($id){
- // FIXME: Add error checking.
OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
try {
$stmt->execute(array($id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG);
return false;
}
@@ -451,14 +450,13 @@ class OC_Contacts_VCard{
* @return boolean
*/
public static function deleteFromDAVData($aid,$uri){
- // FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error.
OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uri));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
try {
$stmt->execute(array($aid,$uri));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG);
return false;
}
OC_Contacts_Addressbook::touch($aid);
@@ -487,14 +485,14 @@ class OC_Contacts_VCard{
* @return array
*/
public static function unescapeDelimiters($value, $delimiter=';') {
- $array = explode($delimiter,$value);
+ $array = explode($delimiter, $value);
for($i=0;$i<count($array);$i++) {
- if(substr($array[$i],-1,1)=="\\") {
+ if(substr($array[$i], -1, 1)=="\\") {
if(isset($array[$i+1])) {
- $array[$i] = substr($array[$i],0,count($array[$i])-2).$delimiter.$array[$i+1];
+ $array[$i] = substr($array[$i], 0, count($array[$i])-2).$delimiter.$array[$i+1];
unset($array[$i+1]);
} else {
- $array[$i] = substr($array[$i],0,count($array[$i])-2).$delimiter;
+ $array[$i] = substr($array[$i], 0, count($array[$i])-2).$delimiter;
}
$i = $i - 1;
}
@@ -510,12 +508,12 @@ class OC_Contacts_VCard{
*
* look at code ...
*/
- public static function structureContact($object){
+ public static function structureContact($object) {
$details = array();
foreach($object->children as $property){
$temp = self::structureProperty($property);
if(!is_null($temp)) {
- if(array_key_exists($property->name,$details)){
+ if(array_key_exists($property->name, $details)) {
$details[$property->name][] = $temp;
}
else{
@@ -539,10 +537,10 @@ class OC_Contacts_VCard{
* NOTE: $value is not escaped anymore. It shouldn't make any difference
* but we should look out for any problems.
*/
- public static function structureProperty($property){
+ public static function structureProperty($property) {
$value = $property->value;
//$value = htmlspecialchars($value);
- if($property->name == 'ADR' || $property->name == 'N'){
+ if($property->name == 'ADR' || $property->name == 'N') {
$value = self::unescapeDelimiters($value);
} elseif($property->name == 'BDAY') {
if(strpos($value, '-') === false) {
@@ -562,17 +560,17 @@ class OC_Contacts_VCard{
// Faulty entries by kaddressbook
// Actually TYPE=PREF is correct according to RFC 2426
// but this way is more handy in the UI. Tanghus.
- if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){
+ if($parameter->name == 'TYPE' && $parameter->value == 'PREF') {
$parameter->name = 'PREF';
$parameter->value = '1';
}
// NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters
// like TYPE=HOME,CELL,VOICE. Tanghus.
- if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE'){
- if (isset($temp['parameters'][$parameter->name])){
+ if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE') {
+ if (isset($temp['parameters'][$parameter->name])) {
$temp['parameters'][$parameter->name][] = $parameter->value;
}
- else{
+ else {
$temp['parameters'][$parameter->name] = array($parameter->value);
}
}
@@ -590,7 +588,7 @@ class OC_Contacts_VCard{
* @return boolean
*
*/
- public static function moveToAddressBook($aid, $id){
+ public static function moveToAddressBook($aid, $id) {
OC_Contacts_App::getAddressbook($aid); // check for user ownership.
if(is_array($id)) {
$id_sql = join(',', array_fill(0, count($id), '?'));
@@ -601,9 +599,9 @@ class OC_Contacts_VCard{
$vals = array_merge((array)$aid, $id);
$result = $stmt->execute($vals);
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals),OCP\Util::DEBUG);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', SQL:'.$prep,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals), OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', SQL:'.$prep, OCP\Util::DEBUG);
return false;
}
} else {
@@ -611,8 +609,8 @@ class OC_Contacts_VCard{
$stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' );
$result = $stmt->execute(array($aid, $id));
} catch(Exception $e) {
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::DEBUG);
- OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' id: '.$id,OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' id: '.$id, OCP\Util::DEBUG);
return false;
}
}
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 4660d61f618..efdf157cd95 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -13,7 +13,7 @@
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
-function getStandardImage(){
+function getStandardImage() {
//OCP\Response::setExpiresHeader('P10D');
OCP\Response::enableCaching();
OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png'));
@@ -27,37 +27,39 @@ if(is_null($id)) {
}
if(!extension_loaded('gd') || !function_exists('gd_info')) {
- OCP\Util::writeLog('contacts','photo.php. GD module not installed',OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'photo.php. GD module not installed', OCP\Util::DEBUG);
getStandardImage();
}
$contact = OC_Contacts_App::getContactVCard($id);
$image = new OC_Image();
-if(!$image) {
+if (!$image) {
getStandardImage();
}
// invalid vcard
-if( is_null($contact)) {
- OCP\Util::writeLog('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
+if (is_null($contact)) {
+ OCP\Util::writeLog('contacts',
+ 'photo.php. The VCard for ID ' . $id . ' is not RFC compatible',
+ OCP\Util::ERROR);
} else {
OCP\Response::enableCaching($caching);
OC_Contacts_App::setLastModifiedHeader($contact);
// Photo :-)
- if($image->loadFromBase64($contact->getAsString('PHOTO'))) {
+ if ($image->loadFromBase64($contact->getAsString('PHOTO'))) {
// OK
OCP\Response::setETagHeader(md5($contact->getAsString('PHOTO')));
}
else
// Logo :-/
- if($image->loadFromBase64($contact->getAsString('LOGO'))) {
+ if ($image->loadFromBase64($contact->getAsString('LOGO'))) {
// OK
OCP\Response::setETagHeader(md5($contact->getAsString('LOGO')));
}
if ($image->valid()) {
$max_size = 200;
- if($image->width() > $max_size ||
- $image->height() > $max_size) {
+ if ($image->width() > $max_size || $image->height() > $max_size) {
$image->resize($max_size);
}
}
@@ -65,8 +67,7 @@ if( is_null($contact)) {
if (!$image->valid()) {
// Not found :-(
getStandardImage();
- //$image->loadFromFile('img/person_large.png');
}
header('Content-Type: '.$image->mimeType());
$image->show();
-//echo OC_Contacts_App::$l10n->t('This card does not contain a photo.');
+
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index 98cb67a26e7..1bc4a195534 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -25,7 +25,7 @@
</div>
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>">
<?php
- if($_['has_contacts']){
+ if($_['has_contacts']) {
echo $this->inc('part.contact');
}
else{
diff --git a/apps/contacts/templates/part.cropphoto.php b/apps/contacts/templates/part.cropphoto.php
index 6d7b1e44777..3f5817622b2 100644
--- a/apps/contacts/templates/part.cropphoto.php
+++ b/apps/contacts/templates/part.cropphoto.php
@@ -2,7 +2,6 @@
$id = $_['id'];
$tmpkey = $_['tmpkey'];
$requesttoken = $_['requesttoken'];
-OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
?>
<script type="text/javascript">
jQuery(function($) {
diff --git a/apps/contacts/templates/part.edit_categories_dialog.php b/apps/contacts/templates/part.edit_categories_dialog.php
deleted file mode 100644
index 8997fa586bd..00000000000
--- a/apps/contacts/templates/part.edit_categories_dialog.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-$categories = isset($_['categories'])?$_['categories']:array();
-?>
-<div id="edit_categories_dialog" title="<?php echo $l->t('Edit categories'); ?>">
-<!-- ?php print_r($types); ? -->
- <form method="post" id="categoryform">
- <div class="scrollarea">
- <ul id="categorylist">
- <?php foreach($categories as $category) { ?>
- <li><input type="checkbox" name="categories[]" value="<?php echo $category; ?>" /><?php echo $category; ?></li>
- <?php } ?>
- </ul>
- </div>
- <div class="bottombuttons"><input type="text" id="category_addinput" name="category" /><button id="category_addbutton" disabled="disabled"><?php echo $l->t('Add'); ?></button></div>
- </form>
-</div>
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index a69e9c74f72..6deb5ca379e 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -25,14 +25,15 @@ OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
session_write_close();
-function getStandardImage(){
+function getStandardImage() {
//OCP\Response::setExpiresHeader('P10D');
OCP\Response::enableCaching();
OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person.png'));
}
if(!extension_loaded('gd') || !function_exists('gd_info')) {
- OCP\Util::writeLog('contacts','thumbnail.php. GD module not installed',OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. GD module not installed', OCP\Util::DEBUG);
getStandardImage();
exit();
}
@@ -43,8 +44,10 @@ $caching = isset($_GET['refresh']) ? 0 : null;
$contact = OC_Contacts_App::getContactVCard($id);
// invalid vcard
-if(is_null($contact)){
- OCP\Util::writeLog('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
+if(is_null($contact)) {
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. The VCard for ID ' . $id . ' is not RFC compatible',
+ OCP\Util::ERROR);
getStandardImage();
exit();
}
@@ -64,16 +67,24 @@ if($photo) {
if($image->show()) {
exit();
} else {
- OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. Couldn\'t display thumbnail for ID ' . $id,
+ OCP\Util::ERROR);
}
} else {
- OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. Couldn\'t resize thumbnail for ID ' . $id,
+ OCP\Util::ERROR);
}
}else{
- OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. Couldn\'t crop thumbnail for ID ' . $id,
+ OCP\Util::ERROR);
}
} else {
- OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts',
+ 'thumbnail.php. Couldn\'t load image string for ID ' . $id,
+ OCP\Util::ERROR);
}
}
getStandardImage();
diff --git a/apps/contacts/tmpphoto.php b/apps/contacts/tmpphoto.php
index 5fde8de9977..156d5c80308 100644
--- a/apps/contacts/tmpphoto.php
+++ b/apps/contacts/tmpphoto.php
@@ -24,7 +24,7 @@ $tmpkey = $_GET['tmpkey'];
$maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1;
header("Cache-Control: no-cache, no-store, must-revalidate");
-OCP\Util::writeLog('contacts','tmpphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
+OCP\Util::writeLog('contacts', 'tmpphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
$image = new OC_Image();
$image->loadFromData(OC_Cache::get($tmpkey));
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php
index e0020537563..46471911d94 100644
--- a/apps/files_encryption/lib/cryptstream.php
+++ b/apps/files_encryption/lib/cryptstream.php
@@ -31,9 +31,7 @@ class OC_CryptStream{
public static $sourceStreams=array();
private $source;
private $path;
- private $readBuffer;//for streams that dont support seeking
private $meta=array();//header/meta for source stream
- private $count;
private $writeCache;
private $size;
private static $rootView;
@@ -100,7 +98,6 @@ class OC_CryptStream{
public function stream_write($data){
$length=strlen($data);
- $written=0;
$currentPos=ftell($this->source);
if($this->writeCache){
$data=$this->writeCache.$data;
diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php
index 35663d431f8..c849db38433 100755
--- a/apps/files_external/lib/dropbox.php
+++ b/apps/files_external/lib/dropbox.php
@@ -208,7 +208,7 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
if (isset(self::$tempFiles[$tmpFile])) {
$handle = fopen($tmpFile, 'r');
try {
- $response = $this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
+ $this->dropbox->putFile(self::$tempFiles[$tmpFile], $handle);
unlink($tmpFile);
} catch (Exception $exception) {
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index 41b560ae84e..2ad85d09d5f 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -178,7 +178,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
if ($collection == '/' || $collection == '\.' || $collection == '.') {
$uri = 'https://docs.google.com/feeds/default/private/full';
// Get parent content link
- } else if ($dom = $this->getResource(basename($dir))) {
+ } else if ($dom = $this->getResource(basename($collection))) {
$uri = $dom->getElementsByTagName('content')->item(0)->getAttribute('src');
}
if (isset($uri)) {
@@ -341,7 +341,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
break;
}
}
- $title = basename($path);
+ $title = basename($path2);
// Construct post data
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007" xmlns:gd="http://schemas.google.com/g/2005" gd:etag='.$etag.'>';
@@ -352,13 +352,13 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
} else {
// Move to different collection
if ($collectionEntry = $this->getResource($collection)) {
- $feedUri = $colelctionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
+ $feedUri = $collectionEntry->getElementsByTagName('content')->item(0)->getAttribute('src');
// Construct post data
$postData = '<?xml version="1.0" encoding="UTF-8"?>';
$postData .= '<entry xmlns="http://www.w3.org/2005/Atom">';
$postData .= '<id>'.$entry->getElementsByTagName('id')->item(0).'</id>';
$postData .= '</entry>';
- $this->sendRequest($uri, 'POST', $postData);
+ $this->sendRequest($feedUri, 'POST', $postData);
return true;
}
}
@@ -424,7 +424,6 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
}
}
if (!isset($uploadUri) && $entry) {
- $etag = $entry->getAttribute('gd:etag');
$links = $entry->getElementsByTagName('link');
foreach ($links as $link) {
if ($link->getAttribute('rel') == 'http://schemas.google.com/g/2005#resumable-create-media') {
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index 5e34deb2337..8a5e993b1d0 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -15,8 +15,6 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
private $root;
private $share;
- private static $tempFiles=array();
-
public function __construct($params){
$this->host=$params['host'];
$this->user=$params['user'];
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index 3d13518f57b..84d64b65193 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -77,16 +77,11 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$path=$this->cleanPath($path);
try{
$response=$this->client->propfind($path, array(),1);
- $stripLength=strlen($this->root)+strlen($path);
$id=md5('webdav'.$this->root.$path);
OC_FakeDirStream::$dirs[$id]=array();
- $skip = true;
- foreach($response as $file=>$data){
- // Skip the first file, because it is the current directory
- if ($skip) {
- $skip = false;
- continue;
- }
+ $files=array_keys($response);
+ array_shift($files);//the first entry is the current directory
+ foreach($files as $file){
$file = urldecode(basename($file));
OC_FakeDirStream::$dirs[$id][]=$file;
}
@@ -120,7 +115,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
public function file_exists($path){
$path=$this->cleanPath($path);
try{
- $response=$this->client->propfind($path, array('{DAV:}resourcetype'));
+ $this->client->propfind($path, array('{DAV:}resourcetype'));
return true;//no 404 exception
}catch(Exception $e){
return false;
@@ -201,7 +196,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
$mtime=time();
}
$path=$this->cleanPath($path);
- $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime,));
+ $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime));
}
public function getFile($path,$target){
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 68481b4e66b..97796bca128 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
}else{
class Test_Filestorage_FTP extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php
index 08116f0e748..806db5a6aaa 100644
--- a/apps/files_external/tests/google.php
+++ b/apps/files_external/tests/google.php
@@ -28,7 +28,6 @@ if(!is_array($config) or !isset($config['google']) or !$config['google']['run'])
class Test_Filestorage_Google extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php
index e1495b7480d..001ef842276 100644
--- a/apps/files_external/tests/smb.php
+++ b/apps/files_external/tests/smb.php
@@ -14,7 +14,6 @@ if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']){
}else{
class Test_Filestorage_SMB extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php
index f0bde6ed605..1520c9473d3 100644
--- a/apps/files_external/tests/swift.php
+++ b/apps/files_external/tests/swift.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']){
}else{
class Test_Filestorage_SWIFT extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php
index 144659819b6..14abbef2cbf 100644
--- a/apps/files_external/tests/webdav.php
+++ b/apps/files_external/tests/webdav.php
@@ -13,7 +13,6 @@ if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run'])
}else{
class Test_Filestorage_DAV extends Test_FileStorage {
private $config;
- private $id;
public function setUp(){
$id=uniqid();
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 4138fc2b399..32fd2124429 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -67,7 +67,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function rmdir($path) {
// The folder will be removed from the database, but won't be deleted from the owner's filesystem
OC_Share::unshareFromMySelf($this->datadir.$path);
- $this->clearFolderSizeCache($path);
}
public function opendir($path) {
@@ -190,7 +189,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function filesize($path) {
if ($path == "" || $path == "/" || $this->is_dir($path)) {
- return $this->getFolderSize($path);
+ return 0;
} else {
$source = $this->getSource($path);
if ($source) {
@@ -200,55 +199,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
}
}
- public function getFolderSize($path) {
- return 0; //depricated
- }
-
- private function calculateFolderSize($path) {
- if ($this->is_file($path)) {
- $path = dirname($path);
- }
- $size = 0;
- if ($dh = $this->opendir($path)) {
- while (($filename = readdir($dh)) !== false) {
- if ($filename != "." && $filename != "..") {
- $subFile = $path."/".$filename;
- if ($this->is_file($subFile)) {
- $size += $this->filesize($subFile);
- } else {
- $size += $this->getFolderSize($subFile);
- }
- }
- }
- if ($size > 0) {
- $dbpath = rtrim($this->datadir.$path, "/");
-// $query = OCP\DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)");
-// $result = $query->execute(array($dbpath, $size));
- }
- }
- return $size;
- }
-
- private function clearFolderSizeCache($path) {
- $path = rtrim($path, "/");
- $path = preg_replace('{(/)\1+}', "/", $path);
- if ($this->is_file($path)) {
- $path = dirname($path);
- }
- $dbpath = rtrim($this->datadir.$path, "/");
-// $query = OCP\DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?");
-// $result = $query->execute(array($dbpath));
- if ($path != "/" && $path != "") {
- $parts = explode("/", $path);
- $part = array_pop($parts);
- if (empty($part)) {
- array_pop($parts);
- }
- $parent = implode("/", $parts);
- $this->clearFolderSizeCache($parent);
- }
- }
-
public function is_readable($path) {
return true;
}
@@ -341,9 +291,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
OCP\Util::emitHook('OC_Filestorage_Shared', 'file_put_contents', $info);
$storage = OC_Filesystem::getStorage($source);
$result = $storage->file_put_contents($this->getInternalPath($source), $data);
- if ($result) {
- $this->clearFolderSizeCache($path);
- }
return $result;
}
}
@@ -365,7 +312,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
} else {
OC_Share::unshareFromMySelf($target);
}
- $this->clearFolderSizeCache($this->getInternalPath($target));
return true;
}
@@ -401,8 +347,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
} else {
OC_Share::setTarget($oldTarget, $newTarget);
}
- $this->clearFolderSizeCache($this->getInternalPath($oldTarget));
- $this->clearFolderSizeCache($this->getInternalPath($newTarget));
return true;
}
@@ -413,9 +357,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($this->is_writable($path2)) {
$tmpFile = $this->toTmpFile($path1);
$result = $this->fromTmpFile($tmpFile, $path2);
- if ($result) {
- $this->clearFolderSizeCache($path2);
- }
return $result;
} else {
return false;
@@ -451,9 +392,6 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
if ($source) {
$storage = OC_Filesystem::getStorage($source);
$result = $storage->fromTmpFile($tmpFile, $this->getInternalPath($source));
- if ($result) {
- $this->clearFolderSizeCache($path);
- }
return $result;
}
} else {
@@ -520,7 +458,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
$source = $this->getSource($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
- return $storage->touch($this->getInternalPath($source),$time);
+ return $storage->touch($this->getInternalPath($source),$mtime);
}
}
diff --git a/apps/files_sharing_log/appinfo/database.xml b/apps/files_sharing_log/appinfo/database.xml
index 92e5f0125bd..dae811f87fa 100644
--- a/apps/files_sharing_log/appinfo/database.xml
+++ b/apps/files_sharing_log/appinfo/database.xml
@@ -3,7 +3,7 @@
<name>*dbname*</name>
<create>true</create>
<overwrite>false</overwrite>
- <charset>latin1</charset>
+ <charset>utf8</charset>
<table>
<name>*dbprefix*sharing_log</name>
<declaration>
diff --git a/apps/files_versions/ajax/expireAll.php b/apps/files_versions/ajax/expireAll.php
index 4f165be0ae9..2a678c7f0a5 100644
--- a/apps/files_versions/ajax/expireAll.php
+++ b/apps/files_versions/ajax/expireAll.php
@@ -27,6 +27,7 @@
// Check user and app status
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('files_versions');
+OCP\JSON::callCheck();
$versions = new OCA_Versions\Storage();
diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php
index 8d1092f8b8e..24d71a914a4 100644
--- a/apps/files_versions/ajax/rollbackVersion.php
+++ b/apps/files_versions/ajax/rollbackVersion.php
@@ -1,6 +1,7 @@
<?php
OCP\JSON::checkAppEnabled('files_versions');
+OCP\JSON::callCheck();
$userDirectory = "/".OCP\USER::getUser()."/files";
diff --git a/apps/files_versions/ajax/togglesettings.php b/apps/files_versions/ajax/togglesettings.php
index 86f614c5c89..546b37ae1aa 100644
--- a/apps/files_versions/ajax/togglesettings.php
+++ b/apps/files_versions/ajax/togglesettings.php
@@ -2,6 +2,7 @@
OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::checkAdminUser();
+OCP\JSON::callCheck();
if (OCP\Config::getSystemValue('versions', 'true')=='true') {
OCP\Config::setSystemValue('versions', 'false');
} else {
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 0ce884c3ea0..f146676757d 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -227,13 +227,13 @@ class Storage {
}
$versions = array_reverse( $versions );
-
+
foreach( $versions as $key => $value ) {
// flag the first matched file in array (which will have latest modification date) as current version
- if ( $versions[$key]['fileMatch'] ) {
+ if ( $value['fileMatch'] ) {
- $versions[$key]['cur'] = 1;
+ $value['cur'] = 1;
break;
}
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index 39d6d3aded1..701949d4d80 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -58,7 +58,7 @@ class OC_Gallery_Album {
return $stmt->execute($args);
}
- public static function removeByName($owner, $name) { self::remove($ownmer, $name); }
+ public static function removeByName($owner, $name) { self::remove($owner, $name); }
public static function removeByPath($owner, $path) { self::remove($owner, null, $path); }
public static function removeByParentPath($owner, $parent) { self::remove($owner, null, null, $parent); }
diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php
index b6ade3d1b1e..575d962dbe3 100644
--- a/apps/gallery/lib/managers.php
+++ b/apps/gallery/lib/managers.php
@@ -29,7 +29,6 @@ class DatabaseManager {
$stmt = \OCP\DB::prepare('INSERT INTO *PREFIX*pictures_images_cache (uid_owner, path, width, height) VALUES (?, ?, ?, ?)');
$stmt->execute(array(\OCP\USER::getUser(), $path, $width, $height));
$ret = array('path' => $path, 'width' => $width, 'height' => $height);
- unset($image);
$dir = dirname($path);
$this->cache[$dir][$path] = $ret;
return $ret;
diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php
index 754734e609e..e36d26d3191 100644
--- a/apps/gallery/lib/tiles.php
+++ b/apps/gallery/lib/tiles.php
@@ -33,7 +33,7 @@ class TilesLine {
}
public function setAvailableSpace($space) {
- $available_space = $space;
+ $this->available_space = $space;
}
public function getTilesCount() {
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index d35cca150b2..d5a093338cc 100644
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -271,7 +271,6 @@ class OC_MEDIA_AMPACHE{
</root>");
return;
}
- global $SITEROOT;
$filter=$params['filter'];
$albums=OC_MEDIA_COLLECTION::getAlbums($filter);
$artist=OC_MEDIA_COLLECTION::getArtistName($filter);
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index e65930f551d..cacab8e959f 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -27,7 +27,6 @@ class OC_MEDIA_COLLECTION{
public static $uid;
private static $artistIdCache=array();
private static $albumIdCache=array();
- private static $songIdCache=array();
private static $queries=array();
/**
@@ -152,7 +151,7 @@ class OC_MEDIA_COLLECTION{
return $artistId;
}else{
$query=OCP\DB::prepare("INSERT INTO `*PREFIX*media_artists` (`artist_name`) VALUES (?)");
- $result=$query->execute(array($name));
+ $query->execute(array($name));
return self::getArtistId($name);;
}
}
diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php
index 9e687a4af2c..54502f42575 100644
--- a/apps/media/lib_media.php
+++ b/apps/media/lib_media.php
@@ -27,12 +27,12 @@ class OC_MEDIA{
* @param array $params, parameters passed from OC_Hook
*/
public static function loginListener($params){
- if(isset($_POST['user']) and $_POST['password']){
- $name=$_POST['user'];
+ if(isset($params['uid']) and $params['password']){
+ $name=$params['uid'];
$query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?");
$uid=$query->execute(array($name))->fetchAll();
if(count($uid)==0){
- $password=hash('sha256',$_POST['password']);
+ $password=hash('sha256',$params['password']);
$query=OCP\DB::prepare("INSERT INTO *PREFIX*media_users (user_id, user_password_sha256) VALUES (?, ?);");
$query->execute(array($name,$password));
}
diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml
index fa878762a05..1388ad9c316 100644
--- a/apps/remoteStorage/appinfo/info.xml
+++ b/apps/remoteStorage/appinfo/info.xml
@@ -7,4 +7,7 @@
<author>Michiel de Jong</author>
<require>4</require>
<shipped>true</shipped>
+ <remote>
+ <remoteStorage>webdav.php</remoteStorage>
+ </remote>
</info>
diff --git a/apps/remoteStorage/appinfo/version b/apps/remoteStorage/appinfo/version
index 490f510fc27..0e2c93950bb 100644
--- a/apps/remoteStorage/appinfo/version
+++ b/apps/remoteStorage/appinfo/version
@@ -1 +1 @@
-0.6 \ No newline at end of file
+0.7 \ No newline at end of file
diff --git a/apps/remoteStorage/appinfo/webfinger.php b/apps/remoteStorage/appinfo/webfinger.php
index 5d481f315f8..e8b237628c4 100644
--- a/apps/remoteStorage/appinfo/webfinger.php
+++ b/apps/remoteStorage/appinfo/webfinger.php
@@ -1,8 +1,8 @@
-<?php if(OC_User::userExists(WF_USER)) { ?>
+<?php if(OC_User::userExists(WF_USER)): ?>
{
"rel":"remoteStorage",
- "template":"<?php echo WF_BASEURL; ?>/apps/remoteStorage/WebDAV.php/<?php echo WF_USER; ?>/remoteStorage/{category}/",
+ "template":"<?php echo WF_BASEURL; ?>/remote.php/remoteStorage/<?php echo WF_USER; ?>/remoteStorage/{category}/",
"api":"WebDAV",
"auth":"<?php echo WF_BASEURL; ?>/?app=remoteStorage&getfile=auth.php&userid=<?php echo WF_USER; ?>"
}
-<?php } ?>
+<?php endif ?>
diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php
index 42cd9c90f64..c1765640c5d 100644
--- a/apps/remoteStorage/lib_remoteStorage.php
+++ b/apps/remoteStorage/lib_remoteStorage.php
@@ -17,12 +17,11 @@ class OC_remoteStorage {
$user=OCP\USER::getUser();
$query=OCP\DB::prepare("SELECT token FROM *PREFIX*authtoken WHERE user=? AND appUrl=? AND category=? LIMIT 1");
$result=$query->execute(array($user, $appUrl, $categories));
- $ret = array();
if($row=$result->fetchRow()) {
- return base64_encode('remoteStorage:'.$row['token']);
- } else {
- return false;
- }
+ return base64_encode('remoteStorage:'.$row['token']);
+ } else {
+ return false;
+ }
}
public static function getAllTokens() {
@@ -42,13 +41,13 @@ class OC_remoteStorage {
public static function deleteToken($token) {
$user=OCP\USER::getUser();
$query=OCP\DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?");
- $result=$query->execute(array($token,$user));
+ $query->execute(array($token,$user));
return 'unknown';//how can we see if any rows were affected?
}
private static function addToken($token, $appUrl, $categories){
$user=OCP\USER::getUser();
$query=OCP\DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)");
- $result=$query->execute(array($token,$appUrl,$user,$categories));
+ $query->execute(array($token,$appUrl,$user,$categories));
}
public static function createCategories($appUrl, $categories) {
$token=uniqid();
diff --git a/apps/remoteStorage/oauth_ro_auth.php b/apps/remoteStorage/oauth_ro_auth.php
index 12d02d1cf5d..bed3093c3b3 100644
--- a/apps/remoteStorage/oauth_ro_auth.php
+++ b/apps/remoteStorage/oauth_ro_auth.php
@@ -9,10 +9,10 @@
class OC_Connector_Sabre_Auth_ro_oauth extends Sabre_DAV_Auth_Backend_AbstractBasic {
private $validTokens;
- private $category;
+ private $category;
public function __construct($validTokensArg, $categoryArg) {
$this->validTokens = $validTokensArg;
- $this->category = $categoryArg;
+ $this->category = $categoryArg;
}
/**
@@ -25,16 +25,16 @@ class OC_Connector_Sabre_Auth_ro_oauth extends Sabre_DAV_Auth_Backend_AbstractBa
*/
protected function validateUserPass($username, $password){
//always give read-only:
- if(($_SERVER['REQUEST_METHOD'] == 'OPTIONS')
+ if(($_SERVER['REQUEST_METHOD'] == 'OPTIONS')
|| (isset($this->validTokens[$password]))
- || (($_SERVER['REQUEST_METHOD'] == 'GET') && ($this->category == 'public'))
- ) {
+ || (($_SERVER['REQUEST_METHOD'] == 'GET') && ($this->category == 'public'))
+ ) {
OC_Util::setUpFS();
return true;
} else {
- //var_export($_SERVER);
- //var_export($this->validTokens);
- //die('not getting in with "'.$username.'"/"'.$password.'"!');
+ //var_export($_SERVER);
+ //var_export($this->validTokens);
+ //die('not getting in with "'.$username.'"/"'.$password.'"!');
return false;
}
}
@@ -48,8 +48,8 @@ class OC_Connector_Sabre_Auth_ro_oauth extends Sabre_DAV_Auth_Backend_AbstractBa
$userpass = $auth->getUserPass();
if (!$userpass) {
if(($_SERVER['REQUEST_METHOD'] == 'OPTIONS')
- ||(($_SERVER['REQUEST_METHOD'] == 'GET') && ($this->category == 'public'))
- ) {
+ ||(($_SERVER['REQUEST_METHOD'] == 'GET') && ($this->category == 'public'))
+ ) {
$userpass = array('', '');
} else {
$auth->requireLogin();
diff --git a/apps/remoteStorage/WebDAV.php b/apps/remoteStorage/webdav.php
index 7a81c18e0af..8d8ec6a45a1 100644
--- a/apps/remoteStorage/WebDAV.php
+++ b/apps/remoteStorage/webdav.php
@@ -25,22 +25,7 @@
*
*/
-
-// Do not load FS ...
-$RUNTIME_NOSETUPFS = true;
-
-
-require_once('../../lib/base.php');
-
-require_once('../../lib/user.php');
-require_once('../../lib/public/user.php');
-
-require_once('../../lib/app.php');
-require_once('../../lib/public/app.php');
-
-require_once('../../3rdparty/Sabre/DAV/Auth/IBackend.php');
-require_once('../../3rdparty/Sabre/DAV/Auth/Backend/AbstractBasic.php');
-require_once('../../lib/connector/sabre/auth.php');
+OC_App::loadApps(array('filesystem','authentication'));
OCP\App::checkAppEnabled('remoteStorage');
require_once('lib_remoteStorage.php');
@@ -61,14 +46,15 @@ if(isset($_SERVER['HTTP_ORIGIN'])) {
header('Access-Control-Allow-Origin: *');
}
-$path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
+$path = substr($_SERVER["REQUEST_URI"], strlen($baseuri));
+
$pathParts = explode('/', $path);
// for webdav:
-// 0/ 1 / 2 / 3...
-// /$ownCloudUser/remoteStorage/$category/
+// 0 / 1 / 2...
+// $ownCloudUser/remoteStorage/$category/
-if(count($pathParts) >= 3 && $pathParts[0] == '') {
- list($dummy, $ownCloudUser, $dummy2, $category) = $pathParts;
+if(count($pathParts) >= 2) {
+ list($ownCloudUser, $dummy2, $category) = $pathParts;
OC_Util::setupFS($ownCloudUser);
@@ -77,13 +63,13 @@ if(count($pathParts) >= 3 && $pathParts[0] == '') {
$server = new Sabre_DAV_Server($publicDir);
// Path to our script
- $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/WebDAV.php/$ownCloudUser");
+ $server->setBaseUri($baseuri.$ownCloudUser);
// Auth backend
$authBackend = new OC_Connector_Sabre_Auth_ro_oauth(
- OC_remoteStorage::getValidTokens($ownCloudUser, $category),
- $category
- );
+ OC_remoteStorage::getValidTokens($ownCloudUser, $category),
+ $category
+ );
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud');//should use $validTokens here
$server->addPlugin($authPlugin);
diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php
index 9f35e7f21ec..d98fdbf3888 100644
--- a/apps/tasks/ajax/addtask.php
+++ b/apps/tasks/ajax/addtask.php
@@ -3,6 +3,7 @@
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
+OCP\JSON::callCheck();
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$first_calendar = reset($calendars);
@@ -21,7 +22,7 @@ $request['description'] = null;
$vcalendar = OC_Task_App::createVCalendarFromRequest($request);
$id = OC_Calendar_Object::add($cid, $vcalendar->serialize());
-$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$user_timezone = OC_Calendar_App::getTimezone();
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
OCP\JSON::success(array('task' => $task));
diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php
deleted file mode 100644
index d86232e2da5..00000000000
--- a/apps/tasks/ajax/addtaskform.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-// Init owncloud
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('tasks');
-
-$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
-$category_options = OC_Calendar_App::getCategoryOptions();
-$percent_options = range(0, 100, 10);
-$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OCP\Template('tasks','part.addtaskform');
-$tmpl->assign('calendars',$calendars);
-$tmpl->assign('category_options', $category_options);
-$tmpl->assign('percent_options', $percent_options);
-$tmpl->assign('priority_options', $priority_options);
-$tmpl->assign('details', new OC_VObject('VTODO'));
-$tmpl->assign('categories', '');
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/delete.php b/apps/tasks/ajax/delete.php
index e29add9b556..cc22c3e3873 100644
--- a/apps/tasks/ajax/delete.php
+++ b/apps/tasks/ajax/delete.php
@@ -23,6 +23,7 @@
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
+OCP\JSON::callCheck();
$id = $_POST['id'];
$task = OC_Calendar_App::getEventObject( $id );
diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php
deleted file mode 100644
index edcc8a7cdcd..00000000000
--- a/apps/tasks/ajax/edittask.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-// Init owncloud
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('tasks');
-
-$l10n = new OC_L10N('tasks');
-
-$id = $_POST['id'];
-$vcalendar = OC_Calendar_App::getVCalendar($id);
-
-$errors = OC_Task_App::validateRequest($_POST);
-if (!empty($errors)) {
- OCP\JSON::error(array('data' => array( 'errors' => $errors )));
- exit();
-}
-
-OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar);
-OC_Calendar_Object::edit($id, $vcalendar->serialize());
-
-$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OCP\Template('tasks','part.details');
-$tmpl->assign('priority_options', $priority_options);
-$tmpl->assign('details', $vcalendar->VTODO);
-$tmpl->assign('id', $id);
-$page = $tmpl->fetchPage();
-
-$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
-$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
-
-OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task )));
diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php
deleted file mode 100644
index e5a0a7297c5..00000000000
--- a/apps/tasks/ajax/edittaskform.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-// Init owncloud
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('tasks');
-
-$id = $_GET['id'];
-$details = OC_Calendar_App::getVCalendar($id)->VTODO;
-$categories = $details->getAsString('CATEGORIES');
-
-$category_options = OC_Calendar_App::getCategoryOptions();
-$percent_options = range(0, 100, 10);
-$priority_options = OC_Task_App::getPriorityOptions();
-
-$tmpl = new OCP\Template('tasks','part.edittaskform');
-$tmpl->assign('category_options', $category_options);
-$tmpl->assign('percent_options', $percent_options);
-$tmpl->assign('priority_options', $priority_options);
-$tmpl->assign('id',$id);
-$tmpl->assign('details',$details);
-$tmpl->assign('categories', $categories);
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php
deleted file mode 100644
index 4ce469e0c9c..00000000000
--- a/apps/tasks/ajax/getdetails.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-// Init owncloud
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('tasks');
-
-$l10n = new OC_L10N('tasks');
-
-$id = $_GET['id'];
-$task = OC_Calendar_Object::find($id);
-$details = OC_VObject::parse($task['calendardata']);
-if (!$details){
- OCP\JSON::error();
- exit;
-}
-
-$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OCP\Template('tasks','part.details');
-$tmpl->assign('priority_options', $priority_options);
-$tmpl->assign('details',$details->VTODO);
-$tmpl->assign('id',$id);
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/tasks/ajax/gettasks.php b/apps/tasks/ajax/gettasks.php
index 011730d0a13..b6183d9cb65 100644
--- a/apps/tasks/ajax/gettasks.php
+++ b/apps/tasks/ajax/gettasks.php
@@ -11,7 +11,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
-$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$user_timezone = OC_Calendar_App::getTimezone();
$tasks = array();
foreach( $calendars as $calendar ){
diff --git a/apps/tasks/ajax/update_property.php b/apps/tasks/ajax/update_property.php
index 46521cf6c58..679cfdefe48 100644
--- a/apps/tasks/ajax/update_property.php
+++ b/apps/tasks/ajax/update_property.php
@@ -9,6 +9,7 @@
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
+OCP\JSON::callCheck();
$id = $_POST['id'];
$property = $_POST['type'];
@@ -38,7 +39,7 @@ switch($property) {
$type = null;
if ($due != 'false') {
try {
- $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
$due = new DateTime('@'.$due);
$due->setTimezone($timezone);
@@ -63,6 +64,6 @@ switch($property) {
}
OC_Calendar_Object::edit($id, $vcalendar->serialize());
-$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$user_timezone = OC_Calendar_App::getTimezone();
$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
OCP\JSON::success(array('data' => $task_info));
diff --git a/apps/tasks/index.php b/apps/tasks/index.php
index 4ff304a5607..f1c4d1e765c 100644
--- a/apps/tasks/index.php
+++ b/apps/tasks/index.php
@@ -21,8 +21,8 @@ OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('tasks', 'tasks');
OCP\Util::addStyle('tasks', 'style');
-OCP\Util::addScript('contacts','jquery.multi-autocomplete');
-OCP\Util::addScript('','oc-vcategories');
+OCP\Util::addScript('contacts', 'jquery.multi-autocomplete');
+OCP\Util::addScript('', 'oc-vcategories');
OCP\App::setActiveNavigationEntry('tasks_index');
$categories = OC_Calendar_App::getCategoryOptions();
diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js
index bc92965bb0b..de627927507 100644
--- a/apps/tasks/js/tasks.js
+++ b/apps/tasks/js/tasks.js
@@ -469,67 +469,5 @@ $(document).ready(function(){
return false;
});
- $('#tasks_addtaskform input[type="submit"]').live('click',function(){
- $.post('ajax/addtask.php',$('#tasks_addtaskform').serialize(),function(jsondata){
- if(jsondata.status == 'success'){
- $('#task_details').data('id',jsondata.data.id);
- $('#task_details').html(jsondata.data.page);
- $('#tasks_list').append(OC.Tasks.create_task_div(jsondata.data.task));
- }
- else{
- alert(jsondata.data.message);
- }
- }, 'json');
- return false;
- });
-
- $('#tasks_edit').live('click',function(){
- var id = $('#task_details').data('id');
- $.getJSON('ajax/edittaskform.php',{'id':id},function(jsondata){
- if(jsondata.status == 'success'){
- $('#task_details').html(jsondata.data.page);
- $('#task_details #categories').multiple_autocomplete({source: categories});
- }
- else{
- alert(jsondata.data.message);
- }
- });
- return false;
- });
-
- $('#tasks_edittaskform #percent_complete').live('change',function(event){
- if ($(event.target).val() == 100){
- $('#tasks_edittaskform #complete').show();
- }else{
- $('#tasks_edittaskform #complete').hide();
- }
- });
-
- $('#tasks_edittaskform input[type="submit"]').live('click',function(){
- $.post('ajax/edittask.php',$('#tasks_edittaskform').serialize(),function(jsondata){
- $('.error_msg').remove();
- $('.error').removeClass('error');
- if(jsondata.status == 'success'){
- var id = jsondata.data.id;
- $('#task_details').data('id',id);
- $('#task_details').html(jsondata.data.page);
- var task = jsondata.data.task;
- $('#tasks .task[data-id='+id+']')
- .data('task', task)
- .html(OC.Tasks.create_task_div(task).html());
- }
- else{
- var errors = jsondata.data.errors;
- for (k in errors){
- $('#'+k).addClass('error')
- .after('<span class="error_msg">'+errors[k]+'</span>');
- }
- $('.error_msg').effect('highlight', {}, 3000);
- $('.error').effect('highlight', {}, 3000);
- }
- }, 'json');
- return false;
- });
-
OCCategories.app = 'calendar';
});
diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php
index 1b42968f0be..a97c6b95d1d 100644
--- a/apps/tasks/lib/app.php
+++ b/apps/tasks/lib/app.php
@@ -77,24 +77,24 @@ class OC_Task_App {
public static function validateRequest($request)
{
$errors = array();
- if($request['summary'] == ''){
+ if($request['summary'] == '') {
$errors['summary'] = self::$l10n->t('Empty Summary');
}
try {
- $timezone = OCP\Config::getUserValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London");
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
new DateTime($request['due'], $timezone);
} catch (Exception $e) {
$errors['due'] = self::$l10n->t('Invalid date/time');
}
- if ($request['percent_complete'] < 0 || $request['percent_complete'] > 100){
+ if ($request['percent_complete'] < 0 || $request['percent_complete'] > 100) {
$errors['percent_complete'] = self::$l10n->t('Invalid percent complete');
}
- if ($request['percent_complete'] == 100 && !empty($request['completed'])){
+ if ($request['percent_complete'] == 100 && !empty($request['completed'])) {
try {
- $timezone = OCP\Config::getUserValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London");
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
new DateTime($request['completed'], $timezone);
} catch (Exception $e) {
@@ -147,7 +147,7 @@ class OC_Task_App {
$vtodo->setString('PRIORITY', $priority);
if ($due) {
- $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
$due = new DateTime($due, $timezone);
$vtodo->setDateTime('DUE', $due);
@@ -168,15 +168,15 @@ class OC_Task_App {
$vtodo->__unset('PERCENT-COMPLETE');
}
- if ($percent_complete == 100){
- if (!$completed){
+ if ($percent_complete == 100) {
+ if (!$completed) {
$completed = 'now';
}
} else {
$completed = null;
}
if ($completed) {
- $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $timezone = OC_Calendar_App::getTimezone();
$timezone = new DateTimeZone($timezone);
$completed = new DateTime($completed, $timezone);
$vtodo->setDateTime('COMPLETED', $completed);
diff --git a/apps/tasks/templates/part.addtaskform.php b/apps/tasks/templates/part.addtaskform.php
deleted file mode 100644
index 0fad5592aa7..00000000000
--- a/apps/tasks/templates/part.addtaskform.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<form id="tasks_addtaskform">
- <?php if(count($_['calendars'])==1): ?>
- <input type="hidden" name="id" value="<?php echo $_['calendars'][0]['id']; ?>">
- <?php else: ?>
- <label for="id"><?php echo $l->t('Calendar'); ?></label>
- <select name="id" size="1">
- <?php foreach($_['calendars'] as $calendar): ?>
- <option value="<?php echo $calendar['id']; ?>"><?php echo $calendar['displayname']; ?></option>
- <?php endforeach; ?>
- </select>
- <br>
- <?php endif; ?>
- <?php echo $this->inc('part.taskform'); ?>
- <input type="submit" name="submit" value="<?php echo $l->t('Create Task'); ?>">
-</form>
diff --git a/apps/tasks/templates/part.details.php b/apps/tasks/templates/part.details.php
deleted file mode 100644
index 89636b6e762..00000000000
--- a/apps/tasks/templates/part.details.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php if(isset($_['details']->SUMMARY)): ?>
-<table>
-<?php
-echo $this->inc('part.property', array('label' => $l->t('Summary'), 'property' => $_['details']->SUMMARY));
-if(isset($_['details']->LOCATION)):
- echo $this->inc('part.property', array('label' => $l->t('Location'), 'property' => $_['details']->LOCATION));
-endif;
-if(isset($_['details']->CATEGORIES)):
- echo $this->inc('part.property', array('label' => $l->t('Categories'), 'property' => $_['details']->CATEGORIES));
-endif;
-if(isset($_['details']->DUE)):
- echo $this->inc('part.property', array('label' => $l->t('Due'), 'property' => $_['details']->DUE[0]));
-endif;
-if(isset($_['details']->PRIORITY)):
- echo $this->inc('part.property', array('label' => $l->t('Priority'), 'property' => $_['details']->PRIORITY[0], 'options' => $_['priority_options']));
-endif;
-if($_['details']->__isset('PERCENT-COMPLETE') || isset($_['details']->COMPLETED)):
-?>
-<tr>
- <th>
- <?php echo $l->t('Complete') ?>
- </th>
- <td>
-<?php if($_['details']->__isset('PERCENT-COMPLETE')):
- echo $_['details']->__get('PERCENT-COMPLETE')->value.' % ';
- endif;
- if(isset($_['details']->COMPLETED)):
- echo $l->t('on '). $l->l('datetime', $_['details']->COMPLETED[0]->getDateTime());
- endif;
- echo '</tr>';
-endif;
-if(isset($_['details']->DESCRIPTION)):
- echo $this->inc('part.property', array('label' => $l->t('Description'), 'property' => $_['details']->DESCRIPTION));
-endif; ?>
-</table>
-<form>
- <input type="button" id="tasks_delete" value="<?php echo $l->t('Delete');?>">
- <input type="button" id="tasks_edit" value="<?php echo $l->t('Edit');?>">
-</form>
-<?php else: ?>
-<?php //var_dump($_['details']); ?>
-<?php endif ?>
diff --git a/apps/tasks/templates/part.edittaskform.php b/apps/tasks/templates/part.edittaskform.php
deleted file mode 100644
index fe123f07ac6..00000000000
--- a/apps/tasks/templates/part.edittaskform.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<form id="tasks_edittaskform">
- <input type="hidden" name="id" value="<?php echo $_['id']; ?>">
- <?php echo $this->inc('part.taskform'); ?>
- <input type="submit" name="submit" value="<?php echo $l->t('Update Task'); ?>">
-</form>
diff --git a/apps/tasks/templates/part.property.php b/apps/tasks/templates/part.property.php
deleted file mode 100644
index 591fd363e6f..00000000000
--- a/apps/tasks/templates/part.property.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<tr>
- <th>
- <?php echo $_['label'] ?>
- </th>
- <td>
- <?php
- switch (get_class($_['property']))
- {
- case 'Sabre_VObject_Element_DateTime':
- echo $l->l('datetime', $_['property']->getDateTime());
- break;
- default:
- $value = $_['property']->value;
- if (isset($_['options']))
- {
- $value = $_['options'][$value];
- }
- echo nl2br($value);
- }
- ?>
- </td>
-</tr>
diff --git a/apps/tasks/templates/part.taskform.php b/apps/tasks/templates/part.taskform.php
deleted file mode 100644
index 0a25ed33c91..00000000000
--- a/apps/tasks/templates/part.taskform.php
+++ /dev/null
@@ -1,36 +0,0 @@
- <label for="summary"><?php echo $l->t('Summary'); ?></label>
- <input type="text" id="summary" name="summary" placeholder="<?php echo $l->t('Summary of the task');?>" value="<?php echo isset($_['details']->SUMMARY) ? $_['details']->SUMMARY[0]->value : '' ?>">
- <br>
- <label for="location"><?php echo $l->t('Location'); ?></label>
- <input type="text" id="location" name="location" placeholder="<?php echo $l->t('Location of the task');?>" value="<?php echo isset($_['details']->LOCATION) ? $_['details']->LOCATION[0]->value : '' ?>">
- <br>
- <label for="categories"><?php echo $l->t('Categories'); ?></label>
- <input id="categories" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? $_['categories'] : '' ?>">
- <a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo OCP\image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a>
- <br>
- <label for="due"><?php echo $l->t('Due'); ?></label>
- <input type="text" id="due" name="due" placeholder="<?php echo $l->t('Due date') ?>" value="<?php echo isset($_['details']->DUE) ? $l->l('datetime', $_['details']->DUE[0]->getDateTime()) : '' ?>">
- <br>
- <select name="percent_complete" id="percent_complete">
- <?php
- foreach($_['percent_options'] as $percent){
- echo '<option value="' . $percent . '"' . (($_['details']->__get('PERCENT-COMPLETE') && $percent == $_['details']->__get('PERCENT-COMPLETE')->value) ? ' selected="selected"' : '') . '>' . $percent . ' %</option>';
- }
- ?>
- </select>
- <label for="percent_complete"><?php echo $l->t('Complete'); ?></label>
- <span id="complete"<?php echo ($_['details']->__get('PERCENT-COMPLETE') && $_['details']->__get('PERCENT-COMPLETE')->value == 100) ? '' : ' style="display:none;"' ?>><label for="completed"><?php echo $l->t('completed on'); ?></label>
- <input type="text" id="completed" name="completed" value="<?php echo isset($_['details']->COMPLETED) ? $l->l('datetime', $_['details']->COMPLETED[0]->getDateTime()) : '' ?>"></span>
- <br>
- <label for="priority"><?php echo $l->t('Priority'); ?></label>
- <select name="priority">
- <?php
- foreach($_['priority_options'] as $priority => $label){
- echo '<option value="' . $priority . '"' . ((isset($_['details']->PRIORITY) && $priority == $_['details']->PRIORITY->value) ? ' selected="selected"' : '') . '>' . $label . '</option>';
- }
- ?>
- </select>
- <br>
- <label for="description"><?php echo $l->t('Description'); ?></label><br>
- <textarea placeholder="<?php echo $l->t('Description of the task');?>" name="description"><?php echo isset($_['details']->DESCRIPTION) ? $_['details']->DESCRIPTION[0]->value : '' ?></textarea>
- <br>
diff --git a/apps/tasks/templates/part.tasks.php b/apps/tasks/templates/part.tasks.php
deleted file mode 100644
index 50be1cd6bed..00000000000
--- a/apps/tasks/templates/part.tasks.php
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php foreach( $_['tasks'] as $task ): ?>
- <li data-id="<?php echo $task['id']; ?>"><a href="index.php?id=<?php echo $task['id']; ?>"><?php echo $task['name']; ?></a> </li>
-<?php endforeach; ?>
diff --git a/apps/user_external/appinfo/app.php b/apps/user_external/appinfo/app.php
new file mode 100644
index 00000000000..c7408ec30d9
--- /dev/null
+++ b/apps/user_external/appinfo/app.php
@@ -0,0 +1,4 @@
+<?php
+OC::$CLASSPATH['OC_User_IMAP']='apps/user_external/lib/imap.php';
+OC::$CLASSPATH['OC_User_SMB']='apps/user_external/lib/smb.php';
+OC::$CLASSPATH['OC_User_FTP']='apps/user_external/lib/ftp.php';
diff --git a/apps/user_external/appinfo/info.xml b/apps/user_external/appinfo/info.xml
new file mode 100644
index 00000000000..1d1dcee5401
--- /dev/null
+++ b/apps/user_external/appinfo/info.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<info>
+ <id>user_external</id>
+ <name>External user support</name>
+ <description>Use external user authentication methods</description>
+ <licence>AGPL</licence>
+ <author>Robin Appelman</author>
+ <require>4</require>
+ <shipped>true</shipped>
+ <types>
+ <authentication/>
+ </types>
+</info>
diff --git a/apps/user_external/appinfo/version b/apps/user_external/appinfo/version
new file mode 100644
index 00000000000..ceab6e11ece
--- /dev/null
+++ b/apps/user_external/appinfo/version
@@ -0,0 +1 @@
+0.1 \ No newline at end of file
diff --git a/apps/user_external/lib/ftp.php b/apps/user_external/lib/ftp.php
new file mode 100644
index 00000000000..e03e17d2b6a
--- /dev/null
+++ b/apps/user_external/lib/ftp.php
@@ -0,0 +1,45 @@
+<?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_User_FTP extends OC_User_Backend{
+ private $host;
+ private $secure;
+ private $protocol;
+
+ public function __construct($host,$secure=false){
+ $this->host=$host;
+ $this->secure=$secure;
+ $this->protocol='ftp';
+ if($this->secure){
+ $this->protocol.='s';
+ }
+ $this->protocol.='://';
+ }
+
+ /**
+ * @brief Check if the password is correct
+ * @param $uid The username
+ * @param $password The password
+ * @returns true/false
+ *
+ * Check if the password is correct without logging in the user
+ */
+ public function checkPassword($uid, $password){
+ $url=$this->protocol.$uid.':'.$password.'@'.$this->host.'/';
+ $result=@opendir($url);
+ if(is_resource($result)){
+ return $uid;
+ }else{
+ return false;
+ }
+ }
+
+ public function userExists($uid){
+ return true;
+ }
+}
diff --git a/apps/user_external/lib/imap.php b/apps/user_external/lib/imap.php
new file mode 100644
index 00000000000..584e9804b18
--- /dev/null
+++ b/apps/user_external/lib/imap.php
@@ -0,0 +1,40 @@
+<?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_User_IMAP extends OC_User_Backend{
+ private $mailbox;
+
+ public function __construct($mailbox){
+ $this->mailbox=$mailbox;
+ }
+
+ /**
+ * @brief Check if the password is correct
+ * @param $uid The username
+ * @param $password The password
+ * @returns true/false
+ *
+ * Check if the password is correct without logging in the user
+ */
+ public function checkPassword($uid, $password){
+ $mbox = @imap_open($this->mailbox, $uid, $password);
+ imap_errors();
+ imap_alerts();
+ if($mbox){
+ imap_close($mbox);
+ return $uid;
+ }else{
+ return false;
+ }
+ }
+
+ public function userExists($uid){
+ return true;
+ }
+}
+
diff --git a/apps/user_external/lib/smb.php b/apps/user_external/lib/smb.php
new file mode 100644
index 00000000000..44d2b7903d8
--- /dev/null
+++ b/apps/user_external/lib/smb.php
@@ -0,0 +1,43 @@
+<?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_User_SMB extends OC_User_Backend{
+ private $host;
+
+ const smbclient='smbclient';
+ const loginError='NT_STATUS_LOGON_FAILURE';
+
+ public function __construct($host){
+ $this->host=$host;
+ }
+
+ /**
+ * @brief Check if the password is correct
+ * @param $uid The username
+ * @param $password The password
+ * @returns true/false
+ *
+ * Check if the password is correct without logging in the user
+ */
+ public function checkPassword($uid, $password){
+ $uidEscaped=escapeshellarg($uid);
+ $password=escapeshellarg($password);
+ $result=array();
+ $command=self::smbclient.' //'.$this->host.'/dummy -U'.$uidEscaped.'%'.$password;
+ $result=exec($command,$result);
+ if(substr($result,-strlen(self::loginError))==self::loginError){
+ return false;
+ }else{
+ return $uid;
+ }
+ }
+
+ public function userExists($uid){
+ return true;
+ }
+} \ No newline at end of file
diff --git a/apps/user_external/tests/config.php b/apps/user_external/tests/config.php
new file mode 100644
index 00000000000..64ee141d32d
--- /dev/null
+++ b/apps/user_external/tests/config.php
@@ -0,0 +1,28 @@
+<?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.
+ */
+
+return array(
+ 'imap'=>array(
+ 'run'=>false,
+ 'mailbox'=>'{imap.gmail.com:993/imap/ssl}INBOX', //see http://php.net/manual/en/function.imap-open.php
+ 'user'=>'foo',//valid username/password combination
+ 'password'=>'bar',
+ ),
+ 'smb'=>array(
+ 'run'=>false,
+ 'host'=>'localhost',
+ 'user'=>'test',//valid username/password combination
+ 'password'=>'test',
+ ),
+ 'ftp'=>array(
+ 'run'=>false,
+ 'host'=>'localhost',
+ 'user'=>'test',//valid username/password combination
+ 'password'=>'test',
+ ),
+);
diff --git a/apps/user_external/tests/ftp.php b/apps/user_external/tests/ftp.php
new file mode 100644
index 00000000000..0cf7565f9c6
--- /dev/null
+++ b/apps/user_external/tests/ftp.php
@@ -0,0 +1,34 @@
+<?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 Test_User_FTP extends UnitTestCase{
+ /**
+ * @var OC_User_IMAP $instance
+ */
+ private $instance;
+
+ private function getConfig(){
+ return include(__DIR__.'/config.php');
+ }
+
+ function skip(){
+ $config=$this->getConfig();
+ $this->skipUnless($config['ftp']['run']);
+ }
+
+ function setUp(){
+ $config=$this->getConfig();
+ $this->instance=new OC_User_FTP($config['ftp']['host']);
+ }
+
+ function testLogin(){
+ $config=$this->getConfig();
+ $this->assertEqual($config['ftp']['user'],$this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password']));
+ $this->assertFalse($this->instance->checkPassword($config['ftp']['user'],$config['ftp']['password'].'foo'));
+ }
+}
diff --git a/apps/user_external/tests/imap.php b/apps/user_external/tests/imap.php
new file mode 100644
index 00000000000..c703b32107f
--- /dev/null
+++ b/apps/user_external/tests/imap.php
@@ -0,0 +1,34 @@
+<?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 Test_User_Imap extends UnitTestCase{
+ /**
+ * @var OC_User_IMAP $instance
+ */
+ private $instance;
+
+ private function getConfig(){
+ return include(__DIR__.'/config.php');
+ }
+
+ function skip(){
+ $config=$this->getConfig();
+ $this->skipUnless($config['imap']['run']);
+ }
+
+ function setUp(){
+ $config=$this->getConfig();
+ $this->instance=new OC_User_IMAP($config['imap']['mailbox']);
+ }
+
+ function testLogin(){
+ $config=$this->getConfig();
+ $this->assertEqual($config['imap']['user'],$this->instance->checkPassword($config['imap']['user'],$config['imap']['password']));
+ $this->assertFalse($this->instance->checkPassword($config['imap']['user'],$config['imap']['password'].'foo'));
+ }
+}
diff --git a/apps/user_external/tests/smb.php b/apps/user_external/tests/smb.php
new file mode 100644
index 00000000000..1ed7eb934be
--- /dev/null
+++ b/apps/user_external/tests/smb.php
@@ -0,0 +1,34 @@
+<?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 Test_User_SMB extends UnitTestCase{
+ /**
+ * @var OC_User_IMAP $instance
+ */
+ private $instance;
+
+ private function getConfig(){
+ return include(__DIR__.'/config.php');
+ }
+
+ function skip(){
+ $config=$this->getConfig();
+ $this->skipUnless($config['smb']['run']);
+ }
+
+ function setUp(){
+ $config=$this->getConfig();
+ $this->instance=new OC_User_SMB($config['smb']['host']);
+ }
+
+ function testLogin(){
+ $config=$this->getConfig();
+ $this->assertEqual($config['smb']['user'],$this->instance->checkPassword($config['smb']['user'],$config['smb']['password']));
+ $this->assertFalse($this->instance->checkPassword($config['smb']['user'],$config['smb']['password'].'foo'));
+ }
+}
diff --git a/apps/user_webfinger/.htaccess b/apps/user_webfinger/.htaccess
new file mode 100644
index 00000000000..1b13cf788ff
--- /dev/null
+++ b/apps/user_webfinger/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+RewriteEngine on
+RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+RewriteRule ^host-meta host-meta.php [QSA,L]
+</IfModule>
diff --git a/apps/user_webfinger/host-meta.php b/apps/user_webfinger/host-meta.php
index 32ffb512057..4ac37b1ea09 100644
--- a/apps/user_webfinger/host-meta.php
+++ b/apps/user_webfinger/host-meta.php
@@ -1,10 +1,27 @@
<?php
+
+if(class_exists('OC')){
+ $WEBROOT=OC::$WEBROOT;
+}else{//not called trough remote.php try to guess the webroot the best we can from here
+ // calculate the root directories
+ $SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-strlen('apps/user_webfinger/host-meta.php')));
+ $WEBROOT=substr($SERVERROOT,strlen(realpath($_SERVER['DOCUMENT_ROOT'])));
+
+ if($WEBROOT!='' and $WEBROOT[0]!=='/'){
+ $WEBROOT='/'.$WEBROOT;
+ }
+}
+
+if(substr($WEBROOT,-1)==='/'){
+ $WEBROOT=substr($WEBROOT,0,-1);
+}
+
$hostMetaHeader = array(
'Access-Control-Allow-Origin' => '*',
'Content-Type' => 'application/xrd+json'
);
$serverName = $_SERVER['SERVER_NAME'];
-$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.'/public.php?service=webfinger&q={uri}"}]}';
+$hostMetaContents = '{"links":[{"rel":"lrdd","template":"http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$serverName.$WEBROOT.'/public.php?service=webfinger&q={uri}"}]}';
foreach($hostMetaHeader as $header => $value) {
header($header . ": " . $value);
}