1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

adding space between) and {

This commit is contained in:
Thomas Mueller 2012-09-07 15:21:03 +02:00
parent b179feeea2
commit 089b7e8f8a
10 changed files with 27 additions and 27 deletions

View File

@ -18,7 +18,7 @@ if(is_null($id)) {
exit();
}
$vcard = OC_Contacts_App::getContactVCard( $id );
foreach($vcard->children as $property){
foreach($vcard->children as $property) {
if($property->name == 'CATEGORIES') {
$checksum = md5($property->serialize());
OCP\JSON::success(array(

View File

@ -51,7 +51,7 @@ class OC_Migration_Provider_Contacts extends OC_Migration_Provider{
$query = $this->content->prepare( 'SELECT * FROM `contacts_cards` WHERE `addressbookid` LIKE ?' );
$results = $query->execute( array( $oldid ) );
while( $row = $results->fetchRow() ){
while( $row = $results->fetchRow() ) {
// Import the contacts
$contactquery = OCP\DB::prepare( 'INSERT INTO `*PREFIX*contacts_cards` (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)' );
$contactquery->execute( array( $newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified'] ) );

View File

@ -23,7 +23,7 @@ if(isset($bookid)) {
$batchsize = OCP\Config::getUserValue(OCP\User::getUser(),
'contacts',
'export_batch_size', 20);
while($cardobjects = OC_Contacts_VCard::all($bookid, $start, $batchsize)){
while($cardobjects = OC_Contacts_VCard::all($bookid, $start, $batchsize)) {
foreach($cardobjects as $card) {
echo $card['carddata'] . $nl;
}

View File

@ -73,7 +73,7 @@ $lines = explode($nl, $file);
$inelement = false;
$parts = array();
$card = array();
foreach($lines as $line){
foreach($lines as $line) {
if(strtoupper(trim($line)) == 'BEGIN:VCARD') {
$inelement = true;
} elseif (strtoupper(trim($line)) == 'END:VCARD') {
@ -109,7 +109,7 @@ if(!count($parts) > 0) {
}
exit();
}
foreach($parts as $part){
foreach($parts as $part) {
$card = OC_VObject::parse($part);
if (!$card) {
$failed += 1;

View File

@ -110,7 +110,7 @@ class OC_Contacts_Addressbook {
* @param string $principaluri
* @return array
*/
public static function allWherePrincipalURIIs($principaluri){
public static function allWherePrincipalURIIs($principaluri) {
$uid = self::extractUserID($principaluri);
return self::all($uid);
}
@ -180,7 +180,7 @@ class OC_Contacts_Addressbook {
return false;
}
$uris = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$uris[] = $row['uri'];
}
@ -320,7 +320,7 @@ class OC_Contacts_Addressbook {
// First delete cards belonging to this addressbook.
$cards = OC_Contacts_VCard::all($id);
foreach($cards as $card){
foreach($cards as $card) {
try {
OC_Contacts_VCard::delete($card['id']);
} catch(Exception $e) {

View File

@ -247,7 +247,7 @@ class OC_Contacts_App {
* @brief returns the default categories of ownCloud
* @return (array) $categories
*/
public static function getDefaultCategories(){
public static function getDefaultCategories() {
return array(
(string)self::$l10n->t('Birthday'),
(string)self::$l10n->t('Business'),

View File

@ -81,7 +81,7 @@ class OC_Contacts_Hooks{
$info = explode('_', $name);
$aid = $info[1];
OC_Contacts_App::getAddressbook($aid);
foreach(OC_Contacts_VCard::all($aid) as $card){
foreach(OC_Contacts_VCard::all($aid) as $card) {
$vcard = OC_VObject::parse($card['carddata']);
if (!$vcard) {
continue;

View File

@ -147,7 +147,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
public function getCards($addressbookid) {
$data = OC_Contacts_VCard::all($addressbookid);
$cards = array();
foreach($data as $i){
foreach($data as $i) {
//OCP\Util::writeLog('contacts', __METHOD__.', uri: ' . $i['uri'], OCP\Util::DEBUG);
$cards[] = array(
'id' => $i['id'],

View File

@ -1,15 +1,15 @@
<?php
class OC_Search_Provider_Contacts extends OC_Search_Provider{
function search($query){
function search($query) {
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser(), 1);
if(count($addressbooks)==0 || !OCP\App::isEnabled('contacts')) {
return array();
}
$results=array();
$l = new OC_l10n('contacts');
foreach($addressbooks as $addressbook){
foreach($addressbooks as $addressbook) {
$vcards = OC_Contacts_VCard::all($addressbook['id']);
foreach($vcards as $vcard){
foreach($vcards as $vcard) {
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

View File

@ -90,7 +90,7 @@ class OC_Contacts_VCard {
* @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_cards` WHERE `id` = ?' );
$result = $stmt->execute(array($id));
@ -109,7 +109,7 @@ class OC_Contacts_VCard {
* @param string $uri the uri ('filename')
* @return associative array or false.
*/
public static function findWhereDAVDataIs($aid,$uri){
public static function findWhereDAVDataIs($aid,$uri) {
try {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? AND `uri` = ?' );
$result = $stmt->execute(array($aid,$uri));
@ -129,7 +129,7 @@ class OC_Contacts_VCard {
* This has to be changed to either TEL;TYPE=HOME,CELL:123456789 or TEL;TYPE=HOME;TYPE=CELL:123456789 - both are valid.
*/
public static function formatPropertyTypes(&$property) {
foreach($property->parameters as $key=>&$parameter){
foreach($property->parameters as $key=>&$parameter) {
$types = OC_Contacts_App::getTypesOfProperty($property->name);
if(is_array($types) && in_array(strtoupper($parameter->name), array_keys($types)) || strtoupper($parameter->name) == 'PREF') {
$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $parameter->name);
@ -146,7 +146,7 @@ class OC_Contacts_VCard {
*/
public static function decodeProperty(&$property) {
// Check out for encoded string and decode them :-[
foreach($property->parameters as $key=>&$parameter){
foreach($property->parameters as $key=>&$parameter) {
if(strtoupper($parameter->name) == 'ENCODING') {
if(strtoupper($parameter->value) == 'QUOTED-PRINTABLE') { // what kind of other encodings could be used?
// Decode quoted-printable and strip any control chars
@ -213,7 +213,7 @@ class OC_Contacts_VCard {
$upgrade = true;
//OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version, OCP\Util::DEBUG);
}
foreach($vcard->children as &$property){
foreach($vcard->children as &$property) {
// Decode string properties and remove obsolete properties.
if($upgrade && in_array($property->name, $stringprops)) {
self::decodeProperty($property);
@ -287,7 +287,7 @@ class OC_Contacts_VCard {
* @param $isChecked boolean If the vCard should be checked for validity and version.
* @return insertid on success or false.
*/
public static function add($aid, OC_VObject $card, $uri=null, $isChecked=false){
public static function add($aid, OC_VObject $card, $uri=null, $isChecked=false) {
if(is_null($card)) {
OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
return null;
@ -350,7 +350,7 @@ class OC_Contacts_VCard {
* @param string $data vCard file
* @return insertid
*/
public static function addFromDAVData($id,$uri,$data){
public static function addFromDAVData($id,$uri,$data) {
$card = OC_VObject::parse($data);
return self::add($id, $card, $uri);
}
@ -359,7 +359,7 @@ class OC_Contacts_VCard {
* @brief Mass updates an array of cards
* @param array $objects An array of [id, carddata].
*/
public static function updateDataByID($objects){
public static function updateDataByID($objects) {
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_cards` SET `carddata` = ?, `lastmodified` = ? WHERE `id` = ?' );
$now = new DateTime;
foreach($objects as $object) {
@ -395,7 +395,7 @@ class OC_Contacts_VCard {
* @param OC_VObject $card vCard file
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function edit($id, OC_VObject $card){
public static function edit($id, OC_VObject $card) {
$oldcard = self::find($id);
if (!$oldcard) {
OCP\Util::writeLog('contacts', __METHOD__.', id: '
@ -465,7 +465,7 @@ class OC_Contacts_VCard {
* @param string $data vCard file
* @return boolean
*/
public static function editFromDAVData($aid, $uri, $data){
public static function editFromDAVData($aid, $uri, $data) {
$oldcard = self::findWhereDAVDataIs($aid, $uri);
$card = OC_VObject::parse($data);
if(!$card) {
@ -491,7 +491,7 @@ class OC_Contacts_VCard {
* @param integer $id id of card
* @return boolean true on success, otherwise an exception will be thrown
*/
public static function delete($id){
public static function delete($id) {
$card = self::find($id);
if (!$card) {
OCP\Util::writeLog('contacts', __METHOD__.', id: '
@ -561,7 +561,7 @@ class OC_Contacts_VCard {
* @param string $uri the uri of the card
* @return boolean
*/
public static function deleteFromDAVData($aid,$uri){
public static function deleteFromDAVData($aid,$uri) {
$addressbook = OC_Contacts_Addressbook::find($aid);
if ($addressbook['userid'] != OCP\User::getUser()) {
$query = OCP\DB::prepare( 'SELECT `id` FROM `*PREFIX*contacts_cards` WHERE `addressbookid` = ? AND `uri` = ?' );
@ -692,7 +692,7 @@ class OC_Contacts_VCard {
'value' => $value,
'parameters' => array(),
'checksum' => md5($property->serialize()));
foreach($property->parameters as $parameter){
foreach($property->parameters as $parameter) {
// Faulty entries by kaddressbook
// Actually TYPE=PREF is correct according to RFC 2426
// but this way is more handy in the UI. Tanghus.