Some more work on the address book
parent
4e5b6f72c1
commit
76fc062f27
@ -0,0 +1,54 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$aid = $_POST['id'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $aid );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your addressbook!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$fn = $_POST['fn'];
|
||||
|
||||
$vcard = new Sabre_VObject_Component('VCARD');
|
||||
$vcard->add(new Sabre_VObject_Property('FN',$fn));
|
||||
$vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_Addressbook::createUID()));
|
||||
$id = OC_Contacts_Addressbook::addCard($aid,$vcard->serialize());
|
||||
|
||||
$details = OC_Contacts_Addressbook::structureContact($vcard);
|
||||
$tmpl = new OC_Template('contacts','part.details');
|
||||
$tmpl->assign('details',$details);
|
||||
$tmpl->assign('id',$id);
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page )));
|
||||
@ -0,0 +1,59 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_POST['id'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
$mimetype = $_FILES['photo']['type'] ? $_FILES['photo']['type'] : 'image/jpeg';
|
||||
$photobase = base64_encode(file_get_contents($_FILES['photo']['tmp_name']));
|
||||
$photo = new Sabre_VObject_Property( 'PHOTO', $photobase );
|
||||
$photo->parameters[] = new Sabre_VObject_Parameter('TYPE',$mimetype);
|
||||
$photo->parameters[] = new Sabre_VObject_Parameter('ENCODING','b');
|
||||
$vcard->add($photo);
|
||||
|
||||
$line = count($vcard->children) - 1;
|
||||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
|
||||
OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'line' => $line, 'checksum' => $checksum )));
|
||||
@ -0,0 +1,73 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_POST['id'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
|
||||
$name = $_POST['name'];
|
||||
$value = $_POST['value'];
|
||||
$parameters = $_POST['parameters'];
|
||||
|
||||
if(is_array($value)){
|
||||
$value = OC_Contacts_Addressbook::escapeSemicolons($value);
|
||||
}
|
||||
$property = new Sabre_VObject_Property( $name, $value );
|
||||
$parameternames = array_keys($parameters);
|
||||
foreach($parameternames as $i){
|
||||
$property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]);
|
||||
}
|
||||
|
||||
$vcard->add($property);
|
||||
|
||||
$line = count($vcard->children) - 1;
|
||||
$checksum = md5($property->serialize());
|
||||
|
||||
OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
|
||||
|
||||
$tmpl = new OC_Template('contacts','part.property');
|
||||
$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($property,$line));
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
|
||||
@ -0,0 +1,44 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $id );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
OC_Contacts_Addressbook::deleteAddressbook($id);
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
|
||||
@ -0,0 +1,50 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
OC_Contacts_Addressbook::deleteCard($id);
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
|
||||
@ -0,0 +1,62 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
$line = $_GET['line'];
|
||||
$checksum = $_GET['checksum'];
|
||||
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
|
||||
if(md5($vcard->children[$line]->serialize()) != $checksum ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
unset($vcard->children[$line]);
|
||||
|
||||
OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
|
||||
@ -0,0 +1,77 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_POST['id'];
|
||||
$line = $_POST['line'];
|
||||
$checksum = $_POST['checksum'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
$mimetype = $_FILES['photo']['type'] ? $_FILES['photo']['type'] : 'image/jpeg';
|
||||
$photobase = base64_encode(file_get_contents($_FILES['photo']['tmp_name']));
|
||||
|
||||
if(md5($vcard->children[$line]->serialize()) != $checksum){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
// replace photo
|
||||
$vcard->children[$line]->setValue($photobase);
|
||||
$encoding = $type = false;
|
||||
foreach($vcard->children[$line]->parameters as &$parameter){
|
||||
if($parameter->name == 'TYPE'){
|
||||
$parameter->value = $mimetype;
|
||||
$type = true;
|
||||
}
|
||||
elseif($parameter->name == 'ENCODING'){
|
||||
$parameter->value = 'b';
|
||||
$encoding = true;
|
||||
}
|
||||
} unset($parameter);
|
||||
if(!$encoding) $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter('ENCODING','b');
|
||||
if(!$type) $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter('TYPE',$mimetype);
|
||||
|
||||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
|
||||
OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'line' => $line, 'checksum' => $checksum )));
|
||||
@ -0,0 +1,93 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_POST['id'];
|
||||
$line = $_POST['line'];
|
||||
$checksum = $_POST['checksum'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
|
||||
if(md5($vcard->children[$line]->serialize()) != $checksum){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set the value
|
||||
$value = $_POST['value'];
|
||||
if(is_array($value)){
|
||||
$value = OC_Contacts_Addressbook::escapeSemicolons($value);
|
||||
}
|
||||
$vcard->children[$line]->setValue($value);
|
||||
|
||||
// Add parameters
|
||||
$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array();
|
||||
for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
|
||||
$name = $vcard->children[$line]->parameters[$i]->name;
|
||||
if(array_key_exists($name,$postparameters)){
|
||||
if($postparameters[$name] == '' || is_null($postparameters[$name])){
|
||||
unset($vcard->children[$line]->parameters[$i]);
|
||||
}
|
||||
else{
|
||||
$vcard->children[$line]->parameters[$i]->value = $postparameters[$name];
|
||||
}
|
||||
unset($postparameters[$name]);
|
||||
}
|
||||
}
|
||||
$missingparameters = array_keys($postparameters);
|
||||
foreach($missingparameters as $i){
|
||||
if(!$postparameters[$i] == '' && !is_null($postparameters[$i])){
|
||||
$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($i,$postparameters[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Do checksum and be happy
|
||||
$checksum = md5($vcard->children[$line]->serialize());
|
||||
|
||||
OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
|
||||
|
||||
$tmpl = new OC_Template('contacts','part.property');
|
||||
$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line],$line));
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] )));
|
||||
@ -0,0 +1,39 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_USER::getUser());
|
||||
$tmpl = new OC_Template('contacts','part.addcardform');
|
||||
$tmpl->assign('addressbooks',$addressbooks);
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
|
||||
@ -0,0 +1,51 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$tmpl = new OC_Template('contacts','part.addpropertyform');
|
||||
$tmpl->assign('id',$id);
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
|
||||
@ -0,0 +1,62 @@
|
||||
<?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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Init owncloud
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
$line = $_GET['line'];
|
||||
$checksum = $_GET['checksum'];
|
||||
$l10n = new OC_L10N('contacts');
|
||||
|
||||
// Check if we are a user
|
||||
if( !OC_User::isLoggedIn()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$card = OC_Contacts_Addressbook::findCard( $id );
|
||||
if( $card === false ){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
|
||||
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($card['carddata']);
|
||||
if(md5($vcard->children[$line]->serialize()) != $checksum){
|
||||
echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload page!'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$tmpl = new OC_Template('contacts','part.setpropertyform');
|
||||
$tmpl->assign('id',$id);
|
||||
$tmpl->assign('checksum',$checksum);
|
||||
$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line],$line));
|
||||
$page = $tmpl->fetchPage();
|
||||
|
||||
echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
|
||||
@ -1 +1 @@
|
||||
|
||||
.contacts_propertyname {float:left;}
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
Name <?php echo $_['details']['FN'][0]['value']; ?>
|
||||
<?php if(array_key_exists('PHOTO',$_['details'])): ?>
|
||||
<img src="photo.php?id=<?php echo $_['id']; ?>">
|
||||
<?php endif; ?>
|
||||
@ -0,0 +1,13 @@
|
||||
<form id="contacts_addcardform">
|
||||
<?php if(count($_['addressbooks'])==1): ?>
|
||||
<input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>">
|
||||
<?php else: ?>
|
||||
<select name="id" size="1">
|
||||
<?php foreach($_['addressbooks'] as $addressbook): ?>
|
||||
<option value="<?php echo $addressbook['id']; ?>"><?php echo $addressbook['displayname']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
<input type="text" name="fn" value=""><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
@ -0,0 +1,43 @@
|
||||
<form id="contacts_addpropertyform">
|
||||
<input type="hidden" name="id" value="<?php echo $_['id']; ?>">
|
||||
<select name="name" size="1">
|
||||
<option value="BDAY"><?php echo $l->t('Birthday'); ?></option>
|
||||
<option value="ADR"><?php echo $l->t('Address'); ?></option>
|
||||
<option value="TEL"><?php echo $l->t('Telephone'); ?></option>
|
||||
<option value="EMAIL" selected="selected"><?php echo $l->t('Email'); ?></option>
|
||||
<option value="ORG"><?php echo $l->t('Organization'); ?></option>
|
||||
</select>
|
||||
<div id="contacts_generic">
|
||||
<input type="text" name="value" value="">
|
||||
</div>
|
||||
<input type="submit">
|
||||
</form>
|
||||
<div id="contacts_addcontactsparts" style="display:none;">
|
||||
<div id="contacts_addresspart">
|
||||
<select name="parameters[TYPE]" size="1">
|
||||
<option value="WORK"><?php echo $l->t('Work'); ?></option>
|
||||
<option value="HOME" selected="selected"><?php echo $l->t('Home'); ?></option>
|
||||
</select>
|
||||
<?php echo $l->t('PO Box'); ?> <input type="text" name="value[0]" value="">
|
||||
<?php echo $l->t('Extended Address'); ?> <input type="text" name="value[1]" value="">
|
||||
<?php echo $l->t('Street Name'); ?> <input type="text" name="value[2]" value="">
|
||||
<?php echo $l->t('City'); ?> <input type="text" name="value[3]" value="">
|
||||
<?php echo $l->t('Region'); ?> <input type="text" name="value[4]" value="">
|
||||
<?php echo $l->t('Postal Code'); ?> <input type="text" name="value[5]" value="">
|
||||
<?php echo $l->t('Country'); ?> <input type="text" name="value[6]" value="">
|
||||
</div>
|
||||
<div id="contacts_phonepart">
|
||||
<select name="parameters[TYPE]" size="1">
|
||||
<option value="WORK"><?php echo $l->t('Work'); ?></option>
|
||||
<option value="CELL" selected="selected"><?php echo $l->t('Mobile'); ?></option>
|
||||
<option value="HOME"><?php echo $l->t('Home'); ?></option>
|
||||
</select>
|
||||
<input type="text" name="value" value="">
|
||||
</div>
|
||||
<div id="contacts_fieldpart">
|
||||
<textarea type="text" name="value"></textarea>
|
||||
</div>
|
||||
<div id="contacts_generic">
|
||||
<input type="text" name="value" value="">
|
||||
</div>
|
||||
</div>
|
||||
@ -1,3 +1,3 @@
|
||||
<?php foreach( $_['contacts'] as $contact ): ?>
|
||||
<li x-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['name']; ?></a></li>
|
||||
<li x-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['name']; ?></a> </li>
|
||||
<?php endforeach; ?>
|
||||
@ -0,0 +1,22 @@
|
||||
<?php if(array_key_exists('PHOTO',$_['details'])): ?>
|
||||
<img src="photo.php?id=<?php echo $_['id']; ?>">
|
||||
<?php endif; ?>
|
||||
<?php echo $this->inc('part.property', array('property' => $_['details']['FN'][0])); ?>
|
||||
<?php if(isset($_['details']['BDAY'])): // Emails first ?>
|
||||
<?php echo $this->inc('part.property', array('property' => $_['details']['BDAY'][0])); ?>
|
||||
<?php endif; ?>
|
||||
<?php if(isset($_['details']['ORG'])): // Emails first ?>
|
||||
<?php echo $this->inc('part.property', array('property' => $_['details']['ORG'][0])); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach(array('EMAIL','TEL','ADR') as $type): ?>
|
||||
<?php if(isset($_['details'][$type])): // Emails first ?>
|
||||
<br>
|
||||
<?php foreach($_['details'][$type] as $property): ?>
|
||||
<?php echo $this->inc('part.property',array('property' => $property )); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<a id="contacts_deletecard"><img src="../../core/img/actions/delete.png"></a>
|
||||
<a id="contacts_addproperty"><img src="../../core/img/actions/download.png"></a>
|
||||
@ -0,0 +1,50 @@
|
||||
<div class="contacts_property" x-line="<?php echo $_['property']['line']; ?>" x-checksum="<?php echo $_['property']['checksum']; ?>">
|
||||
<?php if($_['property']['name'] == 'FN'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Name'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<?php echo $_['property']['value']; ?>
|
||||
</div>
|
||||
<?php elseif($_['property']['name'] == 'BDAY'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Birthday'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<?php echo $l->l('date',new DateTime($_['property']['value'])); ?>
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<span style="display:none;" x-use="delete"><img src="../../core/img/actions/delete.png"></span>
|
||||
</div>
|
||||
<?php elseif($_['property']['name'] == 'ORG'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Organisation'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<?php echo $_['property']['value']; ?>
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<span style="display:none;" x-use="delete"><img src="../../core/img/actions/delete.png"></span>
|
||||
</div>
|
||||
<?php elseif($_['property']['name'] == 'EMAIL'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Email'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<?php echo $_['property']['value']; ?>
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<span style="display:none;" x-use="delete"><img src="../../core/img/actions/delete.png"></span>
|
||||
</div>
|
||||
<?php elseif($_['property']['name'] == 'TEL'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Telefon'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<?php echo $_['property']['value']; ?>
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<span style="display:none;" x-use="delete"><img src="../../core/img/actions/delete.png"></span>
|
||||
</div>
|
||||
<?php elseif($_['property']['name'] == 'ADR'): ?>
|
||||
<div class="contacts_propertyname"><?php echo $l->t('Address'); ?></div>
|
||||
<div class="contacts_propertyvalue">
|
||||
<?php echo $l->t('PO Box'); ?> <?php echo $_['property']['value'][0]; ?><br>
|
||||
<?php echo $l->t('Extended Address'); ?> <?php echo $_['property']['value'][1]; ?><br>
|
||||
<?php echo $l->t('Street Name'); ?> <?php echo $_['property']['value'][2]; ?><br>
|
||||
<?php echo $l->t('City'); ?> <?php echo $_['property']['value'][3]; ?><br>
|
||||
<?php echo $l->t('Region'); ?> <?php echo $_['property']['value'][4]; ?><br>
|
||||
<?php echo $l->t('Postal Code'); ?> <?php echo $_['property']['value'][5]; ?><br>
|
||||
<?php echo $l->t('Country'); ?> <?php echo $_['property']['value'][6]; ?>
|
||||
<span style="display:none;" x-use="edit"><img src="../../core/img/actions/rename.png"></span>
|
||||
<span style="display:none;" x-use="delete"><img src="../../core/img/actions/delete.png"></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -0,0 +1,21 @@
|
||||
<form id="contacts_setpropertyform">
|
||||
<input type="hidden" name="checksum" value="<?php echo $_['property']['checksum']; ?>">
|
||||
<input type="hidden" name="line" value="<?php echo $_['property']['line']; ?>">
|
||||
<input type="hidden" name="id" value="<?php echo $_['id']; ?>">
|
||||
<?php if($_['property']['name']=='ADR'): ?>
|
||||
<?php echo $l->t('PO Box'); ?> <input type="text" name="value[0]" value="<?php echo $_['property']['value'][0]; ?>">
|
||||
<?php echo $l->t('Extended Address'); ?> <input type="text" name="value[1]" value="<?php echo $_['property']['value'][1]; ?>">
|
||||
<?php echo $l->t('Street Name'); ?> <input type="text" name="value[2]" value="<?php echo $_['property']['value'][2]; ?>">
|
||||
<?php echo $l->t('City'); ?> <input type="text" name="value[3]" value="<?php echo $_['property']['value'][3]; ?>">
|
||||
<?php echo $l->t('Region'); ?> <input type="text" name="value[4]" value="<?php echo $_['property']['value'][4]; ?>">
|
||||
<?php echo $l->t('Postal Code'); ?> <input type="text" name="value[5]" value="<?php echo $_['property']['value'][5]; ?>">
|
||||
<?php echo $l->t('Country'); ?> <input type="text" name="value[6]" value="<?php echo $_['property']['value'][6]; ?>">
|
||||
<?php elseif($_['property']['name']=='TEL'): ?>
|
||||
<input type="text" name="value" value="<?php echo $_['property']['value']; ?>">
|
||||
<?php elseif($_['property']['name']=='NOTE'): ?>
|
||||
<textarea type="text" name="value"><?php echo $_['property']['value']; ?></textarea>
|
||||
<?php else: ?>
|
||||
<input type="text" name="value" value="<?php echo $_['property']['value']; ?>">
|
||||
<?php endif; ?>
|
||||
<input type="submit">
|
||||
</form>
|
||||
Loading…
Reference in New Issue