From dd0daa6e33bad82f02333e9df36850042604cc63 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 13 Mar 2012 00:55:15 +0100 Subject: [PATCH] Cleanup in Contacts. --- apps/contacts/ajax/addcard.php | 103 ----- apps/contacts/ajax/categories/edit.php | 28 -- apps/contacts/ajax/messagebox.php | 15 - apps/contacts/ajax/setproperty.php | 106 ----- apps/contacts/ajax/showaddcard.php | 40 -- apps/contacts/ajax/showaddproperty.php | 37 -- apps/contacts/ajax/showsetproperty.php | 52 --- apps/contacts/css/styles.css | 37 -- apps/contacts/js/interface.js | 409 ------------------ apps/contacts/l10n/xgettextfiles | 5 +- apps/contacts/templates/part.addcardform.php | 138 ------ apps/contacts/templates/part.details.php | 96 ---- apps/contacts/templates/part.messagebox.php | 3 - apps/contacts/templates/part.no_contacts.php | 8 - apps/contacts/templates/part.property.FN.php | 9 - apps/contacts/templates/part.property.N.php | 4 - apps/contacts/templates/part.property.php | 86 ---- .../templates/part.setpropertyform.php | 91 ---- 18 files changed, 1 insertion(+), 1266 deletions(-) delete mode 100644 apps/contacts/ajax/addcard.php delete mode 100644 apps/contacts/ajax/categories/edit.php delete mode 100644 apps/contacts/ajax/messagebox.php delete mode 100644 apps/contacts/ajax/setproperty.php delete mode 100644 apps/contacts/ajax/showaddcard.php delete mode 100644 apps/contacts/ajax/showaddproperty.php delete mode 100644 apps/contacts/ajax/showsetproperty.php delete mode 100644 apps/contacts/css/styles.css delete mode 100644 apps/contacts/js/interface.js delete mode 100644 apps/contacts/templates/part.addcardform.php delete mode 100644 apps/contacts/templates/part.details.php delete mode 100644 apps/contacts/templates/part.messagebox.php delete mode 100644 apps/contacts/templates/part.no_contacts.php delete mode 100644 apps/contacts/templates/part.property.FN.php delete mode 100644 apps/contacts/templates/part.property.N.php delete mode 100644 apps/contacts/templates/part.property.php delete mode 100644 apps/contacts/templates/part.setpropertyform.php diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php deleted file mode 100644 index 49a4a16170b..00000000000 --- a/apps/contacts/ajax/addcard.php +++ /dev/null @@ -1,103 +0,0 @@ -. - * - */ - -// Init owncloud -require_once('../../../lib/base.php'); -function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/addcard.php: '.$msg, OC_Log::DEBUG); - exit(); -} - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$aid = $_POST['id']; -OC_Contacts_App::getAddressbook( $aid ); // is owner access check - -$fn = trim($_POST['fn']); -$values = $_POST['value']; -$parameters = $_POST['parameters']; - -$vcard = new OC_VObject('VCARD'); -$vcard->setUID(); - -$n = isset($values['N'][0])?trim($values['N'][0]).';':';'; -$n .= isset($values['N'][1])?trim($values['N'][1]).';':';'; -$n .= isset($values['N'][2])?trim($values['N'][2]).';;':';;'; - -if(!$fn || ($n == ';;;;')) { - bailOut('You have to enter both the extended name and the display name.'); -} - -$vcard->setString('N',$n); -$vcard->setString('FN',$fn); - -// Data to add ... -$add = array('TEL', 'EMAIL', 'ORG'); -$address = false; -for($i = 0; $i < 7; $i++){ - if( isset($values['ADR'][$i] ) && $values['ADR'][$i]) $address = true; -} -if( $address ) $add[] = 'ADR'; - -// Add data -foreach( $add as $propname){ - if( !( isset( $values[$propname] ) && $values[$propname] )){ - continue; - } - $value = $values[$propname]; - if( isset( $parameters[$propname] ) && count( $parameters[$propname] )){ - $prop_parameters = $parameters[$propname]; - } else { - $prop_parameters = array(); - } - if(is_array($value)){ - ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! - $value = OC_VObject::escapeSemicolons($value); - } - $vcard->addProperty($propname, strip_tags($value)); //, $prop_parameters); - $line = count($vcard->children) - 1; - foreach ($prop_parameters as $key=>$element) { - if(is_array($element) && strtoupper($key) == 'TYPE') { - // FIXME: Maybe this doesn't only apply for TYPE? - // And it probably shouldn't be done here anyways :-/ - foreach($element as $e){ - if($e != '' && !is_null($e)){ - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e); - } - } - } else { - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element); - } - } -} -$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); - exit(); -} - -// NOTE: Why is this in OC_Contacts_App? -OC_Contacts_App::renderDetails($id, $vcard); diff --git a/apps/contacts/ajax/categories/edit.php b/apps/contacts/ajax/categories/edit.php deleted file mode 100644 index 8ecc3540b11..00000000000 --- a/apps/contacts/ajax/categories/edit.php +++ /dev/null @@ -1,28 +0,0 @@ - - * 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('contacts'); -function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/categories/edit.php: '.$msg, OC_Log::DEBUG); - exit(); -} -function debug($msg) { - OC_Log::write('contacts','ajax/categories/edit.php: '.$msg, OC_Log::DEBUG); -} - -$tmpl = new OC_TEMPLATE("contacts", "part.edit_categories_dialog"); - -$categories = OC_Contacts_App::$categories->categories(); -debug(print_r($categories, true)); -$tmpl->assign('categories',$categories); -$tmpl->printpage(); - -?> diff --git a/apps/contacts/ajax/messagebox.php b/apps/contacts/ajax/messagebox.php deleted file mode 100644 index 408e7a537aa..00000000000 --- a/apps/contacts/ajax/messagebox.php +++ /dev/null @@ -1,15 +0,0 @@ - - * 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('contacts'); - -$output = new OC_TEMPLATE("contacts", "part.messagebox"); -$output -> printpage(); -?> diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php deleted file mode 100644 index 8e07b4a8f1c..00000000000 --- a/apps/contacts/ajax/setproperty.php +++ /dev/null @@ -1,106 +0,0 @@ -. - * - */ - -// Init owncloud -require_once('../../../lib/base.php'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$id = $_POST['id']; -$checksum = $_POST['checksum']; - -$vcard = OC_Contacts_App::getContactVCard( $id ); -$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); - -// Set the value -$value = $_POST['value']; -if(is_array($value)){ - ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! - foreach(array_keys($value) as $key) { - OC_Log::write('contacts','ajax/setproperty.php: setting: '.$key.': '.$value[$key], OC_Log::DEBUG); - } - $value = OC_VObject::escapeSemicolons($value); -} -OC_Log::write('contacts','ajax/setproperty.php: setting: '.$vcard->children[$line]->name.': '.$value, OC_Log::DEBUG); -$vcard->children[$line]->setValue(strip_tags($value)); - -// Add parameters -$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array(); -if ($vcard->children[$line]->name == 'TEL' && !array_key_exists('TYPE', $postparameters)){ - $postparameters['TYPE']=''; -} -for($i=0;$ichildren[$line]->parameters);$i++){ - $name = $vcard->children[$line]->parameters[$i]->name; - if(array_key_exists($name,$postparameters)){ - if($postparameters[$name] == '' || is_null($postparameters[$name])){ - unset($vcard->children[$line]->parameters[$i]); - } - else{ - unset($vcard->children[$line][$name]); - $values = $postparameters[$name]; - if (!is_array($values)){ - $values = array($values); - } - foreach($values as $value){ - $vcard->children[$line]->add($name, $value); - } - } - unset($postparameters[$name]); - } -} -$missingparameters = array_keys($postparameters); -foreach($missingparameters as $i){ - if(!$postparameters[$i] == '' && !is_null($postparameters[$i])){ - $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($i,$postparameters[$i]); - } -} - -// Do checksum and be happy -// NOTE: This checksum is not used..? -$checksum = md5($vcard->children[$line]->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(); -} - -$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); - -if ($vcard->children[$line]->name == 'FN'){ - $tmpl = new OC_Template('contacts','part.property.FN'); -} -elseif ($vcard->children[$line]->name == 'N'){ - $tmpl = new OC_Template('contacts','part.property.N'); -} -else{ - $tmpl = new OC_Template('contacts','part.property'); -} -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line)); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'] ))); diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php deleted file mode 100644 index 54592c89c0d..00000000000 --- a/apps/contacts/ajax/showaddcard.php +++ /dev/null @@ -1,40 +0,0 @@ -. - * - */ - -// Init owncloud -require_once('../../../lib/base.php'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); - -$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser()); -$tmpl = new OC_Template('contacts','part.addcardform'); -$tmpl->assign('addressbooks',$addressbooks); -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php deleted file mode 100644 index 30eb7634f80..00000000000 --- a/apps/contacts/ajax/showaddproperty.php +++ /dev/null @@ -1,37 +0,0 @@ -. - * - */ - -// Init owncloud -require_once('../../../lib/base.php'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$id = $_GET['id']; -$card = OC_Contacts_App::getContactObject( $id ); - -$tmpl = new OC_Template('contacts','part.addpropertyform'); -$tmpl->assign('id',$id); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php deleted file mode 100644 index 73bef655351..00000000000 --- a/apps/contacts/ajax/showsetproperty.php +++ /dev/null @@ -1,52 +0,0 @@ -. - * - */ - -// Init owncloud -require_once('../../../lib/base.php'); - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$id = $_GET['id']; -$checksum = $_GET['checksum']; - -$vcard = OC_Contacts_App::getContactVCard( $id ); - -$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); -if(is_null($line)){ - OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); - exit(); -} - -$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); - -$tmpl = new OC_Template('contacts','part.setpropertyform'); -$tmpl->assign('id',$id); -$tmpl->assign('checksum',$checksum); -$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line])); -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css deleted file mode 100644 index 58e1bf6c93e..00000000000 --- a/apps/contacts/css/styles.css +++ /dev/null @@ -1,37 +0,0 @@ -#contacts { padding-left:2px; padding-top: 5px; background: #fff; } -#leftcontent a { height: 23px; display: block; margin: 0 0 0 0; padding: 0 0 0 25px; } -#chooseaddressbook {margin-right: 170px; float: right;} -#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;} -#contacts_details_name_n { font-size:0.8em;margin-left:25%;color:#666;} -#contacts_details_photo { margin:.5em 0em .5em 25%; } - -#contacts_deletecard {position:absolute;top:15px;right:25px;} -#contacts_downloadcard {position:absolute;top:15px;right:50px;} -#contacts_details_list { list-style:none; } -#contacts_details_list li { overflow:visible; } -#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; } -#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; clear: right; } -#contacts_setproperty_button { margin-left:25%; } - -#contacts_addcardform legend,label { font-weight: bold; width: 10em; overflow: ellipsis; } -#contacts_addcardform legend { padding-left: 3em; font-size:1.1em; } -#contacts_addcardform input[type="text"] { width: 25em; } -#contacts_addcardform input[type="email"] { width: 15em; } -#contacts_addcardform input[type="tel"] { width: 15em; } - -dl.form { width: 100%; float: left; clear: right; margin: 1em; padding: 0; } -.form dt { display: table-cell; clear: left; float: left; min-width: 10em; margin: 0; padding-top: 0.5em; padding-right: 1em;font-weight: bold; text-align:right; vertical-align: text-bottom; bottom: 0px; } -.form dd { display: table-cell; clear: right; float: left; min-width: 20em; margin: 0; padding: 0; white-space: nowrap; top: 0px; } -.form input { position: relative; width: 20em; } - -.contacts_property_data ul, ol.contacts_property_data { list-style:none; } -.contacts_property_data li { overflow: hidden; } -.contacts_property_data li label { width:20%; float:left; text-align:right;padding-right:0.3em; } -.contacts_property_data input { float:left; } -.contacts_property_data li input { width:70%;overflow:hidden; } - -.chzn-container { margin:3px 0 0; } -.chzn-container .chzn-choices { border-radius: 0.5em; } -.chzn-container.chzn-container-active .chzn-choices { border-bottom-left-radius: 0;border-bottom-right-radius: 0; } -.chzn-container .chzn-drop { border-bottom-left-radius: 0.5em;border-bottom-right-radius: 0.5em; } - diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js deleted file mode 100644 index 5908dd767a2..00000000000 --- a/apps/contacts/js/interface.js +++ /dev/null @@ -1,409 +0,0 @@ -/** - * ownCloud - Addressbook - * - * @author Jakob Sack - * @copyright 2011 Jakob Sack mail@jakobsack.de - * @copyright 2011-2012 Thomas Tanghus - * - * 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 . - * - */ - - -Contacts={ - UI:{ - showCardDAVUrl:function(username, bookname){ - $('#carddav_url').val(totalurl + '/' + username + '/' + bookname); - $('#carddav_url').show(); - $('#carddav_url_close').show(); - }, - messageBox:function(title, msg) { - if($('#messagebox').dialog('isOpen') == true){ - // NOTE: Do we ever get here? - $('#messagebox').dialog('moveToTop'); - }else{ - $('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'messagebox.php'), function(){ - $('#messagebox').dialog( - { - autoOpen: true, - title: title, - buttons: [{ - text: "Ok", - click: function() { $(this).dialog("close"); } - }], - close: function(event, ui) { - $(this).dialog('destroy').remove(); - }, - open: function(event, ui) { - $('#messagebox_msg').html(msg); - } - }); - }); - } - }, - Addressbooks:{ - overview:function(){ - if($('#chooseaddressbook_dialog').dialog('isOpen') == true){ - $('#chooseaddressbook_dialog').dialog('moveToTop'); - }else{ - $('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'chooseaddressbook.php'), function(){ - $('#chooseaddressbook_dialog').dialog({ - width : 600, - close : function(event, ui) { - $(this).dialog('destroy').remove(); - } - }); - }); - } - }, - activation:function(checkbox, bookid) - { - $.post(OC.filePath('contacts', 'ajax', 'activation.php'), { bookid: bookid, active: checkbox.checked?1:0 }, - function(data) { - /* - * Arguments: - * data.status - * data.bookid - * data.active - */ - if (data.status == 'success'){ - checkbox.checked = data.active == 1; - Contacts.UI.Contacts.update(); - } - }); - }, - newAddressbook:function(object){ - var tr = $(document.createElement('tr')) - .load(OC.filePath('contacts', 'ajax', 'addbook.php')); - $(object).closest('tr').after(tr).hide(); - /* TODO: Shouldn't there be some kinda error checking here? */ - }, - editAddressbook:function(object, bookid){ - var tr = $(document.createElement('tr')) - .load(OC.filePath('contacts', 'ajax', 'editaddressbook.php') + "?bookid="+bookid); - $(object).closest('tr').after(tr).hide(); - }, - deleteAddressbook:function(bookid){ - var check = confirm("Do you really want to delete this address book?"); - if(check == false){ - return false; - }else{ - $.post(OC.filePath('contacts', 'ajax', 'deletebook.php'), { id: bookid}, - function(data) { - if (data.status == 'success'){ - $('#chooseaddressbook_dialog').dialog('destroy').remove(); - Contacts.UI.Contacts.update(); - Contacts.UI.Addressbooks.overview(); - } else { - Contacts.UI.messageBox(t('contacts', 'Error'), data.message); - //alert('Error: ' + data.message); - } - }); - } - }, - submit:function(button, bookid){ - var displayname = $("#displayname_"+bookid).val(); - var active = $("#edit_active_"+bookid+":checked").length; - var description = $("#description_"+bookid).val(); - - var url; - if (bookid == 'new'){ - url = OC.filePath('contacts', 'ajax', 'createaddressbook.php'); - }else{ - url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php'); - } - $.post(url, { id: bookid, name: displayname, active: active, description: description }, - function(jsondata){ - if(jsondata.status == 'success'){ - $(button).closest('tr').prev().html(data.page).show().next().remove(); - Contacts.UI.Contacts.update(); - } else { - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - } - }); - }, - cancel:function(button, bookid){ - $(button).closest('tr').prev().show().next().remove(); - } - }, - Contacts:{ - /** - * Reload the contacts list. - */ - update:function(){ - $.getJSON('ajax/contacts.php',{},function(jsondata){ - if(jsondata.status == 'success'){ - $('#contacts').html(jsondata.data.page); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'),jsondata.data.message); - //alert(jsondata.data.message); - } - }); - setTimeout(Contacts.UI.Contacts.lazyupdate, 500); - }, - /** - * Add thumbnails to the contact list as they become visible in the viewport. - */ - lazyupdate:function(){ - $('#contacts li').live('inview', function(){ - if (!$(this).find('a').attr('style')) { - $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat'); - } - }); - } - } - } -} - -$(document).ready(function(){ - /*------------------------------------------------------------------------- - * Event handlers - *-----------------------------------------------------------------------*/ - - /** - * Load the details view for a contact. - */ - $('#leftcontent li').live('click',function(){ - var id = $(this).data('id'); - var oldid = $('#rightcontent').data('id'); - if(oldid != 0){ - $('#leftcontent li[data-id="'+oldid+'"]').removeClass('active'); - } - $.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){ - if(jsondata.status == 'success'){ - $('#rightcontent').data('id',jsondata.data.id); - $('#rightcontent').html(jsondata.data.page); - $('#leftcontent li[data-id="'+jsondata.data.id+'"]').addClass('active'); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }); - return false; - }); - - /** - * Delete currently selected contact (and clear form?) - */ - $('#contacts_deletecard').live('click',function(){ - $('#contacts_deletecard').tipsy('hide'); - var id = $('#rightcontent').data('id'); - $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){ - if(jsondata.status == 'success'){ - $('#leftcontent [data-id="'+jsondata.data.id+'"]').remove(); - $('#rightcontent').data('id',''); - $('#rightcontent').empty(); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }); - return false; - }); - - /** - * Add a property to the contact. - * NOTE: Where does 'contacts_addproperty' exist? - */ - $('#contacts_addproperty').live('click',function(){ - var id = $('#rightcontent').data('id'); - $.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){ - if(jsondata.status == 'success'){ - $('#contacts_details_list').append(jsondata.data.page); - $('#contacts_addproperty').hide(); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - alert('From handler: '+jsondata.data.message); - } - }); - return false; - }); - - /** - * Change the inputs based on which type of property is selected for addition. - */ - $('#contacts_addpropertyform [name="name"]').live('change',function(){ - $('#contacts_addpropertyform #contacts_addresspart').remove(); - $('#contacts_addpropertyform #contacts_phonepart').remove(); - $('#contacts_addpropertyform #contacts_fieldpart').remove(); - $('#contacts_addpropertyform #contacts_generic').remove(); - if($(this).val() == 'ADR'){ - $('#contacts_addresspart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name')); - } - else if($(this).val() == 'TEL'){ - $('#contacts_phonepart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name')); - } - else{ - $('#contacts_generic').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name')); - } - $('#contacts_addpropertyform .contacts_property_data select').chosen(); - }); - - $('#contacts_addpropertyform input[type="submit"]').live('click',function(){ - $.post('ajax/addproperty.php',$('#contacts_addpropertyform').serialize(),function(jsondata){ - if(jsondata.status == 'success'){ - $('#contacts_addpropertyform').before(jsondata.data.page); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - } - }, 'json'); - return false; - }); - - /** - * Show the Addressbook chooser - */ - $('#chooseaddressbook').click(function(){ - Contacts.UI.Addressbooks.overview(); - return false; - }); - - /** - * Open blank form to add new contact. - */ - $('#contacts_newcontact').click(function(){ - $.getJSON('ajax/showaddcard.php',{},function(jsondata){ - if(jsondata.status == 'success'){ - $('#rightcontent').data('id',''); - $('#rightcontent').html(jsondata.data.page) - .find('select').chosen(); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }); - return false; - }); - - /** - * Add and insert a new contact into the list. - */ - $('#contacts_addcardform input[type="submit"]').live('click',function(){ - $.post('ajax/addcard.php',$('#contacts_addcardform').serialize(),function(jsondata){ - if(jsondata.status == 'success'){ - $('#rightcontent').data('id',jsondata.data.id); - $('#rightcontent').html(jsondata.data.page); - $('#leftcontent .active').removeClass('active'); - var item = '
  • '+jsondata.data.name+'
  • '; - var added = false; - $('#leftcontent ul li').each(function(){ - if ($(this).text().toLowerCase() > jsondata.data.name.toLowerCase()) { - $(this).before(item).fadeIn('fast'); - added = true; - return false; - } - }); - if(!added) { - $('#leftcontent ul').append(item); - } - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }, 'json'); - return false; - }); - - /** - * Show inputs for editing a property. - */ - $('.contacts_property [data-use="edit"]').live('click',function(){ - var id = $('#rightcontent').data('id'); - var checksum = $(this).parents('.contacts_property').first().data('checksum'); - $.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum },function(jsondata){ - if(jsondata.status == 'success'){ - $('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page) - .find('select').chosen(); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }); - return false; - }); - - /** - * Save the edited property - */ - $('#contacts_setpropertyform input[type="submit"]').live('click',function(){ - $.post('ajax/setproperty.php',$(this).parents('form').first().serialize(),function(jsondata){ - if(jsondata.status == 'success'){ - $('.contacts_property[data-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - },'json'); - return false; - }); - - $('.contacts_property [data-use="delete"]').live('click',function(){ - var id = $('#rightcontent').data('id'); - var checksum = $(this).parents('li').first().data('checksum'); - $.getJSON('ajax/deleteproperty.php',{'id': id, 'checksum': checksum },function(jsondata){ - if(jsondata.status == 'success'){ - $('.contacts_property[data-checksum="'+checksum+'"]').remove(); - } - else{ - Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message); - //alert(jsondata.data.message); - } - }); - return false; - }); - - - $('.contacts_property').live('mouseenter',function(){ - $(this).find('span[data-use]').show(); - }); - - $('.contacts_property').live('mouseleave',function(){ - $(this).find('span[data-use]').hide(); - }); - - $('#contacts_addcardform select').chosen(); - - $('#contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) { - if (isInView) { //NOTE: I've kept all conditions for future reference ;-) - // element is now visible in the viewport - if (visiblePartY == 'top') { - // top part of element is visible - } else if (visiblePartY == 'bottom') { - // bottom part of element is visible - } else { - // whole part of element is visible - if (!$(this).find('a').attr('style')) { - //alert($(this).data('id') + ' has background: ' + $(this).attr('style')); - $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat'); - }/* else { - alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url')); - }*/ - } - } else { - // element has gone out of viewport - } - }); - - $('.button').tipsy(); - //Contacts.UI.messageBox('Hello','Sailor'); -}); diff --git a/apps/contacts/l10n/xgettextfiles b/apps/contacts/l10n/xgettextfiles index 91d5da46db0..e2492431ff8 100644 --- a/apps/contacts/l10n/xgettextfiles +++ b/apps/contacts/l10n/xgettextfiles @@ -1,20 +1,17 @@ ../appinfo/app.php ../ajax/activation.php ../ajax/addbook.php -../ajax/addcard.php ../ajax/addproperty.php ../ajax/createaddressbook.php ../ajax/deletebook.php ../ajax/deleteproperty.php ../ajax/getdetails.php -../ajax/setproperty.php +../ajax/saveproperty.php ../ajax/updateaddressbook.php ../lib/app.php ../templates/index.php -../templates/part.addcardform.php ../templates/part.chooseaddressbook.php ../templates/part.chooseaddressbook.rowfields.php -../templates/part.details.php ../templates/part.editaddressbook.php ../templates/part.property.php ../templates/part.setpropertyform.php diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php deleted file mode 100644 index 1ad4c18b35b..00000000000 --- a/apps/contacts/templates/part.addcardform.php +++ /dev/null @@ -1,138 +0,0 @@ -
    - - - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - - - -
    -
    -
    -
    -
    -
    - - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    - - -
    -
    -
    -
    - t('Address'); ?> -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - - - -
    -
    - -
    -
    - - - -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    -
    - -
    diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php deleted file mode 100644 index 5badd816155..00000000000 --- a/apps/contacts/templates/part.details.php +++ /dev/null @@ -1,96 +0,0 @@ - - inc('part.property.FN', array('property' => $_['details']['FN'][0])); ?> - inc('part.property.N', array('property' => $_['details']['N'][0])); ?> - - - - - - - -
      - - inc('part.property', array('property' => $_['details']['BDAY'][0])); ?> - - - - inc('part.property', array('property' => $_['details']['ORG'][0])); ?> - - - - - - inc('part.property',array('property' => $property )); ?> - - - -
    • -
      - -

      - -
      - -

      -

      - -

      -
      - -
    • -
    - - diff --git a/apps/contacts/templates/part.messagebox.php b/apps/contacts/templates/part.messagebox.php deleted file mode 100644 index 5db10e7e6c5..00000000000 --- a/apps/contacts/templates/part.messagebox.php +++ /dev/null @@ -1,3 +0,0 @@ -
    -
    - diff --git a/apps/contacts/templates/part.no_contacts.php b/apps/contacts/templates/part.no_contacts.php deleted file mode 100644 index f58fdef09f0..00000000000 --- a/apps/contacts/templates/part.no_contacts.php +++ /dev/null @@ -1,8 +0,0 @@ -
    -You have no contacts in your list. -
    - - - -
    -
    \ No newline at end of file diff --git a/apps/contacts/templates/part.property.FN.php b/apps/contacts/templates/part.property.FN.php deleted file mode 100644 index c9e21c20e60..00000000000 --- a/apps/contacts/templates/part.property.FN.php +++ /dev/null @@ -1,9 +0,0 @@ -

    - - -

    - - - diff --git a/apps/contacts/templates/part.property.N.php b/apps/contacts/templates/part.property.N.php deleted file mode 100644 index 73d599ad7b4..00000000000 --- a/apps/contacts/templates/part.property.N.php +++ /dev/null @@ -1,4 +0,0 @@ -

    - () - -

    diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php deleted file mode 100644 index 7b23fae45b5..00000000000 --- a/apps/contacts/templates/part.property.php +++ /dev/null @@ -1,86 +0,0 @@ -
  • - -

    t('Birthday'); ?>

    -

    - l('date',new DateTime($_['property']['value'])); ?> - -

    - -

    t('Organization'); ?>

    -

    - - - -

    - -

    t('Email'); ?>

    -

    - - - -

    - -

    t('Preferred').' ' : '' ?>t('Phone'); ?>

    -

    - - -t(ucwords(strtolower($type))); - } - } - $label = join(' ', $types); -?> - () - - - -

    - -

    - t('Address'); ?> - -
    -t(ucwords(strtolower($type))); - } -?> - () - -

    -

    - -
    - - -
    - - -
    - - -
    - - -
    - - -
    - - - - - - -

    - -
  • diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php deleted file mode 100644 index 93ade8faaa7..00000000000 --- a/apps/contacts/templates/part.setpropertyform.php +++ /dev/null @@ -1,91 +0,0 @@ -
    - - - -

    -

    -
    -
    -
    -
    -
    -
    - - -
    -
    -

    - -

    - -

    -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - -
    - -
    -
    - - -
    -
    - -
    -
    - - - -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -

    -

    -

    - -

    -

    - -

    -

    - - -
    -- 2.39.5