diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-07-20 00:17:59 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-07-20 00:18:23 +0200 |
commit | b8eea32478df17bc0f512376022de4bfd827af49 (patch) | |
tree | c30e3516eb8c562434657097edb80a7c2a8139db /apps/contacts | |
parent | 1cbddcf211d81065bf91bacee5b318c48b6b27aa (diff) | |
download | nextcloud-server-b8eea32478df17bc0f512376022de4bfd827af49.tar.gz nextcloud-server-b8eea32478df17bc0f512376022de4bfd827af49.zip |
Coding style.
Diffstat (limited to 'apps/contacts')
-rw-r--r-- | apps/contacts/lib/addressbook.php | 80 | ||||
-rw-r--r-- | apps/contacts/lib/app.php | 10 | ||||
-rw-r--r-- | apps/contacts/lib/search.php | 6 | ||||
-rw-r--r-- | apps/contacts/lib/vcard.php | 126 |
4 files changed, 111 insertions, 111 deletions
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index 9d584ff6d61..65e02312bde 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -37,17 +37,17 @@ /** * This class manages our addressbooks. */ -class OC_Contacts_Addressbook{ +class OC_Contacts_Addressbook { /** * @brief Returns the list of addressbooks for a specific user. * @param string $uid * @param boolean $active Only return addressbooks with this $active state, default(=false) is don't care * @return array or false. */ - public static function all($uid, $active=false){ + public static function all($uid, $active=false) { $values = array($uid); $active_where = ''; - if ($active){ + if ($active) { $active_where = ' AND active = ?'; $values[] = 1; } @@ -55,13 +55,13 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' . $active_where . ' ORDER BY displayname' ); $result = $stmt->execute($values); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG); return false; } $addressbooks = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $addressbooks[] = $row; } if(!$active && !count($addressbooks)) { @@ -76,8 +76,8 @@ class OC_Contacts_Addressbook{ * @param integer $uid User id. If null current user will be used. * @return array */ - public static function activeIds($uid = null){ - if(is_null($uid)){ + public static function activeIds($uid = null) { + if(is_null($uid)) { $uid = OCP\USER::getUser(); } $activeaddressbooks = self::all($uid, true); @@ -93,7 +93,7 @@ class OC_Contacts_Addressbook{ * @param string $uid * @return array */ - public static function active($uid){ + public static function active($uid) { return self::all($uid, true); } @@ -112,13 +112,13 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return associative array or false. */ - public static function find($id){ + public static function find($id) { try { $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -129,11 +129,11 @@ class OC_Contacts_Addressbook{ * @brief Adds default address book * @return $id ID of the newly created addressbook or false on error. */ - public static function addDefault($uid = null){ + public static function addDefault($uid = null) { if(is_null($uid)) { $uid = OCP\USER::getUser(); } - $id = self::add($uid,'Contacts','Default Address Book'); + $id = self::add($uid,'Contacts', 'Default Address Book'); if($id !== false) { self::setActive($id, true); } @@ -147,13 +147,13 @@ class OC_Contacts_Addressbook{ * @param string $description * @return insertid */ - public static function add($uid,$name,$description=''){ + public static function add($uid,$name,$description='') { try { $stmt = OCP\DB::prepare( 'SELECT uri FROM *PREFIX*contacts_addressbooks WHERE userid = ? ' ); $result = $stmt->execute(array($uid)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' uid: '.$uid, OCP\Util::DEBUG); return false; } $uris = array(); @@ -166,8 +166,8 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' ); $result = $stmt->execute(array($uid,$name,$uri,$description,1)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG); return false; } @@ -182,16 +182,16 @@ class OC_Contacts_Addressbook{ * @param string $description * @return insertid or false */ - public static function addFromDAVData($principaluri,$uri,$name,$description){ + public static function addFromDAVData($principaluri,$uri,$name,$description) { $uid = self::extractUserID($principaluri); try { $stmt = OCP\DB::prepare('INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)'); $result = $stmt->execute(array($uid,$name,$uri,$description,1)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uid: '.$uid,OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', uri: '.$uri,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uid: '.$uid, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', uri: '.$uri, OCP\Util::DEBUG); return false; } @@ -205,14 +205,14 @@ class OC_Contacts_Addressbook{ * @param string $description * @return boolean */ - public static function edit($id,$name,$description){ + public static function edit($id,$name,$description) { // Need these ones for checking uri $addressbook = self::find($id); - if(is_null($name)){ + if(is_null($name)) { $name = $addressbook['name']; } - if(is_null($description)){ + if(is_null($description)) { $description = $addressbook['description']; } @@ -220,8 +220,8 @@ class OC_Contacts_Addressbook{ $stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_addressbooks SET displayname=?,description=?, ctag=ctag+1 WHERE id=?'); $result = $stmt->execute(array($name,$description,$id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -234,15 +234,15 @@ class OC_Contacts_Addressbook{ * @param boolean $active * @return boolean */ - public static function setActive($id,$active){ + public static function setActive($id,$active) { $sql = 'UPDATE *PREFIX*contacts_addressbooks SET active = ? WHERE id = ?'; - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id.', active: '.intval($active), OCP\Util::ERROR); try { $stmt = OCP\DB::prepare($sql); $stmt->execute(array(intval($active), $id)); return true; } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR); return false; } } @@ -252,7 +252,7 @@ class OC_Contacts_Addressbook{ * @param integer $id ID of the address book. * @return boolean */ - public static function isActive($id){ + public static function isActive($id) { $sql = 'SELECT active FROM *PREFIX*contacts_addressbooks WHERE id = ?'; try { $stmt = OCP\DB::prepare( $sql ); @@ -260,7 +260,7 @@ class OC_Contacts_Addressbook{ $row = $result->fetchRow(); return (bool)$row['active']; } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); } } @@ -269,13 +269,13 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return boolean */ - public static function delete($id){ + public static function delete($id) { self::setActive($id, false); try { $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' ); $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(),OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception for '.$id.': '.$e->getMessage(), OCP\Util::ERROR); return false; } @@ -292,7 +292,7 @@ class OC_Contacts_Addressbook{ * @param integer $id * @return boolean */ - public static function touch($id){ + public static function touch($id) { $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' ); $stmt->execute(array($id)); @@ -305,11 +305,11 @@ class OC_Contacts_Addressbook{ * @param array $existing existing addressbook URIs * @return string new name */ - public static function createURI($name,$existing){ + public static function createURI($name,$existing) { $name = str_replace(' ', '_', strtolower($name)); $newname = $name; $i = 1; - while(in_array($newname,$existing)){ + while(in_array($newname, $existing)) { $newname = $name.$i; $i = $i + 1; } @@ -320,8 +320,8 @@ class OC_Contacts_Addressbook{ * @brief gets the userid from a principal path * @return string */ - public static function extractUserID($principaluri){ - list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri); + public static function extractUserID($principaluri) { + list($prefix, $userid) = Sabre_DAV_URLUtil::splitPath($principaluri); return $userid; } } diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 046ceb0bf00..689149367fa 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -61,11 +61,11 @@ class OC_Contacts_App { if(!is_null($vcard) && !$vcard->__isset('N')) { $version = OCP\App::getAppVersion('contacts'); if($version >= 5) { - OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG); } - OCP\Util::writeLog('contacts','getContactVCard, Missing N field', OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'getContactVCard, Missing N field', OCP\Util::DEBUG); if($vcard->__isset('FN')) { - OCP\Util::writeLog('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG); $n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;'; $vcard->setString('N', $n); OC_Contacts_VCard::edit( $id, $vcard); @@ -203,9 +203,9 @@ class OC_Contacts_App { foreach($vccontacts as $vccontact) { $cards[] = $vccontact['carddata']; } - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', scanning: '.$batchsize.' starting from '.$start, OCP\Util::DEBUG); // only reset on first batch. - self::getVCategories()->rescan($cards, true, ($start==0?true:false)); + self::getVCategories()->rescan($cards, true, ($start == 0 ? true : false)); $start += $batchsize; } } diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php index 5d9ca97e761..53aa2b48496 100644 --- a/apps/contacts/lib/search.php +++ b/apps/contacts/lib/search.php @@ -2,7 +2,7 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{ function search($query){ $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1); - if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')){ + if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')) { return array(); } $results=array(); @@ -10,9 +10,9 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{ foreach($addressbooks as $addressbook){ $vcards = OC_Contacts_VCard::all($addressbook['id']); foreach($vcards as $vcard){ - if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){ + if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) { $link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']); - $results[]=new OC_Search_Result($vcard['fullname'],'', $link,(string)$l->t('Contact'));//$name,$text,$link,$type + $results[]=new OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type } } } diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 4f1ba5f08df..732c5a22581 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -63,9 +63,9 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( $prep ); $result = $stmt->execute($id); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $id),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'SQL:'.$prep,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $id), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'SQL:'.$prep, OCP\Util::DEBUG); return false; } } elseif(is_int($id) || is_string($id)) { @@ -74,12 +74,12 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( $sql ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '. $id, OCP\Util::DEBUG); return false; } } else { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.'. Addressbook id(s) argument is empty: '. $id, OCP\Util::DEBUG); return false; } $cards = array(); @@ -102,8 +102,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' ); $result = $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '. $id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '. $id, OCP\Util::DEBUG); return false; } @@ -121,8 +121,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' ); $result = $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); return false; } @@ -177,16 +177,16 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uid'.$uid, OCP\Util::DEBUG); return false; } - if($result->numRows() > 0){ + if($result->numRows() > 0) { while(true) { - $tmpuid = substr(md5(rand().time()),0,10); + $tmpuid = substr(md5(rand().time()), 0, 10); $uri = $tmpuid.'.vcf'; - $result = $stmt->execute(array($aid,$uri)); - if($result->numRows() > 0){ + $result = $stmt->execute(array($aid, $uri)); + if($result->numRows() > 0) { continue; } else { $uid = $tmpuid; @@ -225,29 +225,29 @@ class OC_Contacts_VCard{ } // Fix format of type parameters. if($upgrade && in_array($property->name, $typeprops)) { - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(), OCP\Util::DEBUG); self::formatPropertyTypes($property); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(), OCP\Util::DEBUG); } - if($property->name == 'FN'){ + if($property->name == 'FN') { $fn = $property->value; } - if($property->name == 'N'){ + if($property->name == 'N') { $n = $property->value; } - if($property->name == 'UID'){ + if($property->name == 'UID') { $uid = $property->value; } - if($property->name == 'ORG'){ + if($property->name == 'ORG') { $org = $property->value; } - if($property->name == 'EMAIL' && is_null($email)){ // only use the first email as substitute for missing N or FN. + if($property->name == 'EMAIL' && is_null($email)) { // only use the first email as substitute for missing N or FN. $email = $property->value; } } // Check for missing 'N', 'FN' and 'UID' properties if(!$fn) { - if($n && $n != ';;;;'){ + if($n && $n != ';;;;') { $fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2))); } elseif($email) { $fn = $email; @@ -257,21 +257,21 @@ class OC_Contacts_VCard{ $fn = 'Unknown Name'; } $vcard->setString('FN', $fn); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn, OCP\Util::DEBUG); } - if(!$n || $n == ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-) + if(!$n || $n == ';;;;') { // Fix missing 'N' field. Ugly hack ahead ;-) $slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse. if(count($slice) < 2) { // If not enought, add one more... $slice[] = ""; } $n = implode(';', $slice).';;;'; $vcard->setString('N', $n); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n, OCP\Util::DEBUG); } if(!$uid) { $vcard->setUID(); $uid = $vcard->getAsString('UID'); - OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid, OCP\Util::DEBUG); } if(self::trueUID($aid, $uid)) { $vcard->setString('UID', $uid); @@ -288,8 +288,8 @@ class OC_Contacts_VCard{ * @return insertid on success or false. */ public static function add($aid, OC_VObject $card, $uri=null, $isnew=false){ - if(is_null($card)){ - OCP\Util::writeLog('contacts','OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR); + if(is_null($card)) { + OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR); return null; }; @@ -298,7 +298,7 @@ class OC_Contacts_VCard{ self::updateValuesFromAdd($aid, $card); } - $card->setString('VERSION','3.0'); + $card->setString('VERSION', '3.0'); // Add product ID is missing. $prodid = trim($card->getAsString('PRODID')); if(!$prodid) { @@ -323,8 +323,8 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($aid,$fn,$data,$uri,time())); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri'.$uri, OCP\Util::DEBUG); return false; } $newid = OCP\DB::insertid('*PREFIX*contacts_cards'); @@ -355,15 +355,15 @@ class OC_Contacts_VCard{ $now = new DateTime; foreach($objects as $object) { $vcard = OC_VObject::parse($object[1]); - if(!is_null($vcard)){ + if(!is_null($vcard)) { $vcard->setString('REV', $now->format(DateTime::W3C)); $data = $vcard->serialize(); try { $result = $stmt->execute(array($data,time(),$object[0])); //OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$object[0],OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$object[0], OCP\Util::DEBUG); } } } @@ -397,8 +397,8 @@ class OC_Contacts_VCard{ try { $result = $stmt->execute(array($fn,$data,time(),$id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id'.$id, OCP\Util::DEBUG); return false; } @@ -414,11 +414,11 @@ class OC_Contacts_VCard{ * @param string $data vCard file * @return boolean */ - public static function editFromDAVData($aid,$uri,$data){ - $oldcard = self::findWhereDAVDataIs($aid,$uri); + public static function editFromDAVData($aid, $uri, $data){ + $oldcard = self::findWhereDAVDataIs($aid, $uri); $card = OC_VObject::parse($data); if(!$card) { - OCP\Util::writeLog('contacts','OC_Contacts_VCard::editFromDAVData. Unable to parse VCARD, uri: '.$uri,OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', Unable to parse VCARD, uri: '.$uri, OCP\Util::ERROR); return false; } return self::edit($oldcard['id'], $card); @@ -435,8 +435,8 @@ class OC_Contacts_VCard{ try { $stmt->execute(array($id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', id: '.$id, OCP\Util::DEBUG); return false; } @@ -455,8 +455,8 @@ class OC_Contacts_VCard{ try { $stmt->execute(array($aid,$uri)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', aid: '.$aid.' uri: '.$uri, OCP\Util::DEBUG); return false; } OC_Contacts_Addressbook::touch($aid); @@ -485,14 +485,14 @@ class OC_Contacts_VCard{ * @return array */ public static function unescapeDelimiters($value, $delimiter=';') { - $array = explode($delimiter,$value); + $array = explode($delimiter, $value); for($i=0;$i<count($array);$i++) { - if(substr($array[$i],-1,1)=="\\") { + if(substr($array[$i],-1, 1)=="\\") { if(isset($array[$i+1])) { - $array[$i] = substr($array[$i],0,count($array[$i])-2).$delimiter.$array[$i+1]; + $array[$i] = substr($array[$i], 0, count($array[$i])-2).$delimiter.$array[$i+1]; unset($array[$i+1]); } else { - $array[$i] = substr($array[$i],0,count($array[$i])-2).$delimiter; + $array[$i] = substr($array[$i], 0, count($array[$i])-2).$delimiter; } $i = $i - 1; } @@ -508,12 +508,12 @@ class OC_Contacts_VCard{ * * look at code ... */ - public static function structureContact($object){ + public static function structureContact($object) { $details = array(); foreach($object->children as $property){ $temp = self::structureProperty($property); if(!is_null($temp)) { - if(array_key_exists($property->name,$details)){ + if(array_key_exists($property->name, $details)) { $details[$property->name][] = $temp; } else{ @@ -537,10 +537,10 @@ class OC_Contacts_VCard{ * NOTE: $value is not escaped anymore. It shouldn't make any difference * but we should look out for any problems. */ - public static function structureProperty($property){ + public static function structureProperty($property) { $value = $property->value; //$value = htmlspecialchars($value); - if($property->name == 'ADR' || $property->name == 'N'){ + if($property->name == 'ADR' || $property->name == 'N') { $value = self::unescapeDelimiters($value); } elseif($property->name == 'BDAY') { if(strpos($value, '-') === false) { @@ -560,17 +560,17 @@ class OC_Contacts_VCard{ // Faulty entries by kaddressbook // Actually TYPE=PREF is correct according to RFC 2426 // but this way is more handy in the UI. Tanghus. - if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){ + if($parameter->name == 'TYPE' && $parameter->value == 'PREF') { $parameter->name = 'PREF'; $parameter->value = '1'; } // NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters // like TYPE=HOME,CELL,VOICE. Tanghus. - if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE'){ - if (isset($temp['parameters'][$parameter->name])){ + if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE') { + if (isset($temp['parameters'][$parameter->name])) { $temp['parameters'][$parameter->name][] = $parameter->value; } - else{ + else { $temp['parameters'][$parameter->name] = array($parameter->value); } } @@ -588,7 +588,7 @@ class OC_Contacts_VCard{ * @return boolean * */ - public static function moveToAddressBook($aid, $id){ + public static function moveToAddressBook($aid, $id) { OC_Contacts_App::getAddressbook($aid); // check for user ownership. if(is_array($id)) { $id_sql = join(',', array_fill(0, count($id), '?')); @@ -599,9 +599,9 @@ class OC_Contacts_VCard{ $vals = array_merge((array)$aid, $id); $result = $stmt->execute($vals); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::ERROR); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', SQL:'.$prep,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::ERROR); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', ids: '.join(',', $vals), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', SQL:'.$prep, OCP\Util::DEBUG); return false; } } else { @@ -609,8 +609,8 @@ class OC_Contacts_VCard{ $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' ); $result = $stmt->execute(array($aid, $id)); } catch(Exception $e) { - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(),OCP\Util::DEBUG); - OCP\Util::writeLog('contacts',__CLASS__.'::'.__METHOD__.' id: '.$id,OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.', exception: '.$e->getMessage(), OCP\Util::DEBUG); + OCP\Util::writeLog('contacts', __CLASS__.'::'.__METHOD__.' id: '.$id, OCP\Util::DEBUG); return false; } } |