Merge branch 'master' of gitorious.org:owncloud/owncloud

This commit is contained in:
Tom Needham 2012-04-13 20:10:35 +00:00
commit 0aaaefbb4b
21 changed files with 247 additions and 81 deletions

View File

@ -0,0 +1,42 @@
<?php
/**
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
foreach ($_POST as $key=>$element) {
debug('_POST: '.$key.'=>'.print_r($element, true));
}
function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg)));
OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
exit();
}
function debug($msg) {
OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
}
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if(count($calendars) == 0) {
bailOut(OC_Calendar_App::$l10n->t('No calendars found.'));
}
$events = array();
foreach($calendars as $calendar) {
$calendar_events = OC_Calendar_Object::all($calendar['id']);
$events = $events + $calendar_events;
}
if(count($events) == 0) {
bailOut(OC_Calendar_App::$l10n->t('No events found.'));
}
OC_Calendar_App::scanCategories($events);
$categories = OC_Calendar_App::getCategoryOptions();
OC_JSON::success(array('data' => array('categories'=>$categories)));

View File

@ -41,13 +41,8 @@ switch($dtstart->getDateType()) {
$summary = $vevent->getAsString('SUMMARY');
$location = $vevent->getAsString('LOCATION');
$categories = $vevent->getAsArray('CATEGORIES');
$categories = $vevent->getAsString('CATEGORIES');
$description = $vevent->getAsString('DESCRIPTION');
foreach($categories as $category){
if (!in_array($category, $category_options)){
array_unshift($category_options, $category);
}
}
$last_modified = $vevent->__get('LAST-MODIFIED');
if ($last_modified){
$lastmodified = $last_modified->getDateTime()->format('U');
@ -189,7 +184,6 @@ if($data['repeating'] == 1){
}
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
$repeat_end_options = OC_Calendar_App::getEndOptions();
$repeat_month_options = OC_Calendar_App::getMonthOptions();
@ -205,7 +199,6 @@ $tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
@ -242,7 +235,14 @@ if($repeat['repeat'] != 'doesnotrepeat'){
$tmpl->assign('repeat_bymonthday', $repeat['bymonthday']);
$tmpl->assign('repeat_bymonth', $repeat['bymonth']);
$tmpl->assign('repeat_byweekno', $repeat['byweekno']);
} else {
$tmpl->assign('repeat_month', 'monthday');
$tmpl->assign('repeat_weekdays', array());
$tmpl->assign('repeat_interval', 1);
$tmpl->assign('repeat_end', 'never');
$tmpl->assign('repeat_count', '10');
$tmpl->assign('repeat_weekofmonth', 'auto');
$tmpl->assign('repeat_date', '');
$tmpl->assign('repeat_year', 'bydate');
}
$tmpl->printpage();
?>

View File

@ -32,7 +32,6 @@ $start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
$repeat_end_options = OC_Calendar_App::getEndOptions();
$repeat_month_options = OC_Calendar_App::getMonthOptions();
@ -46,7 +45,6 @@ $repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
$tmpl->assign('repeat_month_options', $repeat_month_options);
$tmpl->assign('repeat_weekly_options', $repeat_weekly_options);
@ -73,4 +71,3 @@ $tmpl->assign('repeat_weekofmonth', 'auto');
$tmpl->assign('repeat_date', '');
$tmpl->assign('repeat_year', 'bydate');
$tmpl->printpage();
?>

View File

@ -48,7 +48,6 @@ OC_Util::addScript('', 'jquery.multiselect');
OC_Util::addStyle('', 'jquery.multiselect');
OC_Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addScript('','oc-vcategories');
OC_Util::addStyle('','oc-vcategories');
OC_App::setActiveNavigationEntry('calendar_index');
$tmpl = new OC_Template('calendar', 'calendar', 'user');
$tmpl->assign('eventSources', $eventSources);

View File

@ -89,6 +89,41 @@ class OC_Calendar_App{
return $categories;
}
/**
* scan events for categories.
* @param $events VEVENTs to scan. null to check all events for the current user.
*/
public static function scanCategories($events = null) {
if (is_null($events)) {
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if(count($calendars) > 0) {
$events = array();
foreach($calendars as $calendar) {
$calendar_events = OC_Calendar_Object::all($calendar['id']);
$events = $events + $calendar_events;
}
}
}
if(is_array($events) && count($events) > 0) {
$vcategories = self::getVCategories();
$vcategories->delete($vcategories->categories());
foreach($events as $event) {
$vobject = OC_VObject::parse($event['calendardata']);
if(!is_null($vobject)) {
$vcategories->loadFromVObject($vobject->VEVENT, true);
}
}
}
}
/**
* check VEvent for new categories.
* @see OC_VCategories::loadFromVObject
*/
public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
self::getVCategories()->loadFromVObject($calendar->VEVENT, true);
}
public static function getRepeatOptions(){
return OC_Calendar_Object::getRepeatOptions(self::$l10n);
}

View File

@ -44,10 +44,8 @@ class OC_Calendar_Calendar{
/**
* @brief Returns the list of calendars for a specific user.
* @param string $uid User ID
* @param boolean $active
* @param boolean $active Only return calendars with this $active state, default(=null) is don't care
* @return array
*
* TODO: what is active for?
*/
public static function allCalendars($uid, $active=null){
$values = array($uid);

View File

@ -93,6 +93,7 @@ class OC_Calendar_Object{
*/
public static function add($id,$data){
$object = OC_VObject::parse($data);
OC_Calendar_App::loadCategoriesFromVCalendar($object);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
@ -139,6 +140,7 @@ class OC_Calendar_Object{
$oldobject = self::find($id);
$object = OC_VObject::parse($data);
OC_Calendar_App::loadCategoriesFromVCalendar($object);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@ -436,10 +438,6 @@ class OC_Calendar_Object{
$errnum++;
}
if(isset($request['categories']) && !is_array($request['categories'])){
$errors['categories'] = $l10n->t('Not an array');
}
$fromday = substr($request['from'], 0, 2);
$frommonth = substr($request['from'], 3, 2);
$fromyear = substr($request['from'], 6, 4);
@ -607,7 +605,7 @@ class OC_Calendar_Object{
{
$title = $request["title"];
$location = $request["location"];
$categories = isset($request["categories"]) ? $request["categories"] : array();
$categories = $request["categories"];
$allday = isset($request["allday"]);
$from = $request["from"];
$to = $request["to"];
@ -781,7 +779,7 @@ class OC_Calendar_Object{
$vevent->setString('LOCATION', $location);
$vevent->setString('DESCRIPTION', $description);
$vevent->setString('CATEGORIES', join(',', $categories));
$vevent->setString('CATEGORIES', $categories);
/*if($repeat == "true"){
$vevent->RRULE = $repeat;

View File

@ -10,7 +10,7 @@
<tr>
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
<input id="category" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>">
<input id="category" name="categories" type="text" placeholder="<?php echo $l->t('Separate categories with commas'); ?>" value="<?php echo isset($_['categories']) ? htmlspecialchars($_['categories']) : '' ?>">
<a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"><img alt="<?php echo $l->t('Edit categories'); ?>" src="<?php echo image_path('core','actions/rename.svg')?>" class="svg action" style="width: 16px; height: 16px;"></a>
</td>
<?php if(count($_['calendar_options']) > 1) { ?>

View File

@ -52,7 +52,6 @@ OC_Util::addScript('contacts','jquery.inview');
OC_Util::addScript('contacts','jquery.Jcrop');
OC_Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addStyle('','jquery.multiselect');
OC_Util::addStyle('','oc-vcategories');
OC_Util::addStyle('contacts','jquery.combobox');
OC_Util::addStyle('contacts','jquery.Jcrop');
OC_Util::addStyle('contacts','contacts');

View File

@ -53,11 +53,12 @@ class OC_Contacts_App {
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
if ($addressbook === false) {
OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR);
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
}
else {
OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OC_Log::ERROR);
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
}
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
exit();
}
return $addressbook;
@ -194,7 +195,7 @@ class OC_Contacts_App {
* @see OC_VCategories::loadFromVObject
*/
public static function loadCategoriesFromVCard(OC_VObject $contact) {
self::$categories->loadFromVObject($contact);
self::$categories->loadFromVObject($contact, true);
}
public static function setLastModifiedHeader($contact) {

View File

@ -1,18 +1,21 @@
<?php
return array(
'ftp'=>array(
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/test',
),
'webdav'=>array(
'run'=>false,
'host'=>'localhost',
'user'=>'test',
'password'=>'test',
'root'=>'/owncloud/files/webdav.php',
),
'google'=>array(
'run'=>false,
'consumer_key'=>'anonymous',
'consumer_secret'=>'anonymous',
'token'=>'test',

View File

@ -5,19 +5,26 @@
* later.
* See the COPYING-README file.
*/
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
abstract class Test_Filestorage_FTP extends Test_FileStorage{}
return;
}else{
class Test_Filestorage_FTP extends Test_FileStorage {
private $config;
private $id;
class Test_Filestorage_FTP extends Test_FileStorage {
private $config;
private $id;
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_FTP($this->config['ftp']);
}
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_FTP($this->config['ftp']);
}
public function tearDown(){
OC_Helper::rmdirr($this->instance->constructUrl(''));
public function tearDown(){
OC_Helper::rmdirr($this->instance->constructUrl(''));
}
}
}

View File

@ -20,19 +20,26 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
class Test_Filestorage_Google extends Test_FileStorage {
private $config;
private $id;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['google']) or !$config['google']['run']){
abstract class Test_Filestorage_Google extends Test_FileStorage{}
return;
}else{
class Test_Filestorage_Google extends Test_FileStorage {
private $config;
private $id;
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_Google($this->config['google']);
}
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_Google($this->config['google']);
}
public function tearDown(){
$this->instance->rmdir('/');
public function tearDown(){
$this->instance->rmdir('/');
}
}
}

View File

@ -6,18 +6,25 @@
* See the COPYING-README file.
*/
class Test_Filestorage_DAV extends Test_FileStorage {
private $config;
private $id;
$config=include('apps/files_external/tests/config.php');
if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']){
abstract class Test_Filestorage_DAV extends Test_FileStorage{}
return;
}else{
class Test_Filestorage_DAV extends Test_FileStorage {
private $config;
private $id;
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_DAV($this->config['webdav']);
}
public function setUp(){
$id=uniqid();
$this->config=include('apps/files_external/tests/config.php');
$this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in
$this->instance=new OC_Filestorage_DAV($this->config['webdav']);
}
public function tearDown(){
$this->instance->rmdir('/');
public function tearDown(){
$this->instance->rmdir('/');
}
}
}

View File

@ -45,6 +45,30 @@
<notnull>true</notnull>
<length>200</length>
</field>
<index>
<name>album_index</name>
<field>
<name>album_id</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>album_name_index</name>
<field>
<name>album_name</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>album_artist_index</name>
<field>
<name>album_artist</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
@ -81,6 +105,21 @@
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>artist_index</name>
<field>
<name>artist_id</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>artist_name_index</name>
<field>
<name>artist_name</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
@ -223,6 +262,36 @@
<notnull>true</notnull>
<length>4</length>
</field>
<index>
<name>song_index</name>
<field>
<name>song_id</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>song_album_index</name>
<field>
<name>song_album</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>song_artist_index</name>
<field>
<name>song_artist</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>song_name_index</name>
<field>
<name>song_name</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>

View File

@ -3,7 +3,7 @@
<id>media</id>
<name>Media</name>
<description>Media player and server for ownCloud</description>
<version>0.2</version>
<version>0.3</version>
<licence>AGPL</licence>
<author>Robin Appelman</author>
<require>2</require>

View File

@ -1,7 +0,0 @@
#categoryform .scrollarea { position: absolute; left: 10px; top: 10px; right: 10px; bottom: 50px; overflow: auto; border:1px solid #ddd; background: #f8f8f8; }
#categoryform .bottombuttons { position: absolute; bottom: 10px;}
#categoryform .bottombuttons * { float: left;}
/*#categorylist { border:1px solid #ddd;}*/
#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
#categorylist li:hover, li:active { background:#eee; }
#category_addinput { width: 10em; }

View File

@ -106,7 +106,7 @@ label.infield { cursor: text !important; }
#notification { z-index:101; cursor:pointer; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
.action, .selectedActions a, #logout { opacity:.3; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; }
.action, .selectedActions a, #logout { opacity:.5; -webkit-transition:opacity 500ms; -moz-transition:opacity 500ms; -o-transition:opacity 500ms; transition:opacity 500ms; }
.action { width: 16px; height: 16px; }
.action:hover, .selectedActions a:hover, #logout:hover { opacity:1; }
@ -132,9 +132,19 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff
a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px }
/* ---- DIALOGS ---- */
/* ---- DIALOGS ---- */
#dirtree {width: 100%;}
#filelist {height: 270px; overflow:scroll; background-color: white;}
.filepicker_element_selected { background-color: lightblue;}
.filepicker_loader {height: 120px; width: 100%; background-color: #333; opacity: 0.3; visibility: visible; position:absolute; top:0; left:0; text-align:center; padding-top: 150px;}
/* ---- CATEGORIES ---- */
#categoryform .scrollarea { position: absolute; left: 10px; top: 10px; right: 10px; bottom: 50px; overflow: auto; border:1px solid #ddd; background: #f8f8f8; }
#categoryform .bottombuttons { position: absolute; bottom: 10px;}
#categoryform .bottombuttons * { float: left;}
/*#categorylist { border:1px solid #ddd;}*/
#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
#categorylist li:hover, li:active { background:#eee; }
#category_addinput { width: 10em; }

View File

@ -413,9 +413,10 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
$('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
$('.selectedActions a.delete').tipsy({gravity: 'se', fade:true, live:true});
$('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('a.delete').tipsy({gravity: 'se', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});
$('#headerSize').tipsy({gravity:'s', fade:true, live:true});
$('td.filesize').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});

View File

@ -84,16 +84,16 @@ OCCategories={
},
rescan:function(){
console.log('Categories.rescan');
$.getJSON(OC.filePath(OCCategories.app, 'ajax', 'categories/rescan.php'),{},function(jsondata, status, xhr){
if (status == 'error' && xhr.status == 404) {
OC.dialogs.alert('The required file ' + OC.filePath(Categories.app, 'ajax', 'categories/rescan.php') + ' is not installed!', 'Error');
return;
}
$.getJSON(OC.filePath(OCCategories.app, 'ajax', 'categories/rescan.php'),function(jsondata, status, xhr){
if(jsondata.status == 'success'){
OCCategories._update(jsondata.data.categories);
} else {
OC.dialogs.alert(jsondata.data.message, 'Error');
}
}).error(function(xhr){
if (xhr.status == 404) {
OC.dialogs.alert('The required file ' + OC.filePath(Categories.app, 'ajax', 'categories/rescan.php') + ' is not installed!', 'Error');
}
});
},
_update:function(categories){

View File

@ -66,7 +66,7 @@ FileActions={
if(img.call){
img=img(file);
}
var html='<a href="#" title="'+name+'" class="action" style="display:none" />';
var html='<a href="#" original-title="'+name+'" class="action" style="display:none" />';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));
@ -89,7 +89,7 @@ FileActions={
if(img.call){
img=img(file);
}
var html='<a href="#" title="Delete" class="action" style="display:none" />';
var html='<a href="#" original-title="Delete" class="action delete" style="display:none" />';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));