Contacts: cleanup OC_L10N usage
This commit is contained in:
parent
39f342d595
commit
623afb69b6
23 changed files with 29 additions and 59 deletions
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$book = array(
|
||||
|
|
|
@ -31,7 +31,6 @@ function bailOut($msg) {
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
$aid = $_POST['id'];
|
||||
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());
|
||||
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);
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ function debug($msg) {
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
foreach ($_POST as $key=>$element) {
|
||||
debug('_POST: '.$key.'=>'.$element);
|
||||
|
@ -55,7 +54,7 @@ $vcard->setString('N',$n);
|
|||
|
||||
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
|
||||
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);
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
$id = $_POST['id'];
|
||||
$vcard = OC_Contacts_App::getContactVCard( $id );
|
||||
|
@ -36,7 +35,7 @@ $value = $_POST['value'];
|
|||
if(!is_array($value)){
|
||||
$value = trim($value);
|
||||
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();
|
||||
}
|
||||
} elseif($name === 'ADR') { // only add if non-empty elements.
|
||||
|
@ -48,7 +47,7 @@ if(!is_array($value)){
|
|||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +58,7 @@ $current = $vcard->select($name);
|
|||
foreach($current as $item) {
|
||||
$tmpvalue = (is_array($value)?implode(';', $value):$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);
|
||||
exit();
|
||||
}
|
||||
|
@ -114,7 +113,7 @@ foreach ($parameters as $key=>$element) {
|
|||
$checksum = md5($vcard->children[$line]->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);
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
|
||||
|
|
|
@ -34,15 +34,14 @@ function debug($msg) {
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
$id = isset($_GET['id'])?$_GET['id']:null;
|
||||
if(is_null($id)) {
|
||||
bailOut($l->t('Missing ID'));
|
||||
bailOut(OC_Contacts_App::$l10n->t('Missing ID'));
|
||||
}
|
||||
$vcard = OC_Contacts_App::getContactVCard( $id );
|
||||
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);
|
||||
|
||||
|
@ -54,7 +53,7 @@ if(!isset($details['FN'])) {
|
|||
} elseif(isset($details['EMAIL'])) {
|
||||
$details['FN'] = array('value' => $details['EMAIL'][0]['value']);
|
||||
} else {
|
||||
$details['FN'] = array('value' => $l->t('Unknown'));
|
||||
$details['FN'] = array('value' => OC_Contacts_App::$l10n->t('Unknown'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,4 +72,4 @@ if(isset($details['PHOTO'])) {
|
|||
}
|
||||
$details['id'] = $id;
|
||||
|
||||
OC_JSON::success(array('data' => $details));
|
||||
OC_JSON::success(array('data' => $details));
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
|
@ -17,13 +15,13 @@ OC_JSON::checkAppEnabled('contacts');
|
|||
$userid = OC_User::getUser();
|
||||
$bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null);
|
||||
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);
|
||||
exit();
|
||||
}
|
||||
|
||||
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);
|
||||
//exit();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
|
|
|
@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
$id = $_GET['id'];
|
||||
$checksum = $_GET['checksum'];
|
||||
|
@ -34,15 +33,14 @@ $checksum = $_GET['checksum'];
|
|||
$vcard = OC_Contacts_App::getContactVCard( $id );
|
||||
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
|
||||
if(is_null($line)){
|
||||
$l=new OC_L10N('contacts');
|
||||
OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.'))));
|
||||
OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
unset($vcard->children[$line]);
|
||||
|
||||
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);
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
require_once('../../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('contacts');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
$tmpl = new OC_Template('contacts', 'part.import');
|
||||
$tmpl->assign('path', $_POST['path']);
|
||||
$tmpl->assign('filename', $_POST['filename']);
|
||||
|
|
|
@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
// foreach ($_POST as $key=>$element) {
|
||||
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
$l10n = new OC_L10N('contacts');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ OC_Log::write('contacts','ajax/savecrop.php: Huzzah!!!', OC_Log::DEBUG);
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
// foreach ($_POST as $key=>$element) {
|
||||
// OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);
|
||||
|
|
|
@ -26,7 +26,6 @@ require_once('../../../lib/base.php');
|
|||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
function bailOut($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));
|
||||
}
|
||||
if(!$id) {
|
||||
bailOut($l->t('id is not set.'));
|
||||
bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
|
||||
}
|
||||
if(!$checksum) {
|
||||
bailOut($l->t('checksum is not set.'));
|
||||
bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
|
||||
}
|
||||
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 );
|
||||
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
|
||||
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;
|
||||
|
||||
if($element != $name) {
|
||||
bailOut($l->t('Something went FUBAR. ').$name.' != '.$element);
|
||||
bailOut(OC_Contacts_App::$l10n->t('Something went FUBAR. ').$name.' != '.$element);
|
||||
}
|
||||
|
||||
switch($element) {
|
||||
|
@ -123,7 +122,7 @@ $checksum = md5($vcard->children[$line]->serialize());
|
|||
debug('New checksum: '.$checksum);
|
||||
|
||||
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);
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ $vcard = OC_Contacts_App::getContactVCard( $id );
|
|||
|
||||
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
|
||||
if(is_null($line)){
|
||||
$l=new OC_L10N('contacts');
|
||||
OC_JSON::error(array('data' => array( 'message' => $l->t('Information about vCard is incorrect. Please reload the page.'))));
|
||||
OC_JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_JSON::checkAppEnabled('contacts');
|
||||
|
|
|
@ -94,14 +94,13 @@ if (!isset($_FILES['imagefile'])) {
|
|||
}
|
||||
$error = $_FILES['imagefile']['error'];
|
||||
if($error !== UPLOAD_ERR_OK) {
|
||||
$l=new OC_L10N('contacts');
|
||||
$errors = array(
|
||||
0=>$l->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'),
|
||||
2=>$l->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"),
|
||||
4=>$l->t("No file was uploaded"),
|
||||
6=>$l->t("Missing a temporary folder")
|
||||
0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
|
||||
1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
|
||||
2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
|
||||
3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
|
||||
4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
|
||||
6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
|
||||
);
|
||||
bailOut($errors[$error]);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
$l=new OC_L10N('contacts');
|
||||
|
||||
OC::$CLASSPATH['OC_Contacts_App'] = 'apps/contacts/lib/app.php';
|
||||
OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
|
||||
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
|
||||
|
@ -18,9 +16,9 @@ OC_App::addNavigationEntry( array(
|
|||
'order' => 10,
|
||||
'href' => OC_Helper::linkTo( 'contacts', 'index.php' ),
|
||||
'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ),
|
||||
'name' => $l->t('Contacts') ));
|
||||
'name' => OC_Contacts_App::$l10n->t('Contacts') ));
|
||||
|
||||
|
||||
OC_APP::registerPersonal('contacts','settings');
|
||||
OC_UTIL::addScript('contacts', 'loader');
|
||||
require_once('apps/contacts/lib/search.php');
|
||||
require_once('apps/contacts/lib/search.php');
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<?php
|
||||
$l=new OC_L10N('contacts');
|
||||
?>
|
||||
<form id="contacts_addcardform">
|
||||
<?php if(count($_['addressbooks'])==1): ?>
|
||||
<input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>">
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
$l=new OC_L10N('contacts');
|
||||
$id = isset($_['id']) ? $_['id'] : '';
|
||||
?>
|
||||
<div id="card">
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
$l=new OC_L10N('contacts');
|
||||
$name = isset($_['name'])?$_['name']:'';
|
||||
//print_r($name);
|
||||
$id = isset($_['id'])?$_['id']:'';
|
||||
|
|
|
@ -44,8 +44,6 @@ if(!function_exists('imagecreatefromjpeg')) {
|
|||
|
||||
$id = $_GET['id'];
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
$contact = OC_Contacts_App::getContactVCard($id);
|
||||
|
||||
// invalid vcard
|
||||
|
|
Loading…
Reference in a new issue