aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-03-07 23:38:44 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-03-07 23:38:44 +0100
commitae7aab2d6e727f9daf683056001a982aad242c93 (patch)
tree9dc0ade66c54dc846f4591587393aacd11be8622
parent91d85e9b1640e9d62707cd1c232c8c7a9fc8b9c3 (diff)
parentd8cfe77ba5348d29a9e2b046e2c7efc1dd4758cb (diff)
downloadnextcloud-server-ae7aab2d6e727f9daf683056001a982aad242c93.tar.gz
nextcloud-server-ae7aab2d6e727f9daf683056001a982aad242c93.zip
Merge gitorious.org:owncloud/owncloud into vcategories
Conflicts: apps/contacts/ajax/saveproperty.php apps/contacts/lib/vcard.php
-rw-r--r--apps/calendar/lib/object.php11
-rw-r--r--apps/contacts/ajax/addcard.php2
-rw-r--r--apps/contacts/ajax/addcontact.php2
-rw-r--r--apps/contacts/ajax/addproperty.php2
-rw-r--r--apps/contacts/ajax/deleteproperty.php2
-rw-r--r--apps/contacts/ajax/savecrop.php2
-rw-r--r--apps/contacts/ajax/saveproperty.php6
-rw-r--r--apps/contacts/ajax/setproperty.php2
-rw-r--r--apps/contacts/import.php14
-rw-r--r--apps/contacts/js/contacts.js35
-rw-r--r--apps/contacts/lib/app.php2
-rw-r--r--apps/contacts/lib/vcard.php120
-rw-r--r--apps/contacts/templates/part.contactphoto.php2
-rw-r--r--core/css/styles.css2
-rw-r--r--files/ajax/newfile.php26
-rw-r--r--files/ajax/newfolder.php4
-rw-r--r--files/js/files.js69
-rw-r--r--files/templates/index.php1
18 files changed, 154 insertions, 150 deletions
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index b84e575bc83..e0c0e83d5d0 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -96,8 +96,7 @@ class OC_Calendar_Object{
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
- $uid = self::createUID();
- $object->add('UID',$uid);
+ $object->setUID();
$data = $object->serialize();
}
@@ -209,14 +208,6 @@ class OC_Calendar_Object{
}
/**
- * @brief Creates a UID
- * @return string
- */
- protected static function createUID(){
- return substr(md5(rand().time()),0,10);
- }
-
- /**
* @brief Extracts data from a vObject-Object
* @param Sabre_VObject $object
* @return array
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index b1dc69a4691..49a4a16170b 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -92,7 +92,7 @@ foreach( $add as $propname){
}
}
}
-$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
+$id = OC_Contacts_VCard::add($aid,$vcard);
if(!$id) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index 5d17631caa4..839a3919981 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -52,7 +52,7 @@ $vcard->setUID();
$vcard->setString('FN',$fn);
$vcard->setString('N',$n);
-$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
+$id = OC_Contacts_VCard::add($aid,$vcard);
if(!$id) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index a28aed34d2c..e1a31292837 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -116,7 +116,7 @@ foreach ($parameters as $key=>$element) {
}
$checksum = md5($vcard->children[$line]->serialize());
-if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
+if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.'))));
OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR);
exit();
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index a9afffaad4c..ab0958cac58 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -39,7 +39,7 @@ if(is_null($line)){
unset($vcard->children[$line]);
-if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
+if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.'))));
OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR);
exit();
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index 1a84f6fdfae..ffbfaeb6e38 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -95,7 +95,7 @@ if(file_exists($tmp_path)) {
OC_Log::write('contacts','savecrop.php: files: Adding PHOTO property.', OC_Log::DEBUG);
$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
}
- if(!OC_Contacts_VCard::edit($id,$card->serialize())) {
+ if(!OC_Contacts_VCard::edit($id,$card)) {
bailOut('Error saving contact.');
}
unlink($tmpfname);
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index e31c4b7c238..3a50d18e6a6 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -128,8 +128,14 @@ switch($element) {
$checksum = md5($vcard->children[$line]->serialize());
debug('New checksum: '.$checksum);
+<<<<<<< HEAD
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
bailOut(OC_Contacts_App::$l10n->t('Error updating contact property.'));
+=======
+if(!OC_Contacts_VCard::edit($id,$vcard)) {
+ OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error updating contact property.'))));
+ OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
+>>>>>>> d8cfe77ba5348d29a9e2b046e2c7efc1dd4758cb
exit();
}
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index f9e2a8e8647..8e07b4a8f1c 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -80,7 +80,7 @@ foreach($missingparameters as $i){
// NOTE: This checksum is not used..?
$checksum = md5($vcard->children[$line]->serialize());
-if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
+if(!OC_Contacts_VCard::edit($id,$vcard)) {
OC_JSON::error(array('data' => array('message' => $l->t('Error updating contact property.'))));
OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
exit();
diff --git a/apps/contacts/import.php b/apps/contacts/import.php
index 4638bf0d73c..04cfc397d56 100644
--- a/apps/contacts/import.php
+++ b/apps/contacts/import.php
@@ -97,11 +97,15 @@ if(is_writable('import_tmp/')){
fclose($progressfopen);
}
if(count($parts) == 1){
- OC_Contacts_VCard::add($id, $file);
-}else{
- foreach($importready as $import){
- OC_Contacts_VCard::add($id, $import);
+ $importready = array($file);
+}
+foreach($importready as $import){
+ $card = OC_VObject::parse($import);
+ if (!$card) {
+ OC_Log::write('contacts','Import: skipping card. Error parsing VCard: '.$import, OC_Log::ERROR);
+ continue; // Ditch cards that can't be parsed by Sabre.
}
+ OC_Contacts_VCard::add($id, $card);
}
//done the import
if(is_writable('import_tmp/')){
@@ -113,4 +117,4 @@ sleep(3);
if(is_writable('import_tmp/')){
unlink($progressfile);
}
-OC_JSON::success(); \ No newline at end of file
+OC_JSON::success();
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index d86842a4317..483d2a228d1 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -166,7 +166,7 @@ Contacts={
return $(obj).parents('.propertycontainer').first().data('element');
},
showHideContactInfo:function() {
- var show = ($('#emaillist li[class*="propertycontainer"]').length > 0 || $('#phonelist li[class*="propertycontainer"]').length > 0 || $('#addressdisplay dl[class*="propertycontainer"]').length > 0);
+ var show = ($('#emaillist li.propertycontainer').length > 0 || $('#phonelist li.propertycontainer').length > 0 || $('#addressdisplay dl.propertycontainer').length > 0);
console.log('showHideContactInfo: ' + show);
if(show) {
$('#contact_communication').show();
@@ -180,19 +180,19 @@ Contacts={
switch (type) {
case 'EMAIL':
console.log('emails: '+$('#emaillist>li').length);
- if($('#emaillist li[class*="propertycontainer"]').length == 0) {
+ if($('#emaillist li.propertycontainer').length == 0) {
$('#emails').hide();
}
break;
case 'TEL':
console.log('phones: '+$('#phonelist>li').length);
- if($('#phonelist li[class*="propertycontainer"]').length == 0) {
+ if($('#phonelist li.propertycontainer').length == 0) {
$('#phones').hide();
}
break;
case 'ADR':
console.log('addresses: '+$('#addressdisplay>dl').length);
- if($('#addressdisplay dl[class*="propertycontainer"]').length == 0) {
+ if($('#addressdisplay dl.propertycontainer').length == 0) {
$('#addresses').hide();
}
break;
@@ -259,7 +259,7 @@ Contacts={
classes: 'categories'
});
// Style phone types
- $('#phonelist').find('select[class*="contacts_property"]').multiselect({
+ $('#phonelist').find('select.contacts_property').multiselect({
noneSelectedText: t('contacts', 'Select type'),
header: false,
selectedList: 4,
@@ -459,7 +459,7 @@ Contacts={
loadSingleProperties:function() {
var props = ['BDAY', 'NICKNAME', 'ORG'];
// Clear all elements
- $('#ident .propertycontainer[class*="propertycontainer"]').each(function(){
+ $('#ident .propertycontainer').each(function(){
if(props.indexOf($(this).data('element')) > -1) {
$(this).data('checksum', '');
$(this).find('input').val('');
@@ -534,6 +534,9 @@ Contacts={
$('#fn_select option').remove();
$('#fn_select').combobox('value', this.fn);
var names = [this.fullname, this.givname + ' ' + this.famname, this.famname + ' ' + this.givname, this.famname + ', ' + this.givname];
+ if(this.data.ORG) {
+ names[names.length]=this.data.ORG[0].value;
+ }
$.each(names, function(key, value) {
$('#fn_select')
.append($('<option></option>')
@@ -652,8 +655,8 @@ Contacts={
var checksum = container.data('checksum');
var name = container.data('element');
console.log('saveProperty: ' + name);
- var fields = container.find('input[class*="contacts_property"],select[class*="contacts_property"]').serializeArray();
- var q = container.find('input[class*="contacts_property"],select[class*="contacts_property"]').serialize();
+ var fields = container.find('input.contacts_property,select.contacts_property').serializeArray();
+ var q = container.find('input.contacts_property,select.contacts_property').serialize();
if(q == '' || q == undefined) {
console.log('Couldn\'t serialize elements.');
Contacts.UI.loading(container, false);
@@ -863,7 +866,7 @@ Contacts={
},
loadAddresses:function(){
$('#addresses').hide();
- $('#addressdisplay dl[class*="propertycontainer"]').remove();
+ $('#addressdisplay dl.propertycontainer').remove();
for(var adr in this.data.ADR) {
$('#addressdisplay dl').first().clone().insertAfter($('#addressdisplay dl').last()).show();
$('#addressdisplay dl').last().removeClass('template').addClass('propertycontainer');
@@ -1079,15 +1082,15 @@ Contacts={
},
addMail:function() {
//alert('addMail');
- $('#emaillist li[class*="template"]:first-child').clone().appendTo($('#emaillist')).show();
- $('#emaillist li[class*="template"]:last-child').removeClass('template').addClass('propertycontainer');
+ $('#emaillist li.template:first-child').clone().appendTo($('#emaillist')).show();
+ $('#emaillist li.template:last-child').removeClass('template').addClass('propertycontainer');
$('#emaillist li:last-child').find('input[type="email"]').focus();
Contacts.UI.loadListHandlers();
return false;
},
loadMails:function() {
$('#emails').hide();
- $('#emaillist li[class*="propertycontainer"]').remove();
+ $('#emaillist li.propertycontainer').remove();
for(var mail in this.data.EMAIL) {
this.addMail();
//$('#emaillist li:first-child').clone().appendTo($('#emaillist')).show();
@@ -1109,9 +1112,9 @@ Contacts={
return false;
},
addPhone:function() {
- $('#phonelist li[class*="template"]:first-child').clone().appendTo($('#phonelist')); //.show();
- $('#phonelist li[class*="template"]:last-child').find('select').addClass('contacts_property');
- $('#phonelist li[class*="template"]:last-child').removeClass('template').addClass('propertycontainer');
+ $('#phonelist li.template:first-child').clone().appendTo($('#phonelist')); //.show();
+ $('#phonelist li.template:last-child').find('select').addClass('contacts_property');
+ $('#phonelist li.template:last-child').removeClass('template').addClass('propertycontainer');
$('#phonelist li:last-child').find('input[type="text"]').focus();
Contacts.UI.loadListHandlers();
$('#phonelist li:last-child').find('select').multiselect({
@@ -1125,7 +1128,7 @@ Contacts={
},
loadPhones:function() {
$('#phones').hide();
- $('#phonelist li[class*="propertycontainer"]').remove();
+ $('#phonelist li.propertycontainer').remove();
for(var phone in this.data.TEL) {
this.addPhone();
$('#phonelist li:last-child').find('select').multiselect('destroy');
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index 47220e0bc8c..1fa441475d2 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -94,7 +94,7 @@ class OC_Contacts_App {
OC_Log::write('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OC_Log::DEBUG);
$n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;';
$vcard->setString('N', $n);
- OC_Contacts_VCard::edit( $id, $vcard->serialize());
+ OC_Contacts_VCard::edit( $id, $vcard);
} else { // Else just add an empty 'N' field :-P
$vcard->setString('N', 'Unknown;Name;;;');
}
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 3c95dd19abf..50370370898 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -175,6 +175,9 @@ class OC_Contacts_VCard{
if($property->name == 'UID'){
$uid = $property->value;
}
+ if($property->name == 'ORG'){
+ $org = $property->value;
+ }
if($property->name == 'EMAIL' && is_null($email)){ // only use the first email as substitute for missing N or FN.
$email = $property->value;
}
@@ -185,6 +188,8 @@ class OC_Contacts_VCard{
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
} elseif($email) {
$fn = $email;
+ } elseif($org) {
+ $fn = $org;
} else {
$fn = 'Unknown Name';
}
@@ -218,32 +223,37 @@ class OC_Contacts_VCard{
/**
* @brief Adds a card
- * @param integer $id Addressbook id
- * @param string $data vCard file
- * @return insertid on success or null if card is not parseable.
+ * @param integer $aid Addressbook id
+ * @param OC_VObject $card vCard file
+ * @param string $uri the uri of the card, default based on the UID
+ * @return insertid on success or null if no card.
*/
- public static function add($id,$data){
- $fn = null;
-
- $card = OC_VObject::parse($data);
- if(!is_null($card)){
- OC_Contacts_App::$categories->loadFromVObject($card);
- self::updateValuesFromAdd($card);
- $data = $card->serialize();
- }
- else{
- OC_Log::write('contacts','OC_Contacts_VCard::add. Error parsing VCard: '.$data,OC_Log::ERROR);
- return null; // Ditch cards that can't be parsed by Sabre.
+ public static function add($aid, $card, $uri=null){
+ if(is_null($card)){
+ OC_Log::write('contacts','OC_Contacts_VCard::add. No vCard supplied', OC_Log::ERROR);
+ return null;
};
+ OC_Contacts_App::$categories->loadFromVObject($card);
+
+ self::updateValuesFromAdd($card);
+
$fn = $card->getAsString('FN');
- $uid = $card->getAsString('UID');
- $uri = $uid.'.vcf';
+ if (empty($fn)) {
+ $fn = null;
+ }
+
+ if (!$uri) {
+ $uid = $card->getAsString('UID');
+ $uri = $uid.'.vcf';
+ }
+
+ $data = $card->serialize();
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
- $result = $stmt->execute(array($id,$fn,$data,$uri,time()));
+ $result = $stmt->execute(array($aid,$fn,$data,$uri,time()));
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
- OC_Contacts_Addressbook::touch($id);
+ OC_Contacts_Addressbook::touch($aid);
return $newid;
}
@@ -257,23 +267,7 @@ class OC_Contacts_VCard{
*/
public static function addFromDAVData($id,$uri,$data){
$card = OC_VObject::parse($data);
- if(!is_null($card)){
- OC_Contacts_App::$categories->loadFromVObject($card);
- self::updateValuesFromAdd($card);
- $data = $card->serialize();
- } else {
- OC_Log::write('contacts','OC_Contacts_VCard::addFromDAVData. Error parsing VCard: '.$data, OC_Log::ERROR);
- return null; // Ditch cards that can't be parsed by Sabre.
- };
- $fn = $card->getAsString('FN');
-
- $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
- $result = $stmt->execute(array($id,$fn,$data,$uri,time()));
- $newid = OC_DB::insertid('*PREFIX*contacts_cards');
-
- OC_Contacts_Addressbook::touch($id);
-
- return $newid;
+ return self::add($id, $data, $uri);
}
/**
@@ -302,29 +296,25 @@ class OC_Contacts_VCard{
/**
* @brief edits a card
* @param integer $id id of card
- * @param string $data vCard file
+ * @param OC_VObject $card vCard file
* @return boolean
*/
- public static function edit($id, $data){
+ public static function edit($id, OC_VObject $card){
$oldcard = self::find($id);
- $fn = null;
- $card = OC_VObject::parse($data);
- if(!is_null($card)){
- OC_Contacts_App::$categories->loadFromVObject($card);
- foreach($card->children as $property){
- if($property->name == 'FN'){
- $fn = $property->value;
- break;
- }
- }
- } else {
+ if(is_null($card)) {
return false;
}
+
+ $fn = $card->getAsString('FN');
+ if (empty($fn)) {
+ $fn = null;
+ }
+
$now = new DateTime;
$card->setString('REV', $now->format(DateTime::W3C));
- $data = $card->serialize();
+ $data = $card->serialize();
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
$result = $stmt->execute(array($fn,$data,time(),$id));
@@ -342,28 +332,8 @@ class OC_Contacts_VCard{
*/
public static function editFromDAVData($aid,$uri,$data){
$oldcard = self::findWhereDAVDataIs($aid,$uri);
-
- $fn = null;
$card = OC_VObject::parse($data);
- if(!is_null($card)){
- OC_Contacts_App::$categories->loadFromVObject($card);
- foreach($card->children as $property){
- if($property->name == 'FN'){
- $fn = $property->value;
- break;
- }
- }
- }
- $now = new DateTime;
- $card->setString('REV', $now->format(DateTime::W3C));
- $data = $card->serialize();
-
- $stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
- $result = $stmt->execute(array($fn,$data,time(),$oldcard['id']));
-
- OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
-
- return true;
+ return self::edit($oldcard['id'], $card);
}
/**
@@ -380,14 +350,6 @@ class OC_Contacts_VCard{
}
/**
- * @brief Creates a UID
- * @return string
- */
- public static function createUID(){
- return substr(md5(rand().time()),0,10);
- }
-
- /**
* @brief deletes a card with the data provided by sabredav
* @param integer $aid Addressbook id
* @param string $uri the uri of the card
diff --git a/apps/contacts/templates/part.contactphoto.php b/apps/contacts/templates/part.contactphoto.php
index 9e3f5876cd1..8107650d161 100644
--- a/apps/contacts/templates/part.contactphoto.php
+++ b/apps/contacts/templates/part.contactphoto.php
@@ -3,7 +3,7 @@ $id = $_['id'];
$wattr = isset($_['width'])?'width="'.$_['width'].'"':'';
$hattr = isset($_['height'])?'height="'.$_['height'].'"':'';
?>
-<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id; ?>&amp;refresh=<?php echo rand(); ?>" />
+<img class="loading" id="contacts_details_photo" <?php echo $wattr; ?> <?php echo $hattr; ?> src="<?php echo OC_Helper::linkToAbsolute('contacts', 'photo.php'); ?>?id=<?php echo $id; ?>" />
<progress id="contacts_details_photo_progress" style="display:none;" value="0" max="100">0 %</progress>
diff --git a/core/css/styles.css b/core/css/styles.css
index 62f5299ef78..f5a181c4529 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -60,7 +60,7 @@ input[type="submit"].highlight{ background:#ffc100; border:1px solid #db0; text-
#leftcontent, .leftcontent { position:fixed; overflow: auto; top:6.4em; width:20em; background:#f8f8f8; border-right:1px solid #ddd; }
#leftcontent li, .leftcontent 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; }
#leftcontent li:hover, #leftcontent li:active, #leftcontent li.active, .leftcontent li:hover, .leftcontent li:active, .leftcontent li.active { background:#eee; }
-#rightcontent, .rightcontent { position:fixed; top: 6.4em; left: 32.5em; }
+#rightcontent, .rightcontent { position:fixed; top: 6.4em; left: 32.5em; overflow: auto }
/* LOG IN & INSTALLATION ------------------------------------------------------------ */
diff --git a/files/ajax/newfile.php b/files/ajax/newfile.php
index afc444bc0ac..2d1372f06ee 100644
--- a/files/ajax/newfile.php
+++ b/files/ajax/newfile.php
@@ -6,15 +6,35 @@ require_once('../../lib/base.php');
OC_JSON::checkLoggedIn();
// Get the params
-$dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
-$filename = isset( $_GET['filename'] ) ? stripslashes($_GET['filename']) : '';
-$content = isset( $_GET['content'] ) ? $_GET['content'] : '';
+$dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : '';
+$filename = isset( $_POST['filename'] ) ? stripslashes($_POST['filename']) : '';
+$content = isset( $_POST['content'] ) ? $_POST['content'] : '';
+$source = isset( $_POST['source'] ) ? stripslashes($_POST['source']) : '';
if($filename == '') {
OC_JSON::error(array("data" => array( "message" => "Empty Filename" )));
exit();
}
+if($source){
+ if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){
+ OC_JSON::error(array("data" => array( "message" => "Not a valid source" )));
+ exit();
+ }
+ $sourceStream=fopen($source,'rb');
+ $target=$dir.'/'.$filename;
+ $result=OC_Filesystem::file_put_contents($target,$sourceStream);
+ if($result){
+ $mime=OC_Filesystem::getMimetype($target);
+ OC_JSON::success(array("data" => array('mime'=>$mime)));
+ exit();
+ }else{
+ OC_JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target )));
+ exit();
+ }
+}
+
+
if(OC_Files::newFile($dir, $filename, 'file')) {
if($content){
OC_Filesystem::file_put_contents($dir.'/'.$filename,$content);
diff --git a/files/ajax/newfolder.php b/files/ajax/newfolder.php
index 6db045c4e17..228e369fbef 100644
--- a/files/ajax/newfolder.php
+++ b/files/ajax/newfolder.php
@@ -6,8 +6,8 @@ require_once('../../lib/base.php');
OC_JSON::checkLoggedIn();
// Get the params
-$dir = isset( $_GET['dir'] ) ? stripslashes($_GET['dir']) : '';
-$foldername = isset( $_GET['foldername'] ) ? stripslashes($_GET['foldername']) : '';
+$dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : '';
+$foldername = isset( $_POST['foldername'] ) ? stripslashes($_POST['foldername']) : '';
if(trim($foldername) == '') {
OC_JSON::error(array("data" => array( "message" => "Empty Foldername" )));
diff --git a/files/js/files.js b/files/js/files.js
index f5dc40ad45d..a678e12cc2d 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -127,20 +127,6 @@ $(document).ready(function() {
procesSelection();
});
- $('#file_newfolder_form').submit(function(event) {
- event.preventDefault();
- $.ajax({
- url: 'ajax/newfolder.php',
- data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(),
- complete: function(data){boolOperationFinished(data, function(){
- var date=new Date();
- FileList.addDir($('#file_newfolder_name').val(),0,date);
- $('#file_newfolder_name').val('New Folder');
- $('#file_newfolder_name').blur();
- });}
- });
- });
-
$('#file_newfolder_name').click(function(){
if($('#file_newfolder_name').val() == 'New Folder'){
$('#file_newfolder_name').val('');
@@ -312,10 +298,10 @@ $(document).ready(function() {
var name=$(this).val();
switch(type){
case 'file':
- $.ajax({
- url: OC.filePath('files','ajax','newfile.php'),
- data: "dir="+encodeURIComponent($('#dir').val())+"&filename="+encodeURIComponent(name)+'&content=%20%0A',
- complete: function(data){boolOperationFinished(data, function(){
+ $.post(
+ OC.filePath('files','ajax','newfile.php'),
+ {dir:$('#dir').val(),filename:name,content:" \n"},
+ function(data){
var date=new Date();
FileList.addFile(name,0,date);
var tr=$('tr').filterAttr('data-file',name);
@@ -323,18 +309,49 @@ $(document).ready(function() {
getMimeIcon('text/plain',function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')');
});
- });}
- });
+ }
+ );
break;
case 'folder':
- $.ajax({
- url: OC.filePath('files','ajax','newfolder.php'),
- data: "dir="+encodeURIComponent($('#dir').val())+"&foldername="+encodeURIComponent(name),
- complete: function(data){boolOperationFinished(data, function(){
+ $.post(
+ OC.filePath('files','ajax','newfolder.php'),
+ {dir:$('#dir').val(),foldername:name},
+ function(data){
var date=new Date();
FileList.addDir(name,0,date);
- });}
- });
+ }
+ );
+ break;
+ case 'web':
+ if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){
+ name='http://'.name;
+ }
+ var localName=name;
+ if(localName.substr(localName.length-1,1)=='/'){//strip /
+ localName=localName.substr(0,localName.length-1)
+ }
+ if(localName.indexOf('/')){//use last part of url
+ localName=localName.split('/').pop();
+ }else{//or the domain
+ localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.','');
+ }
+ $.post(
+ OC.filePath('files','ajax','newfile.php'),
+ {dir:$('#dir').val(),source:name,filename:localName},
+ function(result){
+ if(result.status == 'success'){
+ var date=new Date();
+ FileList.addFile(localName,0,date);
+ var tr=$('tr').filterAttr('data-file',localName);
+ tr.data('mime',result.data.mime);
+ getMimeIcon(result.data.mime,function(path){
+ tr.find('td.filename').attr('style','background-image:url('+path+')');
+ });
+ }else{
+
+ }
+ }
+ );
break;
}
var li=$(this).parent();
diff --git a/files/templates/index.php b/files/templates/index.php
index 7e9505dec2f..7fc51c288e1 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -7,6 +7,7 @@
<ul class="popup popupTop">
<li style="background-image:url('<?php echo mimetype_icon('text/plain') ?>')" data-type='file'><p><?php echo $l->t('Text file');?></p></li>
<li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='folder'><p><?php echo $l->t('Folder');?></p></li>
+ <li style="background-image:url('<?php echo image_path('core','actions/public.png') ?>')" data-type='web'><p><?php echo $l->t('From url');?></p></li>
</ul>
</div>
<div class="file_upload_wrapper svg">