1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Small coding style update

Fixup OC_Contacts_App
This commit is contained in:
Bart Visscher 2012-02-11 21:57:38 +01:00
parent 0d872d0169
commit e335f60004

View File

@ -10,7 +10,7 @@
* This class manages our app actions
*/
OC_Contacts_App::$l10n = new OC_L10N('contacts');
class OC_Contacts_App{
class OC_Contacts_App {
public static $l10n;
/**
@ -18,7 +18,7 @@ class OC_Contacts_App{
* @param int $id of contact
* @param Sabre_VObject_Component $vcard to render
*/
public static function renderDetails($id, $vcard, $new=false){
public static function renderDetails($id, $vcard, $new=false) {
$property_types = self::getAddPropertyOptions();
$adr_types = self::getTypesOfProperty('ADR');
$phone_types = self::getTypesOfProperty('TEL');
@ -46,9 +46,9 @@ class OC_Contacts_App{
OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
}
public static function getAddressbook($id){
public static function getAddressbook($id) {
$addressbook = OC_Contacts_Addressbook::find( $id );
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()){
if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
if ($addressbook === false) {
OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR);
}
@ -61,9 +61,9 @@ class OC_Contacts_App{
return $addressbook;
}
public static function getContactObject($id){
public static function getContactObject($id) {
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){
if( $card === false ) {
OC_Log::write('contacts', 'Contact could not be found: '.$id, OC_Log::ERROR);
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id)));
exit();
@ -77,12 +77,12 @@ class OC_Contacts_App{
* @brief Gets the VCard as an OC_VObject
* @returns The card or null if the card could not be parsed.
*/
public static function getContactVCard($id){
public static function getContactVCard($id) {
$card = self::getContactObject( $id );
$vcard = OC_VObject::parse($card['carddata']);
// Try to fix cards with missing 'N' field from pre ownCloud 4. Hot damn, this is ugly...
if(!is_null($vcard) && !$vcard->__isset('N')){
if(!is_null($vcard) && !$vcard->__isset('N')) {
$appinfo = $info=OC_App::getAppInfo('contacts');
if($appinfo['version'] >= 5) {
OC_Log::write('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OC_Log::DEBUG);
@ -100,10 +100,10 @@ class OC_Contacts_App{
return $vcard;
}
public static function getPropertyLineByChecksum($vcard, $checksum){
public static function getPropertyLineByChecksum($vcard, $checksum) {
$line = null;
for($i=0;$i<count($vcard->children);$i++){
if(md5($vcard->children[$i]->serialize()) == $checksum ){
for($i=0;$i<count($vcard->children);$i++) {
if(md5($vcard->children[$i]->serialize()) == $checksum ) {
$line = $i;
break;
}
@ -114,7 +114,7 @@ class OC_Contacts_App{
/**
* @return array of vcard prop => label
*/
public static function getAddPropertyOptions(){
public static function getAddPropertyOptions() {
$l10n = self::$l10n;
return array(
'ADR' => $l10n->t('Address'),
@ -127,9 +127,9 @@ class OC_Contacts_App{
/**
* @return types for property $prop
*/
public static function getTypesOfProperty($prop){
public static function getTypesOfProperty($prop) {
$l = self::$l10n;
switch($prop){
switch($prop) {
case 'ADR':
return array(
'WORK' => $l->t('Work'),