Merge branch 'master' into multi_app_dir

This commit is contained in:
Brice Maron 2012-06-21 20:19:31 +00:00
commit a5938e4e37
14 changed files with 137 additions and 109 deletions

View File

@ -17,6 +17,9 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
foreach($calendars as $calendar){
$objects = OC_Calendar_Object::all($calendar['id']);
foreach($objects as $object){
if($object['objecttype']!='VEVENT') {
continue;
}
if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){
$calendardata = OC_VObject::parse($object['calendardata']);
$vevent = $calendardata->VEVENT;
@ -37,7 +40,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
$link = OCP\Util::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']);
$results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type
$results[]=new OC_Search_Result($object['summary'],$info, $link,(string)$l->t('Cal.'));//$name,$text,$link,$type
}
}
}

View File

@ -256,12 +256,14 @@ Contacts={
}
} else {
newid = id;
bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid');
}
var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) {
firstitem.addClass('active');
$('#contacts li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts h3[data-id="'+bookid+'"]').trigger('click');
Contacts.UI.Card.loadContact(jsondata.data, bookid);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -1503,7 +1505,7 @@ Contacts={
},
Contacts:{
// Reload the contacts list.
update:function(){
update:function(id){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page).ready(function() {
@ -1518,7 +1520,7 @@ Contacts={
})}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
});
Contacts.UI.Card.update();
Contacts.UI.Card.update(id);
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@ -1707,5 +1709,5 @@ $(document).ready(function(){
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
Contacts.UI.loadHandlers();
Contacts.UI.Contacts.update();
Contacts.UI.Contacts.update(id);
});

View File

@ -11,7 +11,7 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{
$vcards = OC_Contacts_VCard::all($addressbook['id']);
foreach($vcards as $vcard){
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){
$link = OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
$link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']);
$results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type
}
}

View File

@ -1,6 +1,7 @@
<script type='text/javascript'>
var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
var categories = <?php echo json_encode($_['categories']); ?>;
var id = <?php echo $_['id']; ?>;
var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
</script>
<div id="leftcontent">

View File

@ -3,7 +3,7 @@ foreach($_['books'] as $id => $addressbook) {
echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
echo '<ul class="contacts hidden" data-id="'.$id.'">';
foreach($addressbook['contacts'] as $contact) {
echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="'.link_to('contacts','index.php').'&id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
}
echo '</ul>';
}

View File

@ -8,10 +8,12 @@
class Test_CryptProxy extends UnitTestCase {
private $oldConfig;
private $oldKey;
public function setUp(){
$this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
OCP\Config::setAppValue('files_encryption','enable_encryption','true');
$this->oldKey=isset($_SESSION['enckey'])?$_SESSION['enckey']:null;
//set testing key
@ -36,6 +38,9 @@ class Test_CryptProxy extends UnitTestCase {
public function tearDown(){
OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig);
if(!is_null($this->oldKey)){
$_SESSION['enckey']=$this->oldKey;
}
}
public function testSimple(){

View File

@ -25,7 +25,7 @@ require_once( 'lib_share.php' );
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
class OC_Filestorage_Shared extends OC_Filestorage {
class OC_Filestorage_Shared extends OC_Filestorage_Common {
private $datadir;
private $sourcePaths = array();
@ -492,7 +492,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
return $this->searchInDir($query);
}
private function searchInDir($query, $path = "") {
protected function searchInDir($query, $path = "") {
$files = array();
if ($dh = $this->opendir($path)) {
while (($filename = readdir($dh)) !== false) {

View File

@ -261,10 +261,8 @@ class Storage {
}
/**
* expire old versions of a file.
* @brief Erase a file's versions which exceed the set quota
*/
public static function expire($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
@ -298,90 +296,16 @@ class Storage {
}
/**
* @brief erase all old versions of all user files
* @return
* @brief Erase all old versions of all user files
* @return true/false
*/
public static function expireAll() {
function deleteAll( $directory, $empty = false ) {
// strip leading slash
if( substr( $directory, 0, 1 ) == "/" ) {
$directory = substr( $directory, 1 );
}
// strip trailing slash
if( substr( $directory, -1) == "/" ) {
$directory = substr( $directory, 0, -1 );
}
$view = new \OC_FilesystemView('');
if ( !$view->file_exists( $directory ) || !$view->is_dir( $directory ) ) {
return false;
} elseif( !$view->is_readable( $directory ) ) {
return false;
} else {
$foldername = \OCP\Config::getSystemValue('datadirectory') .'/' . \OCP\USER::getUser() .'/' . $directory; // have to set an absolute path for use with PHP's opendir as OC version doesn't work
$directoryHandle = $view->opendir( \OCP\USER::getUser() . '/' . $directory );
while ( $contents = readdir( $directoryHandle ) ) {
if ( $contents != '.' && $contents != '..') {
$path = $directory . "/" . $contents;
if ( $view->is_dir( $path ) ) {
deleteAll( $path );
} else {
$view->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
}
}
}
//$view->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
if ( $empty == false ) {
if ( !$view->rmdir( $directory ) ) {
return false;
}
}
return true;
}
}
$view = new \OC_FilesystemView('');
$dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
if ( deleteAll( $dir, true ) ) {
return true;
} else {
return false;
}
return $view->deleteAll( $dir, true );
}

View File

@ -33,7 +33,7 @@
.task .completed {position:absolute;left:3em;top:0.3em;}
.task .summary{padding-left:4em;height:2em;}
.task .summary input{position:relative;left:5px;top:0.5em;}
.task .summary input{position:absolute;left:5em;top:0;}
.task.done .summary{text-decoration:line-through;}
.task .tag{border-radius:0.4em;display:inline-block;opacity:0.2;margin:0 0.2em;border:1px solid transparent;padding:0 0.4em;cursor:pointer;}
@ -58,3 +58,5 @@
.task .due{position:absolute;right:0.3em;}
.task .due .date{width:6em;}
.task .due .time{width:6em;}
.task_delete{position:absolute;bottom:2px;right:5px}

View File

@ -97,8 +97,10 @@ OC.Tasks = {
due.find('.time').timepicker('setTime', date.getHours()+':'+date.getMinutes());
}
}
var delete_action = task_container.find('.task_delete').click(OC.Tasks.deleteClickHandler);
$('<div>')
.addClass('more')
.append(delete_action)
.append(description)
.append(due)
.appendTo(task_container);
@ -273,6 +275,19 @@ OC.Tasks = {
$task.find('div.location').show();
$task.find('input.location').hide();
},
deleteClickHandler:function(event){
var $task = $(this).closest('.task'),
task = $task.data('task');
$.post(OC.filePath('tasks', 'ajax', 'delete.php'),{'id':task.id},function(jsondata){
if(jsondata.status == 'success'){
$task.remove();
}
else{
alert(jsondata.data.message);
}
});
return false;
},
complete_task:function() {
var $task = $(this).closest('.task'),
task = $task.data('task'),
@ -441,21 +456,6 @@ $(document).ready(function(){
});
});
$('#tasks_delete').live('click',function(){
var id = $('#task_details').data('id');
$.post('ajax/delete.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
$('#tasks [data-id="'+jsondata.data.id+'"]').remove();
$('#task_details').data('id','');
$('#task_details').html('');
}
else{
alert(jsondata.data.message);
}
});
return false;
});
$('#tasks_addtask').click(function(){
var input = $('#tasks_newtask').val();
$.post(OC.filePath('tasks', 'ajax', 'addtask.php'),{text:input},function(jsondata){

View File

@ -2,7 +2,7 @@
<input type="text" id="tasks_newtask">
<input type="button" id="tasks_addtask" value="<?php echo $l->t('Add Task'); ?>">
<input type="button" id="tasks_order_due" value="<?php echo $l->t('Order Due'); ?>">
<input type="button" id="tasks_order_category" value="<?php echo $l->t('Order Category'); ?>">
<input type="button" id="tasks_order_category" value="<?php echo $l->t('Order List'); ?>">
<input type="button" id="tasks_order_complete" value="<?php echo $l->t('Order Complete'); ?>">
<input type="button" id="tasks_order_location" value="<?php echo $l->t('Order Location'); ?>">
<input type="button" id="tasks_order_prio" value="<?php echo $l->t('Order Priority'); ?>">
@ -25,6 +25,9 @@
<span class="task_less">
<img title="<?php echo $l->t('Less') ?>" src="<?php echo OCP\image_path('core', 'actions/triangle-n.svg') ?>" class="svg"><?php echo $l->t('Less') ?>
</span>
<span class="task_delete">
<img title="<?php echo $l->t('Delete') ?>" src="<?php echo OCP\image_path('core', 'actions/delete.svg') ?>" class="svg"><?php echo $l->t('Delete') ?>
</span>
</p>
<script type='text/javascript'>
var categories = <?php echo json_encode($_['categories']); ?>;

View File

@ -20,6 +20,18 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Storage backend class for providing common filesystem operation methods
* which are not storage-backend specific.
*
* OC_Filestorage_Common is never used directly; it is extended by all other
* storage backends, where its methods may be overridden, and additional
* (backend-specific) methods are defined.
*
* Some OC_Filestorage_Common methods call functions which are first defined
* in classes which extend it, e.g. $this->stat() .
*/
abstract class OC_Filestorage_Common extends OC_Filestorage {
public function __construct($parameters){}
@ -87,6 +99,79 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
return $count>0;
}
// abstract public function fopen($path,$mode);
/**
* @brief Deletes all files and folders recursively within a directory
* @param $directory The directory whose contents will be deleted
* @param $empty Flag indicating whether directory will be emptied
* @returns true/false
*
* @note By default the directory specified by $directory will be
* deleted together with its contents. To avoid this set $empty to true
*/
public function deleteAll( $directory, $empty = false ) {
// strip leading slash
if( substr( $directory, 0, 1 ) == "/" ) {
$directory = substr( $directory, 1 );
}
// strip trailing slash
if( substr( $directory, -1) == "/" ) {
$directory = substr( $directory, 0, -1 );
}
if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) {
return false;
} elseif( !$this->is_readable( \OCP\USER::getUser() . '/' . $directory ) ) {
return false;
} else {
$directoryHandle = $this->opendir( \OCP\USER::getUser() . '/' . $directory );
while ( $contents = readdir( $directoryHandle ) ) {
if ( $contents != '.' && $contents != '..') {
$path = $directory . "/" . $contents;
if ( $this->is_dir( $path ) ) {
deleteAll( $path );
} else {
$this->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
}
}
}
//$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
if ( $empty == false ) {
if ( !$this->rmdir( $directory ) ) {
return false;
}
}
return true;
}
}
public function getMimeType($path){
if(!$this->file_exists($path)){
return false;

View File

@ -2,7 +2,7 @@
/**
* for local filestore, we only have to map the paths
*/
class OC_Filestorage_Local extends OC_Filestorage{
class OC_Filestorage_Local extends OC_Filestorage_Common{
protected $datadir;
private static $mimetypes=null;
public function __construct($arguments){
@ -172,7 +172,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $this->datadir.$path;
}
private function searchInDir($query,$dir=''){
protected function searchInDir($query,$dir=''){
$files=array();
foreach (scandir($this->datadir.$dir) as $item) {
if ($item == '.' || $item == '..') continue;

View File

@ -252,6 +252,9 @@ class OC_FilesystemView {
public function unlink($path){
return $this->basicOperation('unlink',$path,array('delete'));
}
public function deleteAll( $directory, $empty = false ) {
return $this->basicOperation( 'deleteAll', $directory, array('delete'), $empty );
}
public function rename($path1,$path2){
$absolutePath1=$this->getAbsolutePath($path1);
$absolutePath2=$this->getAbsolutePath($path2);