Merge branch 'master' into calendar_export

This commit is contained in:
Georg Ehrke 2012-06-26 14:15:07 +02:00
commit c7de74c471
62 changed files with 376 additions and 224 deletions

View File

@ -31,5 +31,5 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('bookmarks'); OCP\JSON::checkAppEnabled('bookmarks');
require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); 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)); OCP\JSON::success(array('data' => $id));

View File

@ -90,6 +90,7 @@ function addBookmark($url, $title, $tags='') {
if(empty($title)) { if(empty($title)) {
$metadata = getURLMetadata($url); $metadata = getURLMetadata($url);
if(isset($metadata['title'])) // Check for problems fetching the title
$title = $metadata['title']; $title = $metadata['title'];
} }

View File

@ -3,9 +3,9 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Read later - ownCloud</title> <title>Read later - ownCloud</title>
<link rel="stylesheet" href="css/readlater.css">
</head> </head>
<body> <body>
<div class="message"><h1>Saved!</h1></div> <div class="message"><h1>Saved!</h1></div>
<a href="javascript:self.close()" >Close the window</a>
</body> </body>
</html> </html>

View File

@ -28,7 +28,7 @@ $dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch($dtstart->getDateType()) { switch($dtstart->getDateType()) {
case Sabre_VObject_Property_DateTime::UTC: case Sabre_VObject_Property_DateTime::UTC:
$timeOffset = OC_Calendar_App::$tz*60; $timeOffset = $_SESSION['timezone']*60;
$newDT = $dtstart->getDateTime(); $newDT = $dtstart->getDateTime();
$newDT->add(new DateInterval("PT" . $timeOffset . "M")); $newDT->add(new DateInterval("PT" . $timeOffset . "M"));
$dtstart->setDateTime($newDT); $dtstart->setDateTime($newDT);

View File

@ -194,6 +194,9 @@ class OC_Calendar_App{
} else } else
if (isset($calendar->VTODO)) { if (isset($calendar->VTODO)) {
$object = $calendar->VTODO; $object = $calendar->VTODO;
} else
if (isset($calendar->VJOURNAL)) {
$object = $calendar->VJOURNAL;
} }
if ($object) { if ($object) {
self::getVCategories()->loadFromVObject($object, true); self::getVCategories()->loadFromVObject($object, true);

View File

@ -25,11 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/addproperty.php: '.$msg, OCP\Util::DEBUG);
exit();
}
$id = isset($_POST['id'])?$_POST['id']:null; $id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null; $name = isset($_POST['name'])?$_POST['name']:null;

View File

@ -10,18 +10,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
foreach ($_POST as $key=>$element) { require_once('../loghandler.php');
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);
}
$categories = isset($_POST['categories'])?$_POST['categories']:null; $categories = isset($_POST['categories'])?$_POST['categories']:null;

View File

@ -10,18 +10,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
foreach ($_POST as $key=>$element) { require_once('../loghandler.php');
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);
}
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser()); $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
if(count($addressbooks) == 0) { if(count($addressbooks) == 0) {

View File

@ -20,11 +20,7 @@
* *
*/ */
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG);
exit();
}
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();

View File

@ -18,7 +18,6 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
$active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
error_log('active_addressbooks: '.print_r($active_addressbooks, true));
$contacts_addressbook = array(); $contacts_addressbook = array();
$ids = array(); $ids = array();
@ -29,9 +28,7 @@ foreach($active_addressbooks as $addressbook) {
$contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname']; $contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname'];
} }
} }
error_log('ids: '.print_r($ids, true));
$contacts_alphabet = OC_Contacts_VCard::all($ids); $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 // Our new array for the contacts sorted by addressbook
foreach($contacts_alphabet as $contact) { 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)); $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
} }
unset($contacts_alphabet);
uasort($contacts_addressbook, 'cmp'); uasort($contacts_addressbook, 'cmp');
$tmpl = new OCP\Template("contacts", "part.contacts"); $tmpl = new OCP\Template("contacts", "part.contacts");

View File

@ -12,25 +12,20 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once('loghandler.php');
$userid = OCP\USER::getUser(); $userid = OCP\USER::getUser();
$name = trim(strip_tags($_POST['name'])); $name = trim(strip_tags($_POST['name']));
if(!$name) { if(!$name) {
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); bailOut('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();
} }
$bookid = OC_Contacts_Addressbook::add($userid, $name, null); $bookid = OC_Contacts_Addressbook::add($userid, $name, null);
if(!$bookid) { if(!$bookid) {
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); bailOut('Error adding addressbook: '.$name);
OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR);
exit();
} }
if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); bailOut('Error activating addressbook.');
OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
//exit();
} }
$addressbook = OC_Contacts_App::getAddressbook($bookid); $addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); $tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields');

View File

@ -24,11 +24,7 @@
OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR);
exit();
}
if (!isset($_GET['id'])) { if (!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));

View File

@ -19,26 +19,21 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * 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 // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once('loghandler.php');
// foreach($_SERVER as $key=>$value) { // foreach($_SERVER as $key=>$value) {
// OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG); // OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG);
// } // }
foreach($_POST as $key=>$value) { // foreach($_POST as $key=>$value) {
OCP\Util::writeLog('contacts','ajax/saveproperty.php: _POST: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG); // debug($key.'=>'.print_r($value, true));
} // }
foreach($_GET as $key=>$value) { // foreach($_GET as $key=>$value) {
OCP\Util::writeLog('contacts','ajax/saveproperty.php: _GET: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG); // debug($key.'=>'.print_r($value, true));
} // }
$id = isset($_POST['id'])?$_POST['id']:null; $id = isset($_POST['id'])?$_POST['id']:null;
if(!$id) { if(!$id) {

View File

@ -24,6 +24,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
require_once('loghandler.php');
$id = $_POST['id']; $id = $_POST['id'];
$checksum = $_POST['checksum']; $checksum = $_POST['checksum'];
@ -31,16 +32,14 @@ $checksum = $_POST['checksum'];
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
if(is_null($line)){ 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(); exit();
} }
unset($vcard->children[$line]); unset($vcard->children[$line]);
if(!OC_Contacts_VCard::edit($id,$vcard)) { if(!OC_Contacts_VCard::edit($id,$vcard)) {
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.'));
OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR);
exit();
} }
OCP\JSON::success(array('data' => array( 'id' => $id ))); OCP\JSON::success(array('data' => array( 'id' => $id )));

View File

@ -9,11 +9,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
exit();
}
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog"); $tmpl = new OCP\Template("contacts", "part.edit_name_dialog");

View File

@ -24,11 +24,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG);
exit();
}
$id = isset($_GET['id']) ? $_GET['id'] : ''; $id = isset($_GET['id']) ? $_GET['id'] : '';
$refresh = isset($_GET['refresh']) ? true : false; $refresh = isset($_GET['refresh']) ? true : false;

View File

@ -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);
}
}

View File

@ -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,)));

View File

@ -22,11 +22,7 @@
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR);
exit();
}
if(!isset($_GET['id'])) { if(!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));

View File

@ -27,11 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur // Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::setContentTypeHeader('text/plain');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG);
exit();
}
$image = null; $image = null;

View File

@ -19,21 +19,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
require_once('loghandler.php');
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);
}
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck(); OCP\JSON::callCheck();
$id = isset($_POST['id'])?$_POST['id']:null; $id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null; $name = isset($_POST['name'])?$_POST['name']:null;
$value = isset($_POST['value'])?$_POST['value']:null; $value = isset($_POST['value'])?$_POST['value']:null;

View File

@ -11,27 +11,22 @@
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
require_once('loghandler.php');
$bookid = $_POST['id']; $bookid = $_POST['id'];
OC_Contacts_App::getAddressbook($bookid); // is owner access check OC_Contacts_App::getAddressbook($bookid); // is owner access check
$name = trim(strip_tags($_POST['name'])); $name = trim(strip_tags($_POST['name']));
if(!$name) { if(!$name) {
OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); bailOut(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();
} }
if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) {
OCP\JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.'));
OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR);
//exit();
} }
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
OCP\JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'));
OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR);
//exit();
} }
$addressbook = OC_Contacts_App::getAddressbook($bookid); $addressbook = OC_Contacts_App::getAddressbook($bookid);

View File

@ -23,11 +23,7 @@
// Check if we are a user // Check if we are a user
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::checkAppEnabled('contacts');
function bailOut($msg) { require_once('loghandler.php');
OCP\JSON::error(array('data' => array('message' => $msg)));
OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR);
exit();
}
$view = OCP\Files::getStorage('contacts'); $view = OCP\Files::getStorage('contacts');
$tmpfile = md5(rand()); $tmpfile = md5(rand());

View File

@ -27,14 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur // Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::setContentTypeHeader('text/plain');
function bailOut($msg) { require_once('loghandler.php');
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);
}
// If it is a Drag'n'Drop transfer it's handled here. // 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); $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);

View File

@ -5,9 +5,12 @@
#leftcontent a { padding: 0 0 0 25px; } #leftcontent a { padding: 0 0 0 25px; }
#rightcontent { top: 3.5em !important; padding-top: 5px; } #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 { 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 { 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 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;} #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; } #contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; } #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_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 { clear: both; max-width: 15em; margin: 2em; }
#contacts_propertymenu_button { position:relative;top:0;left:0; margin: 0; } #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 { display: block; font-weight: bold; height: 20px; }
#contacts_propertymenu li a { padding: 3px; display: block } #contacts_propertymenu li a { padding: 3px; display: block }
#contacts_propertymenu li:hover { background-color: #1d2d44; } #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"],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; } #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;} 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 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; } .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; } 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;*/ } .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; } #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_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 { 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; } #contacts_details_photo:hover { background: #fff; cursor: default; }

View File

@ -28,6 +28,7 @@ $details = array();
if(is_null($id) && count($contacts) > 0) { if(is_null($id) && count($contacts) > 0) {
$id = $contacts[0]['id']; $id = $contacts[0]['id'];
} }
unset($contacts);
if(!is_null($id)) { if(!is_null($id)) {
$vcard = OC_Contacts_App::getContactVCard($id); $vcard = OC_Contacts_App::getContactVCard($id);
$details = OC_Contacts_VCard::structureContact($vcard); $details = OC_Contacts_VCard::structureContact($vcard);
@ -66,7 +67,6 @@ $tmpl->assign('phone_types', $phone_types);
$tmpl->assign('email_types', $email_types); $tmpl->assign('email_types', $email_types);
$tmpl->assign('categories', $categories); $tmpl->assign('categories', $categories);
$tmpl->assign('addressbooks', $addressbooks); $tmpl->assign('addressbooks', $addressbooks);
$tmpl->assign('contacts', $contacts, false);
$tmpl->assign('details', $details ); $tmpl->assign('details', $details );
$tmpl->assign('id',$id); $tmpl->assign('id',$id);
$tmpl->printPage(); $tmpl->printPage();

View File

@ -314,6 +314,7 @@ Contacts={
return false; return false;
}, },
add:function(n, fn, aid, isnew){ // add a new contact 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) { var localAddcontact = function(n, fn, aid, isnew) {
$.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew }, $.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
function(jsondata) { function(jsondata) {
@ -380,12 +381,12 @@ Contacts={
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
var newid = '', bookid; var newid = '', bookid;
var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]'); var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]');
var newlistitem = curlistitem.prev(); var newlistitem = curlistitem.prev('li');
if(newlistitem == undefined) { if(newlistitem == undefined) {
newlistitem = curlistitem.next(); newlistitem = curlistitem.next('li');
} }
curlistitem.remove(); curlistitem.remove();
if(newlistitem != undefined) { if(!$(newlistitem).is('li')) {
newid = newlistitem.data('id'); newid = newlistitem.data('id');
bookid = newlistitem.data('id'); bookid = newlistitem.data('id');
} }
@ -1504,6 +1505,36 @@ Contacts={
} }
}, },
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. // Reload the contacts list.
update:function(id){ update:function(id){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
@ -1519,6 +1550,23 @@ Contacts={
} }
})}, 100); })}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/ 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); Contacts.UI.Card.update(id);
} }
@ -1605,6 +1653,8 @@ $(document).ready(function(){
}); });
$(document).on('click', '.addressbook', function(event){ $(document).on('click', '.addressbook', function(event){
$('#contacts h3').removeClass('active');
$(this).addClass('active');
$(this).next().slideToggle(300); $(this).next().slideToggle(300);
return false; return false;
}); });

View File

@ -20,6 +20,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. * This class contains all hooks.
*/ */

View File

@ -293,7 +293,7 @@ class OC_Contacts_VCard{
$newid = OCP\DB::insertid('*PREFIX*contacts_cards'); $newid = OCP\DB::insertid('*PREFIX*contacts_cards');
OC_Contacts_Addressbook::touch($aid); OC_Contacts_Addressbook::touch($aid);
OC_Hook::emit('OC_Contacts_VCard', 'post_createVCard', $newid);
return $newid; return $newid;
} }
@ -360,7 +360,7 @@ class OC_Contacts_VCard{
$result = $stmt->execute(array($fn,$data,time(),$id)); $result = $stmt->execute(array($fn,$data,time(),$id));
OC_Contacts_Addressbook::touch($oldcard['addressbookid']); OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
OC_Hook::emit('OC_Contacts_VCard', 'post_updateVCard', $id);
return true; return true;
} }
@ -388,6 +388,7 @@ class OC_Contacts_VCard{
*/ */
public static function delete($id){ public static function delete($id){
// FIXME: Add error checking. // 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 = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
$stmt->execute(array($id)); $stmt->execute(array($id));
@ -402,6 +403,7 @@ class OC_Contacts_VCard{
*/ */
public static function deleteFromDAVData($aid,$uri){ public static function deleteFromDAVData($aid,$uri){
// FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error. // 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 = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
$stmt->execute(array($aid,$uri)); $stmt->execute(array($aid,$uri));
OC_Contacts_Addressbook::touch($aid); OC_Contacts_Addressbook::touch($aid);
@ -559,9 +561,8 @@ class OC_Contacts_VCard{
return false; return false;
} }
} }
OC_Hook::emit('OC_Contacts_VCard', 'post_moveToAddressbook', array('aid' => $aid, 'id' => $id));
OC_Contacts_Addressbook::touch($aid); OC_Contacts_Addressbook::touch($aid);
return true; return true;
} }
} }

View File

@ -23,7 +23,7 @@
OCP\JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
//OCP\User::checkLoggedIn(); //OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts'); OCP\App::checkAppEnabled('contacts');
session_close_write(); session_write_close();
function getStandardImage(){ function getStandardImage(){
//OCP\Response::setExpiresHeader('P10D'); //OCP\Response::setExpiresHeader('P10D');

View File

@ -12,3 +12,4 @@ a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em
a.unshare:hover { opacity:1; } a.unshare:hover { opacity:1; }
#share_with { width: 16em; } #share_with { width: 16em; }
#privateLink label, .edit { font-weight:normal; } #privateLink label, .edit { font-weight:normal; }
#share_with_chzn { display: block; }

View File

@ -61,7 +61,7 @@ OC.Share={
OC.Share.loadItem(item); OC.Share.loadItem(item);
var html = '<div id="dropdown" class="drop" data-item="'+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 += '<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 += '</select>';
html += '<div id="sharedWithList">'; html += '<div id="sharedWithList">';
html += '<ul id="userList"></ul>'; html += '<ul id="userList"></ul>';

View File

@ -94,7 +94,7 @@ for($i = 0; $i<count($root_images); $i++) {
} }
$tmpl = new OCP\Template( 'gallery', 'index', 'user' ); $tmpl = new OCP\Template( 'gallery', 'index', 'user' );
$tmpl->assign('root', $root); $tmpl->assign('root', $root, false);
$tmpl->assign('tl', $tl, false); $tmpl->assign('tl', $tl, false);
$tmpl->printPage(); $tmpl->printPage();
?> ?>

View File

@ -86,7 +86,10 @@ class ThumbnailsManager {
} }
public function delete($path) { 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() {} private function __construct() {}

View File

@ -1,6 +1,6 @@
<script type="text/javascript"> <script type="text/javascript">
var root = "<?php echo OCP\Util::sanitizeHTML($_['root']); ?>"; var root = "<?php echo $_['root']; ?>";
$(document).ready(function() { $(document).ready(function() {
$("a[rel=images]").fancybox({ $("a[rel=images]").fancybox({
@ -18,7 +18,7 @@ $(document).ready(function() {
for ($i = 0; $i < count($paths); $i++) { for ($i = 0; $i < count($paths); $i++) {
$path .= urlencode($paths[$i]).'/'; $path .= urlencode($paths[$i]).'/';
$classess = 'crumb'.($i == count($paths)-1?' last':''); $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>';
} }
} }

View File

@ -22,9 +22,22 @@
$l=OC_L10N::get('media'); $l=OC_L10N::get('media');
require_once('media/lib_media.php'); OC::$CLASSPATH['OC_MEDIA'] = 'media/lib_media.php';
require_once('media/lib_collection.php'); OC::$CLASSPATH['OC_MediaSearchProvider'] = 'media/lib_media.php';
require_once('media/lib_scanner.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\Util::addscript('media','loader');
OCP\App::registerPersonal('media','settings'); OCP\App::registerPersonal('media','settings');

View File

@ -77,7 +77,7 @@ class OC_MEDIA_AMPACHE{
$songs=OC_MEDIA_COLLECTION::getSongCount(); $songs=OC_MEDIA_COLLECTION::getSongCount();
$artists=OC_MEDIA_COLLECTION::getArtistCount(); $artists=OC_MEDIA_COLLECTION::getArtistCount();
$albums=OC_MEDIA_COLLECTION::getAlbumCount(); $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)); $query->execute(array($token,$user));
$expire=date('c',time()+600); $expire=date('c',time()+600);
echo('<?xml version="1.0" encoding="UTF-8"?>'); echo('<?xml version="1.0" encoding="UTF-8"?>');
@ -136,8 +136,14 @@ class OC_MEDIA_AMPACHE{
return false; return false;
} }
} }
$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" );
if($CONFIG_DBTYPE == 'psql'){
$interval = ' \'600s\'::interval ';
}else {
$interval = '600';
}
//remove old sessions //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->execute();
$query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?");

View File

@ -104,7 +104,7 @@ class OC_MEDIA_COLLECTION{
return self::$albumIdCache[$artistId][$albumId][$name]; return self::$albumIdCache[$artistId][$albumId][$name];
}else{ }else{
$uid=$_SESSION['user_id']; $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(); $songs=$query->execute(array($uid,$name,$artistId,$albumId))->fetchAll();
if(is_array($songs) and isset($songs[0])){ if(is_array($songs) and isset($songs[0])){
self::$albumIdCache[$artistId][$albumId][$name]=$songs[0]['song_id']; self::$albumIdCache[$artistId][$albumId][$name]=$songs[0]['song_id'];
@ -277,7 +277,7 @@ class OC_MEDIA_COLLECTION{
$query=self::$queries['addsong']; $query=self::$queries['addsong'];
} }
$query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size)); $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(); // self::setLastUpdated();
return self::getSongId($name,$artist,$album); return self::getSongId($name,$artist,$album);
} }

View File

@ -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{ class OC_MEDIA{
/** /**
* get the sha256 hash of the password needed for ampache * get the sha256 hash of the password needed for ampache

View File

@ -180,6 +180,7 @@ class OC_Task_App {
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
$completed = new DateTime($completed, $timezone); $completed = new DateTime($completed, $timezone);
$vtodo->setDateTime('COMPLETED', $completed); $vtodo->setDateTime('COMPLETED', $completed);
OCP\Util::emitHook('OC_Task', 'taskCompleted', $vtodo);
} else { } else {
unset($vtodo->COMPLETED); unset($vtodo->COMPLETED);
} }

View File

@ -171,7 +171,7 @@ class OC_LDAP {
* returns the internal ownCloud name for the given LDAP DN of the group * returns the internal ownCloud name for the given LDAP DN of the group
*/ */
static public function dn2groupname($dn, $ldapname = null) { 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 false;
} }
return self::dn2ocname($dn, $ldapname, 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 * 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) { 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 false;
} }
return self::dn2ocname($dn, $ldapname, true); return self::dn2ocname($dn, $ldapname, true);
@ -425,7 +425,7 @@ class OC_LDAP {
if(isset($result[$attr]) && $result[$attr]['count'] > 0){ if(isset($result[$attr]) && $result[$attr]['count'] > 0){
$values = array(); $values = array();
for($i=0;$i<$result[$attr]['count'];$i++) { 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; return $values;
} }
@ -508,7 +508,7 @@ class OC_LDAP {
$key = strtolower($key); $key = strtolower($key);
if(isset($item[$key])) { if(isset($item[$key])) {
if($key != 'dn'){ if($key != 'dn'){
$selection[$i][$key] = $item[$key][0]; $selection[$i][$key] = self::resemblesDN($key) ? self::sanitizeDN($item[$key][0]) : $item[$key][0];
} else { } else {
$selection[$i][$key] = self::sanitizeDN($item[$key]); $selection[$i][$key] = self::sanitizeDN($item[$key]);
} }
@ -521,7 +521,7 @@ class OC_LDAP {
$key = strtolower($attr[0]); $key = strtolower($attr[0]);
if(isset($item[$key])) { if(isset($item[$key])) {
if($key == 'dn') { if(self::resemblesDN($key)) {
$selection[] = self::sanitizeDN($item[$key]); $selection[] = self::sanitizeDN($item[$key]);
} else { } else {
$selection[] = $item[$key]; $selection[] = $item[$key];
@ -536,6 +536,15 @@ class OC_LDAP {
return $findings; return $findings;
} }
static private function resemblesDN($attr) {
$resemblingAttributes = array(
'dn',
'uniquemember',
'member'
);
return in_array($attr, $resemblingAttributes);
}
static private function sanitizeDN($dn) { 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! //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); $dn = preg_replace('/([^\\\]),(\s+)/','\1,',$dn);

View File

@ -106,6 +106,7 @@ label.infield { cursor: text !important; }
/* VARIOUS REUSABLE SELECTORS */ /* VARIOUS REUSABLE SELECTORS */
.hidden { display:none; } .hidden { display:none; }
.bold { font-weight: bold; } .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; } #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; }

View File

@ -136,7 +136,7 @@
var option=$('<option selected="selected"/>'); var option=$('<option selected="selected"/>');
option.attr('value',$(this).val()); option.attr('value',$(this).val());
option.text($(this).val()); option.text($(this).val());
select.append(optione); select.append(options);
li.prev().children('input').trigger('click'); li.prev().children('input').trigger('click');
button.parent().data('preventHide',false); button.parent().data('preventHide',false);
if(settings.createCallback){ if(settings.createCallback){

View File

@ -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 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> <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"> <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> </form>
</div></header> </div></header>

View File

@ -381,7 +381,7 @@ class OC_App{
$file= self::getAppPath($appid).'/appinfo/version'; $file= self::getAppPath($appid).'/appinfo/version';
$version=@file_get_contents($file); $version=@file_get_contents($file);
if($version){ if($version){
return $version; return trim($version);
}else{ }else{
$appData=self::getAppInfo($appid); $appData=self::getAppInfo($appid);
return $appData['version']; return $appData['version'];

View File

@ -136,14 +136,16 @@ class OC{
$config_paths = OC_Config::getValue('apps_paths', array()); $config_paths = OC_Config::getValue('apps_paths', array());
if(! empty($config_paths)){ if(! empty($config_paths)){
foreach($config_paths as $paths) { foreach($config_paths as $paths) {
if( isset($paths['url']) && isset($paths['path'])) if( isset($paths['url']) && isset($paths['path'])) {
$paths['url'] = rtrim($paths['url'],'/');
$paths['path'] = rtrim($paths['path'],'/');
OC::$APPSROOTS[] = $paths; OC::$APPSROOTS[] = $paths;
} }
}
}elseif(file_exists(OC::$SERVERROOT.'/apps')){ }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')){ }elseif(file_exists(OC::$SERVERROOT.'/../apps')){
OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => '/apps/', 'writable' => true); OC::$APPSROOTS[] = array('path'=> rtrim(dirname(OC::$SERVERROOT), '/').'/apps', 'url' => '/apps', 'writable' => true);
OC::$APPSROOT=rtrim(dirname(OC::$SERVERROOT), '/');
} }
if(empty(OC::$APPSROOTS)){ if(empty(OC::$APPSROOTS)){

View File

@ -7,9 +7,28 @@
*/ */
class OC_Cache { class OC_Cache {
static protected $cache; static protected $user_cache;
static protected $global_cache;
static protected function init() { 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);
}
}
return self::$global_cache;
}
static public function getUserCache() {
if (!self::$user_cache) {
$fast_cache = null; $fast_cache = null;
if (!$fast_cache && function_exists('xcache_set')) { if (!$fast_cache && function_exists('xcache_set')) {
$fast_cache = new OC_Cache_XCache(); $fast_cache = new OC_Cache_XCache();
@ -17,48 +36,40 @@ class OC_Cache {
if (!$fast_cache && function_exists('apc_store')) { if (!$fast_cache && function_exists('apc_store')) {
$fast_cache = new OC_Cache_APC(); $fast_cache = new OC_Cache_APC();
} }
self::$cache = new OC_Cache_File(); self::$user_cache = new OC_Cache_File();
if ($fast_cache) { if ($fast_cache) {
self::$cache = new OC_Cache_Broker($fast_cache, self::$cache); self::$user_cache = new OC_Cache_Broker($fast_cache, self::$user_cache);
} }
} }
return self::$user_cache;
}
static public function get($key) { static public function get($key) {
if (!self::$cache) { $user_cache = self::getUserCache();
self::init(); return $user_cache->get($key);
}
return self::$cache->get($key);
} }
static public function set($key, $value, $ttl=0) { static public function set($key, $value, $ttl=0) {
if (empty($key)) { if (empty($key)) {
return false; return false;
} }
if (!self::$cache) { $user_cache = self::getUserCache();
self::init(); return $user_cache->set($key, $value, $ttl);
}
return self::$cache->set($key, $value, $ttl);
} }
static public function hasKey($key) { static public function hasKey($key) {
if (!self::$cache) { $user_cache = self::getUserCache();
self::init(); return $user_cache->hasKey($key);
}
return self::$cache->hasKey($key);
} }
static public function remove($key) { static public function remove($key) {
if (!self::$cache) { $user_cache = self::getUserCache();
self::init(); return $user_cache->remove($key);
}
return self::$cache->remove($key);
} }
static public function clear() { static public function clear() {
if (!self::$cache) { $user_cache = self::getUserCache();
self::init(); return $user_cache->clear();
}
return self::$cache->clear();
} }
} }

11
lib/cache/apc.php vendored
View File

@ -7,11 +7,20 @@
*/ */
class OC_Cache_APC { 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 * entries in APC gets namespaced to prevent collisions between owncloud instances and users
*/ */
protected function getNameSpace() { protected function getNameSpace() {
return OC_Util::getInstanceId().'/'.OC_User::getUser().'/'; return $this->prefix;
} }
public function get($key) { public function get($key) {

View File

@ -23,15 +23,13 @@ class OC_Cache_Broker {
} }
public function set($key, $value, $ttl=0) { public function set($key, $value, $ttl=0) {
$set_slow = strlen($value) > 8192; if (!$this->fast_cache->set($key, $value, $ttl)) {
if ($set_slow) {
if ($this->fast_cache->hasKey($key)) { if ($this->fast_cache->hasKey($key)) {
$this->fast_cache->remove($key); $this->fast_cache->remove($key);
} }
$this->slow_cache->set($key, $value, $ttl); return $this->slow_cache->set($key, $value, $ttl);
} else {
$this->fast_cache->set($key, $value, $ttl);
} }
return true;
} }
public function hasKey($key) { public function hasKey($key) {

11
lib/cache/xcache.php vendored
View File

@ -7,11 +7,20 @@
*/ */
class OC_Cache_XCache { 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 * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
*/ */
protected function getNameSpace() { protected function getNameSpace() {
return OC_Util::getInstanceId().'/'.OC_User::getUser().'/'; return $this->prefix;
} }
public function get($key) { public function get($key) {

View File

@ -246,6 +246,7 @@ class OC_DB {
$entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry = 'DB Error: "'.$result->getMessage().'"<br />';
$entry .= 'Offending command was: '.$query.'<br />'; $entry .= 'Offending command was: '.$query.'<br />';
OC_Log::write('core',$entry,OC_Log::FATAL); OC_Log::write('core',$entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry ); die( $entry );
} }
}else{ }else{
@ -255,6 +256,7 @@ class OC_DB {
$entry = 'DB Error: "'.$e->getMessage().'"<br />'; $entry = 'DB Error: "'.$e->getMessage().'"<br />';
$entry .= 'Offending command was: '.$query.'<br />'; $entry .= 'Offending command was: '.$query.'<br />';
OC_Log::write('core',$entry,OC_Log::FATAL); OC_Log::write('core',$entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry ); die( $entry );
} }
$result=new PDOStatementWrapper($result); $result=new PDOStatementWrapper($result);

View File

@ -110,7 +110,9 @@ class OC_FileCache{
$queryParts=array(); $queryParts=array();
foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){ foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){
if(isset($data[$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.'=?'; $queryParts[]=$attribute.'=?';
} }
} }

View File

@ -22,15 +22,18 @@ abstract class OC_Minimizer {
OC_Response::setLastModifiedHeader($last_modified); OC_Response::setLastModifiedHeader($last_modified);
$gzout = false; $gzout = false;
$cache = new OC_Cache_FileGlobal(); $cache = OC_Cache::getGlobalCache();
if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){ if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){
$gzout = $cache->get($cache_key.'.gz'); $gzout = $cache->get($cache_key.'.gz');
if ($gzout) {
OC_Response::setETagHeader(md5($gzout)); OC_Response::setETagHeader(md5($gzout));
} }
}
if (!$gzout) { if (!$gzout) {
$out = $this->minimizeFiles($files); $out = $this->minimizeFiles($files);
$gzout = gzencode($out); $gzout = gzencode($out);
OC_Response::setETagHeader(md5($gzout));
$cache->set($cache_key.'.gz', $gzout); $cache->set($cache_key.'.gz', $gzout);
} }
if ($encoding = OC_Request::acceptGZip()) { if ($encoding = OC_Request::acceptGZip()) {

View File

@ -150,6 +150,7 @@ class OC_Preferences{
$query = OC_DB::prepare( 'UPDATE *PREFIX*preferences SET configvalue = ? WHERE userid = ? AND appid = ? AND configkey = ?' ); $query = OC_DB::prepare( 'UPDATE *PREFIX*preferences SET configvalue = ? WHERE userid = ? AND appid = ? AND configkey = ?' );
$query->execute( array( $value, $user, $app, $key )); $query->execute( array( $value, $user, $app, $key ));
} }
return true;
} }
/** /**

View File

@ -16,20 +16,25 @@ if (!$pos = strpos($path_info, '/', 1)) {
} }
$service=substr($path_info, 1, $pos-1); $service=substr($path_info, 1, $pos-1);
$file = OC_AppConfig::getValue('core', 'remote_' . $service); $file = OC_AppConfig::getValue('core', 'remote_' . $service);
$file = preg_replace('/apps\//','', $file); //Todo Remove after Multiappdir migration
if(is_null($file)){ if(is_null($file)){
OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND);
exit; exit;
} }
if(count(explode('/',$file)) == 3) {
$file = ltrim ($file, '/');
if(count(explode('/',$file)) == 2) {
$parts=explode('/',$file); $parts=explode('/',$file);
$app=$parts[2]; $app=$parts[1];
OC_App::loadApp($app); OC_App::loadApp($app);
$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
require_once( OC::$SERVERROOT.$file); require_once( OC::$SERVERROOT.'/'.$file);
} else { } else {
$parts=explode('/', $file, 4); $parts=explode('/', $file, 2);
$app=$parts[2]; $app=$parts[0];
OC_App::loadApp($app); OC_App::loadApp($app);
$baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/';
require_once(OC_App::getAppPath($app) .'/'. $parts[3]); require_once(OC_App::getAppPath($app) .'/'. $parts[1]);
} }

View File

@ -93,6 +93,8 @@ usort($apps, 'app_sort');
$tmpl = new OC_Template( "settings", "apps", "user" ); $tmpl = new OC_Template( "settings", "apps", "user" );
$tmpl->assign('apps',$apps, false); $tmpl->assign('apps',$apps, false);
$appid = (isset($_GET['appid'])?strip_tags($_GET['appid']):'');
$tmpl->assign('appid',$appid);
$tmpl->printPage(); $tmpl->printPage();

View File

@ -53,3 +53,5 @@ span.version { margin-left:3em; color:#ddd; }
/* ADMIN */ /* ADMIN */
span.securitywarning {color:#C33; font-weight:bold; } span.securitywarning {color:#C33; font-weight:bold; }
h3.settingsNotice { font-size: 1.2em; }
.settingsNotice { font-weight:bold; padding: 0.5em 0; }

View File

@ -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');
}
}
}); });

View File

@ -213,5 +213,6 @@ $(document).ready(function(){
} }
} }
); );
location.reload();
}); });
}); });

View File

@ -3,14 +3,16 @@
* This file is licensed under the Affero General Public License version 3 or later. * This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file. * See the COPYING-README file.
*/?> */?>
<script type='text/javascript'>
var appid = '<?php echo $_['appid']; ?>';
</script>
<div id="controls"> <div id="controls">
<a class="button" target="_blank" href="http://owncloud.org/dev/writing-apps/"><?php echo $l->t('Add your App');?></a> <a class="button" target="_blank" href="http://owncloud.org/dev/writing-apps/"><?php echo $l->t('Add your App');?></a>
</div> </div>
<ul id="leftcontent"> <ul id="leftcontent">
<?php foreach($_['apps'] as $app):?> <?php foreach($_['apps'] as $app):?>
<li <?php if($app['active']) echo 'class="active"'?> data-id="<?php echo $app['id'] ?>"> <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"> <span class="hidden">
<?php OC_JSON::encodedPrint($app,false) ?> <?php OC_JSON::encodedPrint($app,false) ?>
</span> </span>

View File

@ -112,3 +112,8 @@ foreach($_["groups"] as $group) {
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </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;?>

View File

@ -33,11 +33,20 @@ foreach($quotaPreset as &$preset){
$defaultQuota=OC_Appconfig::getValue('files','default_quota','none'); $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 = new OC_Template( "settings", "users", "user" );
$tmpl->assign( "users", $users ); $tmpl->assign( "users", $users );
$tmpl->assign( "groups", $groups ); $tmpl->assign( "groups", $groups );
$tmpl->assign( 'quota_preset', $quotaPreset); $tmpl->assign( 'quota_preset', $quotaPreset);
$tmpl->assign( 'default_quota', $defaultQuota); $tmpl->assign( 'default_quota', $defaultQuota);
$tmpl->assign( 'share_notice', $shareNotice);
$tmpl->printPage(); $tmpl->printPage();
?> ?>