1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Simplify showing intro when no contacts. For reasons unknown also fixes oc-1588.

This commit is contained in:
Thomas Tanghus 2012-09-01 06:41:36 +02:00
parent 214e92cab5
commit c33e5b0517
6 changed files with 13 additions and 143 deletions

View File

@ -1,58 +0,0 @@
<?php
/**
* ownCloud - Addressbook
*
* @author Thomas Tanghus
* @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$requesttoken = $_GET['requesttoken'];
$freeSpace=OC_Filesystem::free_space('/');
$freeSpace=max($freeSpace, 0);
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
$impp_types = OC_Contacts_App::getTypesOfProperty('IMPP');
$ims = OC_Contacts_App::getIMOptions();
$im_protocols = array();
foreach($ims as $name => $values) {
$im_protocols[$name] = $values['displayname'];
}
$tmpl = new OCP\Template('contacts', 'part.contact');
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('requesttoken', $_SERVER['HTTP_REQUESTTOKEN']);
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('adr_types', $adr_types);
$tmpl->assign('phone_types', $phone_types);
$tmpl->assign('email_types', $email_types);
$tmpl->assign('impp_types', $impp_types, false);
$tmpl->assign('im_protocols', $im_protocols, false);
$tmpl->assign('requesttoken', $requesttoken);
$tmpl->assign('id', '');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));

View File

@ -1,31 +0,0 @@
<?php
/**
* ownCloud - Addressbook
*
* @author Thomas Tanghus
* @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$tmpl = new OCP\Template('contacts', 'part.no_contacts');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));

View File

@ -371,28 +371,13 @@ OC.Contacts={
// Make sure proper DOM is loaded.
if(!$('#card').length && newid) {
console.log('Loading card DOM');
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{requesttoken:requesttoken},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() {
OC.Contacts.loadHandlers();
localLoadContact(newid, bookid);
});
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
$('#firstrun').hide();
$('#card').show();
} else if(!newid) {
console.log('Loading intro');
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
if(jsondata.status == 'success'){
id = '';
$('#rightcontent').data('id','');
$('#rightcontent').html(jsondata.data.page);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
// show intro page
$('#firstrun').show();
$('#card').hide();
}
else {
localLoadContact(newid, bookid);
@ -427,11 +412,12 @@ OC.Contacts={
}
return false;
},
add:function(n, fn, aid, isnew){ // add a new contact
add:function(n, fn, aid, isnew) { // add a new contact
console.log('Adding ' + fn);
$('#firstrun').hide();
$('#card').show();
aid = aid?aid:$('#contacts h3.active').first().data('id');
var localAddcontact = function(n, fn, aid, isnew) {
$.post(OC.filePath('contacts', 'ajax', 'contact/add.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
$.post(OC.filePath('contacts', 'ajax', 'contact/add.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
function(jsondata) {
if (jsondata.status == 'success'){
$('#rightcontent').data('id',jsondata.data.id);
@ -458,23 +444,6 @@ OC.Contacts={
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
if(!$('#card').length) {
console.log('Loading card DOM');
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{'requesttoken': requesttoken},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() {
OC.Contacts.loadHandlers();
localAddcontact(n, fn, aid, isnew);
});
} else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
} else {
localAddcontact(n, fn, aid, isnew);
}
},
delayedDelete:function() {
$('#contacts_deletecard').tipsy('hide');
@ -506,14 +475,8 @@ OC.Contacts={
OC.Contacts.Card.update({cid:newid, aid:bookid});
} else {
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
if(jsondata.status == 'success'){
id = '';
$('#rightcontent').html(jsondata.data.page).removeData('id');
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
$('#firstrun').show();
$('#card').hide();
}
OC.Contacts.notify({
data:curlistitem,

View File

@ -25,12 +25,8 @@
</div>
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>">
<?php
if($_['has_contacts']) {
echo $this->inc('part.contact');
}
else{
echo $this->inc('part.no_contacts');
}
?>
<div class="hidden popup" id="ninjahelp">
<a class="close" tabindex="0" role="button" title="<?php echo $l->t('Close'); ?>"></a>

View File

@ -2,7 +2,7 @@
<?php
$id = isset($_['id']) ? $_['id'] : '';
?>
<div id="card">
<div id="card" <?php if(!$_['has_contacts']) { echo 'class="hidden"';} ?>>
<form class="float" id="file_upload_form" action="<?php echo OCP\Util::linkTo('contacts', 'ajax/uploadphoto.php'); ?>" method="post" enctype="multipart/form-data" target="file_upload_target">
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>">
<input type="hidden" name="id" value="<?php echo $_['id'] ?>">

View File

@ -1,5 +1,5 @@
<div id="appsettings" class="popup bottomleft hidden"></div>
<div id="firstrun">
<div id="firstrun" <?php if($_['has_contacts']) { echo 'class="hidden"';} ?>>
<?php echo $l->t('You have no contacts in your addressbook.') ?>
<div id="selections">
<input type="button" value="<?php echo $l->t('Add contact') ?>" onclick="OC.Contacts.Card.editNew()" />