summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-07-19 23:48:17 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-07-20 00:18:23 +0200
commit1cbddcf211d81065bf91bacee5b318c48b6b27aa (patch)
tree750491cb581baa03884160e0bdf4e709489ce861 /apps
parent616f2f336e1e03aaf22aeed7196182b1890669b5 (diff)
downloadnextcloud-server-1cbddcf211d81065bf91bacee5b318c48b6b27aa.tar.gz
nextcloud-server-1cbddcf211d81065bf91bacee5b318c48b6b27aa.zip
Code style
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/ajax/activation.php8
-rw-r--r--apps/contacts/ajax/addaddressbook.php6
-rw-r--r--apps/contacts/ajax/addcontact.php10
-rw-r--r--apps/contacts/ajax/addproperty.php39
-rw-r--r--apps/contacts/ajax/categories/categoriesfor.php15
-rw-r--r--apps/contacts/ajax/categories/delete.php2
-rw-r--r--apps/contacts/ajax/contactdetails.php2
-rw-r--r--apps/contacts/ajax/createaddressbook.php2
-rw-r--r--apps/contacts/ajax/currentphoto.php2
-rw-r--r--apps/contacts/ajax/deletecard.php12
-rw-r--r--apps/contacts/ajax/deleteproperty.php11
-rw-r--r--apps/contacts/ajax/editaddress.php4
-rw-r--r--apps/contacts/ajax/editname.php6
-rw-r--r--apps/contacts/ajax/loadcard.php14
-rw-r--r--apps/contacts/ajax/loadintro.php2
-rw-r--r--apps/contacts/ajax/loadphoto.php2
-rw-r--r--apps/contacts/ajax/loghandler.php10
-rw-r--r--apps/contacts/ajax/oc_photo.php6
-rw-r--r--apps/contacts/ajax/savecrop.php20
-rw-r--r--apps/contacts/ajax/saveproperty.php8
-rw-r--r--apps/contacts/ajax/updateaddressbook.php2
-rw-r--r--apps/contacts/ajax/uploadimport.php28
-rw-r--r--apps/contacts/ajax/uploadphoto.php46
23 files changed, 152 insertions, 105 deletions
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php
index 74cb738ab8f..69173c54c44 100644
--- a/apps/contacts/ajax/activation.php
+++ b/apps/contacts/ajax/activation.php
@@ -16,8 +16,12 @@ $bookid = $_POST['bookid'];
$book = OC_Contacts_App::getAddressbook($bookid);// is owner access check
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
- OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
+ OCP\Util::writeLog('contacts',
+ 'ajax/activation.php: Error activating addressbook: '. $bookid,
+ OCP\Util::ERROR);
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
exit();
}
diff --git a/apps/contacts/ajax/addaddressbook.php b/apps/contacts/ajax/addaddressbook.php
index 3d7885fe468..40773704bb4 100644
--- a/apps/contacts/ajax/addaddressbook.php
+++ b/apps/contacts/ajax/addaddressbook.php
@@ -12,13 +12,15 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
debug('name: '.$_POST['name']);
$userid = OCP\USER::getUser();
$name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null;
-$description = isset($_POST['description'])?trim(strip_tags($_POST['description'])):null;
+$description = isset($_POST['description'])
+ ? trim(strip_tags($_POST['description']))
+ : null;
if(is_null($name)) {
bailOut('Cannot add addressbook with an empty name.');
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index 12f7bb9db96..6aaf5a9df35 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -37,13 +37,15 @@ $n = trim($_POST['n']);
$vcard = new OC_VObject('VCARD');
$vcard->setUID();
-$vcard->setString('FN',$fn);
-$vcard->setString('N',$n);
+$vcard->setString('FN', $fn);
+$vcard->setString('N', $n);
$id = OC_Contacts_VCard::add($aid, $vcard, null, $isnew);
if(!$id) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
- OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
+ OCP\Util::writeLog('contacts', 'ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
exit();
}
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 1b6db0c8f81..96f27b2b9bb 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null;
@@ -33,22 +33,26 @@ $value = isset($_POST['value'])?$_POST['value']:null;
$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
$vcard = OC_Contacts_App::getContactVCard($id);
+$l10n = OC_Contacts_App::$l10n;
if(!$name) {
- bailOut(OC_Contacts_App::$l10n->t('element name is not set.'));
+ bailOut($l10n->t('element name is not set.'));
}
if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
+ bailOut($l10n->t('id is not set.'));
}
if(!$vcard) {
- bailOut(OC_Contacts_App::$l10n->t('Could not parse contact: ').$id);
+ bailOut($l10n->t('Could not parse contact: ').$id);
}
-if(!is_array($value)){
+if(!is_array($value)) {
$value = trim($value);
- if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))) {
- bailOut(OC_Contacts_App::$l10n->t('Cannot add empty property.'));
+ if(!$value && in_array(
+ $name,
+ array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))
+ ) {
+ bailOut($l10n->t('Cannot add empty property.'));
}
} elseif($name === 'ADR') { // only add if non-empty elements.
$empty = true;
@@ -59,7 +63,7 @@ if(!is_array($value)){
}
}
if($empty) {
- bailOut(OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.'));
+ bailOut($l10n->t('At least one of the address fields has to be filled out.'));
}
}
@@ -68,12 +72,14 @@ $current = $vcard->select($name);
foreach($current as $item) {
$tmpvalue = (is_array($value)?implode(';', $value):$value);
if($tmpvalue == $item->value) {
- bailOut(OC_Contacts_App::$l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
+ bailOut($l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
}
}
if(is_array($value)) {
- ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+ // NOTE: Important, otherwise the compound value will
+ // be set in the order the fields appear in the form!
+ ksort($value);
$value = array_map('strip_tags', $value);
} else {
$value = strip_tags($value);
@@ -116,24 +122,25 @@ switch($name) {
$line = count($vcard->children) - 1;
-// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
+// Apparently Sabre_VObject_Parameter doesn't do well with
+// multiple values or I don't know how to do it. Tanghus.
foreach ($parameters as $key=>$element) {
if(is_array($element) && strtoupper($key) == 'TYPE') {
// NOTE: Maybe this doesn't only apply for TYPE?
// And it probably shouldn't be done here anyways :-/
- foreach($element as $e){
+ foreach($element as $e) {
if($e != '' && !is_null($e)){
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e);
+ $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e);
}
}
} else {
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element);
+ $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element);
}
}
$checksum = md5($vcard->children[$line]->serialize());
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error adding contact property: '.$name));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+ bailOut($l10n->t('Error adding contact property: '.$name));
}
OCP\JSON::success(array('data' => array( 'checksum' => $checksum )));
diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php
index 6b6fcad0ebb..8391b14b545 100644
--- a/apps/contacts/ajax/categories/categoriesfor.php
+++ b/apps/contacts/ajax/categories/categoriesfor.php
@@ -12,16 +12,23 @@ OCP\JSON::checkAppEnabled('contacts');
$id = isset($_GET['id'])?$_GET['id']:null;
if(is_null($id)) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided'))));
+ OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('No ID provided'))));
exit();
}
$vcard = OC_Contacts_App::getContactVCard( $id );
foreach($vcard->children as $property){
- //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
if($property->name == 'CATEGORIES') {
$checksum = md5($property->serialize());
- OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'value' => $property->value,
+ 'checksum' => $checksum,
+ )));
exit();
}
}
-OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
+OCP\JSON::error(array(
+ 'data' => array(
+ 'message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
index f53d852d603..bc9f3e14e87 100644
--- a/apps/contacts/ajax/categories/delete.php
+++ b/apps/contacts/ajax/categories/delete.php
@@ -11,7 +11,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once(__DIR__.'/../loghandler.php');
+require_once __DIR__.'/../loghandler.php';
$categories = isset($_POST['categories'])?$_POST['categories']:null;
diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
index d438f708b46..27d7611ade9 100644
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -20,7 +20,7 @@
*
*/
-require_once('loghandler.php');
+require_once 'loghandler.php';
// Check if we are a user
OCP\JSON::checkLoggedIn();
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index 2ec5f542bb3..8dbd63f6425 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -12,7 +12,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$userid = OCP\USER::getUser();
$name = trim(strip_tags($_POST['name']));
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
index 8f60eca08ec..96080e661ef 100644
--- a/apps/contacts/ajax/currentphoto.php
+++ b/apps/contacts/ajax/currentphoto.php
@@ -24,7 +24,7 @@
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
if (!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 1161c18abda..9777046fc82 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -23,17 +23,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
-
-// foreach($_SERVER as $key=>$value) {
-// OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG);
-// }
-// foreach($_POST as $key=>$value) {
-// debug($key.'=>'.print_r($value, true));
-// }
-// foreach($_GET as $key=>$value) {
-// debug($key.'=>'.print_r($value, true));
-// }
+require_once 'loghandler.php';
$id = isset($_POST['id'])?$_POST['id']:null;
if(!$id) {
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 90e5e64903e..6c81dc52b38 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -24,22 +24,23 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = $_POST['id'];
$checksum = $_POST['checksum'];
+$l10n = OC_Contacts_App::$l10n
$vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
-if(is_null($line)){
- bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'));
+if(is_null($line)) {
+ bailOut($l10n->t('Information about vCard is incorrect. Please reload the page.'));
exit();
}
unset($vcard->children[$line]);
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.'));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+ bailOut($l10n->t('Error deleting contact property.'));
}
OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php
index 1eb9429d79c..b5e4b72ed57 100644
--- a/apps/contacts/ajax/editaddress.php
+++ b/apps/contacts/ajax/editaddress.php
@@ -34,8 +34,8 @@ if($checksum) {
$tmpl->assign('adr', $adr, false);
}
-$tmpl->assign('id',$id);
-$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('id', $id);
+$tmpl->assign('adr_types', $adr_types);
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
index 9e7c090eeed..eb55634011d 100644
--- a/apps/contacts/ajax/editname.php
+++ b/apps/contacts/ajax/editname.php
@@ -9,7 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
@@ -25,8 +25,8 @@ if($id) {
}
}
$name = array_map('htmlspecialchars', $name['value']);
- $tmpl->assign('name',$name, false);
- $tmpl->assign('id',$id, false);
+ $tmpl->assign('name', $name, false);
+ $tmpl->assign('id', $id, false);
} else {
bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
}
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
index 1309faaa7a2..75fe33ada6f 100644
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -30,20 +30,20 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$requesttoken = $_GET['requesttoken'];
$freeSpace=OC_Filesystem::free_space('/');
-$freeSpace=max($freeSpace,0);
-$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
+$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');
-$tmpl = new OCP\Template('contacts','part.contact');
+$tmpl = new OCP\Template('contacts', 'part.contact');
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$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('adr_types', $adr_types);
+$tmpl->assign('phone_types', $phone_types);
+$tmpl->assign('email_types', $email_types);
$tmpl->assign('requesttoken', $requesttoken);
-$tmpl->assign('id','');
+$tmpl->assign('id', '');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php
index 6e8fcc4b049..1da08950ca0 100644
--- a/apps/contacts/ajax/loadintro.php
+++ b/apps/contacts/ajax/loadintro.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-$tmpl = new OCP\Template('contacts','part.no_contacts');
+$tmpl = new OCP\Template('contacts', 'part.no_contacts');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
index a35631055eb..be924b5db4d 100644
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -24,7 +24,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$id = isset($_GET['id']) ? $_GET['id'] : '';
$refresh = isset($_GET['refresh']) ? true : false;
diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php
index 831b2e50c1e..be4b98c1112 100644
--- a/apps/contacts/ajax/loghandler.php
+++ b/apps/contacts/ajax/loghandler.php
@@ -20,13 +20,15 @@
*
*/
-function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) {
+function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR)
+{
OCP\JSON::error(array('data' => array('message' => $msg)));
debug($msg, $tracelevel, $debuglevel);
exit();
}
-function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
+function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG)
+{
if(PHP_VERSION >= "5.4") {
$call = debug_backtrace(false, $tracelevel+1);
} else {
@@ -35,6 +37,8 @@ function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
error_log('trace: '.print_r($call, true));
$call = $call[$tracelevel];
if($debuglevel !== false) {
- OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel);
+ OCP\Util::writeLog('contacts',
+ $call['file'].'. Line: '.$call['line'].': '.$msg,
+ $debuglevel);
}
}
diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php
index 710179fffcc..fe37b530f82 100644
--- a/apps/contacts/ajax/oc_photo.php
+++ b/apps/contacts/ajax/oc_photo.php
@@ -22,7 +22,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
if(!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
@@ -50,7 +50,9 @@ if($image->width() > 400 || $image->height() > 400) {
$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
}
if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
- OCP\Util::writeLog('contacts','ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath,
+ OCP\Util::DEBUG);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index adce6be3b39..3958af5c07c 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -27,7 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$image = null;
@@ -48,7 +48,7 @@ if($id == '') {
bailOut('Missing contact id.');
}
-OCP\Util::writeLog('contacts','savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
+OCP\Util::writeLog('contacts', 'savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
$data = OC_Cache::get($tmpkey);
if($data) {
@@ -56,7 +56,9 @@ if($data) {
if($image->loadFromdata($data)) {
$w = ($w != -1 ? $w : $image->width());
$h = ($h != -1 ? $h : $image->height());
- OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h,
+ OCP\Util::DEBUG);
if($image->crop($x1, $y1, $w, $h)) {
if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) {
$card = OC_Contacts_App::getContactVCard($id);
@@ -65,7 +67,9 @@ if($data) {
bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.'));
}
if($card->__isset('PHOTO')) {
- OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php: PHOTO property exists.',
+ OCP\Util::DEBUG);
$property = $card->__get('PHOTO');
if(!$property) {
OC_Cache::remove($tmpkey);
@@ -76,8 +80,12 @@ if($data) {
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
$card->__set('PHOTO', $property);
} else {
- OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
- $card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
+ OCP\Util::writeLog('contacts',
+ 'savecrop.php: files: Adding PHOTO property.',
+ OCP\Util::DEBUG);
+ $card->addProperty('PHOTO',
+ $image->__toString(), array('ENCODING' => 'b',
+ 'TYPE' => $image->mimeType()));
}
$now = new DateTime;
$card->setString('REV', $now->format(DateTime::W3C));
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 5a0a7c14882..c3aaf5a9596 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -19,7 +19,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-require_once('loghandler.php');
+require_once 'loghandler.php';
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
@@ -39,9 +39,11 @@ if(!$id) {
if(!$checksum) {
bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
}
-if(is_array($value)){
+if(is_array($value)) {
$value = array_map('strip_tags', $value);
- ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+ // NOTE: Important, otherwise the compound value will be
+ // set in the order the fields appear in the form!
+ ksort($value);
//if($name == 'CATEGORIES') {
// $value = OC_Contacts_VCard::escapeDelimiters($value, ',');
//} else {
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index d3a772c727f..a14b2158431 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -11,7 +11,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
$bookid = $_POST['id'];
OC_Contacts_App::getAddressbook($bookid); // is owner access check
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
index 3c5a2d750ed..9fb271f54e8 100644
--- a/apps/contacts/ajax/uploadimport.php
+++ b/apps/contacts/ajax/uploadimport.php
@@ -24,7 +24,9 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
+
+$l10n = OC_Contacts_App::$l10n
$view = OCP\Files::getStorage('contacts');
if(!$view->file_exists('imports')) {
@@ -39,25 +41,29 @@ if($fn) {
OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn)));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+ bailOut($l10n->t('Error uploading contacts to storage.'));
}
}
// File input transfers are handled here
if (!isset($_FILES['importfile'])) {
- OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
- OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
+ OCP\Util::writeLog('contacts',
+ 'ajax/uploadphoto.php: No file was uploaded. Unknown error.',
+ OCP\Util::DEBUG);
+ OCP\JSON::error(array('
+ data' => array(
+ 'message' => 'No file was uploaded. Unknown error' )));
exit();
}
$error = $_FILES['importfile']['error'];
if($error !== UPLOAD_ERR_OK) {
$errors = array(
- 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")
+ 0=>$l10n->t("There is no error, the file uploaded with success"),
+ 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+ 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+ 3=>$l10n->t("The uploaded file was only partially uploaded"),
+ 4=>$l10n->t("No file was uploaded"),
+ 6=>$l10n->t("Missing a temporary folder")
);
bailOut($errors[$error]);
}
@@ -67,7 +73,7 @@ if(file_exists($file['tmp_name'])) {
if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) {
OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name'])));
} else {
- bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+ bailOut($l10n->t('Error uploading contacts to storage.'));
}
} else {
bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
index 6bb3fe8a5e0..4cd38db8c72 100644
--- a/apps/contacts/ajax/uploadphoto.php
+++ b/apps/contacts/ajax/uploadphoto.php
@@ -27,13 +27,13 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-require_once('loghandler.php');
-
+require_once 'loghandler.php';
+$l10n = OC_Contacts_App::$l10n;
// If it is a Drag'n'Drop transfer it's handled here.
$fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
if ($fn) {
if (!isset($_GET['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+ bailOut($l10n->t('No contact ID was submitted.'));
}
$id = $_GET['id'];
$tmpkey = 'contact-photo-'.md5($fn);
@@ -48,33 +48,38 @@ if ($fn) {
debug('Couldn\'t save correct image orientation: '.$tmpkey);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpkey)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'mime'=>$_SERVER['CONTENT_TYPE'],
+ 'name'=>$fn,
+ 'id'=>$id,
+ 'tmp'=>$tmpkey)));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
}
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey);
}
}
// Uploads from file dialog are handled here.
if (!isset($_POST['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+ bailOut($l10n->t('No contact ID was submitted.'));
}
if (!isset($_FILES['imagefile'])) {
- bailOut(OC_Contacts_App::$l10n->t('No file was uploaded. Unknown error'));
+ bailOut($l10n->t('No file was uploaded. Unknown error'));
}
$error = $_FILES['imagefile']['error'];
if($error !== UPLOAD_ERR_OK) {
$errors = array(
- 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")
+ 0=>$l10n->t("There is no error, the file uploaded with success"),
+ 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+ 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+ 3=>$l10n->t("The uploaded file was only partially uploaded"),
+ 4=>$l10n->t("No file was uploaded"),
+ 6=>$l10n->t("Missing a temporary folder")
);
bailOut($errors[$error]);
}
@@ -91,13 +96,20 @@ if(file_exists($file['tmp_name'])) {
debug('Couldn\'t save correct image orientation: '.$tmpkey);
}
if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpkey)));
+ OCP\JSON::success(array(
+ 'data' => array(
+ 'mime'=>$file['type'],
+ 'size'=>$file['size'],
+ 'name'=>$file['name'],
+ 'id'=>$_POST['id'],
+ 'tmp'=>$tmpkey,
+ )));
exit();
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+ bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
}
} else {
- bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
+ bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
}
} else {
bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');