2011-09-17 00:26:57 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ownCloud - Addressbook
|
|
|
|
*
|
|
|
|
* @author Jakob Sack
|
|
|
|
* @copyright 2011 Jakob Sack mail@jakobsack.de
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* The following SQL statement is just a help for developers and will not be
|
|
|
|
* executed!
|
|
|
|
*
|
|
|
|
* CREATE TABLE contacts_cards (
|
|
|
|
* id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
|
|
|
* addressbookid INT(11) UNSIGNED NOT NULL,
|
|
|
|
* fullname VARCHAR(255),
|
|
|
|
* carddata TEXT,
|
|
|
|
* uri VARCHAR(100),
|
|
|
|
* lastmodified INT(11) UNSIGNED
|
|
|
|
* );
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class manages our vCards
|
|
|
|
*/
|
|
|
|
class OC_Contacts_VCard{
|
|
|
|
/**
|
|
|
|
* @brief Returns all cards of an address book
|
|
|
|
* @param integer $id
|
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* The cards are associative arrays. You'll find the original vCard in
|
|
|
|
* ['carddata']
|
|
|
|
*/
|
|
|
|
public static function all($id){
|
2012-02-14 02:15:21 +01:00
|
|
|
$result = null;
|
2011-12-30 21:07:16 +01:00
|
|
|
if(is_array($id)) {
|
|
|
|
$id_sql = join(',', array_fill(0, count($id), '?'));
|
|
|
|
$prep = 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid IN ('.$id_sql.') ORDER BY fullname';
|
|
|
|
try {
|
|
|
|
$stmt = OC_DB::prepare( $prep );
|
|
|
|
$result = $stmt->execute($id);
|
|
|
|
} catch(Exception $e) {
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
|
|
|
|
}
|
2012-02-14 02:15:21 +01:00
|
|
|
} elseif($id) {
|
|
|
|
try {
|
|
|
|
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
|
|
|
|
$result = $stmt->execute(array($id));
|
|
|
|
} catch(Exception $e) {
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '. $id,OC_Log::DEBUG);
|
|
|
|
}
|
2011-12-30 21:07:16 +01:00
|
|
|
}
|
2011-12-09 15:10:51 +01:00
|
|
|
$cards = array();
|
2012-02-14 02:15:21 +01:00
|
|
|
if(!is_null($result)) {
|
|
|
|
while( $row = $result->fetchRow()){
|
|
|
|
$cards[] = $row;
|
|
|
|
}
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
|
2011-12-09 15:10:51 +01:00
|
|
|
return $cards;
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns a card
|
|
|
|
* @param integer $id
|
|
|
|
* @return associative array
|
|
|
|
*/
|
|
|
|
public static function find($id){
|
|
|
|
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' );
|
|
|
|
$result = $stmt->execute(array($id));
|
|
|
|
|
|
|
|
return $result->fetchRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief finds a card by its DAV Data
|
|
|
|
* @param integer $aid Addressbook id
|
|
|
|
* @param string $uri the uri ('filename')
|
|
|
|
* @return associative array
|
|
|
|
*/
|
|
|
|
public static function findWhereDAVDataIs($aid,$uri){
|
|
|
|
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
|
|
|
|
$result = $stmt->execute(array($aid,$uri));
|
|
|
|
|
|
|
|
return $result->fetchRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds a card
|
|
|
|
* @param integer $id Addressbook id
|
|
|
|
* @param string $data vCard file
|
2012-02-08 07:56:43 +01:00
|
|
|
* @return insertid on success or null if card is not parseable.
|
2011-09-17 00:26:57 +02:00
|
|
|
*/
|
|
|
|
public static function add($id,$data){
|
|
|
|
$fn = null;
|
|
|
|
|
2011-09-20 14:41:17 +02:00
|
|
|
$card = OC_VObject::parse($data);
|
2011-09-17 00:26:57 +02:00
|
|
|
if(!is_null($card)){
|
2011-09-20 14:41:17 +02:00
|
|
|
$fn = $card->getAsString('FN');
|
2012-02-08 07:56:43 +01:00
|
|
|
if(!$fn){ // Fix missing 'FN' field.
|
|
|
|
$n = $card->getAsString('N');
|
|
|
|
if(!is_null($n)){
|
|
|
|
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
|
|
|
|
$card->setString('FN', $fn);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'FN\' field: '.$fn,OC_Log::DEBUG);
|
|
|
|
} else {
|
|
|
|
$fn = 'Unknown Name';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$n = $card->getAsString('N');
|
|
|
|
if(!$n){ // Fix missing 'N' field.
|
|
|
|
$n = implode(';', array_reverse(array_slice(explode(' ', $fn), 0, 2))).';;;';
|
|
|
|
$card->setString('N', $n);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
|
|
|
|
}
|
2011-09-20 14:41:17 +02:00
|
|
|
$uid = $card->getAsString('UID');
|
2012-02-14 01:56:38 +01:00
|
|
|
if(!$uid){
|
2011-09-20 14:41:17 +02:00
|
|
|
$card->setUID();
|
|
|
|
$uid = $card->getAsString('UID');
|
2011-09-17 00:26:57 +02:00
|
|
|
};
|
2011-09-20 14:41:17 +02:00
|
|
|
$uri = $uid.'.vcf';
|
2012-01-12 11:26:11 +01:00
|
|
|
|
|
|
|
// Add product ID.
|
|
|
|
$prodid = trim($card->getAsString('PRODID'));
|
|
|
|
if(!$prodid) {
|
2012-02-09 19:04:07 +01:00
|
|
|
$appinfo = OC_App::getAppInfo('contacts');
|
2012-02-07 03:17:28 +01:00
|
|
|
$prodid = '//ownCloud//NONSGML '.$appinfo['name'].' '.$appinfo['version'].'//EN';
|
2012-01-12 11:26:11 +01:00
|
|
|
$card->setString('PRODID', $prodid);
|
|
|
|
}
|
2011-09-20 14:41:17 +02:00
|
|
|
// VCARD must have a version
|
|
|
|
$version = $card->getAsString('VERSION');
|
2011-11-09 11:34:04 +01:00
|
|
|
// Add version if needed
|
2012-01-11 06:20:06 +01:00
|
|
|
if(!$version){
|
2011-11-09 11:34:04 +01:00
|
|
|
$card->add(new Sabre_VObject_Property('VERSION','3.0'));
|
2012-01-11 06:20:06 +01:00
|
|
|
//$data = $card->serialize();
|
|
|
|
}/* else {
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Version already set as: '.$version,OC_Log::DEBUG);
|
|
|
|
}*/
|
|
|
|
$now = new DateTime;
|
|
|
|
$card->setString('REV', $now->format(DateTime::W3C));
|
|
|
|
$data = $card->serialize();
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
// that's hard. Creating a UID and not saving it
|
2012-02-08 07:56:43 +01:00
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Error parsing VCard: '.$data,OC_Log::ERROR);
|
|
|
|
return null; // Ditch cards that can't be parsed by Sabre.
|
|
|
|
//$uid = self::createUID();
|
|
|
|
//$uri = $uid.'.vcf';
|
2011-09-17 00:26:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
|
|
|
|
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
|
2012-01-09 23:14:11 +01:00
|
|
|
$newid = OC_DB::insertid('*PREFIX*contacts_cards');
|
2011-09-17 00:26:57 +02:00
|
|
|
|
|
|
|
OC_Contacts_Addressbook::touch($id);
|
|
|
|
|
2012-01-09 23:14:11 +01:00
|
|
|
return $newid;
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Adds a card with the data provided by sabredav
|
|
|
|
* @param integer $id Addressbook id
|
|
|
|
* @param string $uri the uri the card will have
|
|
|
|
* @param string $data vCard file
|
|
|
|
* @return insertid
|
|
|
|
*/
|
|
|
|
public static function addFromDAVData($id,$uri,$data){
|
2012-02-14 01:56:38 +01:00
|
|
|
$fn = $n = $uid = null;
|
2012-01-19 19:47:09 +01:00
|
|
|
$email = null;
|
2011-09-20 14:41:17 +02:00
|
|
|
$card = OC_VObject::parse($data);
|
2011-09-17 00:26:57 +02:00
|
|
|
if(!is_null($card)){
|
|
|
|
foreach($card->children as $property){
|
|
|
|
if($property->name == 'FN'){
|
|
|
|
$fn = $property->value;
|
|
|
|
}
|
2012-02-09 19:04:07 +01:00
|
|
|
if($property->name == 'N'){
|
|
|
|
$n = $property->value;
|
|
|
|
}
|
2012-02-14 01:56:38 +01:00
|
|
|
if($property->name == 'UID'){
|
|
|
|
$uid = $property->value;
|
|
|
|
}
|
2012-01-19 19:47:09 +01:00
|
|
|
if($property->name == 'EMAIL' && is_null($email)){
|
|
|
|
$email = $property->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!$fn) {
|
2012-02-09 19:04:07 +01:00
|
|
|
if($n){
|
|
|
|
$fn = join(' ', array_reverse(array_slice(explode(';', $n), 0, 2)));
|
|
|
|
} elseif($email) {
|
2012-01-19 19:47:09 +01:00
|
|
|
$fn = $email;
|
|
|
|
} else {
|
2012-02-08 07:56:43 +01:00
|
|
|
$fn = 'Unknown Name';
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
2012-02-06 14:18:40 +01:00
|
|
|
$card->addProperty('FN', $fn);
|
2012-01-19 19:47:09 +01:00
|
|
|
$data = $card->serialize();
|
2012-02-09 19:04:07 +01:00
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'FN\' field: '.$n,OC_Log::DEBUG);
|
|
|
|
}
|
|
|
|
if(!$n){ // Fix missing 'N' field.
|
|
|
|
$n = implode(';', array_reverse(array_slice(explode(' ', $fn), 0, 2))).';;;';
|
|
|
|
$card->setString('N', $n);
|
|
|
|
$data = $card->serialize();
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
2012-02-14 01:56:38 +01:00
|
|
|
if(!$uid) {
|
|
|
|
$card->setUID();
|
|
|
|
$data = $card->serialize();
|
|
|
|
}
|
2011-09-17 00:26:57 +02:00
|
|
|
|
|
|
|
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
|
|
|
|
$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
|
|
|
|
|
|
|
|
OC_Contacts_Addressbook::touch($id);
|
|
|
|
|
2011-10-29 11:40:48 +02:00
|
|
|
return OC_DB::insertid('*PREFIX*contacts_cards');
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief edits a card
|
|
|
|
* @param integer $id id of card
|
|
|
|
* @param string $data vCard file
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static function edit($id, $data){
|
|
|
|
$oldcard = self::find($id);
|
|
|
|
$fn = null;
|
|
|
|
|
2011-09-20 14:41:17 +02:00
|
|
|
$card = OC_VObject::parse($data);
|
2011-09-17 00:26:57 +02:00
|
|
|
if(!is_null($card)){
|
|
|
|
foreach($card->children as $property){
|
|
|
|
if($property->name == 'FN'){
|
|
|
|
$fn = $property->value;
|
2012-01-11 03:56:53 +01:00
|
|
|
break;
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
}
|
2012-01-11 06:20:06 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
2012-01-11 06:20:06 +01:00
|
|
|
$now = new DateTime;
|
|
|
|
$card->setString('REV', $now->format(DateTime::W3C));
|
|
|
|
$data = $card->serialize();
|
2011-09-17 00:26:57 +02:00
|
|
|
|
|
|
|
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
|
|
|
|
$result = $stmt->execute(array($fn,$data,time(),$id));
|
|
|
|
|
|
|
|
OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief edits a card with the data provided by sabredav
|
|
|
|
* @param integer $id Addressbook id
|
|
|
|
* @param string $uri the uri of the card
|
|
|
|
* @param string $data vCard file
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static function editFromDAVData($aid,$uri,$data){
|
|
|
|
$oldcard = self::findWhereDAVDataIs($aid,$uri);
|
|
|
|
|
|
|
|
$fn = null;
|
2011-09-20 14:41:17 +02:00
|
|
|
$card = OC_VObject::parse($data);
|
2011-09-17 00:26:57 +02:00
|
|
|
if(!is_null($card)){
|
|
|
|
foreach($card->children as $property){
|
|
|
|
if($property->name == 'FN'){
|
|
|
|
$fn = $property->value;
|
2012-01-11 03:56:53 +01:00
|
|
|
break;
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-11 06:20:06 +01:00
|
|
|
$now = new DateTime;
|
|
|
|
$card->setString('REV', $now->format(DateTime::W3C));
|
|
|
|
$data = $card->serialize();
|
2011-09-17 00:26:57 +02:00
|
|
|
|
|
|
|
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
|
|
|
|
$result = $stmt->execute(array($fn,$data,time(),$oldcard['id']));
|
|
|
|
|
|
|
|
OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief deletes a card
|
|
|
|
* @param integer $id id of card
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static function delete($id){
|
2012-01-11 20:07:15 +01:00
|
|
|
// FIXME: Add error checking.
|
2011-09-17 00:26:57 +02:00
|
|
|
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
|
|
|
|
$stmt->execute(array($id));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Creates a UID
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function createUID(){
|
|
|
|
return substr(md5(rand().time()),0,10);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief deletes a card with the data provided by sabredav
|
|
|
|
* @param integer $aid Addressbook id
|
|
|
|
* @param string $uri the uri of the card
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2011-10-21 21:49:34 +02:00
|
|
|
public static function deleteFromDAVData($aid,$uri){
|
2012-01-11 20:07:15 +01:00
|
|
|
// FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error.
|
2011-09-17 00:26:57 +02:00
|
|
|
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
|
|
|
|
$stmt->execute(array($aid,$uri));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Data structure of vCard
|
|
|
|
* @param object $property
|
|
|
|
* @return associative array
|
|
|
|
*
|
|
|
|
* look at code ...
|
|
|
|
*/
|
|
|
|
public static function structureContact($object){
|
|
|
|
$details = array();
|
|
|
|
foreach($object->children as $property){
|
|
|
|
$temp = self::structureProperty($property);
|
|
|
|
if(array_key_exists($property->name,$details)){
|
|
|
|
$details[$property->name][] = $temp;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$details[$property->name] = array($temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $details;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Data structure of properties
|
|
|
|
* @param object $property
|
|
|
|
* @return associative array
|
|
|
|
*
|
|
|
|
* returns an associative array with
|
|
|
|
* ['name'] name of property
|
|
|
|
* ['value'] htmlspecialchars escaped value of property
|
|
|
|
* ['parameters'] associative array name=>value
|
|
|
|
* ['checksum'] checksum of whole property
|
2012-01-25 01:10:56 +01:00
|
|
|
* NOTE: $value is not escaped anymore. It shouldn't make any difference
|
|
|
|
* but we should look out for any problems.
|
2011-09-17 00:26:57 +02:00
|
|
|
*/
|
|
|
|
public static function structureProperty($property){
|
|
|
|
$value = $property->value;
|
2012-01-24 23:02:02 +01:00
|
|
|
//$value = htmlspecialchars($value);
|
2011-09-17 00:26:57 +02:00
|
|
|
if($property->name == 'ADR' || $property->name == 'N'){
|
2011-09-20 14:41:17 +02:00
|
|
|
$value = OC_VObject::unescapeSemicolons($value);
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
$temp = array(
|
|
|
|
'name' => $property->name,
|
|
|
|
'value' => $value,
|
|
|
|
'parameters' => array(),
|
|
|
|
'checksum' => md5($property->serialize()));
|
|
|
|
foreach($property->parameters as $parameter){
|
|
|
|
// Faulty entries by kaddressbook
|
|
|
|
if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){
|
|
|
|
$parameter->name = 'PREF';
|
|
|
|
$parameter->value = '1';
|
|
|
|
}
|
2011-11-23 21:06:51 +01:00
|
|
|
if ($property->name == 'TEL' && $parameter->name == 'TYPE'){
|
|
|
|
if (isset($temp['parameters'][$parameter->name])){
|
|
|
|
$temp['parameters'][$parameter->name][] = $parameter->value;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$temp['parameters'][$parameter->name] = array($parameter->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$temp['parameters'][$parameter->name] = $parameter->value;
|
|
|
|
}
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|
|
|
|
return $temp;
|
|
|
|
}
|
2012-02-14 00:56:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Move card(s) to an address book
|
|
|
|
* @param integer $aid Address book id
|
|
|
|
* @param $id Array or integer of cards to be moved.
|
|
|
|
* @return boolean
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
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), '?'));
|
|
|
|
$prep = 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id IN ('.$id_sql.')';
|
|
|
|
try {
|
|
|
|
$stmt = OC_DB::prepare( $prep );
|
|
|
|
//$aid = array($aid);
|
|
|
|
$vals = array_merge((array)$aid, $id);
|
|
|
|
$result = $stmt->execute($vals);
|
|
|
|
} catch(Exception $e) {
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' );
|
|
|
|
$result = $stmt->execute(array($aid, $id));
|
|
|
|
} catch(Exception $e) {
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG);
|
|
|
|
OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OC_Log::DEBUG);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OC_Contacts_Addressbook::touch($aid);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-17 00:26:57 +02:00
|
|
|
}
|