diff options
62 files changed, 376 insertions, 224 deletions
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index d66aab58960..6b5a0f71d4e 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -31,5 +31,5 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); -$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']); +$id = addBookmark($_POST['url'], $_POST['title'], $_POST['tags']); OCP\JSON::success(array('data' => $id));
\ No newline at end of file diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index 01b551111e0..92baac2f511 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -90,7 +90,8 @@ function addBookmark($url, $title, $tags='') { if(empty($title)) { $metadata = getURLMetadata($url); - $title = $metadata['title']; + if(isset($metadata['title'])) // Check for problems fetching the title + $title = $metadata['title']; } if(empty($title)) { diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php index dbe673f53a8..357e0a18f25 100644 --- a/apps/bookmarks/templates/addBm.php +++ b/apps/bookmarks/templates/addBm.php @@ -3,9 +3,9 @@ <head> <meta charset="utf-8"> <title>Read later - ownCloud</title> - <link rel="stylesheet" href="css/readlater.css"> </head> <body> <div class="message"><h1>Saved!</h1></div> + <a href="javascript:self.close()" >Close the window</a> </body> </html>
\ No newline at end of file diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 26a0cc2a60a..86dff7b75a7 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -28,7 +28,7 @@ $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { case Sabre_VObject_Property_DateTime::UTC: - $timeOffset = OC_Calendar_App::$tz*60; + $timeOffset = $_SESSION['timezone']*60; $newDT = $dtstart->getDateTime(); $newDT->add(new DateInterval("PT" . $timeOffset . "M")); $dtstart->setDateTime($newDT); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 8e13b13b8a3..344c89f36b0 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -194,6 +194,9 @@ class OC_Calendar_App{ } else if (isset($calendar->VTODO)) { $object = $calendar->VTODO; + } else + if (isset($calendar->VJOURNAL)) { + $object = $calendar->VJOURNAL; } if ($object) { self::getVCategories()->loadFromVObject($object, true); diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index f888b94e386..1b6db0c8f81 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -25,11 +25,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/addproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php index bee2dbe3f6b..76c23d6487d 100644 --- a/apps/contacts/ajax/categories/delete.php +++ b/apps/contacts/ajax/categories/delete.php @@ -10,18 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.print_r($element, true)); -} - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG); -} +require_once('../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 84a67dec0b1..48ec165381f 100644 --- a/apps/contacts/ajax/categories/rescan.php +++ b/apps/contacts/ajax/categories/rescan.php @@ -10,18 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.print_r($element, true)); -} - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); -} +require_once('../loghandler.php'); $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser()); if(count($addressbooks) == 0) { diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index a6ca10f9c94..b697b1a8e5b 100644 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -20,11 +20,7 @@ * */ -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); // Check if we are a user OCP\JSON::checkLoggedIn(); diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index 16730ec9474..4bb7801cb2d 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -18,7 +18,6 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); -error_log('active_addressbooks: '.print_r($active_addressbooks, true)); $contacts_addressbook = array(); $ids = array(); @@ -29,9 +28,7 @@ foreach($active_addressbooks as $addressbook) { $contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname']; } } -error_log('ids: '.print_r($ids, true)); $contacts_alphabet = OC_Contacts_VCard::all($ids); -error_log('contacts_alphabet: '.print_r($contacts_alphabet, true)); // Our new array for the contacts sorted by addressbook foreach($contacts_alphabet as $contact) { @@ -48,7 +45,7 @@ foreach($contacts_alphabet as $contact) { } $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display)); } - +unset($contacts_alphabet); uasort($contacts_addressbook, 'cmp'); $tmpl = new OCP\Template("contacts", "part.contacts"); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 616766bb1a0..2ec5f542bb3 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -12,25 +12,20 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once('loghandler.php'); $userid = OCP\USER::getUser(); $name = trim(strip_tags($_POST['name'])); if(!$name) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); - exit(); + bailOut('Cannot add addressbook with an empty name.'); } $bookid = OC_Contacts_Addressbook::add($userid, $name, null); if(!$bookid) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR); - exit(); + bailOut('Error adding addressbook: '.$name); } if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR); - //exit(); + bailOut('Error activating addressbook.'); } $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php index 5f90128f321..b10e752c453 100644 --- a/apps/contacts/ajax/currentphoto.php +++ b/apps/contacts/ajax/currentphoto.php @@ -24,11 +24,7 @@ OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR); - exit(); -} +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 2a6bd277d19..1161c18abda 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -19,26 +19,21 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} - // Check if we are a user 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) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: _POST: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG); -} -foreach($_GET as $key=>$value) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: _GET: '.$key.'=>'.print_r($value, true), 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)); +// } $id = isset($_POST['id'])?$_POST['id']:null; if(!$id) { diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 55f7e323083..90e5e64903e 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -24,6 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once('loghandler.php'); $id = $_POST['id']; $checksum = $_POST['checksum']; @@ -31,16 +32,14 @@ $checksum = $_POST['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)){ - OCP\JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); + bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')); exit(); } unset($vcard->children[$line]); if(!OC_Contacts_VCard::edit($id,$vcard)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); - OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.')); } OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 62cae894b6f..868ca222e0a 100644 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -9,11 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $tmpl = new OCP\Template("contacts", "part.edit_name_dialog"); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index eac7ca7d02f..61b5356edce 100644 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -24,11 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +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 new file mode 100644 index 00000000000..831b2e50c1e --- /dev/null +++ b/apps/contacts/ajax/loghandler.php @@ -0,0 +1,40 @@ +<?php +/** + * ownCloud - Addressbook + * + * @author Thomas Tanghus + * @copyright 2012 Thomas Tanghus <thomas@tanghus.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +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) { + if(PHP_VERSION >= "5.4") { + $call = debug_backtrace(false, $tracelevel+1); + } else { + $call = debug_backtrace(false); + } + error_log('trace: '.print_r($call, true)); + $call = $call[$tracelevel]; + if($debuglevel !== false) { + OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel); + } +} diff --git a/apps/contacts/ajax/movetoaddressbook.php b/apps/contacts/ajax/movetoaddressbook.php new file mode 100644 index 00000000000..a3336c3cb6c --- /dev/null +++ b/apps/contacts/ajax/movetoaddressbook.php @@ -0,0 +1,41 @@ +<?php +/** +* @author Victor Dubiniuk +* Copyright (c) 2012 Victor Dubiniuk <victor.dubiniuk@gmail.com> +* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net> +* This file is licensed under the Affero General Public License version 3 or +* later. +* See the COPYING-README file. +*/ + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); +OCP\JSON::callCheck(); + +$ids = $_POST['ids']; +$aid = intval($_POST['aid']); +OC_Contacts_App::getAddressbook($aid); + +if(!is_array($ids)) { + $ids = array($ids,); +} +$goodids = array(); +foreach ($ids as $id){ + try { + $card = OC_Contacts_App::getContactObject( intval($id) ); + if($card) { + $goodids[] = $id; + } + } catch (Exception $e) { + OCP\Util::writeLog('contacts', 'Error moving contact "'.$id.'" to addressbook "'.$aid.'"'.$e->getMessage(), OCP\Util::ERROR); + } +} +try { + OC_Contacts_VCard::moveToAddressBook($aid, $ids); +} catch (Exception $e) { + $msg = $e->getMessage(); + OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $ids).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR); + OC_JSON::error(array('data' => array('message' => $msg,))); +} + +OC_JSON::success(array('data' => array('ids' => $goodids,)));
\ No newline at end of file diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php index ea25ebf1763..5c50ba92dbe 100644 --- a/apps/contacts/ajax/oc_photo.php +++ b/apps/contacts/ajax/oc_photo.php @@ -22,11 +22,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR); - exit(); -} +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/savecrop.php b/apps/contacts/ajax/savecrop.php index 6faf6a173d5..adce6be3b39 100644 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -27,11 +27,7 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $image = null; diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 6ee9ec90b56..34fc3cc5351 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -19,21 +19,11 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); -} - +require_once('loghandler.php'); // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); - $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; $value = isset($_POST['value'])?$_POST['value']:null; diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index 19b5b3bddce..d3a772c727f 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -11,27 +11,22 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); +require_once('loghandler.php'); $bookid = $_POST['id']; OC_Contacts_App::getAddressbook($bookid); // is owner access check $name = trim(strip_tags($_POST['name'])); if(!$name) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')); } if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR); - //exit(); + bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.')); } if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR); - //exit(); + bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')); } $addressbook = OC_Contacts_App::getAddressbook($bookid); diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php index 463ca161e56..c1e9c8b1ad1 100644 --- a/apps/contacts/ajax/uploadimport.php +++ b/apps/contacts/ajax/uploadimport.php @@ -23,11 +23,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR); - exit(); -} +require_once('loghandler.php'); $view = OCP\Files::getStorage('contacts'); $tmpfile = md5(rand()); diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php index 889de6a1f8b..8545ca84eee 100644 --- a/apps/contacts/ajax/uploadphoto.php +++ b/apps/contacts/ajax/uploadphoto.php @@ -27,14 +27,7 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG); -} +require_once('loghandler.php'); // 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); diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index 6c65db2b772..1766c28761e 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -5,9 +5,12 @@ #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 { 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; } #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-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;} #contacts_newcontact { float: left; margin: 0.2em 0 0 1em; } #chooseaddressbook { float: right; margin: 0.2em 1em 0 0; } @@ -16,7 +19,7 @@ #contacts_downloadcard {position:relative; float:left; background:url('%webroot%/core/img/actions/download.svg') no-repeat center; } #contacts_propertymenu { clear: both; max-width: 15em; margin: 2em; } #contacts_propertymenu_button { position:relative;top:0;left:0; margin: 0; } -#contacts_propertymenu_dropdown { background-color: #fff; position:relative; right:0; overflow:hidden; text-overflow:ellipsis; /*border: thin solid #1d2d44;*/ -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; } +#contacts_propertymenu_dropdown { background-color: #fff; position:relative; right:0; overflow:hidden; text-overflow:ellipsis; border: thin solid #1d2d44; box-shadow: 0 3px 5px #bbb; /* -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; -moz-border-radius:0.5em; -webkit-border-radius:0.5em;*/ border-radius: 3px; } #contacts_propertymenu li { display: block; font-weight: bold; height: 20px; } #contacts_propertymenu li a { padding: 3px; display: block } #contacts_propertymenu li:hover { background-color: #1d2d44; } @@ -30,7 +33,7 @@ #card input[type="text"],input[type="email"],input[type="url"],input[type="tel"],input[type="date"], select, textarea { background-color: #fefefe; border: 0 !important; -webkit-appearance:none !important; -moz-appearance:none !important; -webkit-box-sizing:none !important; -moz-box-sizing:none !important; box-sizing:none !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; float: left; } #card input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,input[type="email"]:hover,input[type="url"]:hover,input[type="tel"]:hover,input[type="date"]:hover,input[type="date"],input[type="date"]:hover,input[type="date"]:active,input[type="date"]:active,input[type="date"]:active,input[type="email"]:active,input[type="url"]:active,input[type="tel"]:active, select:hover, select:focus, select:active, textarea:focus, textarea:hover { border: 0 !important; -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #ddd, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; } textarea { width: 80%; min-height: 5em; min-width: 30em; margin: 0 !important; padding: 0 !important; outline: 0 !important;} -dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; } +dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; cursor: normal; } .form dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom; color: #bbb;/* white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap;*/ } .form dd { display: table-cell; clear: right; float: left; margin: 0; padding: 0px; white-space: nowrap; vertical-align: text-bottom; } label:hover, dt:hover { color: #333; } @@ -70,7 +73,7 @@ label:hover, dt:hover { color: #333; } .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;*/ } #cropbox { margin: auto; } -#contacts_details_photo_wrapper { min-width: 80px; } +#contacts_details_photo_wrapper { min-width: 120px; } #contacts_details_photo_wrapper.wait { opacity: 0.6; filter:alpha(opacity=0.6); z-index:1000; background: url('%webroot%/core/img/loading.gif') no-repeat center center; cursor: wait; } #contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; margin: 0.3em; background: url('%webroot%/core/img/loading.gif') no-repeat center center; -moz-box-shadow: 0 1px 3px #777; -webkit-box-shadow: 0 1px 3px #777; box-shadow: 0 1px 3px #777; } #contacts_details_photo:hover { background: #fff; cursor: default; } diff --git a/apps/contacts/index.php b/apps/contacts/index.php index bdb52c123ce..f6b37409ea7 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -28,6 +28,7 @@ $details = array(); if(is_null($id) && count($contacts) > 0) { $id = $contacts[0]['id']; } +unset($contacts); if(!is_null($id)) { $vcard = OC_Contacts_App::getContactVCard($id); $details = OC_Contacts_VCard::structureContact($vcard); @@ -66,7 +67,6 @@ $tmpl->assign('phone_types', $phone_types); $tmpl->assign('email_types', $email_types); $tmpl->assign('categories', $categories); $tmpl->assign('addressbooks', $addressbooks); -$tmpl->assign('contacts', $contacts, false); $tmpl->assign('details', $details ); $tmpl->assign('id',$id); $tmpl->printPage(); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 6f5602c2112..036734049b6 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -314,6 +314,7 @@ Contacts={ return false; }, add:function(n, fn, aid, isnew){ // add a new contact + aid = aid?aid:$('#contacts h3.active').first().data('id'); var localAddcontact = function(n, fn, aid, isnew) { $.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew }, function(jsondata) { @@ -380,12 +381,12 @@ Contacts={ if(jsondata.status == 'success'){ var newid = '', bookid; var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]'); - var newlistitem = curlistitem.prev(); + var newlistitem = curlistitem.prev('li'); if(newlistitem == undefined) { - newlistitem = curlistitem.next(); + newlistitem = curlistitem.next('li'); } curlistitem.remove(); - if(newlistitem != undefined) { + if(!$(newlistitem).is('li')) { newid = newlistitem.data('id'); bookid = newlistitem.data('id'); } @@ -1504,6 +1505,36 @@ Contacts={ } }, Contacts:{ + drop:function(event, ui) { + var dragitem = ui.draggable, droptarget = $(this); + //console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id')); + 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') }, + function(jsondata){ + if(jsondata.status == 'success'){ + // Do some inserting/removing/sorting magic + var name = $(dragitem).find('a').html(); + var added = false; + $(droplist).children().each(function(){ + if ($(this).text().toLowerCase() > name.toLowerCase()) { + $(this).before(dragitem.detach()); //.fadeIn('slow'); + added = true; + return false; + } + }); + if(!added) { + $(droplist).append(dragitem.detach()); + } + dragitem.data('bookid', droptarget.data('id')); + Contacts.UI.Contacts.scrollTo(dragitem.data('id')); + } else { + OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); + } + }); + }, // Reload the contacts list. update:function(id){ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){ @@ -1519,6 +1550,23 @@ Contacts={ } })}, 100); setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/ + if($('#contacts h3').length > 1) { + $('#contacts h3,#contacts ul').each(function(index) { + var id = $(this).data('id'); + var accept = 'li:not([data-bookid="'+id+'"])'; + $(this).droppable({ + drop: Contacts.UI.Contacts.drop, + activeClass: 'ui-state-hover', + accept: accept + }); + }); + $('#contacts li').draggable({ + revert: 'invalid', + axis: 'y', containment: '#contacts', + scroll: true, scrollSensitivity: 100, + opacity: 0.7, helper: 'clone' + }); + } }); Contacts.UI.Card.update(id); } @@ -1605,6 +1653,8 @@ $(document).ready(function(){ }); $(document).on('click', '.addressbook', function(event){ + $('#contacts h3').removeClass('active'); + $(this).addClass('active'); $(this).next().slideToggle(300); return false; }); diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php index e74b465a47b..0a920fc519d 100644 --- a/apps/contacts/lib/hooks.php +++ b/apps/contacts/lib/hooks.php @@ -21,6 +21,15 @@ */ /** + * The following signals are being emitted: + * + * OC_Contacts_VCard::post_moveToAddressbook(array('aid' => $aid, 'id' => $id)) + * OC_Contacts_VCard::pre_deleteVCard(array('aid' => $aid, 'id' => $id, 'uri' = $uri)); (NOTE: the values can be null depending on which method emits them) + * OC_Contacts_VCard::post_updateVCard($id) + * OC_Contacts_VCard::post_createVCard($newid) + */ + +/** * This class contains all hooks. */ class OC_Contacts_Hooks{ diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 110d721ace0..0f3a08844b1 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -293,7 +293,7 @@ class OC_Contacts_VCard{ $newid = OCP\DB::insertid('*PREFIX*contacts_cards'); OC_Contacts_Addressbook::touch($aid); - + OC_Hook::emit('OC_Contacts_VCard', 'post_createVCard', $newid); return $newid; } @@ -360,7 +360,7 @@ class OC_Contacts_VCard{ $result = $stmt->execute(array($fn,$data,time(),$id)); OC_Contacts_Addressbook::touch($oldcard['addressbookid']); - + OC_Hook::emit('OC_Contacts_VCard', 'post_updateVCard', $id); return true; } @@ -388,6 +388,7 @@ class OC_Contacts_VCard{ */ 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 = ?' ); $stmt->execute(array($id)); @@ -402,6 +403,7 @@ class OC_Contacts_VCard{ */ 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' => $uid)); $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' ); $stmt->execute(array($aid,$uri)); OC_Contacts_Addressbook::touch($aid); @@ -559,9 +561,8 @@ class OC_Contacts_VCard{ return false; } } - + OC_Hook::emit('OC_Contacts_VCard', 'post_moveToAddressbook', array('aid' => $aid, 'id' => $id)); OC_Contacts_Addressbook::touch($aid); return true; } - } diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index 8378507163e..a69e9c74f72 100644 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -23,7 +23,7 @@ OCP\JSON::checkLoggedIn(); //OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); -session_close_write(); +session_write_close(); function getStandardImage(){ //OCP\Response::setExpiresHeader('P10D'); diff --git a/apps/files_sharing/css/sharing.css b/apps/files_sharing/css/sharing.css index c4b4540e9d1..d4fcf79ee98 100644 --- a/apps/files_sharing/css/sharing.css +++ b/apps/files_sharing/css/sharing.css @@ -12,3 +12,4 @@ a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em a.unshare:hover { opacity:1; } #share_with { width: 16em; } #privateLink label, .edit { font-weight:normal; } +#share_with_chzn { display: block; } diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 96c9017dbf9..9194d2240ab 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -61,7 +61,7 @@ OC.Share={ OC.Share.loadItem(item); var html = '<div id="dropdown" class="drop" data-item="'+item+'">'; html += '<select data-placeholder="User or Group" id="share_with" class="chzen-select">'; - html += '<option value=""></option>'; + html += '<option value="" selected="selected" disabled="disabled">Your groups & members</option>'; html += '</select>'; html += '<div id="sharedWithList">'; html += '<ul id="userList"></ul>'; diff --git a/apps/gallery/index.php b/apps/gallery/index.php index 52a5b81a23a..b8aadacb47f 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -94,7 +94,7 @@ for($i = 0; $i<count($root_images); $i++) { } $tmpl = new OCP\Template( 'gallery', 'index', 'user' ); -$tmpl->assign('root', $root); +$tmpl->assign('root', $root, false); $tmpl->assign('tl', $tl, false); $tmpl->printPage(); ?> diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index d4d978dbdd0..fcce3f40e23 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -86,7 +86,10 @@ class ThumbnailsManager { } public function delete($path) { - unlink(\OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path); + $thumbnail = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path;
+ if (file_exists($thumbnail)) {
+ unlink($thumbnail);
+ } } private function __construct() {} diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index c3b4a178545..c90932cefd0 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,6 +1,6 @@ <script type="text/javascript"> -var root = "<?php echo OCP\Util::sanitizeHTML($_['root']); ?>"; +var root = "<?php echo $_['root']; ?>"; $(document).ready(function() { $("a[rel=images]").fancybox({ @@ -18,7 +18,7 @@ $(document).ready(function() { for ($i = 0; $i < count($paths); $i++) { $path .= urlencode($paths[$i]).'/'; $classess = 'crumb'.($i == count($paths)-1?' last':''); - echo '<div class="'.$classess.'" style="background-image:url(\''.\OCP\image_path('core','breadcrumb.png').'\')"><a href="'.\OCP\Util::linkTo('gallery', 'index.php').'&root='.$path.'">'.$paths[$i].'</a></div>'; + echo '<div class="'.$classess.'" style="background-image:url(\''.\OCP\image_path('core','breadcrumb.png').'\')"><a href="'.\OCP\Util::linkTo('gallery', 'index.php').'&root='.$path.'">'.OCP\Util::sanitizeHTML($paths[$i]).'</a></div>'; } } diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index c5bfc346542..75015d627b4 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -22,9 +22,22 @@ $l=OC_L10N::get('media'); -require_once('media/lib_media.php'); -require_once('media/lib_collection.php'); -require_once('media/lib_scanner.php'); +OC::$CLASSPATH['OC_MEDIA'] = 'media/lib_media.php'; +OC::$CLASSPATH['OC_MediaSearchProvider'] = 'media/lib_media.php'; +OC::$CLASSPATH['OC_MEDIA_COLLECTION'] = 'media/lib_collection.php'; +OC::$CLASSPATH['OC_MEDIA_SCANNER'] = 'media/lib_scanner.php'; + +//we need to have the sha256 hash of passwords for ampache +OCP\Util::connectHook('OC_User','post_login','OC_MEDIA','loginListener'); + +//connect to the filesystem for auto updating +OCP\Util::connectHook('OC_Filesystem','post_write','OC_MEDIA','updateFile'); + +//listen for file deletions to clean the database if a song is deleted +OCP\Util::connectHook('OC_Filesystem','post_delete','OC_MEDIA','deleteFile'); + +//list for file moves to update the database +OCP\Util::connectHook('OC_Filesystem','post_rename','OC_MEDIA','moveFile'); OCP\Util::addscript('media','loader'); OCP\App::registerPersonal('media','settings'); diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index f5c91661abe..255e6f468f8 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -77,7 +77,7 @@ class OC_MEDIA_AMPACHE{ $songs=OC_MEDIA_COLLECTION::getSongCount(); $artists=OC_MEDIA_COLLECTION::getArtistCount(); $albums=OC_MEDIA_COLLECTION::getAlbumCount(); - $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`token`, `user_id`, `start`) VALUES (?, ?, now());"); $query->execute(array($token,$user)); $expire=date('c',time()+600); echo('<?xml version="1.0" encoding="UTF-8"?>'); @@ -136,8 +136,14 @@ class OC_MEDIA_AMPACHE{ return false; } } + $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); + if($CONFIG_DBTYPE == 'psql'){ + $interval = ' \'600s\'::interval '; + }else { + $interval = '600'; + } //remove old sessions - $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)"); + $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW() - ".$interval.")"); $query->execute(); $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index a32a50534ed..598c08d32e2 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -104,7 +104,7 @@ class OC_MEDIA_COLLECTION{ return self::$albumIdCache[$artistId][$albumId][$name]; }else{ $uid=$_SESSION['user_id']; - $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND song_name LIKE ? AND song_artist=? AND song_album=?"); + $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND lower(song_name) LIKE ? AND song_artist=? AND song_album=?"); $songs=$query->execute(array($uid,$name,$artistId,$albumId))->fetchAll(); if(is_array($songs) and isset($songs[0])){ self::$albumIdCache[$artistId][$albumId][$name]=$songs[0]['song_id']; @@ -277,7 +277,7 @@ class OC_MEDIA_COLLECTION{ $query=self::$queries['addsong']; } $query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size)); - $songId=OCP\DB::insertid('*PREFIX*media_songs'); + $songId=OCP\DB::insertid('*PREFIX*media_songs_song'); // self::setLastUpdated(); return self::getSongId($name,$artist,$album); } diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 71069fdf4b9..9e687a4af2c 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -21,18 +21,6 @@ * */ -//we need to have the sha256 hash of passwords for ampache -OCP\Util::connectHook('OC_User','post_login','OC_MEDIA','loginListener'); - -//connect to the filesystem for auto updating -OCP\Util::connectHook('OC_Filesystem','post_write','OC_MEDIA','updateFile'); - -//listen for file deletions to clean the database if a song is deleted -OCP\Util::connectHook('OC_Filesystem','post_delete','OC_MEDIA','deleteFile'); - -//list for file moves to update the database -OCP\Util::connectHook('OC_Filesystem','post_rename','OC_MEDIA','moveFile'); - class OC_MEDIA{ /** * get the sha256 hash of the password needed for ampache diff --git a/apps/tasks/lib/app.php b/apps/tasks/lib/app.php index 7b908420333..1b42968f0be 100644 --- a/apps/tasks/lib/app.php +++ b/apps/tasks/lib/app.php @@ -180,6 +180,7 @@ class OC_Task_App { $timezone = new DateTimeZone($timezone); $completed = new DateTime($completed, $timezone); $vtodo->setDateTime('COMPLETED', $completed); + OCP\Util::emitHook('OC_Task', 'taskCompleted', $vtodo); } else { unset($vtodo->COMPLETED); } diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index c88b18b10d3..21c4e57e293 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -171,7 +171,7 @@ class OC_LDAP { * returns the internal ownCloud name for the given LDAP DN of the group */ static public function dn2groupname($dn, $ldapname = null) { - if(strrpos($dn, self::$ldapBaseGroups) !== (strlen($dn)-strlen(self::$ldapBaseGroups))) { + if(strripos($dn, self::$ldapBaseGroups) !== (strlen($dn)-strlen(self::$ldapBaseGroups))) { return false; } return self::dn2ocname($dn, $ldapname, false); @@ -186,7 +186,7 @@ class OC_LDAP { * returns the internal ownCloud name for the given LDAP DN of the user, false on DN outside of search DN */ static public function dn2username($dn, $ldapname = null) { - if(strrpos($dn, self::$ldapBaseUsers) !== (strlen($dn)-strlen(self::$ldapBaseUsers))) { + if(strripos($dn, self::$ldapBaseUsers) !== (strlen($dn)-strlen(self::$ldapBaseUsers))) { return false; } return self::dn2ocname($dn, $ldapname, true); @@ -425,7 +425,7 @@ class OC_LDAP { if(isset($result[$attr]) && $result[$attr]['count'] > 0){ $values = array(); for($i=0;$i<$result[$attr]['count'];$i++) { - $values[] = $result[$attr][$i]; + $values[] = self::resemblesDN($attr) ? self::sanitizeDN($result[$attr][$i]) : $result[$attr][$i]; } return $values; } @@ -508,7 +508,7 @@ class OC_LDAP { $key = strtolower($key); if(isset($item[$key])) { if($key != 'dn'){ - $selection[$i][$key] = $item[$key][0]; + $selection[$i][$key] = self::resemblesDN($key) ? self::sanitizeDN($item[$key][0]) : $item[$key][0]; } else { $selection[$i][$key] = self::sanitizeDN($item[$key]); } @@ -521,7 +521,7 @@ class OC_LDAP { $key = strtolower($attr[0]); if(isset($item[$key])) { - if($key == 'dn') { + if(self::resemblesDN($key)) { $selection[] = self::sanitizeDN($item[$key]); } else { $selection[] = $item[$key]; @@ -536,6 +536,15 @@ class OC_LDAP { return $findings; } + static private function resemblesDN($attr) { + $resemblingAttributes = array( + 'dn', + 'uniquemember', + 'member' + ); + return in_array($attr, $resemblingAttributes); + } + static private function sanitizeDN($dn) { //OID sometimes gives back DNs with whitespace after the comma a la "uid=foo, cn=bar, dn=..." We need to tackle this! $dn = preg_replace('/([^\\\]),(\s+)/','\1,',$dn); diff --git a/core/css/styles.css b/core/css/styles.css index 6d272845ebe..b818caa279f 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -106,6 +106,7 @@ label.infield { cursor: text !important; } /* VARIOUS REUSABLE SELECTORS */ .hidden { display:none; } .bold { font-weight: bold; } +.center { text-align: center; } #notification { z-index:101; cursor:pointer; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; } diff --git a/core/js/multiselect.js b/core/js/multiselect.js index 5f339006d26..db5afa637c9 100644 --- a/core/js/multiselect.js +++ b/core/js/multiselect.js @@ -136,7 +136,7 @@ var option=$('<option selected="selected"/>'); option.attr('value',$(this).val()); option.text($(this).val()); - select.append(optione); + select.append(options); li.prev().children('input').trigger('click'); button.parent().data('preventHide',false); if(settings.createCallback){ diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d6911fd1e18..7e98fdedc2d 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -47,7 +47,7 @@ <a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a> <a class="header-right header-action" id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a> <form class="searchbox header-right" action="#" method="post"> - <input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo OC_Util::sanitizeHTML($_POST['query']);};?>" autocomplete="off" /> + <input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo OC_Util::sanitizeHTML($_POST['query']);};?>" autocomplete="off" x-webkit-speech /> </form> </div></header> diff --git a/lib/app.php b/lib/app.php index 84d17957def..b337c55ec60 100755 --- a/lib/app.php +++ b/lib/app.php @@ -381,7 +381,7 @@ class OC_App{ $file= self::getAppPath($appid).'/appinfo/version'; $version=@file_get_contents($file); if($version){ - return $version; + return trim($version); }else{ $appData=self::getAppInfo($appid); return $appData['version']; diff --git a/lib/base.php b/lib/base.php index 870550f267d..b4da6434e25 100644 --- a/lib/base.php +++ b/lib/base.php @@ -136,14 +136,16 @@ class OC{ $config_paths = OC_Config::getValue('apps_paths', array()); if(! empty($config_paths)){ foreach($config_paths as $paths) { - if( isset($paths['url']) && isset($paths['path'])) - OC::$APPSROOTS[] = $paths; + if( isset($paths['url']) && isset($paths['path'])) { + $paths['url'] = rtrim($paths['url'],'/'); + $paths['path'] = rtrim($paths['path'],'/'); + OC::$APPSROOTS[] = $paths; + } } }elseif(file_exists(OC::$SERVERROOT.'/apps')){ - OC::$APPSROOTS[] = array('path'=> OC::$SERVERROOT.'/apps', 'url' => '/apps/', 'writable' => true); + OC::$APPSROOTS[] = array('path'=> OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true); }elseif(file_exists(OC::$SERVERROOT.'/../apps')){ - OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => '/apps/', 'writable' => true); - OC::$APPSROOT=rtrim(dirname(OC::$SERVERROOT), '/'); + OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => '/apps', 'writable' => true); } if(empty(OC::$APPSROOTS)){ diff --git a/lib/cache.php b/lib/cache.php index 55d5b064c41..1f269174fad 100644 --- a/lib/cache.php +++ b/lib/cache.php @@ -7,58 +7,69 @@ */ class OC_Cache { - static protected $cache; + static protected $user_cache; + static protected $global_cache; - static protected function init() { - $fast_cache = null; - if (!$fast_cache && function_exists('xcache_set')) { - $fast_cache = new OC_Cache_XCache(); + static public function getGlobalCache() { + if (!self::$global_cache) { + $fast_cache = null; + if (!$fast_cache && function_exists('xcache_set')) { + $fast_cache = new OC_Cache_XCache(true); + } + if (!$fast_cache && function_exists('apc_store')) { + $fast_cache = new OC_Cache_APC(true); + } + self::$global_cache = new OC_Cache_FileGlobal(); + if ($fast_cache) { + self::$global_cache = new OC_Cache_Broker($fast_cache, self::$global_cache); + } } - if (!$fast_cache && function_exists('apc_store')) { - $fast_cache = new OC_Cache_APC(); - } - self::$cache = new OC_Cache_File(); - if ($fast_cache) { - self::$cache = new OC_Cache_Broker($fast_cache, self::$cache); + return self::$global_cache; + } + + static public function getUserCache() { + if (!self::$user_cache) { + $fast_cache = null; + if (!$fast_cache && function_exists('xcache_set')) { + $fast_cache = new OC_Cache_XCache(); + } + if (!$fast_cache && function_exists('apc_store')) { + $fast_cache = new OC_Cache_APC(); + } + self::$user_cache = new OC_Cache_File(); + if ($fast_cache) { + self::$user_cache = new OC_Cache_Broker($fast_cache, self::$user_cache); + } } + return self::$user_cache; } static public function get($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->get($key); + $user_cache = self::getUserCache(); + return $user_cache->get($key); } static public function set($key, $value, $ttl=0) { if (empty($key)) { return false; } - if (!self::$cache) { - self::init(); - } - return self::$cache->set($key, $value, $ttl); + $user_cache = self::getUserCache(); + return $user_cache->set($key, $value, $ttl); } static public function hasKey($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->hasKey($key); + $user_cache = self::getUserCache(); + return $user_cache->hasKey($key); } static public function remove($key) { - if (!self::$cache) { - self::init(); - } - return self::$cache->remove($key); + $user_cache = self::getUserCache(); + return $user_cache->remove($key); } static public function clear() { - if (!self::$cache) { - self::init(); - } - return self::$cache->clear(); + $user_cache = self::getUserCache(); + return $user_cache->clear(); } } diff --git a/lib/cache/apc.php b/lib/cache/apc.php index b1ce87f5267..6cf47d0c158 100644 --- a/lib/cache/apc.php +++ b/lib/cache/apc.php @@ -7,11 +7,20 @@ */ class OC_Cache_APC { + protected $prefix; + + public function __construct($global = false) { + $this->prefix = OC_Util::getInstanceId().'/'; + if (!$global) { + $this->prefix .= OC_User::getUser().'/'; + } + } + /** * entries in APC gets namespaced to prevent collisions between owncloud instances and users */ protected function getNameSpace() { - return OC_Util::getInstanceId().'/'.OC_User::getUser().'/'; + return $this->prefix; } public function get($key) { diff --git a/lib/cache/broker.php b/lib/cache/broker.php index 62a7cd96d15..931d0dd407e 100644 --- a/lib/cache/broker.php +++ b/lib/cache/broker.php @@ -23,15 +23,13 @@ class OC_Cache_Broker { } public function set($key, $value, $ttl=0) { - $set_slow = strlen($value) > 8192; - if ($set_slow) { + if (!$this->fast_cache->set($key, $value, $ttl)) { if ($this->fast_cache->hasKey($key)) { $this->fast_cache->remove($key); } - $this->slow_cache->set($key, $value, $ttl); - } else { - $this->fast_cache->set($key, $value, $ttl); + return $this->slow_cache->set($key, $value, $ttl); } + return true; } public function hasKey($key) { diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php index b57338929e0..bd55cee8f6b 100644 --- a/lib/cache/xcache.php +++ b/lib/cache/xcache.php @@ -7,11 +7,20 @@ */ class OC_Cache_XCache { + protected $prefix; + + public function __construct($global = false) { + $this->prefix = OC_Util::getInstanceId().'/'; + if (!$global) { + $this->prefix .= OC_User::getUser().'/'; + } + } + /** * entries in XCache gets namespaced to prevent collisions between owncloud instances and users */ protected function getNameSpace() { - return OC_Util::getInstanceId().'/'.OC_User::getUser().'/'; + return $this->prefix; } public function get($key) { diff --git a/lib/db.php b/lib/db.php index dc9e3392d0a..9e6835adc6f 100644 --- a/lib/db.php +++ b/lib/db.php @@ -246,6 +246,7 @@ class OC_DB { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$query.'<br />'; OC_Log::write('core',$entry,OC_Log::FATAL); + error_log('DB error: '.$entry); die( $entry ); } }else{ @@ -255,6 +256,7 @@ class OC_DB { $entry = 'DB Error: "'.$e->getMessage().'"<br />'; $entry .= 'Offending command was: '.$query.'<br />'; OC_Log::write('core',$entry,OC_Log::FATAL); + error_log('DB error: '.$entry); die( $entry ); } $result=new PDOStatementWrapper($result); diff --git a/lib/filecache.php b/lib/filecache.php index e3bcc7d0000..d956f34dc48 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -110,7 +110,9 @@ class OC_FileCache{ $queryParts=array(); foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){ if(isset($data[$attribute])){ - $arguments[]=$data[$attribute]; + //Convert to int it args are false + if($data[$attribute] === false) $arguments[] = 0; + else $arguments[] = $data[$attribute]; $queryParts[]=$attribute.'=?'; } } diff --git a/lib/minimizer.php b/lib/minimizer.php index e17c114f065..3bf5ff9980b 100644 --- a/lib/minimizer.php +++ b/lib/minimizer.php @@ -22,15 +22,18 @@ abstract class OC_Minimizer { OC_Response::setLastModifiedHeader($last_modified); $gzout = false; - $cache = new OC_Cache_FileGlobal(); + $cache = OC_Cache::getGlobalCache(); if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){ $gzout = $cache->get($cache_key.'.gz'); - OC_Response::setETagHeader(md5($gzout)); + if ($gzout) { + OC_Response::setETagHeader(md5($gzout)); + } } if (!$gzout) { $out = $this->minimizeFiles($files); $gzout = gzencode($out); + OC_Response::setETagHeader(md5($gzout)); $cache->set($cache_key.'.gz', $gzout); } if ($encoding = OC_Request::acceptGZip()) { diff --git a/lib/preferences.php b/lib/preferences.php index 89fc73aa232..f72378ce94f 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -150,6 +150,7 @@ class OC_Preferences{ $query = OC_DB::prepare( 'UPDATE *PREFIX*preferences SET configvalue = ? WHERE userid = ? AND appid = ? AND configkey = ?' ); $query->execute( array( $value, $user, $app, $key )); } + return true; } /** diff --git a/remote.php b/remote.php index ef610f36947..e68a53800c7 100644 --- a/remote.php +++ b/remote.php @@ -16,20 +16,25 @@ if (!$pos = strpos($path_info, '/', 1)) { } $service=substr($path_info, 1, $pos-1); $file = OC_AppConfig::getValue('core', 'remote_' . $service); +$file = preg_replace('/apps\//','', $file); //Todo Remove after Multiappdir migration + if(is_null($file)){ OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); exit; } -if(count(explode('/',$file)) == 3) { + +$file = ltrim ($file, '/'); + +if(count(explode('/',$file)) == 2) { $parts=explode('/',$file); - $app=$parts[2]; + $app=$parts[1]; OC_App::loadApp($app); $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; - require_once( OC::$SERVERROOT.$file); + require_once( OC::$SERVERROOT.'/'.$file); } else { - $parts=explode('/', $file, 4); - $app=$parts[2]; + $parts=explode('/', $file, 2); + $app=$parts[0]; OC_App::loadApp($app); $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; - require_once(OC_App::getAppPath($app) .'/'. $parts[3]); + require_once(OC_App::getAppPath($app) .'/'. $parts[1]); } diff --git a/settings/apps.php b/settings/apps.php index f85b28158f5..f4ae8b8d977 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -93,6 +93,8 @@ usort($apps, 'app_sort'); $tmpl = new OC_Template( "settings", "apps", "user" ); $tmpl->assign('apps',$apps, false); +$appid = (isset($_GET['appid'])?strip_tags($_GET['appid']):''); +$tmpl->assign('appid',$appid); $tmpl->printPage(); diff --git a/settings/css/settings.css b/settings/css/settings.css index 80e96df5e66..d5634eec81f 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -53,3 +53,5 @@ span.version { margin-left:3em; color:#ddd; } /* ADMIN */ span.securitywarning {color:#C33; font-weight:bold; } +h3.settingsNotice { font-size: 1.2em; } +.settingsNotice { font-weight:bold; padding: 0.5em 0; } diff --git a/settings/js/apps.js b/settings/js/apps.js index 224076aba43..cfef894c6fb 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -73,4 +73,13 @@ $(document).ready(function(){ } } }); + + if(appid) { + var item = $('#leftcontent li[data-id="'+appid+'"]'); + if(item) { + item.trigger('click'); + item.addClass('active'); + $('#leftcontent').animate({scrollTop: $(item).offset().top-70}, 'slow','swing'); + } + } }); diff --git a/settings/js/users.js b/settings/js/users.js index f173357749e..0de0d1df3bc 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -213,5 +213,6 @@ $(document).ready(function(){ } } ); + location.reload(); }); }); diff --git a/settings/templates/apps.php b/settings/templates/apps.php index c620f796e06..6edaf6c5848 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -3,14 +3,16 @@ * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */?> - +<script type='text/javascript'> + var appid = '<?php echo $_['appid']; ?>'; +</script> <div id="controls"> <a class="button" target="_blank" href="http://owncloud.org/dev/writing-apps/"><?php echo $l->t('Add your App');?></a> </div> <ul id="leftcontent"> <?php foreach($_['apps'] as $app):?> <li <?php if($app['active']) echo 'class="active"'?> data-id="<?php echo $app['id'] ?>"> - <a href="?appid=<?php echo $app['id'] ?>"><?php echo $app['name'] ?></a> + <a href="?appid=<?php echo $app['id'] ?>"><?php echo htmlentities($app['name']) ?></a> <span class="hidden"> <?php OC_JSON::encodedPrint($app,false) ?> </span> diff --git a/settings/templates/users.php b/settings/templates/users.php index ea3fe777ffe..c042f2664e2 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -112,3 +112,8 @@ foreach($_["groups"] as $group) { <?php endforeach; ?> </tbody> </table> + +<!-- use a standard notification class / system for this message --> +<?php if( $_["share_notice"] ):?> +<h3 class="settingsNotice center"><?php echo $_["share_notice"]; ?></h3> +<?php endif;?>
\ No newline at end of file diff --git a/settings/users.php b/settings/users.php index 96515a90ce4..026a30a750c 100644 --- a/settings/users.php +++ b/settings/users.php @@ -33,11 +33,20 @@ foreach($quotaPreset as &$preset){ $defaultQuota=OC_Appconfig::getValue('files','default_quota','none'); +$shareNotice = ''; + +if (\OC_App::isEnabled( "files_sharing" ) ) { + + $shareNotice = 'Note: users may only share to groups that they belong to, and their members'; + +} + $tmpl = new OC_Template( "settings", "users", "user" ); $tmpl->assign( "users", $users ); $tmpl->assign( "groups", $groups ); $tmpl->assign( 'quota_preset', $quotaPreset); $tmpl->assign( 'default_quota', $defaultQuota); +$tmpl->assign( 'share_notice', $shareNotice); $tmpl->printPage(); ?> |