diff options
author | Tom Needham <needham.thomas@gmail.com> | 2011-10-03 22:59:40 +0100 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2011-10-03 22:59:40 +0100 |
commit | 02d7b1a1fc8f4bf62bfb973acfa0ee19ffa469ff (patch) | |
tree | dbf59263769a549a09f2aa5af3ccf2c9571bb125 | |
parent | 0825073e8cac2a654bbc89b99b5a83cdfee7a836 (diff) | |
parent | e8c6252a4ce1151b11f1faa8e602c06aae4294d8 (diff) | |
download | nextcloud-server-02d7b1a1fc8f4bf62bfb973acfa0ee19ffa469ff.tar.gz nextcloud-server-02d7b1a1fc8f4bf62bfb973acfa0ee19ffa469ff.zip |
Added breadcrumb and control bar.
190 files changed, 2604 insertions, 593 deletions
diff --git a/.gitignore b/.gitignore index 33f8e0c524b..ea8e5bd42fa 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,8 @@ RCS/* # eclipse .project .settings + +# netbeans +nbproject + +.DS_Store
\ No newline at end of file diff --git a/3rdparty/Sabre/CalDAV/Backend/Abstract.php b/3rdparty/Sabre/CalDAV/Backend/Abstract.php index 7ac282f44a0..b694eef49e4 100644 --- a/3rdparty/Sabre/CalDAV/Backend/Abstract.php +++ b/3rdparty/Sabre/CalDAV/Backend/Abstract.php @@ -36,20 +36,17 @@ abstract class Sabre_CalDAV_Backend_Abstract { * If the creation was a success, an id must be returned that can be used to reference * this calendar in other methods, such as updateCalendar. * - * This function must return a server-wide unique id that can be used - * later to reference the calendar. - * * @param string $principalUri * @param string $calendarUri * @param array $properties - * @return string|int + * @return void */ abstract function createCalendar($principalUri,$calendarUri,array $properties); /** - * Updates properties on this node, + * Updates properties for a calendar. * - * The properties array uses the propertyName in clark-notation as key, + * The mutations array uses the propertyName in clark-notation as key, * and the array value for the property value. In the case a property * should be deleted, the property value will be null. * @@ -79,10 +76,10 @@ abstract class Sabre_CalDAV_Backend_Abstract { * (424 Failed Dependency) because the request needs to be atomic. * * @param string $calendarId - * @param array $properties + * @param array $mutations * @return bool|array */ - public function updateCalendar($calendarId, array $properties) { + public function updateCalendar($calendarId, array $mutations) { return false; @@ -97,7 +94,7 @@ abstract class Sabre_CalDAV_Backend_Abstract { abstract function deleteCalendar($calendarId); /** - * Returns all calendar objects within a calendar object. + * Returns all calendar objects within a calendar. * * Every item contains an array with the following keys: * * id - unique identifier which will be used for subsequent updates diff --git a/3rdparty/Sabre/CalDAV/Backend/PDO.php b/3rdparty/Sabre/CalDAV/Backend/PDO.php index d1785bb8f8f..7b1b33b912e 100644 --- a/3rdparty/Sabre/CalDAV/Backend/PDO.php +++ b/3rdparty/Sabre/CalDAV/Backend/PDO.php @@ -129,7 +129,6 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { * @param string $principalUri * @param string $calendarUri * @param array $properties - * @return mixed */ public function createCalendar($principalUri,$calendarUri, array $properties) { @@ -173,9 +172,9 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { } /** - * Updates a calendars properties + * Updates properties for a calendar. * - * The properties array uses the propertyName in clark-notation as key, + * The mutations array uses the propertyName in clark-notation as key, * and the array value for the property value. In the case a property * should be deleted, the property value will be null. * @@ -205,10 +204,10 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { * (424 Failed Dependency) because the request needs to be atomic. * * @param string $calendarId - * @param array $properties + * @param array $mutations * @return bool|array */ - public function updateCalendar($calendarId, array $properties) { + public function updateCalendar($calendarId, array $mutations) { $newValues = array(); $result = array( @@ -219,13 +218,13 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { $hasError = false; - foreach($properties as $propertyName=>$propertyValue) { + foreach($mutations as $propertyName=>$propertyValue) { // We don't know about this property. if (!isset($this->propertyMap[$propertyName])) { $hasError = true; $result[403][$propertyName] = null; - unset($properties[$propertyName]); + unset($mutations[$propertyName]); continue; } @@ -237,7 +236,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { // If there were any errors we need to fail the request if ($hasError) { // Properties has the remaining properties - foreach($properties as $propertyName=>$propertyValue) { + foreach($mutations as $propertyName=>$propertyValue) { $result[424][$propertyName] = null; } @@ -284,7 +283,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { } /** - * Returns all calendar objects within a calendar object. + * Returns all calendar objects within a calendar. * * Every item contains an array with the following keys: * * id - unique identifier which will be used for subsequent updates diff --git a/3rdparty/Sabre/CalDAV/Calendar.php b/3rdparty/Sabre/CalDAV/Calendar.php index a50aef12b4f..0d2b3875771 100644 --- a/3rdparty/Sabre/CalDAV/Calendar.php +++ b/3rdparty/Sabre/CalDAV/Calendar.php @@ -12,7 +12,7 @@ * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class Sabre_CalDAV_Calendar implements Sabre_DAV_ICollection, Sabre_DAV_IProperties, Sabre_DAVACL_IACL { +class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProperties, Sabre_DAVACL_IACL { /** * This is an array with calendar information @@ -178,6 +178,8 @@ class Sabre_CalDAV_Calendar implements Sabre_DAV_ICollection, Sabre_DAV_IPropert public function createFile($name,$calendarData = null) { $calendarData = stream_get_contents($calendarData); + // Converting to UTF-8, if needed + $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData); $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']; if ($supportedComponents) { diff --git a/3rdparty/Sabre/CalDAV/CalendarObject.php b/3rdparty/Sabre/CalDAV/CalendarObject.php index b5c4e49b838..0c99f18deb7 100644 --- a/3rdparty/Sabre/CalDAV/CalendarObject.php +++ b/3rdparty/Sabre/CalDAV/CalendarObject.php @@ -9,7 +9,7 @@ * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_DAVACL_IACL { +class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV_ICalendarObject, Sabre_DAVACL_IACL { /** * Sabre_CalDAV_Backend_Abstract @@ -93,6 +93,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_DAVACL if (is_resource($calendarData)) $calendarData = stream_get_contents($calendarData); + // Converting to UTF-8, if needed + $calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData); + $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']; if ($supportedComponents) { $supportedComponents = $supportedComponents->getValue(); diff --git a/3rdparty/Sabre/CalDAV/ICalendar.php b/3rdparty/Sabre/CalDAV/ICalendar.php new file mode 100644 index 00000000000..8193dff3a83 --- /dev/null +++ b/3rdparty/Sabre/CalDAV/ICalendar.php @@ -0,0 +1,18 @@ +<?php + +/** + * Calendar interface + * + * Implement this interface to allow a node to be recognized as an calendar. + * + * @package Sabre + * @subpackage CalDAV + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +interface Sabre_CalDAV_ICalendar extends Sabre_DAV_ICollection { + + + +} diff --git a/3rdparty/Sabre/CalDAV/ICalendarObject.php b/3rdparty/Sabre/CalDAV/ICalendarObject.php new file mode 100644 index 00000000000..708300ad7bd --- /dev/null +++ b/3rdparty/Sabre/CalDAV/ICalendarObject.php @@ -0,0 +1,20 @@ +<?php + +/** + * CalendarObject interface +/** + * Extend the ICalendarObject interface to allow your custom nodes to be picked up as + * CalendarObjects. + * + * Calendar objects are resources such as Events, Todo's or Journals. + * + * @package Sabre + * @subpackage CalDAV + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +interface Sabre_CalDAV_ICalendarObject extends Sabre_DAV_IFile { + +} + diff --git a/3rdparty/Sabre/CalDAV/Plugin.php b/3rdparty/Sabre/CalDAV/Plugin.php index 640595e74ba..02747c8395e 100644 --- a/3rdparty/Sabre/CalDAV/Plugin.php +++ b/3rdparty/Sabre/CalDAV/Plugin.php @@ -114,7 +114,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { public function getSupportedReportSet($uri) { $node = $this->server->tree->getNodeForPath($uri); - if ($node instanceof Sabre_CalDAV_Calendar || $node instanceof Sabre_CalDAV_CalendarObject) { + if ($node instanceof Sabre_CalDAV_ICalendar || $node instanceof Sabre_CalDAV_ICalendarObject) { return array( '{' . self::NS_CALDAV . '}calendar-multiget', '{' . self::NS_CALDAV . '}calendar-query', @@ -143,7 +143,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { $server->propertyMap['{' . self::NS_CALDAV . '}supported-calendar-component-set'] = 'Sabre_CalDAV_Property_SupportedCalendarComponentSet'; - $server->resourceTypeMapping['Sabre_CalDAV_Calendar'] = '{urn:ietf:params:xml:ns:caldav}calendar'; + $server->resourceTypeMapping['Sabre_CalDAV_ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar'; $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyRead'] = '{http://calendarserver.org/ns/}calendar-proxy-read'; $server->resourceTypeMapping['Sabre_CalDAV_Principal_ProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write'; @@ -326,7 +326,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } // instanceof IPrincipal - if ($node instanceof Sabre_CalDAV_CalendarObject) { + if ($node instanceof Sabre_CalDAV_ICalendarObject) { // The calendar-data property is not supposed to be a 'real' // property, but in large chunks of the spec it does act as such. // Therefore we simply expose it as a property. diff --git a/3rdparty/Sabre/CalDAV/Version.php b/3rdparty/Sabre/CalDAV/Version.php index 5ecc0cebb37..df8fe1f6bd6 100644 --- a/3rdparty/Sabre/CalDAV/Version.php +++ b/3rdparty/Sabre/CalDAV/Version.php @@ -14,7 +14,7 @@ class Sabre_CalDAV_Version { /** * Full version number */ - const VERSION = '1.5.0'; + const VERSION = '1.5.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php index 04e4c227b86..3333480ea85 100644 --- a/3rdparty/Sabre/CardDAV/AddressBook.php +++ b/3rdparty/Sabre/CardDAV/AddressBook.php @@ -112,6 +112,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca public function createFile($name,$vcardData = null) { $vcardData = stream_get_contents($vcardData); + // Converting to UTF-8, if needed + $vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData); $this->carddavBackend->createCard($this->addressBookInfo['id'],$name,$vcardData); diff --git a/3rdparty/Sabre/CardDAV/Backend/PDO.php b/3rdparty/Sabre/CardDAV/Backend/PDO.php index 63a74745aac..5556d0a7648 100644 --- a/3rdparty/Sabre/CardDAV/Backend/PDO.php +++ b/3rdparty/Sabre/CardDAV/Backend/PDO.php @@ -66,7 +66,9 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract { 'principaluri' => $row['principaluri'], '{DAV:}displayname' => $row['displayname'], '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], - '{http://calendarserver.org/ns/}getctag' => $row['ctag'], + '{http://calendarserver.org/ns/}getctag' => $row['ctag'], + '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => + new Sabre_CardDAV_Property_SupportedAddressData(), ); } diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php index 52d8b79d7dd..5298d31e245 100644 --- a/3rdparty/Sabre/CardDAV/Card.php +++ b/3rdparty/Sabre/CardDAV/Card.php @@ -88,6 +88,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard, if (is_resource($cardData)) $cardData = stream_get_contents($cardData); + // Converting to UTF-8, if needed + $cardData = Sabre_DAV_StringUtil::ensureUTF8($cardData); + $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData); $this->cardData['carddata'] = $cardData; diff --git a/3rdparty/Sabre/CardDAV/Plugin.php b/3rdparty/Sabre/CardDAV/Plugin.php index a96f9aaebb6..17766b78278 100644 --- a/3rdparty/Sabre/CardDAV/Plugin.php +++ b/3rdparty/Sabre/CardDAV/Plugin.php @@ -95,9 +95,10 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { public function getSupportedReportSet($uri) { $node = $this->server->tree->getNodeForPath($uri); - if ($node instanceof Sabre_CardDAV_AddressBook || $node instanceof Sabre_CardDAV_ICard) { + if ($node instanceof Sabre_CardDAV_IAddressBook || $node instanceof Sabre_CardDAV_ICard) { return array( '{' . self::NS_CARDDAV . '}addressbook-multiget', + '{' . self::NS_CARDDAV . '}addressbook-query', ); } return array(); diff --git a/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php new file mode 100644 index 00000000000..d57d3a6e7bd --- /dev/null +++ b/3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php @@ -0,0 +1,69 @@ +<?php + +/** + * Supported-address-data property + * + * This property is a representation of the supported-address-data property + * in the CardDAV namespace. + * + * @package Sabre + * @subpackage CardDAV + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property { + + /** + * supported versions + * + * @var array + */ + protected $supportedData = array(); + + /** + * Creates the property + * + * @param array $components + */ + public function __construct(array $supportedData = null) { + + if (is_null($supportedData)) { + $supportedData = array( + array('contentType' => 'text/vcard', 'version' => '3.0'), + array('contentType' => 'text/vcard', 'version' => '4.0'), + ); + } + + $this->supportedData = $supportedData; + + } + + /** + * Serializes the property in a DOMDocument + * + * @param Sabre_DAV_Server $server + * @param DOMElement $node + * @return void + */ + public function serialize(Sabre_DAV_Server $server,DOMElement $node) { + + $doc = $node->ownerDocument; + + $prefix = + isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ? + $server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] : + 'card'; + + foreach($this->supportedData as $supported) { + + $caldata = $doc->createElementNS(Sabre_CardDAV_Plugin::NS_CARDDAV, $prefix . ':address-data-type'); + $caldata->setAttribute('content-type',$supported['contentType']); + $caldata->setAttribute('version',$supported['version']); + $node->appendChild($caldata); + + } + + } + +} diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php index 8961027fc89..c76ee360354 100644 --- a/3rdparty/Sabre/CardDAV/Version.php +++ b/3rdparty/Sabre/CardDAV/Version.php @@ -18,11 +18,11 @@ class Sabre_CardDAV_Version { /** * Full version number */ - const VERSION = '0.2'; + const VERSION = '1.5.3'; /** * Stability : alpha, beta, stable */ - const STABILITY = 'alpha'; + const STABILITY = 'stable'; } diff --git a/3rdparty/Sabre/DAV/Browser/Plugin.php b/3rdparty/Sabre/DAV/Browser/Plugin.php index 8e0ca24cff2..cd5617babb1 100644 --- a/3rdparty/Sabre/DAV/Browser/Plugin.php +++ b/3rdparty/Sabre/DAV/Browser/Plugin.php @@ -68,9 +68,16 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin { public function httpGetInterceptor($method, $uri) { if ($method!='GET') return true; - - $node = $this->server->tree->getNodeForPath($uri); - if ($node instanceof Sabre_DAV_IFile) return true; + + try { + $node = $this->server->tree->getNodeForPath($uri); + } catch (Sabre_DAV_Exception_FileNotFound $e) { + // We're simply stopping when the file isn't found to not interfere + // with other plugins. + return; + } + if ($node instanceof Sabre_DAV_IFile) + return; $this->server->httpResponse->sendStatus(200); $this->server->httpResponse->setHeader('Content-Type','text/html; charset=utf-8'); @@ -165,6 +172,8 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin { '{DAV:}getlastmodified', ),1); + $parent = $this->server->tree->getNodeForPath($path); + if ($path) { @@ -189,6 +198,7 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin { $type = null; + if (isset($file[200]['{DAV:}resourcetype'])) { $type = $file[200]['{DAV:}resourcetype']->getValue(); @@ -246,7 +256,7 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin { $html.= "<tr><td colspan=\"4\"><hr /></td></tr>"; - if ($this->enablePost) { + if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) { $html.= '<tr><td><form method="post" action=""> <h3>Create new folder</h3> <input type="hidden" name="sabreAction" value="mkcol" /> diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php index c6c63143d13..b99866dad5e 100644 --- a/3rdparty/Sabre/DAV/Server.php +++ b/3rdparty/Sabre/DAV/Server.php @@ -738,6 +738,34 @@ class Sabre_DAV_Server { $body = $this->httpRequest->getBody(); + // Intercepting Content-Range + if ($this->httpRequest->getHeader('Content-Range')) { + /** + Content-Range is dangerous for PUT requests: PUT per definition + stores a full resource. draft-ietf-httpbis-p2-semantics-15 says + in section 7.6: + An origin server SHOULD reject any PUT request that contains a + Content-Range header field, since it might be misinterpreted as + partial content (or might be partial content that is being mistakenly + PUT as a full representation). Partial content updates are possible + by targeting a separately identified resource with state that + overlaps a portion of the larger resource, or by using a different + method that has been specifically defined for partial updates (for + example, the PATCH method defined in [RFC5789]). + This clarifies RFC2616 section 9.6: + The recipient of the entity MUST NOT ignore any Content-* + (e.g. Content-Range) headers that it does not understand or implement + and MUST return a 501 (Not Implemented) response in such cases. + OTOH is a PUT request with a Content-Range currently the only way to + continue an aborted upload request and is supported by curl, mod_dav, + Tomcat and others. Since some clients do use this feature which results + in unexpected behaviour (cf PEAR::HTTP_WebDAV_Client 1.0.1), we reject + all PUT requests with a Content-Range for now. + */ + + throw new Sabre_DAV_Exception_NotImplemented('PUT with Content-Range is not allowed.'); + } + // Intercepting the Finder problem if (($expected = $this->httpRequest->getHeader('X-Expected-Entity-Length')) && $expected > 0) { @@ -798,7 +826,10 @@ class Sabre_DAV_Server { } else { // If we got here, the resource didn't exist yet. - $this->createFile($this->getRequestUri(),$body); + if (!$this->createFile($this->getRequestUri(),$body)) { + // For one reason or another the file was not created. + return; + } $this->httpResponse->setHeader('Content-Length','0'); $this->httpResponse->sendStatus(201); @@ -1377,23 +1408,27 @@ class Sabre_DAV_Server { * Currently this is done by HTTP PUT and HTTP LOCK (in the Locks_Plugin). * It was important to get this done through a centralized function, * allowing plugins to intercept this using the beforeCreateFile event. + * + * This method will return true if the file was actually created * * @param string $uri * @param resource $data - * @return void + * @return bool */ public function createFile($uri,$data) { list($dir,$name) = Sabre_DAV_URLUtil::splitPath($uri); - if (!$this->broadcastEvent('beforeBind',array($uri))) return; - if (!$this->broadcastEvent('beforeCreateFile',array($uri,$data))) return; + if (!$this->broadcastEvent('beforeBind',array($uri))) return false; + if (!$this->broadcastEvent('beforeCreateFile',array($uri,$data))) return false; $parent = $this->tree->getNodeForPath($dir); $parent->createFile($name,$data); $this->tree->markDirty($dir); $this->broadcastEvent('afterBind',array($uri)); + + return true; } /** diff --git a/3rdparty/Sabre/DAV/SimpleFile.php b/3rdparty/Sabre/DAV/SimpleFile.php new file mode 100644 index 00000000000..304dff1c5ec --- /dev/null +++ b/3rdparty/Sabre/DAV/SimpleFile.php @@ -0,0 +1,120 @@ +<?php + +/** + * SimpleFile + * + * The 'SimpleFile' class is used to easily add read-only immutable files to + * the directory structure. One usecase would be to add a 'readme.txt' to a + * root of a webserver with some standard content. + * + * @package Sabre + * @subpackage DAV + * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ +class Sabre_DAV_SimpleFile extends Sabre_DAV_File { + + /** + * File contents + * + * @var string + */ + protected $contents = array(); + + /** + * Name of this resource + * + * @var string + */ + protected $name; + + /** + * A mimetype, such as 'text/plain' or 'text/html' + * + * @var string + */ + protected $mimeType; + + /** + * Creates this node + * + * The name of the node must be passed, as well as the contents of the + * file. + * + * @param string $name + * @param string $contents + */ + public function __construct($name, $contents, $mimeType = null) { + + $this->name = $name; + $this->contents = $contents; + $this->mimeType = $mimeType; + + } + + /** + * Returns the node name for this file. + * + * This name is used to construct the url. + * + * @return string + */ + public function getName() { + + return $this->name; + + } + + /** + * Returns the data + * + * This method may either return a string or a readable stream resource + * + * @return mixed + */ + public function get() { + + return $this->contents; + + } + + /** + * Returns the size of the file, in bytes. + * + * @return int + */ + public function getSize() { + + return strlen($this->contents); + + } + + /** + * Returns the ETag for a file + * + * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. + * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * + * Return null if the ETag can not effectively be determined + */ + public function getETag() { + + return '"' . md5($this->contents) . '"'; + + } + + /** + * Returns the mime-type for a file + * + * If null is returned, we'll assume application/octet-stream + */ + public function getContentType() { + + return $this->mimeType; + + } + +} + +?> diff --git a/3rdparty/Sabre/DAV/StringUtil.php b/3rdparty/Sabre/DAV/StringUtil.php index b0b708f8e0f..440cf6866ca 100644 --- a/3rdparty/Sabre/DAV/StringUtil.php +++ b/3rdparty/Sabre/DAV/StringUtil.php @@ -64,6 +64,27 @@ class Sabre_DAV_StringUtil { } + } + + /** + * This method takes an input string, checks if it's not valid UTF-8 and + * attempts to convert it to UTF-8 if it's not. + * + * Note that currently this can only convert ISO-8559-1 to UTF-8 (latin-1), + * anything else will likely fail. + * + * @param string $input + * @return string + */ + static public function ensureUTF8($input) { + + $encoding = mb_detect_encoding($input , array('UTF-8','ISO-8859-1'), true); + + if ($encoding === 'ISO-8859-1') { + return utf8_encode($input); + } else { + return $input; + } } diff --git a/3rdparty/Sabre/DAV/URLUtil.php b/3rdparty/Sabre/DAV/URLUtil.php index 1502e4dd2ce..8f38749264b 100644 --- a/3rdparty/Sabre/DAV/URLUtil.php +++ b/3rdparty/Sabre/DAV/URLUtil.php @@ -30,9 +30,14 @@ class Sabre_DAV_URLUtil { */ static function encodePath($path) { - $path = explode('/',$path); - return implode('/',array_map(array('Sabre_DAV_URLUtil','encodePathSegment'), $path)); - + $valid_chars = '/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.~()'; + $newStr = ''; + for( $i=0; isset($path[$i]); ++$i ) { + if( strpos($valid_chars,($c=$path[$i]))===false ) $newStr .= '%'.sprintf('%02x',ord($c)); + else $newStr .= $c; + } + return $newStr; + } /** @@ -45,35 +50,13 @@ class Sabre_DAV_URLUtil { */ static function encodePathSegment($pathSegment) { + $valid_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.~()'; $newStr = ''; - for($i=0;$i<strlen($pathSegment);$i++) { - $c = ord($pathSegment[$i]); - - if( - - /* Unreserved chacaters */ - - ($c>=0x41 /* A */ && $c<=0x5a /* Z */) || - ($c>=0x61 /* a */ && $c<=0x7a /* z */) || - ($c>=0x30 /* 0 */ && $c<=0x39 /* 9 */) || - $c===0x5f /* _ */ || - $c===0x2d /* - */ || - $c===0x2e /* . */ || - $c===0x7E /* ~ */ || - - /* Reserved, but no reserved purpose */ - $c===0x28 /* ( */ || - $c===0x29 /* ) */ - - ) { - $newStr.=$pathSegment[$i]; - } else { - $newStr.='%' . str_pad(dechex($c), 2, '0', STR_PAD_LEFT); - } - + for( $i=0; isset($pathSegment[$i]); ++$i ) { + if( strpos($valid_chars,($c=$pathSegment[$i]))===false ) $newStr .= '%'.sprintf('%02x',ord($c)); + else $newStr .= $c; } return $newStr; - } /** @@ -103,6 +86,7 @@ class Sabre_DAV_URLUtil { case 'ISO-8859-1' : $path = utf8_encode($path); + } return $path; diff --git a/3rdparty/Sabre/DAV/Version.php b/3rdparty/Sabre/DAV/Version.php index c93d793ab67..e7f7f83e6ff 100644 --- a/3rdparty/Sabre/DAV/Version.php +++ b/3rdparty/Sabre/DAV/Version.php @@ -14,11 +14,11 @@ class Sabre_DAV_Version { /** * Full version number */ - const VERSION = '1.5.0'; + const VERSION = '1.5.3'; /** * Stability : alpha, beta, stable */ - const STABILITY = 'alpha'; + const STABILITY = 'stable'; } diff --git a/3rdparty/Sabre/DAVACL/Principal.php b/3rdparty/Sabre/DAVACL/Principal.php index 158b271058c..790603c900f 100644 --- a/3rdparty/Sabre/DAVACL/Principal.php +++ b/3rdparty/Sabre/DAVACL/Principal.php @@ -68,12 +68,19 @@ class Sabre_DAVACL_Principal extends Sabre_DAV_Node implements Sabre_DAVACL_IPri */ public function getAlternateUriSet() { + $uris = array(); + if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { + + $uris = $this->principalProperties['{DAV:}alternate-URI-set']; + + } + if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) { - return array('mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']); - } else { - return array(); + $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address']; } + return array_unique($uris); + } /** diff --git a/3rdparty/Sabre/DAVACL/Version.php b/3rdparty/Sabre/DAVACL/Version.php index a705507486c..124463e311e 100644 --- a/3rdparty/Sabre/DAVACL/Version.php +++ b/3rdparty/Sabre/DAVACL/Version.php @@ -14,7 +14,7 @@ class Sabre_DAVACL_Version { /** * Full version number */ - const VERSION = '1.4.4'; + const VERSION = '1.5.2'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/HTTP/Response.php b/3rdparty/Sabre/HTTP/Response.php index c8c77251a17..dce6feac553 100644 --- a/3rdparty/Sabre/HTTP/Response.php +++ b/3rdparty/Sabre/HTTP/Response.php @@ -23,7 +23,7 @@ class Sabre_HTTP_Response { 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', - 200 => 'Ok', + 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authorative Information', diff --git a/3rdparty/Sabre/HTTP/Version.php b/3rdparty/Sabre/HTTP/Version.php index f8d1bb75429..67be232fc26 100644 --- a/3rdparty/Sabre/HTTP/Version.php +++ b/3rdparty/Sabre/HTTP/Version.php @@ -14,7 +14,7 @@ class Sabre_HTTP_Version { /** * Full version number */ - const VERSION = '1.4.1'; + const VERSION = '1.5.3'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/Sabre/VObject/Property.php b/3rdparty/Sabre/VObject/Property.php index 201e6356ad6..624dd4b8a58 100644 --- a/3rdparty/Sabre/VObject/Property.php +++ b/3rdparty/Sabre/VObject/Property.php @@ -128,6 +128,44 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { } + /** + * Adds a new componenten or element + * + * You can call this method with the following syntaxes: + * + * add(Sabre_VObject_Parameter $element) + * add(string $name, $value) + * + * The first version adds an Parameter + * The second adds a property as a string. + * + * @param mixed $item + * @param mixed $itemValue + * @return void + */ + public function add($item, $itemValue = null) { + + if ($item instanceof Sabre_VObject_Parameter) { + if (!is_null($itemValue)) { + throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + } + $this->parameters[] = $item; + } elseif(is_string($item)) { + + if (!is_scalar($itemValue)) { + throw new InvalidArgumentException('The second argument must be scalar'); + } + $this->parameters[] = new Sabre_VObject_Parameter($item,$itemValue); + + } else { + + throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + + } + + } + + /* ArrayAccess interface {{{ */ /** diff --git a/3rdparty/Sabre/VObject/Reader.php b/3rdparty/Sabre/VObject/Reader.php index 9c20e33cea0..c38afbfb632 100644 --- a/3rdparty/Sabre/VObject/Reader.php +++ b/3rdparty/Sabre/VObject/Reader.php @@ -42,16 +42,10 @@ class Sabre_VObject_Reader { */ static function read($data) { - // Detecting line endings - if (strpos($data,"\r\n")!==false) { - $newLine = "\r\n"; - } elseif (strpos($data,"\r")) { - $newLine = "\r"; - } else { - $newLine = "\n"; - } + // Normalizing newlines + $data = str_replace(array("\r","\n\n"), array("\n","\n"), $data); - $lines = explode($newLine, $data); + $lines = explode("\n", $data); // Unfolding lines $lines2 = array(); diff --git a/3rdparty/Sabre/VObject/Version.php b/3rdparty/Sabre/VObject/Version.php index 8c3fe67b1f4..950c1c51104 100644 --- a/3rdparty/Sabre/VObject/Version.php +++ b/3rdparty/Sabre/VObject/Version.php @@ -14,7 +14,7 @@ class Sabre_VObject_Version { /** * Full version number */ - const VERSION = '1.2.0'; + const VERSION = '1.2.2'; /** * Stability : alpha, beta, stable diff --git a/3rdparty/css/chosen.css b/3rdparty/css/chosen.css index 247d07bf021..96bae0fe95a 100644 --- a/3rdparty/css/chosen.css +++ b/3rdparty/css/chosen.css @@ -10,6 +10,7 @@ select.chzn-select { display: inline-block; zoom: 1; *display: inline; + vertical-align: bottom; } .chzn-container .chzn-drop { background: #fff; @@ -4,7 +4,7 @@ It is alpha software in development and should be treated accordingly. http://ownCloud.org -Installation instructions: http://owncloud.org/index.php/Installation +Installation instructions: http://owncloud.org/install Source code: http://gitorious.org/owncloud Mailing list: http://mail.kde.org/mailman/listinfo/owncloud diff --git a/apps/admin_export/appinfo/app.php b/apps/admin_export/appinfo/app.php new file mode 100644 index 00000000000..beebb4864e9 --- /dev/null +++ b/apps/admin_export/appinfo/app.php @@ -0,0 +1,33 @@ +<?php + +/** +* ownCloud - user_ldap +* +* @author Dominik Schmidt +* @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + + +OC_APP::registerAdmin('admin_export','settings'); + +// add settings page to navigation +$entry = array( + 'id' => "admin_export_settings", + 'order'=>1, + 'href' => OC_Helper::linkTo( "admin_export", "settings.php" ), + 'name' => 'Export' +); diff --git a/apps/admin_export/appinfo/info.xml b/apps/admin_export/appinfo/info.xml new file mode 100644 index 00000000000..c4a2a9b398c --- /dev/null +++ b/apps/admin_export/appinfo/info.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<info> + <id>admin_export</id> + <name>Import/Export</name> + <description>Import/Export your owncloud data</description> + <version>0.1</version> + <licence>AGPL</licence> + <author>Thomas Schmidt</author> + <require>2</require> +</info> diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php new file mode 100644 index 00000000000..8308a2b89b5 --- /dev/null +++ b/apps/admin_export/settings.php @@ -0,0 +1,96 @@ +<?php + +/** + * ownCloud - admin export + * + * @author Thomas Schmidt + * @copyright 2011 Thomas Schmidt tom@opensuse.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ +OC_Util::checkAdminUser(); +OC_Util::checkAppEnabled('admin_export'); +if (isset($_POST['admin_export'])) { + $root = OC::$SERVERROOT . "/"; + $zip = new ZipArchive(); + $filename = sys_get_temp_dir() . "/owncloud_export_" . date("y-m-d_H-i-s") . ".zip"; + error_log("Creating export file at: " . $filename); + if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { + exit("Cannot open <$filename>\n"); + } + + if (isset($_POST['owncloud_system'])) { + // adding owncloud system files + error_log("Adding owncloud system files to export"); + zipAddDir($root, $zip, false); + foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dirname) { + zipAddDir($root . $dirname, $zip, true, basename($root) . "/"); + } + } + + if (isset($_POST['owncloud_config'])) { + // adding owncloud config + // todo: add database export + error_log("Adding owncloud config to export"); + zipAddDir($root . "config/", $zip, true, basename($root) . "/"); + $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/owncloud.db"); + } + + if (isset($_POST['user_files'])) { + // adding user files + $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/.htaccess"); + $zip->addFile($root . '/data/index.html', basename($root) . "/data/index.html"); + foreach (OC_User::getUsers() as $i) { + error_log("Adding owncloud user files of $i to export"); + zipAddDir($root . "data/" . $i, $zip, true, basename($root) . "/data/"); + } + } + + $zip->close(); + + header("Content-Type: application/zip"); + header("Content-Disposition: attachment; filename=" . basename($filename)); + header("Content-Length: " . filesize($filename)); + ob_end_clean(); + readfile($filename); + unlink($filename); +} else { +// fill template + $tmpl = new OC_Template('admin_export', 'settings'); + return $tmpl->fetchPage(); +} + +function zipAddDir($dir, $zip, $recursive=true, $internalDir='') { + $dirname = basename($dir); + $zip->addEmptyDir($internalDir . $dirname); + $internalDir.=$dirname.='/'; + + if ($dirhandle = opendir($dir)) { + while (false !== ( $file = readdir($dirhandle))) { + + if (( $file != '.' ) && ( $file != '..' )) { + + if (is_dir($dir . '/' . $file) && $recursive) { + zipAddDir($dir . '/' . $file, $zip, $recursive, $internalDir); + } elseif (is_file($dir . '/' . $file)) { + $zip->addFile($dir . '/' . $file, $internalDir . $file); + } + } + } + closedir($dirhandle); + } else { + error_log("Was not able to open directory: " . $dir); + } +} diff --git a/apps/admin_export/templates/settings.php b/apps/admin_export/templates/settings.php new file mode 100644 index 00000000000..47689facbbc --- /dev/null +++ b/apps/admin_export/templates/settings.php @@ -0,0 +1,13 @@ +<form id="export" action="#" method="post"> + <fieldset class="personalblock"> + <legend><strong><?php echo $l->t('Export this ownCloud instance');?></strong></legend> + <p><?php echo $l->t('This will create a compressed file that contains the data of this owncloud instance. + Please choose which components should be included:');?> + </p> + <p><input type="checkbox" id="user_files" name="user_files" value="true"><label for="user_files"><?php echo $l->t('User files');?></label><br/> + <input type="checkbox" id="owncloud_system" name="owncloud_system" value="true"><label for="owncloud_system"><?php echo $l->t('ownCloud system files');?></label><br/> + <input type="checkbox" id="owncloud_config" name="owncloud_config" value="true"><label for="owncloud_config"><?php echo $l->t('ownCloud configuration');?></label> + </p> + <input type="submit" name="admin_export" value="Export" /> + </fieldset> +</form> diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php index b62fcdfbeb0..a2a39134eab 100644 --- a/apps/bookmarks/addBm.php +++ b/apps/bookmarks/addBm.php @@ -25,6 +25,7 @@ require_once('../../lib/base.php'); // Check if we are a user OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('bookmarks'); require_once('bookmarksHelper.php'); diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index 9b0beb388a0..0dc83d9014d 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php index afe60f7d1bf..4aef86e771b 100644 --- a/apps/bookmarks/ajax/delBookmark.php +++ b/apps/bookmarks/ajax/delBookmark.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); $params=array( htmlspecialchars_decode($_GET["url"]), diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php index 5125f9ce898..b427a175e5f 100644 --- a/apps/bookmarks/ajax/editBookmark.php +++ b/apps/bookmarks/ajax/editBookmark.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ diff --git a/apps/bookmarks/ajax/getMeta.php b/apps/bookmarks/ajax/getMeta.php index 4583ef204b4..ca797315ef4 100644 --- a/apps/bookmarks/ajax/getMeta.php +++ b/apps/bookmarks/ajax/getMeta.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); // $metadata = array(); diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php index f5f7c20c6a0..e6fdfe043e1 100644 --- a/apps/bookmarks/ajax/recordClick.php +++ b/apps/bookmarks/ajax/recordClick.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); $query = OC_DB::prepare(" UPDATE *PREFIX*bookmarks diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php index de3480d6c3a..8e9bda0bc20 100644 --- a/apps/bookmarks/ajax/updateList.php +++ b/apps/bookmarks/ajax/updateList.php @@ -28,6 +28,7 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('bookmarks'); $params=array(OC_User::getUser()); $CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' ); diff --git a/apps/bookmarks/index.php b/apps/bookmarks/index.php index 45c9a52f557..50fea3fddbd 100644 --- a/apps/bookmarks/index.php +++ b/apps/bookmarks/index.php @@ -25,6 +25,7 @@ require_once('../../lib/base.php'); // Check if we are a user OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('bookmarks'); OC_App::setActiveNavigationEntry( 'bookmarks_index' ); diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php index cbc4910e1ae..36f04e135b6 100644 --- a/apps/bookmarks/templates/addBm.php +++ b/apps/bookmarks/templates/addBm.php @@ -1,8 +1,8 @@ <div class="bookmarks_addBm"> - <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<? echo $_['URL']; ?>"/></p> - <p><label class="bookmarks_label">Title</label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<? echo $_['TITLE']; ?>" /></p> - <p><label class="bookmarks_label">Description</label><input type="text" id="bookmark_add_description" class="bookmarks_input" value="<? echo $_['DESCRIPTION']; ?>" /></p> - <p><label class="bookmarks_label">Tags</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> - <p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p> - <p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p> -</div>
\ No newline at end of file + <p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" value="<?php echo $_['URL']; ?>"/></p> + <p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" value="<?php echo $_['TITLE']; ?>" /></p> + <p><label class="bookmarks_label"><?php echo $l->t('Description'); ?></label><input type="text" id="bookmark_add_description" class="bookmarks_input" value="<?php echo $_['DESCRIPTION']; ?>" /></p> + <p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> + <p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p> + <p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p> +</div> diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index 2aa5093c82b..d73657b36ac 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -1,30 +1,27 @@ <input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_GET['tag'])) echo htmlentities($_GET['tag']); ?>" /> -<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? 'Bookmarks with tag: ' . urldecode($_GET["tag"]) : 'All bookmarks'; ?></h2> +<h2 class="bookmarks_headline"><?php echo isset($_GET["tag"]) ? $l->t('Bookmarks with tag: ') . urldecode($_GET["tag"]) : $l->t('All bookmarks'); ?></h2> <div class="bookmarks_menu"> - <input type="button" class="bookmarks_addBtn" value="Add Bookmark"/> - <a class="bookmarks_addBml" href="javascript:var url = encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks');" title="Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.">Add page to ownCloud</a> + <input type="button" class="bookmarks_addBtn" value="<?php echo $l->t('Add bookmark'); ?>"/> + <a class="bookmarks_addBml" href="javascript:var url = encodeURIComponent(location.href);window.open('<?php echo OC_Helper::linkTo('bookmarks', 'addBm.php', null, true); ?>?url='+url, 'owncloud-bookmarks');" title="<?php echo $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage.'); ?>"><?php echo $l->t('Add page to ownCloud'); ?></a> </div> <div class="bookmarks_add"> <input type="hidden" id="bookmark_add_id" value="0" /> - <p><label class="bookmarks_label">Address</label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p> - <p><label class="bookmarks_label">Title</label><input type="text" id="bookmark_add_title" class="bookmarks_input" /> + <p><label class="bookmarks_label"><?php echo $l->t('Address'); ?></label><input type="text" id="bookmark_add_url" class="bookmarks_input" /></p> + <p><label class="bookmarks_label"><?php echo $l->t('Title'); ?></label><input type="text" id="bookmark_add_title" class="bookmarks_input" /> <img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p> - <p><label class="bookmarks_label">Description</label><input type="text" id="bookmark_add_description" class="bookmarks_input" /> + <p><label class="bookmarks_label"><?php echo $l->t('Description'); ?></label><input type="text" id="bookmark_add_description" class="bookmarks_input" /> <img class="loading_meta" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></p> - <p><label class="bookmarks_label">Tags</label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> - <p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p> - <p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p> + <p><label class="bookmarks_label"><?php echo $l->t('Tags'); ?></label><input type="text" id="bookmark_add_tags" class="bookmarks_input" /></p> + <p><label class="bookmarks_label"> </label><label class="bookmarks_hint"><?php echo $l->t('Hint: Use space to separate tags.'); ?></label></p> + <p><label class="bookmarks_label"></label><input type="submit" value="<?php echo $l->t('Add bookmark'); ?>" id="bookmark_add_submit" /></p> </div> <div class="bookmarks_sorting pager"> <ul> - <li class="bookmarks_sorting_recent">Recent Bookmarks</li> - <li class="bookmarks_sorting_clicks">Most clicks</li> + <li class="bookmarks_sorting_recent"><?php echo $l->t('Recent Bookmarks'); ?></li> + <li class="bookmarks_sorting_clicks"><?php echo $l->t('Most clicks'); ?></li> </ul> </div> <div class="clear"></div> <div class="bookmarks_list"> - <noscript> - JavaScript is needed to display your Bookmarks - </noscript> - You have no bookmarks + <?php echo $l->t('You have no bookmarks'); ?> </div> diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php index 38f727e9488..89239f21759 100644 --- a/apps/calendar/ajax/activation.php +++ b/apps/calendar/ajax/activation.php @@ -10,6 +10,7 @@ require_once ("../../../lib/base.php"); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +OC_JSON::checkAppEnabled('calendar'); $calendarid = $_POST['calendarid']; OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $cal = OC_Calendar_Calendar::findCalendar($calendarid); diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php index d19a11585a0..b396ff4945b 100644 --- a/apps/calendar/ajax/changeview.php +++ b/apps/calendar/ajax/changeview.php @@ -10,6 +10,7 @@ require_once ("../../../lib/base.php"); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +OC_JSON::checkAppEnabled('calendar'); $currentview = $_GET["v"]; OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview); ?> diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/choosecalendar.php index 44ff22906f1..0935a4c42ad 100644 --- a/apps/calendar/ajax/choosecalendar.php +++ b/apps/calendar/ajax/choosecalendar.php @@ -11,6 +11,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +OC_JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); $output -> printpage(); ?> diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php index 7d80333b258..82176d4368a 100644 --- a/apps/calendar/ajax/createcalendar.php +++ b/apps/calendar/ajax/createcalendar.php @@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); $userid = OC_User::getUser(); $calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], $_POST['description'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']); diff --git a/apps/calendar/ajax/daysofweekend.php b/apps/calendar/ajax/daysofweekend.php new file mode 100755 index 00000000000..606d13b1e1c --- /dev/null +++ b/apps/calendar/ajax/daysofweekend.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); +?> diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php index 30607b92e6f..e8ffe0d0598 100644 --- a/apps/calendar/ajax/deletecalendar.php +++ b/apps/calendar/ajax/deletecalendar.php @@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } +OC_JSON::checkAppEnabled('calendar'); $cal = $_POST["calendarid"]; $calendar = OC_Calendar_Calendar::findCalendar($cal); diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php index a6750267bd2..9e3c7dd87dd 100644 --- a/apps/calendar/ajax/deleteevent.php +++ b/apps/calendar/ajax/deleteevent.php @@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } +OC_JSON::checkAppEnabled('calendar'); $id = $_POST['id']; $data = OC_Calendar_Object::find($id); diff --git a/apps/calendar/ajax/duration.php b/apps/calendar/ajax/duration.php new file mode 100644 index 00000000000..cdc41388abd --- /dev/null +++ b/apps/calendar/ajax/duration.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); +OC_JSON::encodedPrint(array("duration" => $duration)); +?> diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php index 8f798d1bbf2..5f61cf50135 100644 --- a/apps/calendar/ajax/editcalendar.php +++ b/apps/calendar/ajax/editcalendar.php @@ -11,9 +11,21 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +$calendarcolor_options = array( + 'ff0000', // "Red" + '00ff00', // "Green" + 'ffff00', // "Yellow" + '808000', // "Olive" + 'ffa500', // "Orange" + 'ff7f50', // "Coral" + 'ee82ee', // "Violet" + 'ecc255', // dark yellow +); +OC_JSON::checkAppEnabled('calendar'); $calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']); $tmpl = new OC_Template("calendar", "part.editcalendar"); $tmpl->assign('new', false); +$tmpl->assign('calendarcolor_options', $calendarcolor_options); $tmpl->assign('calendar', $calendar); $tmpl->printPage(); ?> diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php index 7187e05d56f..3abf4de98b3 100644 --- a/apps/calendar/ajax/editevent.php +++ b/apps/calendar/ajax/editevent.php @@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } +OC_JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index 47008e02e90..34d6c657cec 100644 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php @@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } +OC_JSON::checkAppEnabled('calendar'); $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); $category_options = OC_Calendar_Object::getCategoryOptions($l10n); @@ -28,9 +29,10 @@ if($calendar['userid'] != OC_User::getUser()){ $object = Sabre_VObject_Reader::read($data['calendardata']); $vevent = $object->VEVENT; $dtstart = $vevent->DTSTART; -$dtend = $vevent->DTEND; +$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { case Sabre_VObject_Element_DateTime::LOCALTZ: + case Sabre_VObject_Element_DateTime::LOCAL: $startdate = $dtstart->getDateTime()->format('d-m-Y'); $starttime = $dtstart->getDateTime()->format('H:i'); $enddate = $dtend->getDateTime()->format('d-m-Y'); @@ -54,6 +56,11 @@ if (isset($vevent->CATEGORIES)){ $categories = explode(',', $vevent->CATEGORIES->value); $categories = array_map('trim', $categories); } +foreach($categories as $category){ + if (!in_array($category, $category_options)){ + array_unshift($category_options, $category); + } +} $repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : ''; $description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : ''; diff --git a/apps/calendar/ajax/firstdayofweek.php b/apps/calendar/ajax/firstdayofweek.php new file mode 100755 index 00000000000..eff82cece1d --- /dev/null +++ b/apps/calendar/ajax/firstdayofweek.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$firstdayofweek = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); +OC_JSON::encodedPrint(array("firstdayofweek" => $firstdayofweek)); +?>
\ No newline at end of file diff --git a/apps/calendar/ajax/getcal.php b/apps/calendar/ajax/getcal.php index 9794a83ce49..a65c6cf2602 100644 --- a/apps/calendar/ajax/getcal.php +++ b/apps/calendar/ajax/getcal.php @@ -10,6 +10,61 @@ require_once ("../../../lib/base.php"); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } -$output = new OC_TEMPLATE("calendar", "part.getcal"); -$output -> printpage(); -?> +OC_JSON::checkAppEnabled('calendar'); + +$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); +$events = array(); +$return = array('calendars'=>array()); +foreach($calendars as $calendar) { + $tmp = OC_Calendar_Object::all($calendar['id']); + $events = array_merge($events, $tmp); + $return['calendars'][$calendar['id']] = array( + 'displayname' => $calendar['displayname'], + 'color' => '#'.$calendar['calendarcolor'] + ); +} + +$select_year = $_GET["year"]; +$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); +foreach($events as $event) +{ + if ($select_year != substr($event['startdate'], 0, 4)) + continue; + $object = Sabre_VObject_Reader::read($event['calendardata']); + $vevent = $object->VEVENT; + $dtstart = $vevent->DTSTART; + $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); + $start_dt = $dtstart->getDateTime(); + $start_dt->setTimezone(new DateTimeZone($user_timezone)); + $end_dt = $dtend->getDateTime(); + $end_dt->setTimezone(new DateTimeZone($user_timezone)); + $year = $start_dt->format('Y'); + $month = $start_dt->format('n') - 1; // return is 0 based + $day = $start_dt->format('j'); + $hour = $start_dt->format('G'); + if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE) { + $hour = 'allday'; + } + + $return_event = array(); + foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop) + { + $return_event[$prop] = $event[$prop]; + } + $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i')); + $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i')); + $return_event['description'] = $event['summary']; + if ($hour == 'allday') + { + $return_event['allday'] = true; + } + if (isset($return[$year][$month][$day][$hour])) + { + $return[$year][$month][$day][$hour][] = $return_event; + } + else + { + $return[$year][$month][$day][$hour] = array(1 => $return_event); + } +} +OC_JSON::encodedPrint($return); diff --git a/apps/calendar/ajax/geteventinfo.php b/apps/calendar/ajax/geteventinfo.php deleted file mode 100644 index 2e5e713c197..00000000000 --- a/apps/calendar/ajax/geteventinfo.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -?> diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php new file mode 100644 index 00000000000..e2b777969da --- /dev/null +++ b/apps/calendar/ajax/moveevent.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +error_reporting(E_ALL); +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$data = OC_Calendar_Object::find($_POST["id"]); +$calendarid = $data["calendarid"]; +$cal = $calendarid; +$id = $_POST["id"]; +$calendar = OC_Calendar_Calendar::findCalendar($calendarid); +if(OC_User::getUser() != $calendar["userid"]){ + OC_JSON::error(); + exit; +} +$newdate = $_POST["newdate"]; +$caldata = array(); +//modified part of editeventform.php +$object = Sabre_VObject_Reader::read($data['calendardata']); +$vevent = $object->VEVENT; +$dtstart = $vevent->DTSTART; +$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); +switch($dtstart->getDateType()) { + case Sabre_VObject_Element_DateTime::LOCALTZ: + case Sabre_VObject_Element_DateTime::LOCAL: + $startdate = $dtstart->getDateTime()->format('d-m-Y'); + $starttime = $dtstart->getDateTime()->format('H:i'); + $enddate = $dtend->getDateTime()->format('d-m-Y'); + $endtime = $dtend->getDateTime()->format('H:i'); + $allday = false; + break; + case Sabre_VObject_Element_DateTime::DATE: + $startdate = $dtstart->getDateTime()->format('d-m-Y'); + $starttime = '00:00'; + $dtend->getDateTime()->modify('-1 day'); + $enddate = $dtend->getDateTime()->format('d-m-Y'); + $endtime = '23:59'; + $allday = true; + break; +} +$caldata["title"] = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : ''; +$caldata["location"] = isset($vevent->LOCATION) ? $vevent->LOCATION->value : ''; +$caldata["categories"] = array(); +if (isset($vevent->CATEGORIES)){ + $caldata["categories"] = explode(',', $vevent->CATEGORIES->value); + $caldata["categories"] = array_map('trim', $categories); +} +foreach($caldata["categories"] as $category){ + if (!in_array($category, $category_options)){ + array_unshift($category_options, $category); + } +} +$caldata["repeat"] = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : ''; +$caldata["description"] = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : ''; +//end part of editeventform.php +$startdatearray = explode("-", $startdate); +$starttimearray = explode(":", $starttime); +$startunix = mktime($starttimearray[0], $starttimearray[1], 0, $startdatearray[1], $startdatearray[0], $startdatearray[2]); +$enddatearray = explode("-", $enddate); +$endtimearray = explode(":", $endtime); +$endunix = mktime($endtimearray[0], $endtimearray[1], 0, $enddatearray[1], $enddatearray[0], $enddatearray[2]); +$difference = $endunix - $startunix; +if(strlen($newdate) > 10){ + $newdatestringarray = explode("-", $newdate); + if($newdatestringarray[1] == "allday"){ + $allday = true; + $newdatestringarray[1] = "00:00"; + }else{ + if($allday == true){ + $difference = 3600; + } + $allday = false; + } +}else{ + $newdatestringarray = array(); + $newdatestringarray[0] = $newdate; + $newdatestringarray[1] = $starttime; +} +$newdatearray = explode(".", $newdatestringarray[0]); +$newtimearray = explode(":", $newdatestringarray[1]); +$newstartunix = mktime($newtimearray[0], $newtimearray[1], 0, $newdatearray[1], $newdatearray[0], $newdatearray[2]); +$newendunix = $newstartunix + $difference; +if($allday == true){ + $caldata["allday"] = true; +}else{ + unset($caldata["allday"]); +} +$caldata["from"] = date("d-m-Y", $newstartunix); +$caldata["fromtime"] = date("H:i", $newstartunix); +$caldata["to"] = date("d-m-Y", $newendunix); +$caldata["totime"] = date("H:i", $newendunix); +//modified part of editevent.php +$vcalendar = Sabre_VObject_Reader::read($data["calendardata"]); +OC_Calendar_Object::updateVCalendarFromRequest($caldata, $vcalendar); + +$result = OC_Calendar_Object::edit($id, $vcalendar->serialize()); +OC_JSON::success(); +//end part of editevent.php +?>
\ No newline at end of file diff --git a/apps/calendar/ajax/newcalendar.php b/apps/calendar/ajax/newcalendar.php index ffcffb8afd7..e01ae01ee8a 100644 --- a/apps/calendar/ajax/newcalendar.php +++ b/apps/calendar/ajax/newcalendar.php @@ -11,11 +11,12 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +OC_JSON::checkAppEnabled('calendar'); $calendar = array( 'id' => 'new', - 'displayname' => 'Test', - 'description' => 'Test calendar', - 'calendarcolor' => 'black', + 'displayname' => '', + 'description' => '', + 'calendarcolor' => '', ); $tmpl = new OC_Template('calendar', 'part.editcalendar'); $tmpl->assign('new', true); diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php index 9ac3b0aaff6..1a696cf7780 100644 --- a/apps/calendar/ajax/newevent.php +++ b/apps/calendar/ajax/newevent.php @@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die("<script type=\"text/javascript\">document.location = oc_webroot;</script>"); } +OC_JSON::checkAppEnabled('calendar'); $errarr = OC_Calendar_Object::validateRequest($_POST); if($errarr){ diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php index 7a4c6f469e5..9d4dcfa2e13 100644 --- a/apps/calendar/ajax/neweventform.php +++ b/apps/calendar/ajax/neweventform.php @@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar'); if(!OC_USER::isLoggedIn()) { die('<script type="text/javascript">document.location = oc_webroot;</script>'); } +OC_JSON::checkAppEnabled('calendar'); $calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); $category_options = OC_Calendar_Object::getCategoryOptions($l10n); @@ -28,21 +29,21 @@ if($starttime != 'undefined' && !is_nan($starttime) && !$allday){ $starttime = '0'; $startminutes = '00'; }else{ - $starttime = date('H'); + $starttime = date('G'); + $startminutes = date('i'); } -$endday = $startday; -$endmonth = $startmonth; -$endyear = $startyear; -$endtime = $starttime; -$endminutes = $startminutes; -if($endtime == 23) { - $endday++; - $endtime = 0; -} else { - $endtime++; -} +$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear); +$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60"); +$datetimestamp = $datetimestamp + ($duration * 60); +$endmonth = date("m", $datetimestamp); +$endday = date("d", $datetimestamp); +$endyear = date("Y", $datetimestamp); +$endtime = date("G", $datetimestamp); +$endminutes = date("i", $datetimestamp); + + $tmpl = new OC_Template('calendar', 'part.newevent'); $tmpl->assign('calendar_options', $calendar_options); diff --git a/apps/calendar/ajax/setdaysofweekend.php b/apps/calendar/ajax/setdaysofweekend.php new file mode 100755 index 00000000000..b5ef5f8573f --- /dev/null +++ b/apps/calendar/ajax/setdaysofweekend.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$weekenddays = array("Monday"=>"false", "Tuesday"=>"false", "Wednesday"=>"false", "Thursday"=>"false", "Friday"=>"false", "Saturday"=>"false", "Sunday"=>"false"); +for($i = 0;$i < count($_POST["weekend"]); $i++){ + switch ($_POST["weekend"][$i]){ + case "Monday": + case "Tuesday": + case "Wednesday": + case "Thursday": + case "Friday": + case "Saturday": + case "Sunday": + break; + default: + OC_JSON::error(); + exit; + } + $weekenddays[$_POST["weekend"][$i]] = "true"; +} +$setValue = json_encode($weekenddays); +OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'weekend', $setValue); +OC_JSON::success(); +?> diff --git a/apps/calendar/ajax/setduration.php b/apps/calendar/ajax/setduration.php new file mode 100644 index 00000000000..a75c8faea42 --- /dev/null +++ b/apps/calendar/ajax/setduration.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["duration"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'duration', $_POST["duration"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/ajax/setfirstdayofweek.php b/apps/calendar/ajax/setfirstdayofweek.php new file mode 100755 index 00000000000..571b95af0e3 --- /dev/null +++ b/apps/calendar/ajax/setfirstdayofweek.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["firstdayofweek"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'firstdayofweek', $_POST["firstdayofweek"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> diff --git a/apps/calendar/ajax/settimeformat.php b/apps/calendar/ajax/settimeformat.php new file mode 100644 index 00000000000..7805120ba5e --- /dev/null +++ b/apps/calendar/ajax/settimeformat.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +if(isset($_POST["timeformat"])){ + OC_Preferences::setValue(OC_User::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]); + OC_JSON::success(); +}else{ + OC_JSON::error(); +} +?> + diff --git a/apps/calendar/ajax/settimezone.php b/apps/calendar/ajax/settimezone.php index 2b82bc8e4bc..c726a11471d 100644 --- a/apps/calendar/ajax/settimezone.php +++ b/apps/calendar/ajax/settimezone.php @@ -13,6 +13,7 @@ $l=new OC_L10N('calendar'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); // Get data if( isset( $_POST['timezone'] ) ){ diff --git a/apps/calendar/ajax/timeformat.php b/apps/calendar/ajax/timeformat.php new file mode 100644 index 00000000000..3533adcf8e0 --- /dev/null +++ b/apps/calendar/ajax/timeformat.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$timeformat = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24"); +OC_JSON::encodedPrint(array("timeformat" => $timeformat)); +?> diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php index d53515d0deb..5cf48d50ea1 100644 --- a/apps/calendar/ajax/updatecalendar.php +++ b/apps/calendar/ajax/updatecalendar.php @@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('calendar'); $calendarid = $_POST['id']; OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']); diff --git a/apps/calendar/caldav.php b/apps/calendar/caldav.php index 83f6a5ab51d..b581274398d 100644 --- a/apps/calendar/caldav.php +++ b/apps/calendar/caldav.php @@ -10,6 +10,7 @@ $RUNTIME_NOSETUPFS = true; require_once('../../lib/base.php'); +OC_Util::checkAppEnabled('calendar'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css index f1bd0f9a9c4..5e19b88f55a 100644 --- a/apps/calendar/css/style.css +++ b/apps/calendar/css/style.css @@ -45,6 +45,7 @@ .weekend_thead, .weekend_row{height: 20px;text-align: center;text-align: center;background: #F3F3F3;} .thisday{background: #FFFABC;} .event {position:relative;} +.event.colored {border-bottom: 1px solid white;} .popup {display: none; position: absolute; z-index: 1000; background: #eeeeee; color: #000000; border: 1px solid #1a1a1a; font-size: 90%;} .event_popup {width: 280px; height: 40px; padding: 10px;} @@ -57,3 +58,6 @@ color:#A9A9A9; } select#category{width:140px;} button.category{margin:0 3px;} + +.calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;} +.calendar-colorpicker-color.active{background-image:url("../../../core/img/jquery-ui/ui-icons_222222_256x240.png");background-position:-62px -143px;} diff --git a/apps/calendar/export.php b/apps/calendar/export.php index a6fdaba1d2f..b3e5ecd6834 100644 --- a/apps/calendar/export.php +++ b/apps/calendar/export.php @@ -8,16 +8,31 @@ require_once ("../../lib/base.php"); OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('calendar'); $cal = $_GET["calid"]; -$calendar = OC_Calendar_Calendar::findCalendar($cal); -if($calendar["userid"] != OC_User::getUser()){ - header( 'Location: '.OC_Helper::linkTo('', 'index.php')); - exit; -} -$calobjects = OC_Calendar_Object::all($cal); -header("Content-Type: text/Calendar"); -header("Content-Disposition: inline; filename=calendar.ics"); -for($i = 0;$i <= count($calobjects); $i++){ - echo $calobjects[$i]["calendardata"] . "\n"; +$event = $_GET["eventid"]; +if(isset($cal)){ + $calendar = OC_Calendar_Calendar::findCalendar($cal); + if($calendar["userid"] != OC_User::getUser()){ + OC_JSON::error(); + exit; + } + $calobjects = OC_Calendar_Object::all($cal); + header("Content-Type: text/Calendar"); + header("Content-Disposition: inline; filename=calendar.ics"); + for($i = 0;$i <= count($calobjects); $i++){ + echo $calobjects[$i]["calendardata"] . "\n"; + } +}elseif(isset($event)){ + $data = OC_Calendar_Object::find($_GET["eventid"]); + $calendarid = $data["calendarid"]; + $calendar = OC_Calendar_Calendar::findCalendar($calendarid); + if($calendar["userid"] != OC_User::getUser()){ + OC_JSON::error(); + exit; + } + header("Content-Type: text/Calendar"); + header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics"); + echo $data["calendardata"]; } ?> diff --git a/apps/calendar/index.php b/apps/calendar/index.php index 39f961d1bb9..1e4d724b307 100644 --- a/apps/calendar/index.php +++ b/apps/calendar/index.php @@ -8,6 +8,7 @@ require_once ('../../lib/base.php'); OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('calendar'); // Create default calendar ... $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); if( count($calendars) == 0){ diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 1b345452912..131325007a0 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -8,6 +8,8 @@ Calendar={ space:' ', + firstdayofweek: '', + weekend: '', Date:{ normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], @@ -79,7 +81,7 @@ Calendar={ }, UI:{ - weekdays: ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"], + weekdays: '', formatDayShort:function(day){ if (typeof(day) == 'undefined'){ day = Calendar.Date.current.getDay(); @@ -124,7 +126,7 @@ Calendar={ $('#'+this.currentview + "_radio").removeClass('active'); this.currentview = view; //sending ajax request on every change view - $("#sysbox").load(oc_webroot + "/apps/calendar/ajax/changeview.php?v="+view); + $("#sysbox").load(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view); //not necessary to check whether the response is true or not switch(view) { case "onedayview": @@ -153,6 +155,7 @@ Calendar={ Calendar.UI.updateView() }); }, + drageventid: '', updateDate:function(direction){ if(direction == 'forward' && this.current.forward) { this.current.forward(); @@ -178,18 +181,19 @@ Calendar={ if( typeof (this.events[year]) == "undefined") { this.events[year] = [] } - $.getJSON(oc_webroot + "/apps/calendar/ajax/getcal.php?year=" + year, function(newevents, status) { + $.getJSON(OC.filePath('calendar', 'ajax', 'getcal.php') + "?year=" + year, function(jsondata, status) { if(status == "nosession") { alert("You are not logged in. That can happen if you don't use owncloud for a long time."); document.location(oc_webroot); } - if(status == "parsingfail" || typeof (newevents) == "undefined") { + if(status == "parsingfail" || typeof (jsondata) == "undefined") { $.ready(function() { $( "#parsingfail_dialog" ).dialog(); }); } else { - if (typeof(newevents[year]) != 'undefined'){ - Calendar.UI.events[year] = newevents[year]; + if (typeof(jsondata[year]) != 'undefined'){ + Calendar.UI.calendars = jsondata['calendars']; + Calendar.UI.events[year] = jsondata[year]; } $(document).ready(function() { Calendar.UI.updateView(); @@ -218,7 +222,7 @@ Calendar={ if (!events) { return; } - var weekday = (date.getDay()+6)%7; + var weekday = (date.getDay()+7-Calendar.firstdayofweek)%7; if( typeof (events["allday"]) != "undefined") { var eventnumber = 1; var eventcontainer = this.current.getEventContainer(week, weekday, "allday"); @@ -244,7 +248,17 @@ Calendar={ .data('event_info', event) .hover(this.createEventPopup, this.hideEventPopup) + .draggable({ + drag: function() { + Calendar.UI.drageventid = event.id; + } + }) .click(this.editEvent); + var color = this.calendars[event['calendarid']]['color']; + if (color){ + event_holder.css('background-color', color) + .addClass('colored'); + } eventcontainer.append(event_holder); }, startEventDialog:function(){ @@ -286,7 +300,7 @@ Calendar={ // TODO: save event $('#event').dialog('destroy').remove(); }else{ - $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/neweventform.php?d=' + date + '&t=' + time, Calendar.UI.startEventDialog); + $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php') + '?d=' + date + '&t=' + time, Calendar.UI.startEventDialog); } }, editEvent:function(event){ @@ -297,12 +311,12 @@ Calendar={ // TODO: save event $('#event').dialog('destroy').remove(); }else{ - $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, Calendar.UI.startEventDialog); + $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog); } }, submitDeleteEventForm:function(url){ var post = $( "#event_form" ).serialize(); - $("#errorbox").html(""); + $("#errorbox").empty(); $.post(url, post, function(data){ if(data.status == 'success'){ $('#event').dialog('destroy').remove(); @@ -315,7 +329,7 @@ Calendar={ }, validateEventForm:function(url){ var post = $( "#event_form" ).serialize(); - $("#errorbox").html(""); + $("#errorbox").empty(); $.post(url, post, function(data){ if(data.status == "error"){ @@ -352,6 +366,12 @@ Calendar={ } },"json"); }, + moveevent:function(eventid, newstartdate){ + $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate}, + function(data) { + console.log("Event moved successfully"); + }); + }, showadvancedoptions:function(){ $("#advanced_options").css("display", "block"); $("#advanced_options_button").css("display", "none"); @@ -425,7 +445,7 @@ Calendar={ if(check == false){ return false; }else{ - $.post(oc_webroot + "/apps/calendar/ajax/deletecalendar.php", { calendarid: calid}, + $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid}, function(data) { Calendar.UI.loadEvents(); $('#choosecalendar_dialog').dialog('destroy').remove(); @@ -438,7 +458,7 @@ Calendar={ if($('#choosecalendar_dialog').dialog('isOpen') == true){ $('#choosecalendar_dialog').dialog('moveToTop'); }else{ - $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/choosecalendar.php', function(){ + $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){ $('#choosecalendar_dialog').dialog({ width : 600, close : function(event, ui) { @@ -450,7 +470,7 @@ Calendar={ }, activation:function(checkbox, calendarid) { - $.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 }, + $.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 }, function(data) { checkbox.checked = data == 1; Calendar.UI.loadEvents(); @@ -458,14 +478,43 @@ Calendar={ }, newCalendar:function(object){ var tr = $(document.createElement('tr')) - .load(oc_webroot + "/apps/calendar/ajax/newcalendar.php"); + .load(OC.filePath('calendar', 'ajax', 'newcalendar.php')); $(object).closest('tr').after(tr).hide(); }, edit:function(object, calendarid){ var tr = $(document.createElement('tr')) - .load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid); + .load(OC.filePath('calendar', 'ajax', 'editcalendar.php') + "?calendarid="+calendarid, + function(){Calendar.UI.Calendar.colorPicker(this)}); $(object).closest('tr').after(tr).hide(); }, + colorPicker:function(container){ + // based on jquery-colorpicker at jquery.webspirited.com + var obj = $('.colorpicker', container); + var picker = $('<div class="calendar-colorpicker"></div>'); + var size = 20; + + //build an array of colors + var colors = {}; + $(obj).children('option').each(function(i, elm) { + colors[i] = {}; + colors[i].color = $(elm).val(); + colors[i].label = $(elm).text(); + }); + for (var i in colors) { + picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + '; width: ' + size + 'px; height: ' + size + 'px;"></span>'); + } + picker.delegate(".calendar-colorpicker-color", "click", function() { + $(obj).val($(this).attr('rel')); + $(obj).change(); + picker.children('.calendar-colorpicker-color.active').removeClass('active'); + $(this).addClass('active'); + }); + $(obj).after(picker); + $(obj).css({ + position: 'absolute', + left: -10000 + }); + }, submit:function(button, calendarid){ var displayname = $("#displayname_"+calendarid).val(); var active = $("#edit_active_"+calendarid+":checked").length; @@ -490,7 +539,7 @@ Calendar={ cancel:function(button, calendarid){ $(button).closest('tr').prev().show().next().remove(); }, - }, + },/* OneDay:{ forward:function(){ Calendar.Date.forward_day(); @@ -499,7 +548,7 @@ Calendar={ Calendar.Date.backward_day(); }, removeEvents:function(){ - $("#onedayview .calendar_row").html(""); + $("#onedayview .calendar_row").empty(); }, renderCal:function(){ $("#datecontrol_date").val(Calendar.UI.formatDayShort() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort() + Calendar.space + Calendar.Date.current.getFullYear()); @@ -520,7 +569,7 @@ Calendar={ return $(document.createElement('p')) .html(time + event['description']) }, - }, + },*/ OneWeek:{ forward:function(){ Calendar.Date.forward_week(); @@ -530,7 +579,7 @@ Calendar={ }, removeEvents:function(){ for( i = 0; i <= 6; i++) { - $("#oneweekview ." + Calendar.UI.weekdays[i]).html(""); + $("#oneweekview ." + Calendar.UI.weekdays[i]).empty(); } $("#oneweekview .thisday").removeClass("thisday"); }, @@ -539,7 +588,23 @@ Calendar={ var dates = this.generateDates(); var today = new Date(); for(var i = 0; i <= 6; i++){ - $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+1)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth())); + $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth())); + $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + "allday"); + $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").droppable({ + drop: function() { + Calendar.UI.moveevent(Calendar.UI.drageventid, this.title); + Calendar.UI.loadEvents(); + } + }); + for(var ii = 0;ii <= 23; ii++){ + $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + String(ii) + ":00"); + $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).droppable({ + drop: function() { + Calendar.UI.moveevent(Calendar.UI.drageventid, this.title); + Calendar.UI.loadEvents(); + } + }); + } if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){ $("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday"); } @@ -570,14 +635,18 @@ Calendar={ if(dayofweek == 0) { dayofweek = 7; } - date.setDate(date.getDate() - dayofweek + 1); + if(Calendar.firstdayofweek > dayofweek){ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7); + }else{ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek); + } for(var i = 0; i <= 6; i++) { dates[i] = new Date(date) date.setDate(date.getDate() + 1); } return dates; }, - }, + },/* FourWeeks:{ forward:function(){ Calendar.Date.forward_week(); @@ -587,7 +656,7 @@ Calendar={ }, removeEvents:function(){ $('#fourweeksview .day.thisday').removeClass('thisday'); - $('#fourweeksview .day .events').html(''); + $('#fourweeksview .day .events').empty(); }, renderCal:function(){ var calw1 = Calendar.Date.calw(); @@ -674,7 +743,7 @@ Calendar={ } return dates; }, - }, + },*/ OneMonth:{ forward:function(){ Calendar.Date.forward_month(); @@ -684,7 +753,7 @@ Calendar={ }, removeEvents:function(){ $('#onemonthview .day.thisday').removeClass('thisday'); - $('#onemonthview .day .events').html(''); + $('#onemonthview .day .events').empty(); }, renderCal:function(){ $("#datecontrol_date").val(Calendar.UI.formatMonthLong() + Calendar.space + Calendar.Date.current.getFullYear()); @@ -712,6 +781,13 @@ Calendar={ var month = dates[i].getMonth(); var year = dates[i].getFullYear(); $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month)); + $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).attr('title', dayofmonth + "." + String(parseInt(month) + 1) + "." + year); + $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).droppable({ + drop: function() { + Calendar.UI.moveevent(Calendar.UI.drageventid, this.title); + Calendar.UI.loadEvents(); + } + }); if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){ $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday'); } @@ -776,7 +852,11 @@ Calendar={ dayofweek = 7; this.rows++; } - date.setDate(date.getDate() - dayofweek + 1); + if(Calendar.firstdayofweek > dayofweek){ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7); + }else{ + date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek); + } for(var i = 0; i <= 41; i++) { dates[i] = new Date(date) date.setDate(date.getDate() + 1); @@ -786,7 +866,7 @@ Calendar={ }, List:{ removeEvents:function(){ - this.eventContainer = $('#listview #events').html(''); + this.eventContainer = $('#listview #events').empty(); this.startdate = new Date(); this.enddate = new Date(); this.enddate.setDate(this.enddate.getDate()); diff --git a/apps/calendar/js/settings.js b/apps/calendar/js/settings.js index 90876389858..6c00be06b39 100644 --- a/apps/calendar/js/settings.js +++ b/apps/calendar/js/settings.js @@ -3,9 +3,61 @@ $(document).ready(function(){ OC.msg.startSaving('#calendar .msg') // Serialize the data var post = $( "#timezone" ).serialize(); - $.post( oc_webroot + '/apps/calendar/ajax/settimezone.php', post, function(data){ - OC.msg.finishedSaving('#calendar .msg', data); + $.post( OC.filePath('calendar', 'ajax', 'settimezone.php'), post, function(data){ + //OC.msg.finishedSaving('#calendar .msg', data); }); return false; }); + $("#timezone").chosen(); + $("#firstdayofweek").change( function(){ + var data = $("#firstdayofweek").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'setfirstdayofweek.php'), data, function(data){ + if(data == "error"){ + console.log("saving first day of week failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'firstdayofweek.php'), function(jsondata, status) { + $("#select_" + jsondata.firstdayofweek).attr('selected',true); + $("#firstdayofweek").chosen(); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'daysofweekend.php'), function(jsondata, status) { + for(day in jsondata){ + if(jsondata[day] == "true"){ + $("#selectweekend_" + day).attr('selected',true); + } + } + $("#weekend").chosen(); + }); + $("#timeformat").change( function(){ + var data = $("#timeformat").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'settimeformat.php'), data, function(data){ + if(data == "error"){ + console.log("saving timeformat failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'timeformat.php'), function(jsondata, status) { + $("#" + jsondata.timeformat).attr('selected',true); + $("#timeformat").chosen(); + }); + $("#duration").blur( function(){ + var data = $("#duration").val(); + $.post( OC.filePath('calendar', 'ajax', 'setduration.php'), {duration: data}, function(data){ + if(data == "error"){ + console.log("saving duration failed"); + } + }); + }); + $.getJSON(OC.filePath('calendar', 'ajax', 'duration.php'), function(jsondata, status) { + $("#duration").val(jsondata.duration); + }); + $("#weekend").change( function(){ + var data = $("#weekend").serialize(); + $.post( OC.filePath('calendar', 'ajax', 'setdaysofweekend.php'), data, function(data){ + if(data == "error"){ + console.log("saving days of weekend failed"); + } + }); + }); }); diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index 0c7649776d5..0c3e497d4f2 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -286,6 +286,30 @@ class OC_Calendar_Object{ } } + public static function getDTEndFromVEvent($vevent) + { + if ($vevent->DTEND) { + $dtend = $vevent->DTEND; + }else{ + $dtend = clone $vevent->DTSTART; + if ($vevent->DURATION){ + $duration = strval($vevent->DURATION); + $invert = 0; + if ($duration[0] == '-'){ + $duration = substr($duration, 1); + $invert = 1; + } + if ($duration[0] == '+'){ + $duration = substr($duration, 1); + } + $interval = new DateInterval($duration); + $interval->invert = $invert; + $dtend->getDateTime()->add($interval); + } + } + return $dtend; + } + public static function getCategoryOptions($l10n) { return array( @@ -482,6 +506,7 @@ class OC_Calendar_Object{ } $vevent->DTSTART = $dtstart; $vevent->DTEND = $dtend; + unset($vevent->DURATION); if($location != ""){ $vevent->LOCATION = $location; diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index a185d3e7087..317bb17ddbc 100644 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -1,5 +1,5 @@ <?php -$hours = array( +$hours24 = array( 'allday' => $l->t('All day'), 0 => '0', 1 => '1', @@ -26,9 +26,58 @@ $hours = array( 22 => '22', 23 => '23', ); -$weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); +$hoursampm = array( + 'allday' => $l->t('All day'), + 0 => '12 a.m.', + 1 => '1 a.m.', + 2 => '2 a.m.', + 3 => '3 a.m.', + 4 => '4 a.m.', + 5 => '5 a.m.', + 6 => '6 a.m.', + 7 => '7 a.m.', + 8 => '8 a.m.', + 9 => '9 a.m.', + 10 => '10 a.m.', + 11 => '11 a.m.', + 12 => '12 p.m.', + 13 => '1 p.m.', + 14 => '2 p.m.', + 15 => '3 p.m.', + 16 => '4 p.m.', + 17 => '5 p.m.', + 18 => '6 p.m.', + 19 => '7 p.m.', + 20 => '8 p.m.', + 21 => '9 p.m.', + 22 => '10 p.m.', + 23 => '11 p.m.', +); +if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){ + $hours = $hours24; +}else{ + $hours = $hoursampm; +} +$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); +$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); +$weekdays = array(); +for($i = 0;$i <= 6; $i++){ + $weekdays[$i] = $weekdaynames[$dayforgenerator]; + if($dayforgenerator == 6){ + $dayforgenerator = 0; + }else{ + $dayforgenerator++; + } +} +$weekendjson = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}'); +$weekend = json_decode($weekendjson, true); +$weekenddays = array("sunday"=>$weekend["Sunday"], "monday"=>$weekend["Monday"], "tuesday"=>$weekend["Tuesday"], "wednesday"=>$weekend["Wednesday"], "thursday"=>$weekend["Thursday"], "friday"=>$weekend["Friday"], "saturday"=>$weekend["Saturday"]); ?> <script type="text/javascript"> + <?php + echo "var weekdays = new Array('".$weekdays[0]."','".$weekdays[1]."','".$weekdays[2]."','".$weekdays[3]."','".$weekdays[4]."','".$weekdays[5]."','".$weekdays[6]."');\n"; + ?> + Calendar.UI.weekdays = weekdays; Calendar.UI.daylong = new Array("<?php echo $l -> t("Sunday");?>", "<?php echo $l -> t("Monday");?>", "<?php echo $l -> t("Tuesday");?>", "<?php echo $l -> t("Wednesday");?>", "<?php echo $l -> t("Thursday");?>", "<?php echo $l -> t("Friday");?>", "<?php echo $l -> t("Saturday");?>"); Calendar.UI.dayshort = new Array("<?php echo $l -> t("Sun.");?>", "<?php echo $l -> t("Mon.");?>", "<?php echo $l -> t("Tue.");?>", "<?php echo $l -> t("Wed.");?>", "<?php echo $l -> t("Thu.");?>", "<?php echo $l -> t("Fri.");?>", "<?php echo $l -> t("Sat.");?>"); Calendar.UI.monthlong = new Array("<?php echo $l -> t("January");?>", "<?php echo $l -> t("February");?>", "<?php echo $l -> t("March");?>", "<?php echo $l -> t("April");?>", "<?php echo $l -> t("May");?>", "<?php echo $l -> t("June");?>", "<?php echo $l -> t("July");?>", "<?php echo $l -> t("August");?>", "<?php echo $l -> t("September");?>", "<?php echo $l -> t("October");?>", "<?php echo $l -> t("November");?>", "<?php echo $l -> t("December");?>"); @@ -37,6 +86,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur Calendar.UI.cws_label = "<?php echo $l->t("Weeks");?>"; Calendar.UI.more_before = String('<?php echo $l->t('More before {startdate}') ?>'); Calendar.UI.more_after = String('<?php echo $l->t('More after {enddate}') ?>'); + Calendar.firstdayofweek = parseInt("<?php echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); ?>"); //use last view as default on the next Calendar.UI.setCurrentView("<?php echo OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") ?>"); var totalurl = "<?php echo OC_Helper::linkTo('calendar', 'caldav.php', null, true) . '/calendars'; ?>"; @@ -93,7 +143,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <tr> <th class="calendar_time"><?php echo $l->t("Time");?></th> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <th class="calendar_row <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th> + <th class="calendar_row <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th> <?php endforeach; ?> </tr> </thead> @@ -102,7 +152,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <tr> <td class="calendar_time"><?php echo $time_label?></td> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekdaynr > 4 ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td> + <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td> <?php endforeach; ?> </tr> <?php endforeach; ?> @@ -139,7 +189,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <thead> <tr> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <th class="calendar_row <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th> + <th class="calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th> <?php endforeach; ?> </tr> </thead> @@ -147,7 +197,7 @@ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'satur <?php foreach(range(1, 6) as $week): ?> <tr class="week_<?php echo $week ?>"> <?php foreach($weekdays as $weekdaynr => $weekday): ?> - <td class="day <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')"> + <td class="day <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')"> <div class="dateinfo"></div> <div class="events"></div> </td> diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 9495e7192bb..65eb39cbfdf 100644 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -11,12 +11,12 @@ for($i = 0; $i < count($option_calendars); $i++){ } ?> <tr> - <td colspan="4"> + <td colspan="6"> <a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><?php echo $l->t('New Calendar') ?></a> </td> </tr> <tr> - <td colspan="4"> + <td colspan="6"> <p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="caldav_url" onmouseover="$('#caldav_url').select();" title="<?php echo $l->t("CalDav Link"); ?>"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#caldav_url').hide();$('#caldav_url_close').hide();"/></p> </td> </tr> diff --git a/apps/calendar/templates/part.editcalendar.php b/apps/calendar/templates/part.editcalendar.php index b5c786f63c1..c2c22913bee 100644 --- a/apps/calendar/templates/part.editcalendar.php +++ b/apps/calendar/templates/part.editcalendar.php @@ -6,7 +6,7 @@ * See the COPYING-README file. */ ?> -<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>calendar_dialog" title="<?php echo $_['new'] ? $l->t("New calendar") : $l->t("Edit calendar"); ?>" colspan="4"> +<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>calendar_dialog" title="<?php echo $_['new'] ? $l->t("New calendar") : $l->t("Edit calendar"); ?>" colspan="6"> <table width="100%" style="border: 0;"> <tr> <th><?php echo $l->t('Displayname') ?></th> @@ -34,7 +34,14 @@ <tr> <th><?php echo $l->t('Calendar color') ?></th> <td> - <input id="calendarcolor_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['calendarcolor'] ?>"> + <select id="calendarcolor_<?php echo $_['calendar']['id'] ?>" class="colorpicker"> + <?php + if (!isset($_['calendar']['calendarcolor'])) {$_['calendar']['calendarcolor'] = false;} + foreach($_['calendarcolor_options'] as $color){ + echo '<option value="' . $color . '"' . ($_['calendar']['calendarcolor'] == $color ? ' selected="selected"' : '') . '>' . $color . '</option>'; + } + ?> + </select> </td> </tr> </table> diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index be637aeae55..ae969f2dc3b 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -6,6 +6,7 @@ <span id="actions"> <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="Calendar.UI.validateEventForm('ajax/editevent.php');"> <input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');"> + <input type="button" class="submit" style="float: right;" name="export" value="<?php echo $l->t("Export");?>" onclick="window.location='export.php?eventid=<?php echo $_['id'] ?>';"> </span> </form> </div> diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 4c34b3e1fcc..8588b9168f7 100644 --- a/apps/calendar/templates/part.eventform.php +++ b/apps/calendar/templates/part.eventform.php @@ -12,8 +12,8 @@ <td> <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>"> <?php + if (!isset($_['categories'])) {$_['categories'] = array();} foreach($_['category_options'] as $category){ - if (!isset($_['categories'])) {$_['categories'] = array();} echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>'; } ?> @@ -22,8 +22,8 @@ <td> <select style="width:140px;" name="calendar"> <?php + if (!isset($_['calendar'])) {$_['calendar'] = false;} foreach($_['calendar_options'] as $calendar){ - if (!isset($_['calendar'])) {$_['calendar'] = false;} echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>'; } ?> diff --git a/apps/calendar/templates/part.getcal.php b/apps/calendar/templates/part.getcal.php deleted file mode 100644 index 900a43b3df2..00000000000 --- a/apps/calendar/templates/part.getcal.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1); -$events = array(); -foreach($calendars as $calendar) { - $tmp = OC_Calendar_Object::all($calendar['id']); - $events = array_merge($events, $tmp); -} -$select_year = $_GET["year"]; -$return_events = array(); -$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); -foreach($events as $event) -{ - if ($select_year != substr($event['startdate'], 0, 4)) - continue; - $start_dt = new DateTime($event['startdate'], new DateTimeZone('UTC')); - $start_dt->setTimezone(new DateTimeZone($user_timezone)); - $end_dt = new DateTime($event['enddate'], new DateTimeZone('UTC')); - $end_dt->setTimezone(new DateTimeZone($user_timezone)); - $year = $start_dt->format('Y'); - $month = $start_dt->format('n') - 1; // return is 0 based - $day = $start_dt->format('j'); - $hour = $start_dt->format('G'); - - // hack - if (strstr($event['calendardata'], 'DTSTART;VALUE=DATE:')) { - $hour = 'allday'; - } - $return_event = array(); - foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop) - { - $return_event[$prop] = $event[$prop]; - } - $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i')); - $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i')); - $return_event['description'] = $event['summary']; - if ($hour == 'allday') - { - $return_event['allday'] = true; - } - if (isset($return_events[$year][$month][$day][$hour])) - { - $return_events[$year][$month][$day][$hour][] = $return_event; - } - else - { - $return_events[$year][$month][$day][$hour] = array(1 => $return_event); - } -} -OC_JSON::encodedPrint($return_events); -?> diff --git a/apps/calendar/templates/settings.php b/apps/calendar/templates/settings.php index ac13b2aa402..44fbb230a43 100644 --- a/apps/calendar/templates/settings.php +++ b/apps/calendar/templates/settings.php @@ -1,15 +1,18 @@ <?php /** * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ +OC_UTIL::addScript('', 'jquery.multiselect'); +OC_UTIL::addStyle('', 'jquery.multiselect'); ?> <form id="calendar"> <fieldset class="personalblock"> <label for="timezone"><strong><?php echo $l->t('Timezone');?></strong></label> - <select id="timezone" name="timezone"> + <select style="display: none;" id="timezone" name="timezone"> <?php $continent = ''; foreach($_['timezones'] as $timezone): @@ -24,6 +27,34 @@ echo '<option value="'.$timezone.'"'.($_['timezone'] == $timezone?' selected="selected"':'').'>'.$city.'</option>'; endif; endforeach;?> - </select><span class="msg"></span> + </select> + <label for="timeformat"><strong><?php echo $l->t('Timeformat');?></strong></label> + <select style="display: none;" id="timeformat" title="<?php echo "timeformat"; ?>" name="timeformat"> + <option value="24" id="24h"><?php echo $l->t("24h"); ?></option> + <option value="ampm" id="ampm"><?php echo $l->t("12h"); ?></option> + </select><br /> + <label for="firstdayofweek"><strong><?php echo $l->t('First day of the week');?></strong></label> + <select style="display: none;" id="firstdayofweek" name="firstdayofweek"> + <?php + $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); + for($i = 0;$i <= 6;$i++){ + echo '<option value="'.$i.'" id="select_'.$i.'">' . $l->t($weekdays[$i]) . '</option>'; + } + ?> + </select><br /> + <label for="weekend"><strong><?php echo $l->t('Days of weekend');?></strong></label> + <select id="weekend" name="weekend[]" style="width: 50%;" multiple="multiple" title="<?php echo $l->t("Weekend"); ?>"> + <?php + $weekdays = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); + for($i = 0;$i <= 6;$i++){ + echo '<option value="'.$weekdays[$i].'" id="selectweekend_' . $weekdays[$i] . '">' . $l->t($weekdays[$i]) . '</option>'; + } + ?> + </select><br /> + <label for="duration"><strong><?php echo $l->t('Event duration');?></strong></label> + <input type="text" maxlength="3" size="3" style="width: 2em;" id="duration" name="duration" /> <?php echo $l->t("Minutes");?> + <br /> + <?php echo $l->t('Calendar CalDAV syncing address:');?> + <?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?><br /> </fieldset> </form> diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php index cfae3327f56..ee95513732d 100644 --- a/apps/contacts/ajax/addcard.php +++ b/apps/contacts/ajax/addcard.php @@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $addressbook = OC_Contacts_Addressbook::find( $aid ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 5a37f77f858..0b218c6298f 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php index 13be33eb5a9..c13217ef2e2 100644 --- a/apps/contacts/ajax/deletebook.php +++ b/apps/contacts/ajax/deletebook.php @@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $addressbook = OC_Contacts_Addressbook::find( $id ); if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){ diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index c69638320ed..a0a6b8c3ea8 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 40b765cf845..0a3a3c293a0 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -31,6 +31,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php index 47d88a771e6..0e76de61afb 100644 --- a/apps/contacts/ajax/getdetails.php +++ b/apps/contacts/ajax/getdetails.php @@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php index b4fc2162d90..18e00872473 100644 --- a/apps/contacts/ajax/setproperty.php +++ b/apps/contacts/ajax/setproperty.php @@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php index 58567392d7c..2f534f0fe2d 100644 --- a/apps/contacts/ajax/showaddcard.php +++ b/apps/contacts/ajax/showaddcard.php @@ -27,6 +27,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser()); $tmpl = new OC_Template('contacts','part.addcardform'); diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php index 0d01b37d8ef..f87cd05359b 100644 --- a/apps/contacts/ajax/showaddproperty.php +++ b/apps/contacts/ajax/showaddproperty.php @@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php index 0b30a8e68ec..6188f4773c3 100644 --- a/apps/contacts/ajax/showsetproperty.php +++ b/apps/contacts/ajax/showsetproperty.php @@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts'); // Check if we are a user OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('contacts'); $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 98416ead2fc..fc7b3769c53 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -17,3 +17,6 @@ OC_App::addNavigationEntry( array( 'href' => OC_Helper::linkTo( 'contacts', 'index.php' ), 'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ), 'name' => 'Contacts' )); + + +OC_APP::registerPersonal('contacts','settings'); diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php index b17a9395355..df7c858b1a0 100644 --- a/apps/contacts/carddav.php +++ b/apps/contacts/carddav.php @@ -24,6 +24,7 @@ $RUNTIME_NOSETUPFS = true; require_once('../../lib/base.php'); +OC_Util::checkAppEnabled('contacts'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); diff --git a/apps/contacts/index.php b/apps/contacts/index.php index c9cf348dfd7..7e8eb8e6951 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -29,6 +29,7 @@ require_once('../../lib/base.php'); // Check if we are a user OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('contacts'); // Check if the user has an addressbook $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser()); diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 66ee6772198..3ec84a3c8ba 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -34,7 +34,7 @@ $(document).ready(function(){ if(jsondata.status == 'success'){ $('#leftcontent [data-id="'+jsondata.data.id+'"]').remove(); $('#rightcontent').data('id',''); - $('#rightcontent').html(''); + $('#rightcontent').empty(); } else{ alert(jsondata.data.message); diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 7ba2002b13d..5178fe7a078 100644 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -22,18 +22,13 @@ // Init owncloud require_once('../../lib/base.php'); +OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('contacts'); $id = $_GET['id']; $l10n = new OC_L10N('contacts'); -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo $l10n->t('You need to log in.'); - exit(); -} - - $card = OC_Contacts_VCard::find( $id ); if( $card === false ){ echo $l10n->t('Contact could not be found.'); diff --git a/apps/contacts/settings.php b/apps/contacts/settings.php new file mode 100644 index 00000000000..b88128823a7 --- /dev/null +++ b/apps/contacts/settings.php @@ -0,0 +1,6 @@ +<?php + +$tmpl = new OC_Template( 'contacts', 'settings'); + +return $tmpl->fetchPage(); +?> diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php new file mode 100644 index 00000000000..f5c37c5a044 --- /dev/null +++ b/apps/contacts/templates/settings.php @@ -0,0 +1,7 @@ +<form id="mediaform"> + <fieldset class="personalblock"> + <strong>Contacts</strong><br /> + CardDAV syncing address: + <?php echo OC_Helper::linkTo('apps/contacts', 'carddav.php', null, true); ?><br /> + </fieldset> +</form> diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php index e7bda0f6144..8d51c146523 100644 --- a/apps/files_sharing/ajax/getitem.php +++ b/apps/files_sharing/ajax/getitem.php @@ -2,6 +2,7 @@ $RUNTIME_NOAPPS = true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('files_sharing'); require_once('../lib_share.php'); $userDirectory = "/".OC_User::getUser()."/files"; diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php index 8e0bac0b06f..7ee8f0e57bd 100644 --- a/apps/files_sharing/ajax/setpermissions.php +++ b/apps/files_sharing/ajax/setpermissions.php @@ -2,6 +2,7 @@ $RUNTIME_NOAPPS = true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('files_sharing'); require_once('../lib_share.php'); $source = "/".OC_User::getUser()."/files".$_GET['source']; @@ -9,4 +10,4 @@ $uid_shared_with = $_GET['uid_shared_with']; $permissions = $_GET['permissions']; OC_Share::setPermissions($source, $uid_shared_with, $permissions); -?>
\ No newline at end of file +?> diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php index e672cf02403..6a2b45b3a7d 100644 --- a/apps/files_sharing/ajax/share.php +++ b/apps/files_sharing/ajax/share.php @@ -2,6 +2,7 @@ $RUNTIME_NOAPPS = true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('files_sharing'); require_once('../lib_share.php'); $userDirectory = "/".OC_User::getUser()."/files"; @@ -26,4 +27,4 @@ foreach ($sources as $source) { } } -?>
\ No newline at end of file +?> diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php index b9230d257b7..a19a85cfda3 100644 --- a/apps/files_sharing/ajax/unshare.php +++ b/apps/files_sharing/ajax/unshare.php @@ -2,10 +2,11 @@ $RUNTIME_NOAPPS = true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('files_sharing'); require_once('../lib_share.php'); $source = "/".OC_User::getUser()."/files".$_GET['source']; $uid_shared_with = $_GET['uid_shared_with']; OC_Share::unshare($source, $uid_shared_with); -?>
\ No newline at end of file +?> diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php index a3158cf72d6..21516c3d091 100644 --- a/apps/files_sharing/ajax/userautocomplete.php +++ b/apps/files_sharing/ajax/userautocomplete.php @@ -4,6 +4,7 @@ $RUNTIME_NOAPPS = true; require_once('../../../lib/base.php'); OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('files_sharing'); $users = array(); $ocusers = OC_User::getUsers(); diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php index 33918bf9e7d..083f48e1127 100644 --- a/apps/files_sharing/get.php +++ b/apps/files_sharing/get.php @@ -3,6 +3,7 @@ $RUNTIME_NOAPPS=true; //no need to load the apps $RUNTIME_NOSETUPFS=true; //don't setup the fs yet require_once '../../lib/base.php'; +OC_JSON::checkAppEnabled('files_sharing'); require_once 'lib_share.php'; //get the path of the shared file diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php index a5f99f38041..721620dc922 100644 --- a/apps/files_sharing/list.php +++ b/apps/files_sharing/list.php @@ -24,6 +24,7 @@ require_once('../../lib/base.php'); require_once('lib_share.php'); OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('files_sharing'); OC_App::setActiveNavigationEntry("files_sharing_list"); diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php index 7faf2cf4ba6..d46ff818ac1 100644 --- a/apps/files_sharing/templates/list.php +++ b/apps/files_sharing/templates/list.php @@ -1,11 +1,11 @@ <fieldset> - <legend>Your Shared Files</legend> + <legend><?php echo $l->t('Your Shared Files');?></legend> <table id="itemlist"> <thead> <tr> - <th>Item</th> - <th>Shared With</th> - <th>Permissions</th> + <th><?php echo $l->t('Item');?></th> + <th><?php echo $l->t('Shared With');?></th> + <th><?php echo $l->t('Permissions');?></th> </tr> </thead> <tbody> @@ -13,8 +13,8 @@ <tr class="item"> <td class="source"><?php echo substr($item['source'], strlen("/".$_SESSION['user_id']."/files/"));?></td> <td class="uid_shared_with"><?php echo $item['uid_shared_with'];?></td> - <td class="permissions"><?php echo "Read"; echo($item['permissions'] & OC_SHARE::WRITE ? ", Edit" : ""); echo($item['permissions'] & OC_SHARE::DELETE ? ", Delete" : "");?></td> - <td><button class="delete" data-source="<?php echo $item['source'];?>" data-uid_shared_with="<?php echo $item['uid_shared_with'];?>">Delete</button></td> + <td class="permissions"><?php echo $l->t('Read'); echo($item['permissions'] & OC_SHARE::WRITE ? ", ".$l->t('Edit') : ""); echo($item['permissions'] & OC_SHARE::DELETE ? ", ".$l->t('Delete') : "");?></td> + <td><button class="delete" data-source="<?php echo $item['source'];?>" data-uid_shared_with="<?php echo $item['uid_shared_with'];?>"><?php echo $l->t('Delete');?></button></td> </tr> <?php endforeach;?> <tr id="share_item_row"> diff --git a/apps/files_texteditor/css/style.css b/apps/files_texteditor/css/style.css index cfad02100ab..3555119dffc 100644 --- a/apps/files_texteditor/css/style.css +++ b/apps/files_texteditor/css/style.css @@ -14,3 +14,9 @@ left: 160px; display: none; } +#editorbar{ + margin-left: auto; + margin-right: 10px; + display: block; + width: 300px; +}
\ No newline at end of file diff --git a/apps/files_texteditor/js/editor.js b/apps/files_texteditor/js/editor.js index b912b448586..d4c5bca51f2 100644 --- a/apps/files_texteditor/js/editor.js +++ b/apps/files_texteditor/js/editor.js @@ -1,7 +1,7 @@ function setEditorSize(){ // Sets the size of the text editor window. - $('#editor').css('height', $(window).height()-90); - $('#editor').css('width', $(window).width()-180); + $('#editor').css('height', $(window).height()-81); + $('#editor').css('width', $(window).width()-160); $('#editor').css('padding-top', '40px'); } @@ -33,31 +33,54 @@ function setSyntaxMode(ext){ } } -function showControlBar(){ +function showControlBar(filename){ // Loads the control bar at the top. - $('.actions,#file_action_panel').fadeOut('slow', function(){ + $('.actions,#file_action_panel').fadeOut('slow').promise().done(function() { // Load the new toolbar. - var html = '<div id="editorbar"><input type="button" id="editor_save" value="'+t('files_texteditor','Save')+'"><input type="button" id="editor_close" value="Close"></div>'; + var html = '<div id="editorbar"><input type="button" id="editor_save" value="'+t('files_texteditor','Save')+'"><input type="button" id="editor_close" value="'+t('files_texteditor','Close Editor')+'"></div>'; if($('#editorbar').length==0){ - $('#controls').append(html).fadeIn('slow'); + $('#controls').append(html); + $('#editorbar').fadeIn('slow'); } - bindControlEvents(); + var breadcrumbhtml = '<div class="crumb svg" style="background-image:url("/core/img/breadcrumb.png")"><a href="#">'+filename+'</a></div>'; + $('.actions').before(breadcrumbhtml); }); } - + function bindControlEvents(){ - $('#editor_save').bind('click', function() { - $(this).val('Saving...'); + $("#editor_save").live('click',function() { + doFileSave(); + }); + + $('#editor_close').live('click',function() { + hideFileEditor(); + }); + + $(document).bind('keydown', 'Ctrl+s', doFileSave); +} + +function editorIsShown(){ + if($('#editor').length!=0){ + return true; + } else { + return false; + } +} + +function doFileSave(){ + if(editorIsShown()){ + $('#editor_save').val(t('files_texteditor','Saving')+'...'); var filecontents = window.aceEditor.getSession().getValue(); var dir = $('#editor').attr('data-dir'); - var file = $('#editor').attr('data-file'); + var file = $('#editor').attr('data-filename'); $.post('http://cloud.tomneedham.com/apps/files_texteditor/ajax/savefile.php', { filecontents: filecontents, file: file, dir: dir },function(jsondata){ + if(jsondata.status == 'failure'){ var answer = confirm(jsondata.data.message); if(answer){ $.post(OC.filePath('apps','files_texteditor','ajax','savefile.php'),{ filecontents: filecontents, file: file, dir: dir, force: 'true' },function(jsondata){ if(jsondata.status =='success'){ - $('#editor_save').val('Save'); + $('#editor_save').val(t('files_texteditor','Save')); $('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000); } else { @@ -69,23 +92,24 @@ function bindControlEvents(){ else { // Don't save! $('#editor_save').effect("highlight", {color:'#FF5757'}, 3000); - $('#editor_save').val('Save'); + $('#editor_save').val(t('files_texteditor','Save')); } } else if(jsondata.status == 'success'){ // Success - $('#editor_save').val('Save'); + $('#editor_save').val(t('files_texteditor','Save')); $('#editor_save').effect("highlight", {color:'#4BFF8D'}, 3000); } }, 'json'); - // TODO give focus back to the editor - // window.aceEditor.focus(); - }); - - $('#editor_close').bind('click', function() { - hideFileEditor(); - }); -} + giveEditorFocus(); + } else { + return; + } +}; + +function giveEditorFocus(){ + window.aceEditor.focus(); +}; function showFileEditor(dir,filename){ // Loads the file editor and display it. @@ -94,7 +118,7 @@ function showFileEditor(dir,filename){ complete: function(data){ var data = data.responseText; // Initialise the editor - showControlBar(); + showControlBar(filename); $('table').fadeOut('slow', function() { $('#editor').html(data); // encodeURIComponenet? @@ -106,8 +130,8 @@ function showFileEditor(dir,filename){ OC.addScript('files_texteditor','aceeditor/theme-clouds', function(){ window.aceEditor.setTheme("ace/theme/clouds"); }); - showControlBar(); }); + bindControlEvents(); // End success } // End ajax @@ -116,10 +140,17 @@ function showFileEditor(dir,filename){ } function hideFileEditor(){ + // Fade out controls $('#editorbar').fadeOut('slow'); + // Fade out breadcrumb + $('.actions').prev().fadeOut('slow'); + // Fade out editor $('#editor').fadeOut('slow', function(){ - $('#editorbar').html(''); - $('#editor').html(''); + $('#editorbar').remove(); + $('#editor').remove(); + $('.actions').prev().remove(); + var editorhtml = '<div id="editor"></div>'; + $('table').after(editorhtml); $('.actions,#file_access_panel').fadeIn('slow'); $('table').fadeIn('slow'); }); diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php new file mode 100644 index 00000000000..375905ec520 --- /dev/null +++ b/apps/gallery/ajax/cover.php @@ -0,0 +1,62 @@ +<?php +require_once('../../../lib/base.php'); + +function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. + //getting the image dimensions + list($width_orig, $height_orig) = getimagesize($imgSrc); + switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { + case "jpeg": + case "jpg": + $myImage = imagecreatefromjpeg($imgSrc); + break; + default: + exit(); + } + $ratio_orig = $width_orig/$height_orig; + + if ($thumbnail_width/$thumbnail_height > $ratio_orig) { + $new_height = $thumbnail_width/$ratio_orig; + $new_width = $thumbnail_width; + } else { + $new_width = $thumbnail_height*$ratio_orig; + $new_height = $thumbnail_height; + } + + $x_mid = $new_width/2; //horizontal middle + $y_mid = $new_height/2; //vertical middle + + $process = imagecreatetruecolor(round($new_width), round($new_height)); + + imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); + $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height); + imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height); + + imagedestroy($process); + imagedestroy($myImage); + return $thumb; +} + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); + exit(); +} +$box_size = 200; +$album_name = $_GET['album']; +$x = $_GET['x']; + +$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id'); +$result = $stmt->execute(array(OC_User::getUser(), $album_name)); +$x = min((int)($x/($box_size/$result->numRows())), $result->numRows()-1); // get image to display +$result->seek($x); // never throws +$path = $result->fetchRow(); +$path = $path['file_path']; +$tmp = OC::$CONFIG_DATADIRECTORY . $path; +$imagesize = getimagesize($tmp); + +header('Content-Type: image/png'); +$image = CroppedThumbnail($tmp, $box_size, $box_size); + +imagepng($image); +imagedestroy($image); +?> diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php new file mode 100644 index 00000000000..3a490bdc3bd --- /dev/null +++ b/apps/gallery/ajax/createAlbum.php @@ -0,0 +1,14 @@ +<?php +require_once('../../../lib/base.php'); + +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); + exit(); +} + +$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")'); +$stmt->execute(array()); + +echo json_encode(array( 'status' => 'success', 'name' => $_GET['album_name'])); + +?> diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php new file mode 100644 index 00000000000..6b551ac49d5 --- /dev/null +++ b/apps/gallery/ajax/getAlbums.php @@ -0,0 +1,22 @@ +<?php +require_once('../../../lib/base.php'); + +if (!OC_User::IsLoggedIn()) { + echo json_encode(array('status' => 'error', 'message' => 'You need to log in')); + exit(); +} + +$a = array(); +$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?'); +$result = $stmt->execute(array(OC_User::getUser())); + +while ($r = $result->fetchRow()) { + $album_name = $r['album_name']; + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?'); + $tmp_res = $stmt->execute(array($r['album_id'])); + $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10)); +} + +echo json_encode(array('status'=>'success', 'albums'=>$a)); + +?> diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php new file mode 100644 index 00000000000..d56bf6fa4b7 --- /dev/null +++ b/apps/gallery/ajax/getCovers.php @@ -0,0 +1,66 @@ +<?php +require_once('../../../lib/base.php'); + +function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $shift) { + //getting the image dimensions + list($width_orig, $height_orig) = getimagesize($imgSrc); + switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { + case "jpeg": + case "jpg": + case "tiff": + $myImage = imagecreatefromjpeg($imgSrc); + break; + case "png": + $myImage = imagecreatefrompng($imgSrc); + break; + default: + exit(); + } + $ratio_orig = $width_orig/$height_orig; + + if ($thumbnail_width/$thumbnail_height > $ratio_orig) { + $new_height = $thumbnail_width/$ratio_orig; + $new_width = $thumbnail_width; + } else { + $new_width = $thumbnail_height*$ratio_orig; + $new_height = $thumbnail_height; + } + + $x_mid = $new_width/2; //horizontal middle + $y_mid = $new_height/2; //vertical middle + + $process = imagecreatetruecolor(round($new_width), round($new_height)); + + imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); + imagecopyresampled($tgtImg, $process, $shift, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height); + + imagedestroy($process); + imagedestroy($myImage); +} + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); + exit(); +} +$box_size = 200; +$album_name= $_GET['album_name']; + +$stmt = OC_DB::prepare('SELECT file_path FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.uid_owner = ? AND album_name = ? AND *PREFIX*gallery_photos.album_id == *PREFIX*gallery_albums.album_id'); +$result = $stmt->execute(array(OC_User::getUser(), $album_name)); + +$numOfItems = min($result->numRows(),10); + +$targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size); +$counter = 0; +while (($i = $result->fetchRow()) && $counter < $numOfItems) { + $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path']; + CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size); + $counter++; +} + +header('Content-Type: image/png'); + +imagepng($targetImg); +imagedestroy($targetImg); +?> diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php new file mode 100644 index 00000000000..a04ad62b1bf --- /dev/null +++ b/apps/gallery/ajax/scanForAlbums.php @@ -0,0 +1,14 @@ +<?php + +require_once('../../../lib/base.php'); +require_once('../lib_scanner.php'); + +if (!OC_User::IsLoggedIn()) { + echo json_encode(array('status' => 'error', 'message' => 'You need to log in')); + exit(); +} + +echo json_encode(array( 'status' => 'success', 'albums' => OC_GALLERY_SCANNER::scan(''))); +//echo json_encode(array('status' => 'success', 'albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa'))))); + +?> diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php new file mode 100644 index 00000000000..db428eeff34 --- /dev/null +++ b/apps/gallery/ajax/thumbnail.php @@ -0,0 +1,58 @@ +<?php +require_once('../../../lib/base.php'); + +function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. + //getting the image dimensions + list($width_orig, $height_orig) = getimagesize($imgSrc); + switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) { + case "jpeg": + case "jpg": + case "tiff": + $myImage = imagecreatefromjpeg($imgSrc); + break; + case "png": + $myImage = imagecreatefrompng($imgSrc); + break; + default: + exit(); + } + $ratio_orig = $width_orig/$height_orig; + + if ($thumbnail_width/$thumbnail_height > $ratio_orig) { + $new_height = $thumbnail_width/$ratio_orig; + $new_width = $thumbnail_width; + } else { + $new_width = $thumbnail_height*$ratio_orig; + $new_height = $thumbnail_height; + } + + $x_mid = $new_width/2; //horizontal middle + $y_mid = $new_height/2; //vertical middle + + $process = imagecreatetruecolor(round($new_width), round($new_height)); + + imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); + $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height); + imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height); + + imagedestroy($process); + imagedestroy($myImage); + return $thumb; +} + +// Check if we are a user +if( !OC_User::isLoggedIn()){ + echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); + exit(); +} +$box_size = 200; +$img = $_GET['img']; + +$tmp = OC::$CONFIG_DATADIRECTORY . $img; + +header('Content-Type: image/png'); +$image = CroppedThumbnail($tmp, $box_size, $box_size); + +imagepng($image); +imagedestroy($image); +?> diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php new file mode 100644 index 00000000000..5760bb149d8 --- /dev/null +++ b/apps/gallery/appinfo/app.php @@ -0,0 +1,27 @@ +<?php +OC_App::register(array( + 'order' => 20, + 'id' => 'gallery', + 'name' => 'Gallery')); + +OC_App::addNavigationEntry( array( + 'id' => 'gallery_index', + 'order' => 20, + 'href' => OC_Helper::linkTo('gallery', 'index.php'), + 'icon' => OC_Helper::linkTo('', 'core/img/filetypes/image.png'), + 'name' => 'Gallery')); + + class OC_GallerySearchProvider extends OC_Search_Provider{ + function search($query){ + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?'); + $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%')); + $results=array(); + while($row=$result->fetchRow()){ + $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo( 'apps/gallery', 'index.php?view='.$row['album_name']),'Galleries'); + } + return $results; + } +} + +new OC_GallerySearchProvider(); +?> diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml new file mode 100644 index 00000000000..fd55b3a6fb4 --- /dev/null +++ b/apps/gallery/appinfo/database.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<database> + <name>*dbname*</name> + <create>true</create> + <overwrite>false</overwrite> + <charset>latin1</charset> + <table> + <name>*dbprefix*gallery_albums</name> + <declaration> + <field> + <name>album_id</name> + <type>integer</type> + <default>0</default> + <notnull>true</notnull> + <autoincrement>1</autoincrement> + <length>4</length> + </field> + <field> + <name>uid_owner</name> + <type>text</type> + <notnull>true</notnull> + <length>64</length> + </field> + <field> + <name>album_name</name> + <type>text</type> + <notnull>true</notnull> + <length>100</length> + </field> + </declaration> + </table> + <table> + <name>*dbprefix*gallery_photos</name> + <declaration> + <field> + <name>photo_id</name> + <type>integer</type> + <default>0</default> + <notnull>true</notnull> + <autoincrement>1</autoincrement> + <length>4</length> + </field> + <field> + <name>album_id</name> + <type>integer</type> + <default>0</default> + <notnull>true</notnull> + <length>4</length> + </field> + <field> + <name>file_path</name> + <type>text</type> + <notnull>true</notnull> + <length>100</length> + </field> + </declaration> + </table> +</database> diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml new file mode 100644 index 00000000000..154b5fcf7ae --- /dev/null +++ b/apps/gallery/appinfo/info.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<info> + <id>gallery</id> + <name>Gallery</name> + <version>0.1</version> + <licence>AGPL</licence> + <author>Bartosz Przybylski</author> + <require>2</require> + <description></description> + <default_enable/> +</info> diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css new file mode 100644 index 00000000000..03b179138e6 --- /dev/null +++ b/apps/gallery/css/styles.css @@ -0,0 +1,23 @@ +div#gallery_list { + margin: 90pt 20pt; +} + +div#gallery_album_box { + width: 200px; + text-align: center; + border: 0; + float: left; + margin: 5pt; +} + +div#gallery_album_box h1 { + font-size: 12pt; + font-family: Arial; +} + +div#gallery_album_cover { + width: 199px; + height: 199px; + border: solid 1px black; +} + diff --git a/apps/gallery/index.php b/apps/gallery/index.php new file mode 100644 index 00000000000..c8d5892e555 --- /dev/null +++ b/apps/gallery/index.php @@ -0,0 +1,33 @@ +<?php +require_once('../../lib/base.php'); + +OC_Util::checkLoggedIn(); +OC_App::setActiveNavigationEntry( 'gallery_index' ); + + +if (!isset($_GET['view'])) { + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?'); + $result = $stmt->execute(array(OC_User::getUser())); + + $r = array(); + while ($row = $result->fetchRow()) + $r[] = $row; + + $tmpl = new OC_Template( 'gallery', 'index', 'user' ); + $tmpl->assign('r', $r); + $tmpl->printPage(); +} else { + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id'); + + $result = $stmt->execute(array(OC_User::getUser(), $_GET['view'])); + + $photos = array(); + while ($p = $result->fetchRow()) + $photos[] = $p['file_path']; + + $tmpl = new OC_Template( 'gallery', 'view_album', 'user' ); + $tmpl->assign('photos', $photos); + $tmpl->assign('albumName', $_GET['view']); + $tmpl->printPage(); +} +?> diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js new file mode 100644 index 00000000000..776feae32cc --- /dev/null +++ b/apps/gallery/js/album_cover.js @@ -0,0 +1,41 @@ +var actual_cover; +$(document).ready(function() { + $.getJSON('ajax/getAlbums.php', function(r) { + if (r.status == 'success') { + for (var i in r.albums) { + var a = r.albums[i]; + Albums.add(a.name, a.numOfItems); + } + var targetDiv = document.getElementById('gallery_list'); + if (targetDiv) { + Albums.display(targetDiv); + } else { + alert('Error occured: no such layer `gallery_list`'); + } + } else { + alert('Error occured: ' + r.message); + } + }); +}); + +function createNewAlbum() { + var name = prompt("album name", ""); + if (name != null && name != "") { + $.getJSON("ajax/createAlbum.php", {album_name: name}, function(r) { + if (r.status == "success") { + var v = '<div class="gallery_album_box"><a href="?view='+r.name+'"><img class="gallery_album_cover"/></a><h1>'+r.name+'</h1></div>'; + $('div#gallery_list').append(v); + } + }); + } +} + +function scanForAlbums() { + $.getJSON('ajax/scanForAlbums.php', function(r) { + if (r.status == 'success') { + window.location.reload(true); + } else { + alert('Error occured: ' + r.message); + } + }); +} diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js new file mode 100644 index 00000000000..7ab243ededf --- /dev/null +++ b/apps/gallery/js/albums.js @@ -0,0 +1,80 @@ +Albums={ + // album item in this array should look as follow + // {name: string, + // numOfCovers: int} + // + // previews array should be an array of base64 decoded images + // to display to user as preview picture when scrolling throught + // the album cover + albums:new Array(), + // add simply adds new album to internal structure + // however albums names must be unique so other + // album with the same name wont be insered, + // and false will be returned + // true on success + add: function(album_name, num) { + for (var a in Albums.albums) { + if (a.name == album_name) { + return false; + } + } + Albums.albums.push({name: album_name, numOfCovers: num}); + return true; + }, + // remove element with given name + // returns remove element or undefined if no such element was present + remove: function(name) { + var i = -1, tmp = 0; + for (var a in Albums.albums) { + if (a.name == name) { + i = tmp; + break; + } + tmp++; + } + if (i != -1) { + return Albums.albums.splice(i,1); + } + return undefined; + }, + // return element which match given name + // of undefined if such element do not exist + find: function(name) { + var i = -1, tmp = 0; + for (var k in Albums.albums) { + var a = Albums.albums[k]; + if (a.name == name) { + i = tmp; + break; + } + tmp++; + } + if (i != -1) { + return Albums.albums[i]; + } + return undefined; + }, + // displays gallery in linear representation + // on given element, and apply default styles for gallery + display: function(element) { + var displayTemplate = '<div id="gallery_album_box" title="*NAME*"><a href="?view=*NAME*"><div id="gallery_album_cover"></div></a><h1>*NAME*</h1></div></div>'; + for (var i in Albums.albums) { + var a = Albums.albums[i]; + var local = $(displayTemplate.replace(/\*NAME\*/g, a.name)); + local.css('background-repeat', 'no-repeat'); + local.css('background-position', '0 0'); + local.css('background-image','url("ajax/getCovers.php?album_name='+a.name+'")'); + local.mousemove(function(e) { + var albumMetadata = Albums.find(this.title); + if (albumMetadata == undefined) { + return; + } + var x = Math.min(Math.floor((e.clientX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1); + x *= this.offsetWidth; + $(this).css('background-position', -x+'px 0'); + }); + $(element).append(local); + } + } + +} diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php new file mode 100644 index 00000000000..fe14b68add1 --- /dev/null +++ b/apps/gallery/lib_scanner.php @@ -0,0 +1,57 @@ +<?php + +require_once('base.php'); // base lib + +class OC_GALLERY_SCANNER { + + public static function scan($root) { + $albums = array(); + self::scanDir($root, $albums); + return $albums; + } + + public static function scanDir($path, &$albums) { + $current_album = array('name'=> $path, 'imagesCount' => 0, 'images' => array()); + $current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name'])); + $current_album['name'] = ($current_album['name']==='')?'main':$current_album['name']; + + if ($dh = OC_Filesystem::opendir($path)) { + while (($filename = readdir($dh)) !== false) { + $filepath = $path.'/'.$filename; + if (substr($filename, 0, 1) == '.') continue; + if (OC_Filesystem::is_dir($filepath)) { + self::scanDir($filepath, $albums); + } elseif (self::isPhoto($path.'/'.$filename)) { + $current_album['images'][] = $filepath; + } + } + } + $current_album['imagesCount'] = count($current_album['images']); + $albums[] = $current_album; + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?'); + $result = $stmt->execute(array(OC_User::getUser(), $current_album['name'])); + if ($result->numRows() == 0 && count($current_album['images'])) { + $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES (?, ?)'); + $stmt->execute(array(OC_User::getUser(), $current_album['name'])); + } + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE "uid_owner" = ? AND "album_name" = ?'); + $result = $stmt->execute(array(OC_User::getUser(), $current_album['name'])); + $albumId = $result->fetchRow(); + $albumId = $albumId['album_id']; + foreach ($current_album['images'] as $img) { + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE "album_id" = ? AND "file_path" = ?'); + $result = $stmt->execute(array($albumId, $img)); + if ($result->numRows() == 0) { + $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_photos ("album_id", "file_path") VALUES (?, ?)'); + $stmt->execute(array($albumId, $img)); + } + } + } + + public static function isPhoto($filename) { + if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") + return 1; + return 0; + } +} +?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php new file mode 100644 index 00000000000..0e89e448768 --- /dev/null +++ b/apps/gallery/templates/index.php @@ -0,0 +1,12 @@ +<?php +OC_Util::addStyle('gallery', 'styles'); +OC_Util::addScript('gallery', 'albums'); +OC_Util::addScript('gallery', 'album_cover'); +?> + +<div id="controls"> + <!-- <input type="button" value="New album" onclick="javascript:createNewAlbum();" />--> + <input type="button" value="Rescan" onclick="javascript:scanForAlbums();" /><br/> +</div> +<div id="gallery_list"> +</div> diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php new file mode 100644 index 00000000000..ea2969e0110 --- /dev/null +++ b/apps/gallery/templates/view_album.php @@ -0,0 +1,20 @@ +<?php +OC_Util::addStyle('gallery', 'styles'); +OC_Util::addScript('gallery', 'album_cover'); +OC_Util::addScript( 'files_imageviewer', 'lightbox' ); +OC_Util::addStyle( 'files_imageviewer', 'lightbox' ); +?> + +<div id="controls"> + <a href="?"><input type="button" value="Back" /></a><br/> +</div> +<div id="gallery_list"> +<?php +foreach ($_['photos'] as $a) { +?> +<a onclick="javascript:viewImage('/','<?php echo $a; ?>');"><img src="ajax/thumbnail.php?img=<?php echo $a ?>"></a> +<?php + } +?> + +</div> diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php index 84ee6334463..29f61a2207f 100644 --- a/apps/media/ajax/api.php +++ b/apps/media/ajax/api.php @@ -27,6 +27,7 @@ header('Content-type: text/html; charset=UTF-8') ; $RUNTIME_NOAPPS=true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('media'); require_once('../lib_collection.php'); require_once('../lib_scanner.php'); diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php index ad103d1c39b..ff0923ca032 100644 --- a/apps/media/ajax/autoupdate.php +++ b/apps/media/ajax/autoupdate.php @@ -28,6 +28,7 @@ $RUNTIME_NOAPPS=true; $RUNTIME_NOSETUPFS=true; require_once('../../../lib/base.php'); +OC_JSON::checkAppEnabled('media'); if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);} $autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true'); diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index 0d36217bd4d..dd1a830a94b 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -25,6 +25,7 @@ $l=new OC_L10N('media'); require_once('apps/media/lib_media.php'); OC_Util::addScript('media','loader'); +OC_APP::registerPersonal('media','settings'); OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' )); diff --git a/apps/media/css/music.css b/apps/media/css/music.css index ddfe3429830..c4db4e05855 100644 --- a/apps/media/css/music.css +++ b/apps/media/css/music.css @@ -9,8 +9,9 @@ div.jp-progress { position:absolute; overflow:hidden; top:.5em; left:8em; width: div.jp-seek-bar { background:#eee; width:0; height:100%; cursor:pointer; } div.jp-play-bar { background:#ccc; width:0; height:100%; } div.jp-seeking-bg { background:url("../img/pbar-ani.gif"); } -div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:1em; left:13.5em; } -div.jp-duration { left:33em; } +div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:0.9em; left:13.5em; } +div.jp-duration { display: none } +div.jp-current-song { left: 33em; position: absolute; top: 0.9em; } div.jp-duration { text-align:right; } a.jp-mute,a.jp-unmute { left:24em; } @@ -21,9 +22,11 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; } #collection li.album,#collection li.song { margin-left:3em; } #leftcontent img.remove { display:none; float:right; cursor:pointer; } #leftcontent li:hover img.remove { display:inline; } +#leftcontent li {white-space: normal; } #collection li button { float:right; } #collection li,#playlist li { list-style-type:none; } .template { display:none; } +.collection_playing { background:#eee; } #collection li { padding-right:10px; } #searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; } @@ -34,6 +37,7 @@ tr td { border-top:1px solid #eee; height:2.2em; } tr .artist img { vertical-align:middle; } tr.album td.artist { padding-left:1em; } tr.song td.artist { padding-left:2em; } +.add {margin: 0 0.5em 0 0; } #scan { position:absolute; right:13em; top:0em; } #scan .start { position:relative; display:inline; float:right; } diff --git a/apps/media/css/player.css b/apps/media/css/player.css new file mode 100644 index 00000000000..c4a098543d1 --- /dev/null +++ b/apps/media/css/player.css @@ -0,0 +1,23 @@ +#playercontrols{ + display:inline; + margin-left:1em; + width:7em; + height:1em; + position:fixed; + top:auto; + left:auto; + background:transparent; + box-shadow:none; + -webkit-box-shadow:none; +} +#playercontrols li{ + float:left; +} +#playercontrols a, #playercontrols li{ + margin:0px; + padding:0; + left:0; + background:transparent !important; + border:none !important; + text-shadow:none; +}
\ No newline at end of file diff --git a/apps/media/index.php b/apps/media/index.php index d5273ae45cb..419d4ae0bde 100644 --- a/apps/media/index.php +++ b/apps/media/index.php @@ -26,6 +26,7 @@ require_once('../../lib/base.php'); // Check if we are a user OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('media'); require_once('lib_collection.php'); require_once('lib_scanner.php'); diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js index 7eb027348ce..29ba45919cf 100644 --- a/apps/media/js/collection.js +++ b/apps/media/js/collection.js @@ -50,6 +50,10 @@ Collection={ } } + Collection.artists.sort(function(a,b){ + return a.name.localeCompare(b.name); + }); + Collection.loaded=true; Collection.loading=false; for(var i=0;i<Collection.loadedListeners.length;i++){ @@ -79,8 +83,13 @@ Collection={ $.each(Collection.artists,function(i,artist){ if(artist.name && artist.songs.length>0){ var tr=template.clone().removeClass('template'); - tr.find('td.title a').text(artist.songs.length+' '+t('media','songs')); - tr.find('td.album a').text(artist.albums.length+' '+t('media','albums')); + if(artist.songs.length>1){ + tr.find('td.title a').text(artist.songs.length+' '+t('media','songs')); + tr.find('td.album a').text(artist.albums.length+' '+t('media','albums')); + }else{ + tr.find('td.title a').text(artist.songs[0].name); + tr.find('td.album a').text(artist.albums[0].name); + } tr.find('td.artist a').text(artist.name); tr.data('artistData',artist); tr.find('td.artist a').click(function(event){ @@ -90,18 +99,20 @@ Collection={ Collection.parent.find('tr').removeClass('active'); $('tr[data-artist="'+artist.name+'"]').addClass('active'); }); - var expander=$('<a class="expander">></a>'); - expander.data('expanded',false); - expander.click(function(event){ - var tr=$(this).parent().parent(); - if(expander.data('expanded')){ - Collection.hideArtist(tr.data('artist')); - }else{ - Collection.showArtist(tr.data('artist')); - } - }); - tr.find('td.artist').addClass('buttons'); - Collection.addButtons(tr,artist); + if(artist.songs.length>1){ + var expander=$('<a class="expander">></a>'); + expander.data('expanded',false); + expander.click(function(event){ + var tr=$(this).parent().parent(); + if(expander.data('expanded')){ + Collection.hideArtist(tr.data('artist')); + }else{ + Collection.showArtist(tr.data('artist')); + } + }); + } + tr.find('td.artist').addClass('buttons'); + Collection.addButtons(tr,artist); tr.children('td.artist').append(expander); tr.attr('data-artist',artist.name); Collection.parent.find('tbody').append(tr); @@ -115,14 +126,16 @@ Collection={ var nextRow=tr.next(); var artist=tr.data('artistData'); var first=true; - $.each(artist.albums,function(foo,album){ + $.each(artist.albums,function(j,album){ $.each(album.songs,function(i,song){ if(first){ newRow=tr; }else{ var newRow=tr.clone(); + newRow.find('td.artist').text(''); + newRow.find('.expander').remove(); } - newRow.find('.expander').remove(); + newRow.find('td.album .expander').remove(); if(i==0){ newRow.find('td.album a').text(album.name); newRow.find('td.album a').click(function(event){ @@ -132,21 +145,23 @@ Collection={ Collection.parent.find('tr').removeClass('active'); $('tr[data-album="'+album.name+'"]').addClass('active'); }); - var expander=$('<a class="expander">v </a>'); - expander.data('expanded',true); - expander.click(function(event){ - var tr=$(this).parent().parent(); - if(expander.data('expanded')) { - Collection.hideAlbum(tr.data('artist'),tr.data('album')); - } else { - Collection.showAlbum(tr.data('artist'),tr.data('album')); - } - }); - newRow.children('td.artist').append(expander); - Collection.addButtons(newRow,album); + if(album.songs.length>1){ + var expander=$('<a class="expander">v </a>'); + expander.data('expanded',true); + expander.click(function(event){ + var tr=$(this).parent().parent(); + if(expander.data('expanded')) { + Collection.hideAlbum(tr.data('artist'),tr.data('album')); + } else { + Collection.showAlbum(tr.data('artist'),tr.data('album')); + } + }); + newRow.children('td.album').append(expander); + } + Collection.addButtons(newRow,album); } else { newRow.find('td.album a').text(''); - Collection.addButtons(newRow,song); + Collection.addButtons(newRow,song); } newRow.find('td.title a').text(song.name); newRow.find('td.title a').click(function(event){ @@ -159,6 +174,7 @@ Collection={ newRow.attr('data-album',album.name); newRow.attr('data-title',song.name); newRow.attr('data-artist',artist.name); + newRow.data('albumData',album); if(!first){ nextRow.before(newRow); } @@ -166,43 +182,62 @@ Collection={ }); }); tr.removeClass('collapsed'); - tr.find('a.expander').data('expanded',true); - tr.find('a.expander').addClass('expanded'); - tr.find('a.expander').text('v'); + tr.find('td.artist a.expander').data('expanded',true); + tr.find('td.artist a.expander').addClass('expanded'); + tr.find('td.artist a.expander').text('v'); }, hideArtist:function(artist){ var tr=Collection.parent.find('tr[data-artist="'+artist+'"]'); - if(tr.length>1){ - var artist=tr.first().data('artistData'); - tr.first().find('td.album a').text(artist.albums.length+' '+t('media','albums')); - tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs')); - tr.first().find('td.album a').unbind('click'); - tr.first().find('td.title a').unbind('click'); - tr.each(function(i,row){ - if(i>0){ - $(row).remove(); - } - }); - tr.find('a.expander').data('expanded',false); - tr.find('a.expander').removeClass('expanded'); - tr.find('a.expander').text('>'); - Collection.addButtons(tr,artist); - } + var artist=tr.first().data('artistData'); + tr.first().find('td.album a').first().text(artist.albums.length+' '+t('media','albums')); + tr.first().find('td.album a.expander').remove(); + tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs')); + tr.first().find('td.album a').unbind('click'); + tr.first().find('td.title a').unbind('click'); + tr.each(function(i,row){ + if(i>0){ + $(row).remove(); + } + }); + tr.find('td.artist a.expander').data('expanded',false); + tr.find('td.artist a.expander').removeClass('expanded'); + tr.find('td.artist a.expander').text('>'); + Collection.addButtons(tr,artist); }, showAlbum:function(artist,album){ - var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]'); - tr.find('a.expander').data('expanded',true); - tr.find('a.expander').addClass('expanded'); - tr.find('a.expander').text('v '); - tr.show(); + var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]'); + var albumData=tr.data('albumData'); + tr.find('td.album a.expander').data('expanded',true); + tr.find('td.album a.expander').addClass('expanded'); + tr.find('td.album a.expander').text('v'); + var nextRow=tr.next(); + $.each(albumData.songs,function(i,song){ + if(i>0){ + var newRow=tr.clone(); + newRow.find('a.expander').remove(); + newRow.find('td.album a').text(''); + newRow.find('td.artist a').text(''); + }else{ + var newRow=tr; + } + newRow.find('td.title a').text(song.name); + if(i>0){ + nextRow.before(newRow); + } + }); }, hideAlbum:function(artist,album){ var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]'); - tr.find('a.expander').data('expanded',false); - tr.find('a.expander').removeClass('expanded'); - tr.find('a.expander').text('> '); - tr.hide(); - tr.first().show(); + var albumData=tr.data('albumData'); + tr.first().find('td.title a').text(albumData.songs.length+' '+t('media','songs')); + tr.find('td.album a.expander').data('expanded',false); + tr.find('td.album a.expander').removeClass('expanded'); + tr.find('td.album a.expander').text('> '); + tr.each(function(i,row){ + if(i>0){ + $(row).remove(); + } + }); }, parent:null, hide:function(){ @@ -239,7 +274,7 @@ Collection={ }, findArtist:function(name){ for(var i=0;i<Collection.artists.length;i++){ - if(Collection.artists[i].artist_name==name){ + if(Collection.artists[i].name==name){ return Collection.artists[i]; } } @@ -248,7 +283,7 @@ Collection={ var artist=Collection.findArtist(artistName); if(artist){ for(var i=0;i<artist.albums.length;i++){ - if(artist.albums[i].album_name==albumName){ + if(artist.albums[i].name==albumName){ return artist.albums[i]; } } @@ -258,7 +293,7 @@ Collection={ var album=Collection.findAlbum(artistName,albumName); if(album){ for(var i=0;i<album.songs.length;i++){ - if(album.songs[i].song_name==songName){ + if(album.songs[i].name==songName){ return album.songs[i]; } } diff --git a/apps/media/js/loader.js b/apps/media/js/loader.js index c6c834d3a31..dff4163897f 100644 --- a/apps/media/js/loader.js +++ b/apps/media/js/loader.js @@ -22,16 +22,17 @@ function addAudio(filename){ function loadPlayer(type,ready){ if(!loadPlayer.done){ + loadPlayer.done=true; + OC.addStyle('media','player'); OC.addScript('media','jquery.jplayer.min',function(){ OC.addScript('media','player',function(){ - $('body').append($('<div id="playerPlaceholder"/>')) - $('#playerPlaceholder').append($('<div/>')).load(OC.filePath('media','templates','player.php'),function(){ - loadPlayer.done=true; + var navItem=$('#apps a[href="'+OC.linkTo('media','index.php')+'"]'); + navItem.height(navItem.height()); + navItem.load(OC.filePath('media','templates','player.php'),function(){ PlayList.init(type,ready); }); }); }); - OC.addStyle('media','player'); }else{ ready(); } diff --git a/apps/media/js/music.js b/apps/media/js/music.js index c04c579d1ca..bf082207829 100644 --- a/apps/media/js/music.js +++ b/apps/media/js/music.js @@ -15,7 +15,7 @@ $(document).ready(function(){ PlayList.play(oldSize); PlayList.render(); }); - var button=$('<input type="button" title="'+t('media','Add to playlist')+'" class="add"></input>'); + var button=$('<input type="button" title="'+t('media','Add album to playlist')+'" class="add"></input>'); button.css('background-image','url('+OC.imagePath('core','actions/play-add')+')') button.click(function(event){ event.stopPropagation(); @@ -23,6 +23,7 @@ $(document).ready(function(){ PlayList.render(); }); row.find('div.name').append(button); + button.tipsy({gravity:'n', fade:true, delayIn: 400, live:true}); } Collection.display(); }); diff --git a/apps/media/js/player.js b/apps/media/js/player.js index f696b87bbde..3c022e9f8c4 100644 --- a/apps/media/js/player.js +++ b/apps/media/js/player.js @@ -28,17 +28,19 @@ var PlayList={ if(index==null){ index=PlayList.current; } + PlayList.save(); if(index>-1 && index<items.length){ PlayList.current=index; if(PlayList.player){ if(PlayList.player.data('jPlayer').options.supplied!=items[index].type){//the the audio type changes we need to reinitialize jplayer PlayList.player.jPlayer("play",time); - localStorage.setItem(oc_current_user+'oc_playlist_time',time); + localStorage.setItem(oc_current_user+'oc_playlist_time',time); PlayList.player.jPlayer("destroy"); - PlayList.save(); // so that the init don't lose the playlist +// PlayList.save(); // so that the init don't lose the playlist PlayList.init(items[index].type,null); // init calls load that calls play }else{ PlayList.player.jPlayer("setMedia", items[PlayList.current]); + $(".jp-current-song").text(items[PlayList.current].name); items[index].playcount++; PlayList.player.jPlayer("play",time); if(index>0){ @@ -56,6 +58,7 @@ var PlayList={ if (typeof Collection !== 'undefined') { Collection.registerPlay(); } + PlayList.render(); if(ready){ ready(); } @@ -63,10 +66,12 @@ var PlayList={ }else{ localStorage.setItem(oc_current_user+'oc_playlist_time',time); localStorage.setItem(oc_current_user+'oc_playlist_playing','true'); - PlayList.save(); // so that the init don't lose the playlist +// PlayList.save(); // so that the init don't lose the playlist PlayList.init(items[index].type,null); // init calls load that calls play } } + $(".song").removeClass("collection_playing"); + $(".jp-playlist-" + index).addClass("collection_playing"); }, init:function(type,ready){ if(!PlayList.player){ @@ -82,7 +87,7 @@ var PlayList={ PlayList.render(); return false; }); - PlayList.player=$('#controls div.player'); + PlayList.player=$('#jp-player'); } $(PlayList.player).jPlayer({ ended:PlayList.next, @@ -100,7 +105,7 @@ var PlayList={ } }, volume:PlayList.volume, - cssSelectorAncestor:'#controls', + cssSelectorAncestor:'.player-controls', swfPath:OC.linkTo('media','js'), }); }, @@ -127,7 +132,7 @@ var PlayList={ var type=musicTypeFromFile(song.path); var item={name:song.name,type:type,artist:song.artist,album:song.album,length:song.length,playcount:song.playCount}; item[type]=PlayList.urlBase+encodeURIComponent(song.path); - PlayList.items.push(item); + PlayList.items.push(item); } }, addFile:function(path){ @@ -157,17 +162,15 @@ var PlayList={ if(typeof localStorage !== 'undefined' && localStorage){ localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items)); localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current); - if(PlayList.player) { - if(PlayList.player.data('jPlayer')) { - var time=Math.round(PlayList.player.data('jPlayer').status.currentTime); - localStorage.setItem(oc_current_user+'oc_playlist_time',time); - var volume=PlayList.player.data('jPlayer').options.volume*100; - localStorage.setItem(oc_current_user+'oc_playlist_volume',volume); - } - } - if(PlayList.active){ - localStorage.setItem(oc_current_user+'oc_playlist_active','false'); + if(PlayList.player) { + if(PlayList.player.data('jPlayer')) { + var time=Math.round(PlayList.player.data('jPlayer').status.currentTime); + localStorage.setItem(oc_current_user+'oc_playlist_time',time); + var volume=PlayList.player.data('jPlayer').options.volume*100; + localStorage.setItem(oc_current_user+'oc_playlist_volume',volume); + } } + localStorage.setItem(oc_current_user+'oc_playlist_active','true'); } }, load:function(){ @@ -204,6 +207,9 @@ var PlayList={ $(document).ready(function(){ $(window).bind('beforeunload', function (){ PlayList.save(); + if(PlayList.active){ + localStorage.setItem(oc_current_user+'oc_playlist_active','false'); + } }); $('jp-previous').tipsy({gravity:'n', fade:true, live:true}); diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js index cb7f24522a4..57180b3be7b 100644 --- a/apps/media/js/playlist.js +++ b/apps/media/js/playlist.js @@ -5,6 +5,7 @@ PlayList.render=function(){ var item=PlayList.items[i]; var li=$('<li/>'); li.append(item.name); + li.attr('class', 'jp-playlist-' + i); var img=$('<img class="remove svg action" src="'+OC.imagePath('core','actions/delete')+'"/>'); img.click(function(event){ event.stopPropagation(); @@ -18,6 +19,7 @@ PlayList.render=function(){ li.addClass('song'); PlayList.parent.append(li); } + $(".jp-playlist-" + PlayList.current).addClass("collection_playing"); } PlayList.getSelected=function(){ return $('tbody td.name input:checkbox:checked').parent().parent(); @@ -28,6 +30,7 @@ PlayList.hide=function(){ $(document).ready(function(){ PlayList.parent=$('#leftcontent'); + PlayList.init(); $('#selectAll').click(function(){ if($(this).attr('checked')){ // Check all diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php index 387c3480047..44a16793bf2 100644 --- a/apps/media/server/xml.server.php +++ b/apps/media/server/xml.server.php @@ -23,6 +23,7 @@ require_once('../../../lib/base.php'); +OC_Util::checkAppEnabled('media'); require_once('../lib_collection.php'); require_once('../lib_ampache.php'); diff --git a/apps/media/settings.php b/apps/media/settings.php new file mode 100644 index 00000000000..133440a9af6 --- /dev/null +++ b/apps/media/settings.php @@ -0,0 +1,6 @@ +<?php + +$tmpl = new OC_Template( 'media', 'settings'); + +return $tmpl->fetchPage(); +?> diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php index 6c8d740cc13..7764a315a8f 100644 --- a/apps/media/templates/music.php +++ b/apps/media/templates/music.php @@ -1,4 +1,4 @@ -<div id="controls"> +<div class='player-controls' id="controls"> <ul class="jp-controls"> <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play-big.svg'); ?>" /></a></li> <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause-big.svg'); ?>" /></a></li> @@ -17,6 +17,7 @@ <div class="jp-volume-bar"> <div class="jp-volume-bar-value"></div> </div> + <div class="jp-current-song"></div> <div class="player" id="jp-player"></div> diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php new file mode 100644 index 00000000000..295f33ab9e0 --- /dev/null +++ b/apps/media/templates/player.php @@ -0,0 +1,17 @@ +<?php +if(!isset($_)){//allow the template to be loaded standalone + require_once '../../../lib/base.php'; + $tmpl = new OC_Template( 'media', 'player'); + $tmpl->printPage(); + exit; +} +?> +Music +<div class='player-controls' id="playercontrols"> + <div class="player" id="jp-player"></div> + <ul class="jp-controls"> + <li><a href="#" class="jp-play action"><img class="svg" alt="<?php echo $l->t('Play');?>" src="<?php echo image_path('core', 'actions/play.svg'); ?>" /></a></li> + <li><a href="#" class="jp-pause action"><img class="svg" alt="<?php echo $l->t('Pause');?>" src="<?php echo image_path('core', 'actions/pause.svg'); ?>" /></a></li> + <li><a href="#" class="jp-next action"><img class="svg" alt="<?php echo $l->t('Next');?>" src="<?php echo image_path('core', 'actions/play-next.svg'); ?>" /></a></li> + </ul> +</div>
\ No newline at end of file diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php new file mode 100644 index 00000000000..da9346166e4 --- /dev/null +++ b/apps/media/templates/settings.php @@ -0,0 +1,7 @@ +<form id="mediaform"> + <fieldset class="personalblock"> + <strong>Media</strong><br /> + Ampache address: + <?php echo OC_Helper::linkTo('apps/media', 'tomahawk.php', null, true); ?><br /> + </fieldset> +</form> diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php index 1db982a3504..68401db67ae 100644 --- a/apps/media/tomahawk.php +++ b/apps/media/tomahawk.php @@ -24,6 +24,7 @@ $_POST=$_GET; //debug require_once('../../lib/base.php'); +OC_JSON::checkAppEnabled('media'); require_once('lib_collection.php'); $user=isset($_POST['user'])?$_POST['user']:''; diff --git a/apps/unhosted/compat.php b/apps/unhosted/compat.php index 00d6a7c2eeb..a514018f71a 100644 --- a/apps/unhosted/compat.php +++ b/apps/unhosted/compat.php @@ -30,6 +30,7 @@ $RUNTIME_NOSETUPFS = true; require_once('../../lib/base.php'); +OC_Util::checkAppEnabled('unhosted'); require_once('Sabre/autoload.php'); require_once('lib_unhosted.php'); require_once('oauth_ro_auth.php'); diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index d90e0b71900..3cbc38491ca 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -37,6 +37,7 @@ if($USERNAME=='' and isset($_SERVER['PHP_AUTH_USER'])){ $RUNTIME_NOAPPS=true; $RUNTIME_NOAPPS=false; require_once '../../lib/base.php'; +OC_Util::checkAppEnabled('user_openid'); if(!OC_User::userExists($USERNAME)){ if(defined("DEBUG") && DEBUG) {error_log($USERNAME.' doesn\'t exist');} diff --git a/core/css/jquery-ui-1.8.14.custom.css b/core/css/jquery-ui-1.8.14.custom.css index 2ddee46c84f..887e4b5e57b 100644 --- a/core/css/jquery-ui-1.8.14.custom.css +++ b/core/css/jquery-ui-1.8.14.custom.css @@ -33,6 +33,9 @@ /* states and images */ .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } +/* states and images */ +.ui-icon { width: 16px; height: 16px; } +.ui-icon-closethick { background-image: url(../img/actions/delete.png); } /* Misc visuals ----------------------------------*/ diff --git a/core/css/multiselect.css b/core/css/multiselect.css index 22e5098d3bf..ee426351769 100644 --- a/core/css/multiselect.css +++ b/core/css/multiselect.css @@ -1,5 +1,5 @@ ul.multiselectoptions { z-index:49; position:absolute; background-color:#fff; padding-top:.5em; border:1px solid #ddd; border-top:none; -moz-border-radius-bottomleft:.5em; -webkit-border-bottom-left-radius:.5em; border-bottom-left-radius:.5em; -moz-border-radius-bottomright:.5em; -webkit-border-bottom-right-radius:.5em; border-bottom-right-radius:.5em; -moz-box-shadow:0 1px 1px #ddd; -webkit-box-shadow:0 1px 1px #ddd; box-shadow:0 1px 1px #ddd; } -div.multiselect { padding-right:.6em; display:inline; position:relative; display:inline-block } +div.multiselect { padding-right:.6em; display:inline; position:relative; display:inline-block; vertical-align: bottom; } div.multiselect.active { background-color:#fff; border-bottom:none; border-bottom-left-radius:0; border-bottom-right-radius:0; z-index:50; position:relative } div.multiselect>span:first-child { margin-right:2em; float:left; } div.multiselect>span:last-child { float:right; position:relative } diff --git a/core/css/styles.css b/core/css/styles.css index 343ee4ca42d..8f309333318 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -16,7 +16,7 @@ body { background:#fefefe; font:normal .8em/1.6em "Lucida Grande", Arial, Verdan /* HEADERS */ #body-user #header, #body-settings #header { position:fixed; top:0; z-index:100; width:100%; height:2.5em; padding:.5em; background:#1d2d44; -moz-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; -webkit-box-shadow:0 0 10px #000, inset 0 -2px 10px #222; box-shadow:0 0 10px #000, inset 0 -2px 10px #222; } -#body-login #header { margin:-2em auto 0; text-align:center; height:10em; +#body-login #header { margin: -2em auto 0; text-align:center; height:10em; -moz-box-shadow:0 0 1em #000; -webkit-box-shadow:0 0 1em #000; box-shadow:0 0 1em #000; background: #1d2d44; /* Old browsers */ background: -moz-linear-gradient(top, #35537a 0%, #1d2d42 100%); /* FF3.6+ */ @@ -42,13 +42,13 @@ input[type="checkbox"] { width:auto; } #quota { cursor:default; } #body-login input { font-size:1.5em; } -#body-login input[type="submit"] { float:right; margin-right:.8em; } +#body-login input[type="text"], #body-login input[type="password"] { width: 13em; } +#body-login input.login { width: auto; float: right; } #remember_login { margin:.8em .2em 0 1em; } form.searchbox input[type="search"] { position:fixed; font-size:1.2em; top:.4em; right:3em; padding:.2em .5em .2em 1.5em; background-image:url('../img/actions/search.svg'); background-repeat:no-repeat; background-position:.5em center; border:0; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; } input[type="submit"].enabled { background:#66f866; border:1px solid #5e5; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #cfc inset; } input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text-shadow:#ffeedd 0 1px 0; -moz-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; -webkit-box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; box-shadow:0 1px 1px #f8f8f8, 0 1px 1px #ffeedd inset; } - /* CONTENT ------------------------------------------------------------------ */ #controls { width:100%; top:3.5em; height:2.8em; margin:0; background:#f7f7f7; border-bottom:1px solid #eee; position:fixed; z-index:50; -moz-box-shadow:0 -3px 7px #000; -webkit-box-shadow:0 -3px 7px #000; box-shadow:0 -3px 7px #000; } #controls .button { display:inline-block; } @@ -61,17 +61,22 @@ input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text- /* LOG IN & INSTALLATION ------------------------------------------------------------ */ #body-login { background:#ddd; } -#body-login p.info { width:16em; margin:2em auto; padding:1em; background:#eee; -moz-box-shadow:0 1px 0 #bbb inset; -webkit-box-shadow:0 1px 0 #bbb inset; box-shadow:0 1px 0 #bbb inset; -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em; } -#body-login p.info a { font-weight:bold; } +#body-login div.buttons { text-align: center; } +#body-login p.info { width:22em; text-align: center; margin:2em auto; color:#777; text-shadow:#fff 0 1px 0; } +#body-login p.info a { font-weight:bold; color:#777; } #login { min-height:30em; margin:2em auto 0; border-bottom:1px solid #f8f8f8; background:#eee; } -#login form { width:18em; margin:2em auto 5em; padding:0; } +#login form { width:22em; margin:2em auto 2em; padding:0; } #login form fieldset { background:0; border:0; margin-bottom:2em; padding:0; } #login form fieldset legend { font-weight:bold; } -#login form label { position:absolute; margin:.8em .8em; font-size:1.5em; color:#666; } -#login #dbhostlabel, #login #directorylabel { display:block; margin:.95em 0 .8em -7em; } +#login form label { margin:.8em .8em; color:#666; } +/* NEEDED FOR INFIELD LABELS */ +p.infield { position: relative; } +label.infield { cursor: text !important; } +#login form label.infield { position:absolute; font-size:1.5em; color:#AAA; } +#login #dbhostlabel, #login #directorylabel { display:block; margin:.95em 0 .8em -8em; } #login form input[type="checkbox"]+label { position:relative; margin:0; font-size:1em; text-shadow:#fff 0 1px 0; } -#login form ul.errors { background:#fed7d7; border:1px solid #f00; list-style-indent:inside; margin:0 0 4em 0; padding:1em 1em 1em 5em; } +#login form ul.errors { background:#fed7d7; border:1px solid #f00; list-style-indent:inside; margin:0 0 2em; padding:1em; } #login form #selectDbType { text-align:center; } #login form #selectDbType label { position:static; font-size:1em; margin:0 -.3em 1em; cursor:pointer; padding:.4em; border:1px solid #ddd; font-weight:bold; background:#f8f8f8; color:#555; text-shadow:#eee 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; } @@ -105,6 +110,7 @@ tbody tr:hover, tr:active { background-color:#f8f8f8; } #body-settings .personalblock, #body-settings .helpblock { padding:.5em 1em; margin:1em; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; } #body-settings .personalblock#quota { position:relative; margin-top:4.5em; padding:0; } #body-settings #controls+.helpblock { position:relative; margin-top:7.3em; } +.personalblock > legend { margin-top:2em; } #quota div, div.jp-play-bar, div.jp-seek-bar { padding:0; background:#e6e6e6; font-weight:normal; white-space:nowrap; -moz-border-radius-bottomleft:.4em; -webkit-border-bottom-left-radius:.4em; border-bottom-left-radius:.4em; -moz-border-radius-topleft:.4em; -webkit-border-top-left-radius:.4em; border-top-left-radius:.4em; } #quotatext {padding: .6em 1em;} diff --git a/core/js/jquery.infieldlabel.min.js b/core/js/jquery.infieldlabel.min.js new file mode 100755 index 00000000000..8f0ab9f7c5e --- /dev/null +++ b/core/js/jquery.infieldlabel.min.js @@ -0,0 +1,12 @@ +/* + * In-Field Label jQuery Plugin + * http://fuelyourcoding.com/scripts/infield.html + * + * Copyright (c) 2009 Doug Neiner + * Dual licensed under the MIT and GPL licenses. + * Uses the same license as jQuery, see: + * http://docs.jquery.com/License + * + * @version 0.1 + */ +(function($){$.InFieldLabels=function(b,c,d){var f=this;f.$label=$(b);f.label=b;f.$field=$(c);f.field=c;f.$label.data("InFieldLabels",f);f.showing=true;f.init=function(){f.options=$.extend({},$.InFieldLabels.defaultOptions,d);if(f.$field.val()!=""){f.$label.hide();f.showing=false};f.$field.focus(function(){f.fadeOnFocus()}).blur(function(){f.checkForEmpty(true)}).bind('keydown.infieldlabel',function(e){f.hideOnChange(e)}).change(function(e){f.checkForEmpty()}).bind('onPropertyChange',function(){f.checkForEmpty()})};f.fadeOnFocus=function(){if(f.showing){f.setOpacity(f.options.fadeOpacity)}};f.setOpacity=function(a){f.$label.stop().animate({opacity:a},f.options.fadeDuration);f.showing=(a>0.0)};f.checkForEmpty=function(a){if(f.$field.val()==""){f.prepForShow();f.setOpacity(a?1.0:f.options.fadeOpacity)}else{f.setOpacity(0.0)}};f.prepForShow=function(e){if(!f.showing){f.$label.css({opacity:0.0}).show();f.$field.bind('keydown.infieldlabel',function(e){f.hideOnChange(e)})}};f.hideOnChange=function(e){if((e.keyCode==16)||(e.keyCode==9))return;if(f.showing){f.$label.hide();f.showing=false};f.$field.unbind('keydown.infieldlabel')};f.init()};$.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};$.fn.inFieldLabels=function(c){return this.each(function(){var a=$(this).attr('for');if(!a)return;var b=$("input#"+a+"[type='text'],"+"input#"+a+"[type='password'],"+"textarea#"+a);if(b.length==0)return;(new $.InFieldLabels(this,b[0],c))})}})(jQuery);
\ No newline at end of file diff --git a/core/js/js.js b/core/js/js.js index a75e1d41f60..61a60c52485 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -252,7 +252,7 @@ $(document).ready(function(){ } $('form.searchbox').submit(function(event){ event.preventDefault(); - }) + }); $('#searchbox').keyup(function(event){ if(event.keyCode==13){//enter if(OC.search.currentResult>-1){ @@ -290,6 +290,9 @@ $(document).ready(function(){ // 'show password' checkbox $('#pass2').showPassword(); + //use infield labels + $("label.infield").inFieldLabels(); + // hide log in button etc. when form fields not filled $('#submit').hide(); $('#remember_login').hide(); @@ -301,14 +304,13 @@ $(document).ready(function(){ empty = true; } }); - if(empty) { $('#submit').fadeOut(); - $('#remember_login').fadeOut(); + $('#remember_login').hide(); $('#remember_login+label').fadeOut(); } else { $('#submit').fadeIn(); - $('#remember_login').fadeIn(); + $('#remember_login').show(); $('#remember_login+label').fadeIn(); } }); @@ -320,7 +322,7 @@ $(document).ready(function(){ }); $('#settings #expanddiv').click(function(event){ event.stopPropagation(); - }) + }); $('#settings #expand').hover(function(){ $('#settings #expand+span').fadeToggle(); }); diff --git a/core/js/multiselect.js b/core/js/multiselect.js index 559cdf9b167..26380824047 100644 --- a/core/js/multiselect.js +++ b/core/js/multiselect.js @@ -43,25 +43,25 @@ }); button.addClass('active'); event.stopPropagation(); - var options=$(this).parent().next().children().map(function(){return $(this).val()}); + var options=$(this).parent().next().children().map(function(){return $(this).val();}); var list=$('<ul class="multiselectoptions"/>').hide().appendTo($(this).parent()); function createItem(item,checked){ var id='ms'+multiSelectId+'-option-'+item; var input=$('<input id="'+id+'" type="checkbox"/>'); var label=$('<label for="'+id+'">'+item+'</label>'); if(settings.checked.indexOf(item)!=-1 || checked){ - input.attr('checked','checked'); + input.attr('checked',true); } if(checked){ settings.checked.push(item); } input.change(function(){ var groupname=$(this).next().text(); - if($(this).attr('checked')){ + if($(this).is(':checked')){ settings.checked.push(groupname); if(settings.oncheck){ if(settings.oncheck(groupname)===false){ - $(this).removeAttr('checked'); + $(this).attr('checked', false); return; } } @@ -70,7 +70,7 @@ settings.checked.splice(index,1); if(settings.onuncheck){ if(settings.onuncheck(groupname)===false){ - $(this).attr('checked','checked'); + $(this).attr('checked',true); return; } } @@ -81,7 +81,7 @@ }else{ button.children('span').first().text(settings.title); } - var newOuterWidth=Math.max((button.outerWidth()-2),settings.minOuterWidth)+'px' + var newOuterWidth=Math.max((button.outerWidth()-2),settings.minOuterWidth)+'px'; var newWidth=Math.max(button.width(),settings.minWidth); button.css('height',button.height()); button.css('white-space','nowrap'); diff --git a/core/js/setup.js b/core/js/setup.js index 0ed0ea69120..b765d41ba35 100644 --- a/core/js/setup.js +++ b/core/js/setup.js @@ -1,8 +1,8 @@ $(document).ready(function() { $('#selectDbType').buttonset(); - $('#datadirField').hide(250); + $('#datadirContent').hide(250); + $('#databaseField').hide(250); if($('#hasSQLite').val()=='true'){ - $('#databaseField').hide(); $('#use_other_db').hide(); $('#dbhost').hide(); $('#dbhostlabel').hide(); @@ -26,11 +26,11 @@ $(document).ready(function() { $('#dbhostlabel').show(250); }); + $('input[checked]').trigger('click'); + $('#showAdvanced').click(function() { - $('#datadirField').slideToggle(250); - if($('#hasSQLite').val()=='true'){ - $('#databaseField').slideToggle(250); - } + $('#datadirContent').slideToggle(250); + $('#databaseField').slideToggle(250); }); $("form").submit(function(){ // Save form parameters diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php new file mode 100644 index 00000000000..de0d393ec78 --- /dev/null +++ b/core/lostpassword/index.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright (c) 2010 Frank Karlitschek karlitschek@kde.org + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. +*/ + +$RUNTIME_NOAPPS = TRUE; //no apps +require_once('../../lib/base.php'); + +// Someone lost their password: +if (isset($_POST['user'])) { + if (OC_User::userExists($_POST['user'])) { + $token = sha1($_POST['user']+uniqId()); + OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token); + $email = OC_Preferences::getValue($_POST['user'], 'lostpassword', 'email', ''); + if (!empty($email)) { + $link = OC_Helper::linkTo('core/lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token; + $tmpl = new OC_Template('core/lostpassword', 'email'); + $tmpl->assign('link', $link); + $msg = $tmpl->fetchPage(); + $l = new OC_L10N('core'); + mail($email, $l->t('Owncloud password reset'), $msg); + } + OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true)); + } else { + OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false)); + } +} else { + OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false)); +} diff --git a/core/lostpassword/resetpassword.php b/core/lostpassword/resetpassword.php new file mode 100644 index 00000000000..1c78d720947 --- /dev/null +++ b/core/lostpassword/resetpassword.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2010 Frank Karlitschek karlitschek@kde.org + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. +*/ + +$RUNTIME_NOAPPS = TRUE; //no apps +require_once('../../lib/base.php'); + +// Someone wants to reset their password: +if(isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], 'owncloud', 'lostpassword') === $_GET['token']) { + if (isset($_POST['password'])) { + if (OC_User::setPassword($_GET['user'], $_POST['password'])) { + OC_Preferences::deleteKey($_GET['user'], 'owncloud', 'lostpassword'); + OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => true)); + } else { + OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => false)); + } + } else { + OC_Template::printGuestPage('core/lostpassword', 'resetpassword', array('success' => false)); + } +} else { + // Someone lost their password + OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false)); +} diff --git a/core/lostpassword/templates/email.php b/core/lostpassword/templates/email.php new file mode 100644 index 00000000000..d146d8e4c37 --- /dev/null +++ b/core/lostpassword/templates/email.php @@ -0,0 +1 @@ +<?php echo str_replace('{link}', $_['link'], $l->t('Use the following link to reset your password: {link}')) ?> diff --git a/core/templates/lostpassword.php b/core/lostpassword/templates/lostpassword.php index 67e34164d08..4b871963b80 100644 --- a/core/templates/lostpassword.php +++ b/core/lostpassword/templates/lostpassword.php @@ -1,4 +1,4 @@ -<form action="index.php?lostpassword" method="post"> +<form action="index.php" method="post"> <fieldset> <?php echo $l->t('You will receive a link to reset your password via Email.'); ?> <?php if ($_['requested']): ?> @@ -7,8 +7,11 @@ <?php if ($_['error']): ?> <?php echo $l->t('Login failed!'); ?> <?php endif; ?> - <input type="text" name="user" id="user" placeholder="<?php echo $l->t('Username or Email'); ?>" value="" autocomplete="off" required autofocus /> + <p class="infield"> + <label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label> + <input type="text" name="user" id="user" value="" autocomplete="off" required autofocus /> + </p> <input type="submit" id="submit" value="<?php echo $l->t('Request reset'); ?>" /> <?php endif; ?> </fieldset> -</form>
\ No newline at end of file +</form> diff --git a/core/lostpassword/templates/resetpassword.php b/core/lostpassword/templates/resetpassword.php new file mode 100644 index 00000000000..56257de7f13 --- /dev/null +++ b/core/lostpassword/templates/resetpassword.php @@ -0,0 +1,14 @@ +<form action="<?php echo 'resetpassword.php?'.$_SERVER['QUERY_STRING']; ?>" method="post"> + <fieldset> + <?php if($_['success']): ?> + <h1><?php echo $l->t('Your password was reset'); ?></h1> + <p><a href="<?php echo OC::$WEBROOT ?>/"><?php echo $l->t('To login page'); ?></a></p> + <?php else: ?> + <p class="infield"> + <label for="password" class="infield"><?php echo $l->t( 'New password' ); ?></label> + <input type="password" name="password" id="password" value="" required /> + </p> + <input type="submit" id="submit" value="<?php echo $l->t('Reset password'); ?>" /> + <?php endif; ?> + </fieldset> +</form> diff --git a/core/templates/installation.php b/core/templates/installation.php index 09f9ad8c359..70a545d66cf 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -18,21 +18,35 @@ <fieldset> <legend><?php echo $l->t( 'Create an <strong>admin account</strong>' ); ?></legend> - <input type="text" name="adminlogin" id="adminlogin" value="<?php print OC_Helper::init_var('adminlogin'); ?>" placeholder="<?php echo $l->t( 'Username' ); ?>" autocomplete="off" autofocus required /> - <input type="password" name="adminpass" id="adminpass" value="<?php print OC_Helper::init_var('adminpass'); ?>" placeholder="<?php echo $l->t( 'Password' ); ?>" required /> + <p class="infield"> + <label for="adminlogin" class="infield"><?php echo $l->t( 'Username' ); ?></label> + <input type="text" name="adminlogin" id="adminlogin" value="<?php print OC_Helper::init_var('adminlogin'); ?>" autocomplete="off" autofocus required /> + </p> + <p class="infield"> + <label for="adminpass" class="infield"><?php echo $l->t( 'Password' ); ?></label> + <input type="password" name="adminpass" id="adminpass" value="<?php print OC_Helper::init_var('adminpass'); ?>" required /> + </p> </fieldset> - + + <fieldset id="datadirField"> + <legend><a id="showAdvanced"><?php echo $l->t( 'Advanced' ); ?> ▾</a></legend> + <div id="datadirContent"> + <label for="directory"><?php echo $l->t( 'Data folder' ); ?>:</label><br/> + <input type="text" name="directory" id="directory" value="<?php print OC_Helper::init_var('directory', $_['directory']); ?>" /> + </div> + </fieldset> + <fieldset id='databaseField'> <?php if($_['hasMySQL'] or $_['hasPostgreSQL']) $hasOtherDB = true; //other than SQLite ?> <legend><?php echo $l->t( 'Configure the database' ); ?></legend> <div id="selectDbType"> <?php if($_['hasSQLite']): ?> - <input type='hidden' id='hasSQLite' value='true' /> + <input type='hidden' id='hasSQLite' value="true" /> <?php if(!$hasOtherDB): ?> <p>SQLite <?php echo $l->t( 'will be used' ); ?>.</p> <input type="hidden" id="dbtype" name="dbtype" value="sqlite" /> <?php else: ?> - <input type="radio" name="dbtype" value='sqlite' id="sqlite" <?php OC_Helper::init_radio('dbtype', 'sqlite', 'sqlite'); ?>/> + <input type="radio" name="dbtype" value="sqlite" id="sqlite" <?php OC_Helper::init_radio('dbtype', 'sqlite', 'sqlite'); ?>/> <label class="sqlite" for="sqlite">SQLite</label> <?php endif; ?> <?php endif; ?> @@ -43,7 +57,7 @@ <p>MySQL <?php echo $l->t( 'will be used' ); ?>.</p> <input type="hidden" id="dbtype" name="dbtype" value="mysql" /> <?php else: ?> - <input type="radio" name="dbtype" value='mysql' id="mysql" <?php OC_Helper::init_radio('dbtype','pgsql', 'mysql', 'sqlite'); ?>/> + <input type="radio" name="dbtype" value="mysql" id="mysql" <?php OC_Helper::init_radio('dbtype','mysql', 'sqlite'); ?>/> <label class="mysql" for="mysql">MySQL</label> <?php endif; ?> <?php endif; ?> @@ -54,27 +68,32 @@ <input type="hidden" id="dbtype" name="dbtype" value="pgsql" /> <?php else: ?> <label class="pgsql" for="pgsql">PostgreSQL</label> - <input type="radio" name="dbtype" value='pgsql' id="pgsql" <?php OC_Helper::init_radio('dbtype','pgsql', 'mysql', 'sqlite'); ?>/> + <input type="radio" name="dbtype" value='pgsql' id="pgsql" <?php OC_Helper::init_radio('dbtype','pgsql', 'sqlite'); ?>/> <?php endif; ?> <?php endif; ?> </div> <?php if($hasOtherDB): ?> <div id="use_other_db"> - <input type="text" name="dbuser" id="dbuser" value="<?php print OC_Helper::init_var('dbuser'); ?>" placeholder="<?php echo $l->t( 'Database user' ); ?>" autocomplete="off" /> - <input type="password" name="dbpass" id="dbpass" value="<?php print OC_Helper::init_var('dbpass'); ?>" placeholder="<?php echo $l->t( 'Database password' ); ?>" /> - <input type="text" name="dbname" id="dbname" value="<?php print OC_Helper::init_var('dbname'); ?>" placeholder="<?php echo $l->t( 'Database name' ); ?>" autocomplete="off" /> + <p class="infield"> + <label for="dbuser" class="infield"><?php echo $l->t( 'Database user' ); ?></label> + <input type="text" name="dbuser" id="dbuser" value="<?php print OC_Helper::init_var('dbuser'); ?>" autocomplete="off" /> + </p> + <p class="infield"> + <label for="dbpass" class="infield"><?php echo $l->t( 'Database password' ); ?></label> + <input type="password" name="dbpass" id="dbpass" value="<?php print OC_Helper::init_var('dbpass'); ?>" /> + </p> + <p class="infield"> + <label for="dbname" class="infield"><?php echo $l->t( 'Database name' ); ?></label> + <input type="text" name="dbname" id="dbname" value="<?php print OC_Helper::init_var('dbname'); ?>" autocomplete="off" /> + </p> </div> <?php endif; ?> - - </fieldset> - - <a id='showAdvanced'><strong><?php echo $l->t( 'Advanced' ); ?> ▾</strong></a> - - <fieldset id='datadirField'> - <label id="dbhostlabel" for="dbhost"><?php echo $l->t( 'Database host' ); ?></label><input type="text" name="dbhost" id="dbhost" value="<?php print OC_Helper::init_var('dbhost', 'localhost'); ?>" placeholder="<?php echo $l->t( 'Database host' ); ?>" /> - <label id="directorylabel" for="directory"><?php echo $l->t( 'Data folder' ); ?></label><input type="text" name="directory" id="directory" value="<?php print OC_Helper::init_var('directory', $_['directory']); ?>" placeholder="<?php echo $l->t( 'Data folder' ); ?>" /> + <p class="infield"> + <label for="dbhost" class="infield"><?php echo $l->t( 'Database host' ); ?></label> + <input type="text" name="dbhost" id="dbhost" value="<?php print OC_Helper::init_var('dbhost', 'localhost'); ?>" /> + </p> </fieldset> - <input type="submit" value="<?php echo $l->t( 'Finish setup' ); ?>" /> + <div class="buttons"><input type="submit" value="<?php echo $l->t( 'Finish setup' ); ?>" /></div> </form> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 7e05fce0ecf..96f3d2662fb 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -32,6 +32,6 @@ </div></header> <?php echo $_['content']; ?> </div> - <footer><p class="info"><a href="http://owncloud.org/">ownCloud</a> <?php echo $l->t( 'gives you freedom and control over your own data' ); ?></p></footer> + <footer><p class="info"><a href="http://owncloud.org/">ownCloud</a>: <?php echo $l->t( 'web services under your control' ); ?></p></footer> </body> </html> diff --git a/core/templates/login.php b/core/templates/login.php index 717f6bcabda..aff0afac203 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -1,17 +1,17 @@ <form action="index.php" method="post"> <fieldset> <?php if($_['error']): ?> - <a href="index.php?lostpassword"><?php echo $l->t('Lost your password?'); ?></a> + <a href="./core/lostpassword/"><?php echo $l->t('Lost your password?'); ?></a> <?php endif; ?> - <?php if(empty($_["username"])): ?> - <input type="text" name="user" id="user" placeholder="Username" value="" autocomplete="off" required autofocus /> - <input type="password" name="password" id="password" placeholder="Password" value="" required /> - <input type="checkbox" name="remember_login" id="remember_login" /><label for="remember_login"><?php echo $l->t('remember'); ?></label> - <?php else: ?> - <input type="text" name="user" id="user" placeholder="Username" value="<?php echo $_['username']; ?>" autocomplete="off" required > - <input type="password" name="password" id="password" placeholder="Password" value="" required autofocus /> - <input type="checkbox" name="remember_login" id="remember_login" checked /><label for="remember_login"><?php echo $l->t('remember'); ?></label> - <?php endif; ?> - <input type="submit" id="submit" value="Log in" /> + <p class="infield"> + <label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label> + <input type="text" name="user" id="user" value="<?php echo !empty($_POST['user'])?$_POST['user'].'"':'" autofocus'; ?> autocomplete="off" required /> + </p> + <p class="infield"> + <label for="password" class="infield"><?php echo $l->t( 'Password' ); ?></label> + <input type="password" name="password" id="password" value="" required <?php echo !empty($_POST['user'])?'autofocus':''; ?> /> + </p> + <input type="checkbox" name="remember_login" value="1" id="remember_login" /><label for="remember_login"><?php echo $l->t('remember'); ?></label> + <input type="submit" id="submit" class="login" value="<?php echo $l->t( 'Log in' ); ?>" /> </fieldset> </form> diff --git a/core/templates/resetpassword.php b/core/templates/resetpassword.php deleted file mode 100644 index 2f43a93cfb5..00000000000 --- a/core/templates/resetpassword.php +++ /dev/null @@ -1,10 +0,0 @@ -<form action="<?php echo 'index.php?'.$_SERVER['QUERY_STRING']; ?>" method="post"> - <fieldset> - <?php if($_['success']): ?> - <?php echo $l->t('Your password was reset'); ?> - <?php else: ?> - <input type="password" name="password" id="password" placeholder="<?php echo $l->t('New password'); ?>" value="" required /> - <input type="submit" id="submit" value="<?php echo $l->t('Reset password'); ?>" /> - <?php endif; ?> - </fieldset> -</form> diff --git a/files/ajax/delete.php b/files/ajax/delete.php index b6bc859897c..48df5862db2 100644 --- a/files/ajax/delete.php +++ b/files/ajax/delete.php @@ -20,7 +20,7 @@ foreach($files as $file) { } } -if(success) { +if($success) { OC_JSON::success(array("data" => array( "dir" => $dir, "files" => $files ))); } else { OC_JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError ))); diff --git a/files/css/files.css b/files/css/files.css index 27ead667dc4..1766d03d967 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -59,7 +59,7 @@ table thead.fixed { height:2em; } #fileList tr td.filename { -webkit-transition:background-image 500ms; -moz-transition:background-image 500ms; -o-transition:background-image 500ms; transition:background-image 500ms; } #select_all { float:left; margin:.3em 0.6em 0 .5em; } #uploadsize-message,#delete-confirm { display:none; } -.selectedActions a, a.action { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; } +.selectedActions a,#fileList a.action { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; } .selectedActions { display:none; } /* add breadcrumb divider to the File item in navigation panel */ diff --git a/files/js/fileactions.js b/files/js/fileactions.js index 24e01c34db7..81aedbd98b9 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -53,7 +53,7 @@ FileActions={ }, display:function(parent){ FileActions.currentFile=parent; - $('.action').remove(); + $('#fileList .action').remove(); var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType()); var file=FileActions.getCurrentFile(); if($('tr[data-file="'+file+'"]').data('renaming')){ @@ -104,12 +104,12 @@ FileActions={ }); parent.parent().children().last().append(element); } - $('.action').hide(); - $('.action').fadeIn(200); + $('#fileList .action').hide(); + $('#fileList .action').fadeIn(200); return false; }, hide:function(){ - $('.action').fadeOut(200,function(){ + $('#fileList .action').fadeOut(200,function(){ $(this).remove(); }); }, @@ -125,7 +125,7 @@ FileActions={ } FileActions.register('all','Download',function(){return OC.imagePath('core','actions/download')},function(filename){ - window.location='ajax/download.php?files='+filename+'&dir='+$('#dir').val(); + window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val()); }); FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){ diff --git a/files/templates/part.breadcrumb.php b/files/templates/part.breadcrumb.php index 9a265a9c1ea..63242dd326c 100644 --- a/files/templates/part.breadcrumb.php +++ b/files/templates/part.breadcrumb.php @@ -2,4 +2,4 @@ <div class="crumb svg" data-dir='<?php echo $crumb["dir"];?>' style='background-image:url("<?php echo image_path('core','breadcrumb.png');?>")'> <a href="<?php echo $_['baseURL'].$crumb["dir"]; ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a> </div> - <?php endforeach; ?> + <?php endforeach; ?>
\ No newline at end of file diff --git a/files/templates/part.list.php b/files/templates/part.list.php index 398094f56d0..6bf5efe2fb2 100644 --- a/files/templates/part.list.php +++ b/files/templates/part.list.php @@ -8,7 +8,7 @@ <tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'> <td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)"> <?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?> - <a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$file['directory'].'/'.$file['name']; else echo $_['downloadURL'].$file['directory'].'/'.$file['name']; ?>" title=""> + <a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$file['directory'].'/'.$file['name']; else echo $_['downloadURL'].urlencode($file['directory']).'/'.urlencode($file['name']); ?>" title=""> <span class="nametext"> <?php if($file['type'] == 'dir'):?> <?php echo htmlspecialchars($file['name']);?> diff --git a/index.php b/index.php index 2ac3f6df7bb..fb8d1922dd4 100644 --- a/index.php +++ b/index.php @@ -52,85 +52,43 @@ elseif(OC_User::isLoggedIn()) { } } -// remember was checked after last login -elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) { +// For all others cases, we display the guest page : +else { OC_App::loadApps(); - if(defined("DEBUG") && DEBUG) {error_log("Trying to login from cookie");} - // confirm credentials in cookie - if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && - OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) { - OC_User::setUserId($_COOKIE['oc_username']); - OC_Util::redirectToDefaultPage(); - } - else { - OC_Template::printGuestPage("", "login", array("error" => true)); - } -} + $error = false; -// Someone wants to log in : -elseif(isset($_POST["user"]) && isset($_POST['password'])) { - OC_App::loadApps(); - if(OC_User::login($_POST["user"], $_POST["password"])) { - if(!empty($_POST["remember_login"])){ - if(defined("DEBUG") && DEBUG) {error_log("Setting remember login to cookie");} - $token = md5($_POST["user"].time()); - OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); - OC_User::setMagicInCookie($_POST["user"], $token); + // remember was checked after last login + if(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) { + if(defined("DEBUG") && DEBUG) { + error_log("Trying to login from cookie"); } - else { - OC_User::unsetMagicInCookie(); + // confirm credentials in cookie + if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && + OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) { + OC_User::setUserId($_COOKIE['oc_username']); + OC_Util::redirectToDefaultPage(); } - OC_Util::redirectToDefaultPage(); } - else { - if(isset($_COOKIE["oc_username"])){ - OC_Template::printGuestPage("", "login", array("error" => true, "username" => $_COOKIE["oc_username"])); - }else{ - OC_Template::printGuestPage("", "login", array("error" => true)); - } - } -} - -// Someone lost their password: -elseif(isset($_GET['lostpassword'])) { - OC_App::loadApps(); - if (isset($_POST['user'])) { - if (OC_User::userExists($_POST['user'])) { - $token = sha1($_POST['user']+uniqId()); - OC_Preferences::setValue($_POST['user'], "owncloud", "lostpassword", $token); - // TODO send email with link+token - OC_Template::printGuestPage("", "lostpassword", array("error" => false, "requested" => true)); + + // Someone wants to log in : + elseif(isset($_POST["user"]) && isset($_POST['password'])) { + if(OC_User::login($_POST["user"], $_POST["password"])) { + if(!empty($_POST["remember_login"])){ + if(defined("DEBUG") && DEBUG) { + error_log("Setting remember login to cookie"); + } + $token = md5($_POST["user"].time()); + OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); + OC_User::setMagicInCookie($_POST["user"], $token); + } + else { + OC_User::unsetMagicInCookie(); + } + OC_Util::redirectToDefaultPage(); } else { - OC_Template::printGuestPage("", "lostpassword", array("error" => true, "requested" => false)); + $error = true; } - } else { - OC_Template::printGuestPage("", "lostpassword", array("error" => false, "requested" => false)); } -} -// Someone wants to reset their password: -elseif(isset($_GET['resetpassword']) && isset($_GET['token']) && isset($_GET['user']) && OC_Preferences::getValue($_GET['user'], "owncloud", "lostpassword") === $_GET['token']) { - OC_App::loadApps(); - if (isset($_POST['password'])) { - if (OC_User::setPassword($_GET['user'], $_POST['password'])) { - OC_Preferences::deleteKey($_GET['user'], "owncloud", "lostpassword"); - OC_Template::printGuestPage("", "resetpassword", array("success" => true)); - } else { - OC_Template::printGuestPage("", "resetpassword", array("success" => false)); - } - } else { - OC_Template::printGuestPage("", "resetpassword", array("success" => false)); - } + OC_Template::printGuestPage('', 'login', array('error' => $error )); } - -// For all others cases, we display the guest page : -else { - OC_App::loadApps(); - if(isset($_COOKIE["username"])){ - OC_Template::printGuestPage("", "login", array("error" => false, "username" => $_COOKIE["username"])); - }else{ - OC_Template::printGuestPage("", "login", array("error" => false)); - } -} - -?> diff --git a/lib/appconfig.php b/lib/appconfig.php index 392782b2586..f43ef141732 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -100,7 +100,18 @@ class OC_Appconfig{ return $default; } } - + + /** + * @brief check if a key is set in the appconfig + * @param string $app + * @param string $key + * @return bool + */ + public static function hasKey($app,$key){ + $exists = self::getKeys( $app ); + return in_array( $key, $exists ); + } + /** * @brief sets a value in the appconfig * @param $app app @@ -112,10 +123,7 @@ class OC_Appconfig{ */ public static function setValue( $app, $key, $value ){ // Does the key exist? yes: update. No: insert - $exists = self::getKeys( $app ); - - // null: does not exist - if( !in_array( $key, $exists )){ + if(! self::hasKey($app,$key)){ $query = OC_DB::prepare( 'INSERT INTO *PREFIX*appconfig ( appid, configkey, configvalue ) VALUES( ?, ?, ? )' ); $query->execute( array( $app, $key, $value )); } diff --git a/lib/base.php b/lib/base.php index de2e7a36eee..0156febe231 100644 --- a/lib/base.php +++ b/lib/base.php @@ -115,6 +115,7 @@ class OC{ OC_Util::addScript( "jquery-1.6.4.min" ); OC_Util::addScript( "jquery-ui-1.8.14.custom.min" ); OC_Util::addScript( "jquery-showpassword" ); + OC_Util::addScript( "jquery.infieldlabel.min" ); OC_Util::addScript( "jquery-tipsy" ); OC_Util::addScript( "js" ); //OC_Util::addScript( "multiselect" ); diff --git a/lib/config.php b/lib/config.php index 67df5e94c6d..3aa69327f56 100644 --- a/lib/config.php +++ b/lib/config.php @@ -175,7 +175,7 @@ class OC_Config{ $result=@file_put_contents( OC::$SERVERROOT."/config/config.php", $content ); if(!$result) { $tmpl = new OC_Template( '', 'error', 'guest' ); - $tmpl->assign('errors',array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by setting the owner of 'config' to the user that the web server uses (".exec('whoami').")"))); + $tmpl->assign('errors',array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by setting the owner of 'config' to the user that the web server uses (".OC_Util::checkWebserverUser().")"))); $tmpl->printPage(); exit; } diff --git a/lib/helper.php b/lib/helper.php index 1661f38e8ab..b6332b54aea 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -266,8 +266,14 @@ class OC_Helper { return $r; } + /** + * returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe? + * @param string $s Name of radio-button element name + * @param string $v Value of current radio-button element + * @param string $d Value of default radio-button element + */ public static function init_radio($s, $v, $d) { - if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || $v == $d) + if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || (!isset($_REQUEST[$s]) && $v == $d)) print "checked=\"checked\" "; } diff --git a/lib/json.php b/lib/json.php index 5ebd6c6b759..cedf79fd7c3 100644 --- a/lib/json.php +++ b/lib/json.php @@ -11,7 +11,7 @@ class OC_JSON{ /** * set Content-Type header to jsonrequest */ - public static function setContentTypeHeader($type='application/jsonrequest'){ + public static function setContentTypeHeader($type='application/json'){ if (!self::$send_content_type_header){ // We send json data header( 'Content-Type: '.$type ); @@ -20,6 +20,17 @@ class OC_JSON{ } /** + * Check if the app is enabled, send json error msg if not + */ + public static function checkAppEnabled($app){ + if( !OC_App::isEnabled($app)){ + $l = new OC_L10N('core'); + self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') ))); + exit(); + } + } + + /** * Check if the user is logged in, send json error msg if not */ public static function checkLoggedIn(){ diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php index 24679257199..e0570e84ea5 100644 --- a/lib/mimetypes.list.php +++ b/lib/mimetypes.list.php @@ -32,6 +32,8 @@ return array( 'gz'=>'application/x-gzip', 'html'=>'text/html', 'htm'=>'text/html', + 'ics'=>'text/calendar', + 'ical'=>'text/calendar', 'jpeg'=>'image/jpeg', 'jpg'=>'image/jpeg', 'js'=>'application/javascript', diff --git a/lib/setup.php b/lib/setup.php index 8d3079720cc..355d979dc65 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -55,9 +55,6 @@ class OC_Setup { if(empty($options['dbuser'])) { $error[] = "$dbprettyname enter the database username."; } - if(empty($options['dbpass'])) { - $error[] = "$dbprettyname enter the database password."; - } if(empty($options['dbname'])) { $error[] = "$dbprettyname enter the database name."; } diff --git a/lib/util.php b/lib/util.php index c7a2c509800..5d03c56f18e 100644 --- a/lib/util.php +++ b/lib/util.php @@ -24,7 +24,7 @@ class OC_Util { $success=@mkdir($CONFIG_DATADIRECTORY_ROOT); if(!$success) { $tmpl = new OC_Template( '', 'error', 'guest' ); - $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by setting the owner of '".OC::$SERVERROOT."' to the user that the web server uses (".exec('whoami').")"))); + $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by setting the owner of '".OC::$SERVERROOT."' to the user that the web server uses (".OC_Util::checkWebserverUser().")"))); $tmpl->printPage(); exit; } @@ -90,7 +90,15 @@ class OC_Util { * @return array */ public static function getVersion(){ - return array(1,90,0); + return array(1,92,0); + } + + /** + * get the current installed version string of ownCloud + * @return string + */ + public static function getVersionString(){ + return '2 beta 3'; } /** @@ -200,28 +208,21 @@ class OC_Util { } $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); $CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" ); - - //try to get the username the httpd server runs on, used in hints - $stat=stat($_SERVER['DOCUMENT_ROOT']); - if(is_callable('posix_getpwuid')){ - $serverUser=posix_getpwuid($stat['uid']); - $serverUser='\''.$serverUser['name'].'\''; - }else{ - $serverUser='\'www-data\' for ubuntu/debian';//TODO: try to detect the distro and give a guess based on that - } + $serverUser=OC_Util::checkWebserverUser(); //common hint for all file permissons error messages $permissionsHint="Permissions can usually be fixed by setting the owner of the file or directory to the user the web server runs as ($serverUser)"; //check for correct file permissions if(!stristr(PHP_OS, 'WIN')){ + $permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users."; $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)),-3); if(substr($prems,-1)!='0'){ OC_Helper::chmodr($CONFIG_DATADIRECTORY_ROOT,0770); clearstatcache(); $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY_ROOT)),-3); if(substr($prems,2,1)!='0'){ - $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable from the web<br/>','hint'=>$permissionsHint); + $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY_ROOT.') is readable for other users<br/>','hint'=>$permissionsModHint); } } if( OC_Config::getValue( "enablebackup", false )){ @@ -231,7 +232,7 @@ class OC_Util { clearstatcache(); $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3); if(substr($prems,2,1)!='0'){ - $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable from the web<br/>','hint'=>$permissionsHint); + $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint); } } } @@ -244,16 +245,55 @@ class OC_Util { // check if all required php modules are present if(!class_exists('ZipArchive')){ - $errors[]=array('error'=>'PHP module ZipArchive not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module zip not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } if(!function_exists('mb_detect_encoding')){ $errors[]=array('error'=>'PHP module mb multibyte not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } + if(!function_exists('ctype_digit')){ + $errors[]=array('error'=>'PHP module ctype is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); + } return $errors; } + public static function displayLoginPage($parameters = array()){ + if(isset($_COOKIE["username"])){ + $parameters["username"] = $_COOKIE["username"]; + } else { + $parameters["username"] = ''; + } + OC_Template::printGuestPage("", "login", $parameters); + } + + /** + * Try to get the username the httpd server runs on, used in hints + */ + public static function checkWebserverUser(){ + $stat=stat($_SERVER['DOCUMENT_ROOT']); + if(is_callable('posix_getpwuid')){ + $serverUser=posix_getpwuid($stat['uid']); + $serverUser='\''.$serverUser['name'].'\''; + }elseif(exec('whoami')){ + $serverUser=exec('whoami'); + }else{ + $serverUser='\'www-data\' for ubuntu/debian'; //TODO: try to detect the distro and give a guess based on that + } + return $serverUser; + } + + + /** + * Check if the app is enabled, send json error msg if not + */ + public static function checkAppEnabled($app){ + if( !OC_App::isEnabled($app)){ + header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true)); + exit(); + } + } + /** * Check if the user is logged in, redirects to home if not */ diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php index 12f6b32a4f3..06dd3c2ac6b 100644 --- a/settings/ajax/disableapp.php +++ b/settings/ajax/disableapp.php @@ -1,6 +1,7 @@ <?php // Init owncloud require_once('../../lib/base.php'); +OC_JSON::checkAdminUser(); OC_JSON::setContentTypeHeader(); OC_App::disable($_POST['appid']); diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index 8be80cd2ece..639df2aecc0 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -2,6 +2,7 @@ // Init owncloud require_once('../../lib/base.php'); +OC_JSON::checkAdminUser(); OC_JSON::setContentTypeHeader(); OC_App::enable($_POST['appid']); diff --git a/settings/ajax/lostpassword.php b/settings/ajax/lostpassword.php new file mode 100644 index 00000000000..a2dfc033206 --- /dev/null +++ b/settings/ajax/lostpassword.php @@ -0,0 +1,19 @@ +<?php + +// Init owncloud +require_once('../../lib/base.php'); + +OC_JSON::checkLoggedIn(); + +$l=new OC_L10N('core'); + +// Get data +if( isset( $_POST['email'] ) ){ + $email=trim($_POST['email']); + OC_Preferences::setValue(OC_User::getUser(),'settings','email',$email); + OC_JSON::success(array("data" => array( "message" => $l->t("email Changed") ))); +}else{ + OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") ))); +} + +?> diff --git a/settings/ajax/openid.php b/settings/ajax/openid.php index 4226ae740f0..c4b119b448d 100644 --- a/settings/ajax/openid.php +++ b/settings/ajax/openid.php @@ -6,6 +6,7 @@ require_once('../../lib/base.php'); $l=new OC_L10N('settings'); OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('user_openid'); // Get data if( isset( $_POST['identity'] ) ){ diff --git a/settings/apps.php b/settings/apps.php index 672cb18775e..27b4c17f9e6 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -43,21 +43,22 @@ foreach($registeredApps as $app){ } } -$catagoryNames=OC_OCSClient::getCategories(); -if(is_array($catagoryNames)){ - $categories=array_keys($catagoryNames); - $externalApps=OC_OCSClient::getApplications($categories); - foreach($externalApps as $app){ - $apps[]=array( - 'name'=>$app['name'], - 'id'=>$app['id'], - 'active'=>false, - 'description'=>$app['description'], - 'author'=>$app['personid'], - 'license'=>$app['license'], - ); - } -} +// dissabled for now +// $catagoryNames=OC_OCSClient::getCategories(); +// if(is_array($catagoryNames)){ +// $categories=array_keys($catagoryNames); +// $externalApps=OC_OCSClient::getApplications($categories); +// foreach($externalApps as $app){ +// $apps[]=array( +// 'name'=>$app['name'], +// 'id'=>$app['id'], +// 'active'=>false, +// 'description'=>$app['description'], +// 'author'=>$app['personid'], +// 'license'=>$app['license'], +// ); +// } +// } diff --git a/settings/css/settings.css b/settings/css/settings.css index a0ed2c69f44..4b5bc06b218 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -12,14 +12,16 @@ input#identity { width:20em; } /* USERS */ form { display:inline; } +table th { height:2em; color:#999; } +table th, table td { border-bottom:1px solid #ddd; padding:0 .5em; padding-left:.8em; text-align:left; font-weight:normal; } td.name, td.password { padding-left:.8em; } -td.password>img, td.remove>img { display:none; cursor:pointer; } -td.password>span { margin-right:1.2em; } -td.password { width:12em; cursor:pointer; } +td.password>img, td.remove>img, td.quota>img { visibility:hidden; } +td.password, td.quota { width:12em; cursor:pointer; } +td.password>span, td.quota>span { margin-right: 1.2em; color: #C7C7C7; } td.remove { width:1em; padding-right:1em; } tr:hover>td.password>span { margin:0; cursor:pointer; } -tr:hover>td.remove>img, tr:hover>td.password>img { display:inline; cursor:pointer; } +tr:hover>td.remove>img, tr:hover>td.password>img, tr:hover>td.quota>img { visibility:visible; cursor:pointer; } tr:hover>td.remove>img { float:right; } li.selected { background-color:#ddd; } #content>table { margin-top:6.5em; } diff --git a/settings/js/personal.js b/settings/js/personal.js index 9578fb2c890..8108da433c8 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -32,6 +32,15 @@ $(document).ready(function(){ }); + $('#lostpassword #email').blur(function(event){ + event.preventDefault(); + OC.msg.startSaving('#lostpassword .msg'); + var post = $( "#lostpassword" ).serialize(); + $.post( 'ajax/lostpassword.php', post, function(data){ + OC.msg.finishedSaving('#lostpassword .msg', data); + }); + }); + $("#languageinput").chosen(); $("#languageinput").change( function(){ diff --git a/settings/js/users.js b/settings/js/users.js index c60fb32c40e..4944f3a62f6 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -7,7 +7,7 @@ $(document).ready(function(){ function applyMultiplySelect(element){ var checked=[]; - var user=element.data('username') + var user=element.data('username'); if(element.data('userGroups')){ checked=element.data('userGroups').split(', '); } @@ -24,7 +24,7 @@ $(document).ready(function(){ }, function(){} ); - } + }; }else{ checkHandeler=false; } @@ -88,7 +88,6 @@ $(document).ready(function(){ var uid=img.parent().parent().data('uid'); var input=$('<input>'); var quota=img.parent().children('span').text(); - img if(quota=='None'){ quota=''; } diff --git a/settings/personal.php b/settings/personal.php index 05dbda473ac..c27ca0aed63 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -9,9 +9,11 @@ require_once('../lib/base.php'); OC_Util::checkLoggedIn(); // Highlight navigation entry -OC_Util::addScript( "settings", "personal" ); -OC_Util::addStyle( "settings", "settings" ); -OC_App::setActiveNavigationEntry( "personal" ); +OC_Util::addScript( 'settings', 'personal' ); +OC_Util::addStyle( 'settings', 'settings' ); +OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); +OC_Util::addStyle( '3rdparty', 'chosen' ); +OC_App::setActiveNavigationEntry( 'personal' ); // calculate the disc space $used=OC_Filesystem::filesize('/'); @@ -19,6 +21,8 @@ $free=OC_Filesystem::free_space(); $total=$free+$used; $relative=round(($used/$total)*10000)/100; +$email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email',''); + $lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', 'en' ); $languageCodes=OC_L10N::findAvailableLanguages(); //put the current language in the front @@ -31,10 +35,11 @@ foreach($languageCodes as $lang){ } // Return template -$tmpl = new OC_Template( "settings", "personal", "user"); +$tmpl = new OC_Template( 'settings', 'personal', 'user'); $tmpl->assign('usage',OC_Helper::humanFileSize($used)); $tmpl->assign('total_space',OC_Helper::humanFileSize($total)); $tmpl->assign('usage_relative',$relative); +$tmpl->assign('email',$email); $tmpl->assign('languages',$languages); $forms=OC_App::getForms('personal'); diff --git a/settings/settings.php b/settings/settings.php index b08cb08db09..a49de85520b 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -8,8 +8,8 @@ require_once('../lib/base.php'); OC_Util::checkLoggedIn(); -OC_Util::addStyle( "settings", "settings" ); -OC_App::setActiveNavigationEntry( "settings" ); +OC_Util::addStyle( 'settings', 'settings' ); +OC_App::setActiveNavigationEntry( 'settings' ); $tmpl = new OC_Template( 'settings', 'settings', 'user'); $forms=OC_App::getForms('settings'); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index eee5f3979c3..3c4ad085165 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -19,6 +19,14 @@ </fieldset> </form> +<form id="lostpassword"> + <fieldset class="personalblock"> + <label for="email"><strong><?php echo $l->t('Email');?></strong></label> + <input type="text" name="email" id="email" value="<?php echo $_['email']; ?>" placeholder="<?php echo $l->t('Your email address');?>" /><span class="msg"></span><br /> + <em><?php echo $l->t('Fill in an email address to enable password recovery');?></em> + </fieldset> +</form> + <form> <fieldset class="personalblock"> <label for="languageinput"><strong><?php echo $l->t('Language');?></strong></label> @@ -40,3 +48,11 @@ <?php foreach($_['forms'] as $form){ echo $form; };?> + +<p class="personalblock"> + <strong>ownCloud</strong> + <?php echo(OC_Util::getVersionString()); ?> +</p> + + + diff --git a/settings/templates/users.php b/settings/templates/users.php index a97774cea0b..bcc4d65fe43 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -10,19 +10,29 @@ foreach($_["groups"] as $group) { } ?> +<div id="controls"> + <form id="newuser"> + <th class="name"><input id="newusername" placeholder="<?php echo $l->t('Name')?>" /></th> + <th class="password"><input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" /></th> + <th class="groups"><select id="newusergroups" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple"> + <?php foreach($_["groups"] as $group): ?> + <option value="<?php echo $group['name'];?>"><?php echo $group['name'];?></option> + <?php endforeach;?> + </select></th> + <th class="quota"></th> + <th><input type="submit" value="<?php echo $l->t('Create')?>" /></th> + </form> +</div> + <table data-groups="<?php echo implode(', ',$allGroups);?>"> - <thead id="controls"> - <tr><form id="newuser"> - <th class="name"><input id="newusername" placeholder="<?php echo $l->t('Name')?>" /></th> - <th class="password"><input type="password" id="newuserpassword" placeholder="<?php echo $l->t('Password')?>" /></th> - <th class="groups"><select id="newusergroups" data-placeholder="groups" title="<?php echo $l->t('Groups')?>" multiple="multiple"> - <?php foreach($_["groups"] as $group): ?> - <option value="<?php echo $group['name'];?>"><?php echo $group['name'];?></option> - <?php endforeach;?> - </select></th> - <th class="quota"></th> - <th><input type="submit" value="<?php echo $l->t('Create')?>" /></th> - </form></tr> + <thead> + <tr> + <th id='headerName'><?php echo $l->t('Name')?></th> + <th id="headerPassword"><?php echo $l->t( 'Password' ); ?></th> + <th id="headerGroups"><?php echo $l->t( 'Groups' ); ?></th> + <th id="headerQuota"><?php echo $l->t( 'Quota' ); ?></th> + <th id="headerRemove"> </th> + </tr> </thead> <tbody> <?php foreach($_["users"] as $user): ?> diff --git a/settings/users.php b/settings/users.php index 08d6c53840f..686c4b6a9bf 100644 --- a/settings/users.php +++ b/settings/users.php @@ -12,8 +12,6 @@ OC_Util::checkAdminUser(); OC_Util::addScript( 'settings', 'users' ); OC_Util::addScript( 'core', 'multiselect' ); OC_Util::addStyle( 'settings', 'settings' ); -OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' ); -OC_Util::addStyle( '3rdparty', 'chosen' ); OC_App::setActiveNavigationEntry( 'core_users' ); $users = array(); diff --git a/status.php b/status.php new file mode 100644 index 00000000000..94c8cfce842 --- /dev/null +++ b/status.php @@ -0,0 +1,34 @@ +<?php + +/** +* ownCloud status page. usefull if you want to check from the outside if an owncloud installation exists +* +* @author Frank Karlitschek +* @copyright 2010 Frank Karlitschek karlitschek@kde.org +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +$RUNTIME_NOAPPS = TRUE; //no apps, yet + +require_once('lib/base.php'); + +if(OC_Config::getValue('installed')==1) $installed='true'; else $installed='false'; +$values=array('installed'=>$installed,'version'=>implode('.',OC_Util::getVersion()),'versionstring'=>OC_Util::getVersionString()); + +echo(json_encode($values)); + + +?> diff --git a/tests/index.php b/tests/index.php index efa730f6f8f..08e53f1a575 100644 --- a/tests/index.php +++ b/tests/index.php @@ -26,6 +26,7 @@ */ $RUNTIME_NOSETUPFS=true; require_once('../lib/base.php'); +OC_Util::checkAdminUser(); $testCases=loadFiles(__DIR__,array('index.php','templates')); ob_end_clean(); @@ -74,4 +75,4 @@ function loadFiles($path,$exclude=false){ } return $results; } -?>
\ No newline at end of file +?> |