Contacts: cleanup OC_L10N usage

This commit is contained in:
Bart Visscher 2012-02-12 16:11:41 +01:00
parent 39f342d595
commit 623afb69b6
23 changed files with 29 additions and 59 deletions

View File

@ -7,7 +7,6 @@
*/ */
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$book = array( $book = array(

View File

@ -31,7 +31,6 @@ function bailOut($msg) {
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
$aid = $_POST['id']; $aid = $_POST['id'];
OC_Contacts_App::getAddressbook( $aid ); // is owner access check OC_Contacts_App::getAddressbook( $aid ); // is owner access check
@ -95,7 +94,7 @@ foreach( $add as $propname){
} }
$id = OC_Contacts_VCard::add($aid,$vcard->serialize()); $id = OC_Contacts_VCard::add($aid,$vcard->serialize());
if(!$id) { if(!$id) {
OC_JSON::error(array('data' => array('message' => $l->t('There was an error adding the contact.')))); 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); OC_Log::write('contacts','ajax/addcard.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
exit(); exit();
} }

View File

@ -34,7 +34,6 @@ function debug($msg) {
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
foreach ($_POST as $key=>$element) { foreach ($_POST as $key=>$element) {
debug('_POST: '.$key.'=>'.$element); debug('_POST: '.$key.'=>'.$element);
@ -55,7 +54,7 @@ $vcard->setString('N',$n);
$id = OC_Contacts_VCard::add($aid,$vcard->serialize()); $id = OC_Contacts_VCard::add($aid,$vcard->serialize());
if(!$id) { if(!$id) {
OC_JSON::error(array('data' => array('message' => $l->t('There was an error adding the contact.')))); 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); OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
exit(); exit();
} }

View File

@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
$id = $_POST['id']; $id = $_POST['id'];
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
@ -36,7 +35,7 @@ $value = $_POST['value'];
if(!is_array($value)){ if(!is_array($value)){
$value = trim($value); $value = trim($value);
if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME'))) { if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME'))) {
OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add empty property.'))));
exit(); exit();
} }
} elseif($name === 'ADR') { // only add if non-empty elements. } elseif($name === 'ADR') { // only add if non-empty elements.
@ -48,7 +47,7 @@ if(!is_array($value)){
} }
} }
if($empty) { if($empty) {
OC_JSON::error(array('data' => array('message' => $l->t('At least one of the address fields has to be filled out.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.'))));
exit(); exit();
} }
} }
@ -59,7 +58,7 @@ $current = $vcard->select($name);
foreach($current as $item) { foreach($current as $item) {
$tmpvalue = (is_array($value)?implode(';', $value):$value); $tmpvalue = (is_array($value)?implode(';', $value):$value);
if($tmpvalue == $item->value) { if($tmpvalue == $item->value) {
OC_JSON::error(array('data' => array('message' => $l->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue)));
OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG); OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG);
exit(); exit();
} }
@ -114,7 +113,7 @@ foreach ($parameters as $key=>$element) {
$checksum = md5($vcard->children[$line]->serialize()); $checksum = md5($vcard->children[$line]->serialize());
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.')))); 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); OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR);
exit(); exit();
} }

View File

@ -7,7 +7,6 @@
*/ */
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');

View File

@ -34,15 +34,14 @@ function debug($msg) {
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
$id = isset($_GET['id'])?$_GET['id']:null; $id = isset($_GET['id'])?$_GET['id']:null;
if(is_null($id)) { if(is_null($id)) {
bailOut($l->t('Missing ID')); bailOut(OC_Contacts_App::$l10n->t('Missing ID'));
} }
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
if(is_null($vcard)) { if(is_null($vcard)) {
bailOut($l->t('Error parsing VCard for ID: "'.$id.'"')); bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "'.$id.'"'));
} }
$details = OC_Contacts_VCard::structureContact($vcard); $details = OC_Contacts_VCard::structureContact($vcard);
@ -54,7 +53,7 @@ if(!isset($details['FN'])) {
} elseif(isset($details['EMAIL'])) { } elseif(isset($details['EMAIL'])) {
$details['FN'] = array('value' => $details['EMAIL'][0]['value']); $details['FN'] = array('value' => $details['EMAIL'][0]['value']);
} else { } else {
$details['FN'] = array('value' => $l->t('Unknown')); $details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown'));
} }
} }

View File

@ -8,8 +8,6 @@
*/ */
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
@ -17,13 +15,13 @@ OC_JSON::checkAppEnabled('contacts');
$userid = OC_User::getUser(); $userid = OC_User::getUser();
$bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null); $bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null);
if(!$bookid) { if(!$bookid) {
OC_JSON::error(array('data' => array('message' => $l->t('Error adding addressbook.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR); OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR);
exit(); exit();
} }
if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
OC_JSON::error(array('data' => array('message' => $l->t('Error activating addressbook.')))); OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR); OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR);
//exit(); //exit();
} }

View File

@ -23,7 +23,6 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');

View File

@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l10n = new OC_L10N('contacts');
$id = $_GET['id']; $id = $_GET['id'];
$checksum = $_GET['checksum']; $checksum = $_GET['checksum'];
@ -34,15 +33,14 @@ $checksum = $_GET['checksum'];
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
if(is_null($line)){ if(is_null($line)){
$l=new OC_L10N('contacts'); OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.'))));
exit(); exit();
} }
unset($vcard->children[$line]); unset($vcard->children[$line]);
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
OC_JSON::error(array('data' => array('message' => $l->t('Error deleting contact property.')))); 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); OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR);
exit(); exit();
} }

View File

@ -7,7 +7,6 @@
*/ */
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); $addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']);

View File

@ -9,7 +9,6 @@
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_Util::checkAppEnabled('contacts'); OC_Util::checkAppEnabled('contacts');
$l10n = new OC_L10N('contacts');
$tmpl = new OC_Template('contacts', 'part.import'); $tmpl = new OC_Template('contacts', 'part.import');
$tmpl->assign('path', $_POST['path']); $tmpl->assign('path', $_POST['path']);
$tmpl->assign('filename', $_POST['filename']); $tmpl->assign('filename', $_POST['filename']);

View File

@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); // OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);

View File

@ -7,7 +7,6 @@
*/ */
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');

View File

@ -28,7 +28,6 @@ OC_Log::write('contacts','ajax/savecrop.php: Huzzah!!!', OC_Log::DEBUG);
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
// foreach ($_POST as $key=>$element) { // foreach ($_POST as $key=>$element) {
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG); // OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);

View File

@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');
$l=new OC_L10N('contacts');
function bailOut($msg) { function bailOut($msg) {
OC_JSON::error(array('data' => array('message' => $msg))); OC_JSON::error(array('data' => array('message' => $msg)));
@ -59,24 +58,24 @@ if(is_array($value)){ // FIXME: How to strip_tags for compound values?
$value = trim(strip_tags($value)); $value = trim(strip_tags($value));
} }
if(!$id) { if(!$id) {
bailOut($l->t('id is not set.')); bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
} }
if(!$checksum) { if(!$checksum) {
bailOut($l->t('checksum is not set.')); bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
} }
if(!$name) { if(!$name) {
bailOut($l->t('element name is not set.')); bailOut(OC_Contacts_App::$l10n->t('element name is not set.'));
} }
$vcard = OC_Contacts_App::getContactVCard( $id ); $vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
if(is_null($line)) { if(is_null($line)) {
bailOut($l->t('Information about vCard is incorrect. Please reload the page.'.$checksum.' "'.$line.'"')); bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'.$checksum.' "'.$line.'"'));
} }
$element = $vcard->children[$line]->name; $element = $vcard->children[$line]->name;
if($element != $name) { if($element != $name) {
bailOut($l->t('Something went FUBAR. ').$name.' != '.$element); bailOut(OC_Contacts_App::$l10n->t('Something went FUBAR. ').$name.' != '.$element);
} }
switch($element) { switch($element) {
@ -123,7 +122,7 @@ $checksum = md5($vcard->children[$line]->serialize());
debug('New checksum: '.$checksum); debug('New checksum: '.$checksum);
if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
OC_JSON::error(array('data' => array('message' => $l->t('Error updating contact property.')))); 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); OC_Log::write('contacts','ajax/setproperty.php: Error updating contact property: '.$value, OC_Log::ERROR);
exit(); exit();
} }

View File

@ -34,8 +34,7 @@ $vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
if(is_null($line)){ if(is_null($line)){
$l=new OC_L10N('contacts'); OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.'))));
exit(); exit();
} }

View File

@ -8,8 +8,6 @@
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user // Check if we are a user
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts'); OC_JSON::checkAppEnabled('contacts');

View File

@ -94,14 +94,13 @@ if (!isset($_FILES['imagefile'])) {
} }
$error = $_FILES['imagefile']['error']; $error = $_FILES['imagefile']['error'];
if($error !== UPLOAD_ERR_OK) { if($error !== UPLOAD_ERR_OK) {
$l=new OC_L10N('contacts');
$errors = array( $errors = array(
0=>$l->t("There is no error, the file uploaded with success"), 0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
1=>$l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'), 1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
2=>$l->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), 2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
3=>$l->t("The uploaded file was only partially uploaded"), 3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
4=>$l->t("No file was uploaded"), 4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
6=>$l->t("Missing a temporary folder") 6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
); );
bailOut($errors[$error]); bailOut($errors[$error]);
} }

View File

@ -1,6 +1,4 @@
<?php <?php
$l=new OC_L10N('contacts');
OC::$CLASSPATH['OC_Contacts_App'] = 'apps/contacts/lib/app.php'; OC::$CLASSPATH['OC_Contacts_App'] = 'apps/contacts/lib/app.php';
OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php'; OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php'; OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
@ -18,7 +16,7 @@ OC_App::addNavigationEntry( array(
'order' => 10, 'order' => 10,
'href' => OC_Helper::linkTo( 'contacts', 'index.php' ), 'href' => OC_Helper::linkTo( 'contacts', 'index.php' ),
'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ), 'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ),
'name' => $l->t('Contacts') )); 'name' => OC_Contacts_App::$l10n->t('Contacts') ));
OC_APP::registerPersonal('contacts','settings'); OC_APP::registerPersonal('contacts','settings');

View File

@ -1,6 +1,3 @@
<?php
$l=new OC_L10N('contacts');
?>
<form id="contacts_addcardform"> <form id="contacts_addcardform">
<?php if(count($_['addressbooks'])==1): ?> <?php if(count($_['addressbooks'])==1): ?>
<input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>"> <input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>">

View File

@ -1,5 +1,4 @@
<?php <?php
$l=new OC_L10N('contacts');
$id = isset($_['id']) ? $_['id'] : ''; $id = isset($_['id']) ? $_['id'] : '';
?> ?>
<div id="card"> <div id="card">

View File

@ -1,5 +1,4 @@
<?php <?php
$l=new OC_L10N('contacts');
$name = isset($_['name'])?$_['name']:''; $name = isset($_['name'])?$_['name']:'';
//print_r($name); //print_r($name);
$id = isset($_['id'])?$_['id']:''; $id = isset($_['id'])?$_['id']:'';

View File

@ -44,8 +44,6 @@ if(!function_exists('imagecreatefromjpeg')) {
$id = $_GET['id']; $id = $_GET['id'];
$l10n = new OC_L10N('contacts');
$contact = OC_Contacts_App::getContactVCard($id); $contact = OC_Contacts_App::getContactVCard($id);
// invalid vcard // invalid vcard