Merge branch 'master' of gitorious.org:owncloud/owncloud

This commit is contained in:
Michael Gapczynski 2011-12-28 12:48:08 -05:00
Родитель 9b59bf40df 16e4e6dcc3
Коммит 349923c5b8
24 изменённых файлов: 548 добавлений и 50 удалений

Просмотреть файл

@ -17,6 +17,8 @@
#editentry_dialog {display: none;}
#parsingfail_dialog{display: none;}
#loading { display: none; left: 40%; position: fixed; top: 4.4em; z-index: 100; }
#calendar_holder {position: relative;bottom: 0; right: 0; left: 0; top: 3em;}
.fc-content{padding:2px 4px;}
#listview {margin: 0; padding: 10px; background: #EEEEEE;}

Просмотреть файл

@ -6,25 +6,25 @@
* See the COPYING-README file.
*/
require_once ("../../lib/base.php");
require_once ('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL;
$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL;
$cal = isset($_GET['calid']) ? $_GET['calid'] : NULL;
$event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL;
if(isset($cal)){
$calendar = OC_Calendar_App::getCalendar($cal);
$calobjects = OC_Calendar_Object::all($cal);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
foreach($calobjects as $calobject){
echo $calobject["calendardata"] . "\n";
echo $calobject['calendardata'] . '\n';
}
}elseif(isset($event)){
$data = OC_Calendar_App::getEventObject($_GET["eventid"]);
$calendarid = $data["calendarid"];
$data = OC_Calendar_App::getEventObject($_GET['eventid']);
$calendarid = $data['calendarid'];
$calendar = OC_Calendar_App::getCalendar($calendarid);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
echo $data["calendardata"];
header('Content-Type: text/Calendar');
header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
echo $data['calendardata'];
}
?>

Просмотреть файл

@ -8,7 +8,15 @@
Calendar={
UI:{
loading: function(isLoading){
if (isLoading){
$('#loading').show();
}else{
$('#loading').hide();
}
},
startEventDialog:function(){
Calendar.UI.loading(false);
$('.tipsy').remove();
$('#calendar_holder').fullCalendar('unselect');
Calendar.UI.lockTime();
@ -41,6 +49,7 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
}
},
@ -50,13 +59,16 @@ Calendar={
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'editeventform.php') + '?id=' + id, Calendar.UI.startEventDialog);
}
},
submitDeleteEventForm:function(url){
var post = $( '#event_form' ).serialize();
$('#errorbox').empty();
Calendar.UI.loading(true);
$.post(url, post, function(data){
Calendar.UI.loading(false);
if(data.status == 'success'){
$('#calendar_holder').fullCalendar('removeEvents', $('#event_form input[name=id]').val());
$('#event').dialog('destroy').remove();
@ -69,8 +81,10 @@ Calendar={
validateEventForm:function(url){
var post = $( "#event_form" ).serialize();
$("#errorbox").empty();
Calendar.UI.loading(true);
$.post(url, post,
function(data){
Calendar.UI.loading(false);
if(data.status == "error"){
var output = missing_field + ": <br />";
if(data.title == "true"){
@ -107,8 +121,10 @@ Calendar={
},
moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
$('.tipsy').remove();
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
event.lastmodified = data.lastmodified;
console.log("Event moved successfully");
@ -120,8 +136,10 @@ Calendar={
},
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
$('.tipsy').remove();
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
event.lastmodified = data.lastmodified;
console.log("Event resized successfully");
@ -210,6 +228,7 @@ Calendar={
if($('#choosecalendar_dialog').dialog('isOpen') == true){
$('#choosecalendar_dialog').dialog('moveToTop');
}else{
Calendar.UI.loading(true);
$('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'choosecalendar.php'), function(){
$('#choosecalendar_dialog').dialog({
width : 600,
@ -217,13 +236,16 @@ Calendar={
$(this).dialog('destroy').remove();
}
});
Calendar.UI.loading(false);
});
}
},
activation:function(checkbox, calendarid)
{
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
Calendar.UI.loading(false);
if (data.status == 'success'){
checkbox.checked = data.active == 1;
if (data.active == 1){
@ -520,6 +542,7 @@ $(document).ready(function(){
}
});
},
loading: Calendar.UI.loading,
eventSources: eventSources
});
$('#oneweekview_radio').click(function(){

Просмотреть файл

@ -19,6 +19,7 @@
var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars';
</script>
<div id="loading"><img src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" /></div>
<div id="controls">
<div>
<form>

Просмотреть файл

@ -0,0 +1,22 @@
<?php
/**
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once ("../../../lib/base.php");
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$bookid = $_POST['bookid'];
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']);
$book = OC_Contacts_App::getAddressbook($bookid);
/* is there an OC_JSON::error() ? */
OC_JSON::success(array(
'active' => OC_Contacts_Addressbook::isActive($bookid),
'bookid' => $bookid,
'book' => $book,
));

Просмотреть файл

@ -0,0 +1,21 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$book = array(
'id' => 'new',
'displayname' => '',
);
$tmpl = new OC_Template('contacts', 'part.editaddressbook');
$tmpl->assign('new', true);
$tmpl->assign('addressbook', $book);
$tmpl->printPage();
?>

Просмотреть файл

@ -0,0 +1,16 @@
<?php
/**
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$output = new OC_TEMPLATE("contacts", "part.chooseaddressbook");
$output -> printpage();
?>

Просмотреть файл

@ -0,0 +1,34 @@
<?php
/**
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
function contacts_namesort($a,$b){
return strcasecmp($a['fullname'],$b['fullname']);
}
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
$contacts = array();
foreach( $addressbooks as $addressbook ){
$addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']);
foreach( $addressbookcontacts as $contact ){
if(is_null($contact['fullname'])){
continue;
}
$contacts[] = $contact;
}
}
usort($contacts,'contacts_namesort');
$tmpl = new OC_TEMPLATE("contacts", "part.contacts");
$tmpl->assign('contacts', $contacts);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
?>

Просмотреть файл

@ -0,0 +1,26 @@
<?php
/**
* Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$userid = OC_User::getUser();
$bookid = OC_Contacts_Addressbook::add($userid, $_POST['name'], null);
OC_Contacts_Addressbook::setActive($bookid, 1);
$addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
$tmpl->assign('addressbook', $addressbook);
OC_JSON::success(array(
'page' => $tmpl->fetchPage(),
'addressbook' => $addressbook,
));

Просмотреть файл

@ -23,11 +23,13 @@
// Init owncloud
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$id = $_GET['id'];
//$id = $_GET['id'];
$id = $_POST['id'];
$addressbook = OC_Contacts_App::getAddressbook( $id );
OC_Contacts_Addressbook::delete($id);

Просмотреть файл

@ -0,0 +1,18 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']);
$tmpl = new OC_Template("contacts", "part.editaddressbook");
$tmpl->assign('new', false);
$tmpl->assign('addressbook', $addressbook);
$tmpl->printPage();
?>

Просмотреть файл

@ -0,0 +1,26 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
$l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$bookid = $_POST['id'];
OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null);
OC_Contacts_Addressbook::setActive($bookid, $_POST['active']);
$addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
$tmpl->assign('addressbook', $addressbook);
OC_JSON::success(array(
'page' => $tmpl->fetchPage(),
'addressbook' => $addressbook,
));

Просмотреть файл

@ -1,3 +1,4 @@
#chooseaddressbook {margin-right: 170px; float: right;}
#contacts_details_name { font-weight:bold;font-size:1.1em;margin-left:25%;}
#contacts_details_photo { margin:.5em 0em .5em 25%; }

39
apps/contacts/export.php Normal file
Просмотреть файл

@ -0,0 +1,39 @@
<?php
/**
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once ("../../lib/base.php");
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
$book = isset($_GET['bookid']) ? $_GET['bookid'] : NULL;
$contact = isset($_GET['contactid']) ? $_GET['contactid'] : NULL;
if(isset($book)){
$addressbook = OC_Contacts_App::getAddressbook($book);
if($addressbook['userid'] != OC_User::getUser()){
OC_JSON::error();
exit;
}
$cardobjects = OC_Contacts_VCard::all($book);
header('Content-Type: text/directory');
header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf');
for($i = 0;$i <= count($cardobjects); $i++){
echo $cardobjects[$i]['carddata'];
//echo '\r\n';
}
}elseif(isset($contact)){
$data = OC_Contacts_App::getContactObject($contact);
$addressbookid = $data['addressbookid'];
$addressbook = OC_Contacts_App::getAddressbook($addressbookid);
if($addressbook['userid'] != OC_User::getUser()){
OC_JSON::error();
exit;
}
header('Content-Type: text/directory');
header('Content-Disposition: inline; filename=' . $data['fullname'] . '.vcf');
echo $data['carddata'];
}
?>

Просмотреть файл

@ -21,7 +21,7 @@
*/
function contacts_namesort($a,$b){
return strcmp($a['name'],$b['name']);
return strcmp($a['fullname'],$b['fullname']);
}
// Init owncloud
@ -31,17 +31,8 @@ require_once('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
// Check if the user has an addressbook
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
if( count($addressbooks) == 0){
OC_Contacts_Addressbook::add(OC_User::getUser(),'default','Default Address Book');
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
}
$prefbooks = OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null);
if(is_null($prefbooks)){
$prefbooks = $addressbooks[0]['id'];
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',$prefbooks);
}
// Get active address books. This creates a default one if none exists.
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
// Load the files we need
OC_App::setActiveNavigationEntry( 'contacts_index' );
@ -51,17 +42,15 @@ $id = isset( $_GET['id'] ) ? $_GET['id'] : null;
// sort addressbooks (use contactsort)
usort($addressbooks,'contacts_namesort');
// Addressbooks to load
$openaddressbooks = explode(';',$prefbooks);
$contacts = array();
foreach( $openaddressbooks as $addressbook ){
$addressbookcontacts = OC_Contacts_VCard::all($addressbook);
foreach( $addressbooks as $addressbook ){
$addressbookcontacts = OC_Contacts_VCard::all($addressbook['id']);
foreach( $addressbookcontacts as $contact ){
if(is_null($contact['fullname'])){
continue;
}
$contacts[] = array( 'name' => $contact['fullname'], 'id' => $contact['id'] );
$contacts[] = $contact;
}
}
@ -74,6 +63,13 @@ if( !is_null($id)/* || count($contacts)*/){
$details = OC_Contacts_VCard::structureContact($vcard);
}
// Include Style and Script
OC_Util::addScript('contacts','interface');
OC_Util::addStyle('contacts','styles');
OC_Util::addStyle('contacts','formtastic');
OC_Util::addScript('', 'jquery.multiselect');
OC_Util::addStyle('', 'jquery.multiselect');
$property_types = OC_Contacts_App::getAddPropertyOptions();
$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');

Просмотреть файл

@ -1,3 +1,118 @@
Contacts={
UI:{
showCardDAVUrl:function(username, bookname){
$('#carddav_url').val(totalurl + '/' + username + '/' + bookname);
$('#carddav_url').show();
$('#carddav_url_close').show();
},
Addressbooks:{
overview:function(){
if($('#chooseaddressbook_dialog').dialog('isOpen') == true){
$('#chooseaddressbook_dialog').dialog('moveToTop');
}else{
$('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'chooseaddressbook.php'), function(){
$('#chooseaddressbook_dialog').dialog({
width : 600,
close : function(event, ui) {
$(this).dialog('destroy').remove();
}
});
});
}
},
activation:function(checkbox, bookid)
{
$.post(OC.filePath('contacts', 'ajax', 'activation.php'), { bookid: bookid, active: checkbox.checked?1:0 },
function(data) {
/*
* Arguments:
* data.status
* data.bookid
* data.active
*/
if (data.status == 'success'){
checkbox.checked = data.active == 1;
Contacts.UI.Contacts.update();
}
});
},
newAddressbook:function(object){
var tr = $(document.createElement('tr'))
.load(OC.filePath('contacts', 'ajax', 'addbook.php'));
$(object).closest('tr').after(tr).hide();
/* TODO: Shouldn't there be some kinda error checking here? */
},
editAddressbook:function(object, bookid){
var tr = $(document.createElement('tr'))
.load(OC.filePath('contacts', 'ajax', 'editaddressbook.php') + "?bookid="+bookid);
$(object).closest('tr').after(tr).hide();
},
deleteAddressbook:function(bookid){
var check = confirm("Do you really want to delete this address book?");
if(check == false){
return false;
}else{
$.post(OC.filePath('contacts', 'ajax', 'deletebook.php'), { id: bookid},
function(data) {
if (data.status == 'success'){
$('#chooseaddressbook_dialog').dialog('destroy').remove();
Contacts.UI.Contacts.update();
Contacts.UI.Addressbooks.overview();
} else {
alert('Error: ' + data.message);
}
});
}
},
submit:function(button, bookid){
var displayname = $("#displayname_"+bookid).val();
var active = $("#edit_active_"+bookid+":checked").length;
var description = $("#description_"+bookid).val();
var url;
if (bookid == 'new'){
url = OC.filePath('contacts', 'ajax', 'createaddressbook.php');
}else{
url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php');
}
$.post(url, { id: bookid, name: displayname, active: active, description: description },
function(data){
if(data.status == 'success'){
$(button).closest('tr').prev().html(data.page).show().next().remove();
}
});
Contacts.UI.Contacts.update();
},
cancel:function(button, bookid){
$(button).closest('tr').prev().show().next().remove();
}
},
Contacts:{
update:function(){
$.getJSON('ajax/contacts.php',{},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page);
}
else{
alert(jsondata.data.message);
}
});
/*
var contactlist = $('#contacts');
var contacts = contactlist.children('li').get();
//alert(contacts);
contacts.sort(function(a, b) {
var compA = $(a).text().toUpperCase();
var compB = $(b).text().toUpperCase();
return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
})
$.each(contacts, function(idx, itm) { contactlist.append(itm); });
*/
}
}
}
}
$(document).ready(function(){
/*-------------------------------------------------------------------------
* Event handlers
@ -79,6 +194,11 @@ $(document).ready(function(){
return false;
});
$('#chooseaddressbook').click(function(){
Contacts.UI.Addressbooks.overview();
return false;
});
$('#contacts_newcontact').click(function(){
$.getJSON('ajax/showaddcard.php',{},function(jsondata){
if(jsondata.status == 'success'){

Просмотреть файл

@ -44,7 +44,7 @@ class OC_Contacts_Addressbook{
* @return array
*/
public static function all($uid){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ?' );
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ? ORDER BY displayname' );
$result = $stmt->execute(array($uid));
$addressbooks = array();
@ -140,12 +140,98 @@ class OC_Contacts_Addressbook{
return true;
}
/**
* @brief Get active addressbooks for a user.
* @param integer $uid User id. If null current user will be used.
* @return array
*/
public static function activeIds($uid = null){
if(is_null($uid)){
$uid = OC_User::getUser();
}
$prefbooks = OC_Preferences::getValue($uid,'contacts','openaddressbooks',null);
if(is_null($prefbooks)){
$addressbooks = OC_Contacts_Addressbook::all($uid);
if(count($addressbooks) == 0){
OC_Contacts_Addressbook::add($uid,'default','Default Address Book');
$addressbooks = OC_Contacts_Addressbook::all($uid);
}
$prefbooks = $addressbooks[0]['id'];
OC_Preferences::setValue($uid,'contacts','openaddressbooks',$prefbooks);
}
return explode(';',$prefbooks);
}
/**
* @brief Returns the list of active addressbooks for a specific user.
* @param string $uid
* @return array
*/
public static function active($uid){
$active = self::activeIds($uid);
$addressbooks = array();
/** FIXME: Is there a way to prepare a statement 'WHERE id IN ([range])'?
*/
foreach( $active as $aid ){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' );
$result = $stmt->execute(array($aid,));
while( $row = $result->fetchRow()){
$addressbooks[] = $row;
}
}
return $addressbooks;
}
/**
* @brief Activates an addressbook
* @param integer $id
* @param integer $name
* @return boolean
*/
public static function setActive($id,$active){
// Need these ones for checking uri
//$addressbook = self::find($id);
if(is_null($id)){
$id = 0;
}
$openaddressbooks = self::activeIds();
if($active) {
if(!in_array($id, $openaddressbooks)) {
$openaddressbooks[] = $id;
}
} else {
if(in_array($id, $openaddressbooks)) {
unset($openaddressbooks[array_search($id, $openaddressbooks)]);
}
}
sort($openaddressbooks, SORT_NUMERIC);
// FIXME: I alway end up with a ';' prepending when imploding the array..?
OC_Preferences::setValue(OC_User::getUser(),'contacts','openaddressbooks',implode(';', $openaddressbooks));
return true;
}
/**
* @brief Checks if an addressbook is active.
* @param integer $id ID of the address book.
* @return boolean
*/
public static function isActive($id){
OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
return in_array($id, self::activeIds());
}
/**
* @brief removes an address book
* @param integer $id
* @return boolean
*/
public static function delete($id){
self::setActive($id, false);
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
$stmt->execute(array($id));

Просмотреть файл

@ -47,15 +47,15 @@ class OC_Contacts_VCard{
* ['carddata']
*/
public static function all($id){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ?' );
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
$result = $stmt->execute(array($id));
$addressbooks = array();
$cards = array();
while( $row = $result->fetchRow()){
$addressbooks[] = $row;
$cards[] = $row;
}
return $addressbooks;
return $cards;
}
/**

Просмотреть файл

@ -1,16 +1,14 @@
<?php // Include Style and Script
OC_Util::addScript('contacts','interface');
OC_Util::addStyle('contacts','styles');
OC_Util::addStyle('contacts','formtastic');
?>
<script type='text/javascript'>
var totalurl = '<?php echo OC_Helper::linkTo('contacts', 'carddav.php', null, true); ?>/addressbooks';
</script>
<div id="controls">
<form>
<input type="button" id="contacts_newcontact" value="<?php echo $l->t('Add Contact'); ?>">
<input type="button" id="chooseaddressbook" value="<?php echo $l->t('Address Books'); ?>">
</form>
</div>
<div id="leftcontent" class="leftcontent">
<ul>
<ul id="contacts">
<?php echo $this->inc("part.contacts"); ?>
</ul>
</div>
@ -24,3 +22,9 @@ OC_Util::addStyle('contacts','formtastic');
}
?>
</div>
<!-- Dialogs -->
<div id="dialog_holder"></div>
<div id="parsingfail_dialog" title="Parsing Fail">
<?php echo $l->t("There was a fail, while parsing the file."); ?>
</div>
<!-- End of Dialogs -->

Просмотреть файл

@ -0,0 +1,24 @@
<div id="chooseaddressbook_dialog" title="<?php echo $l->t("Choose active Address Books"); ?>">
<table width="100%" style="border: 0;">
<?php
$option_addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
for($i = 0; $i < count($option_addressbooks); $i++){
echo "<tr>";
$tmpl = new OC_Template('contacts', 'part.chooseaddressbook.rowfields');
$tmpl->assign('addressbook', $option_addressbooks[$i]);
$tmpl->assign('active', OC_Contacts_Addressbook::isActive($option_addressbooks[$i]['id']));
$tmpl->printpage();
echo "</tr>";
}
?>
<tr>
<td colspan="5">
<a href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
</td>
</tr>
<tr>
<td colspan="5">
<p style="margin: 0 auto;width: 90%;"><input style="display:none;width: 90%;float: left;" type="text" id="carddav_url" onmouseover="$('#carddav_url').select();" title="<?php echo $l->t("CardDav Link"); ?>"><img id="carddav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="../../core/img/actions/delete.svg" alt="close" onclick="$('#carddav_url').hide();$('#carddav_url_close').hide();"/></p>
</td>
</tr>
</table>

Просмотреть файл

@ -0,0 +1,5 @@
<?php
echo "<td width=\"20px\"><input id=\"active_" . $_['addressbook']["id"] . "\" type=\"checkbox\" onClick=\"Contacts.UI.Addressbooks.activation(this, " . $_['addressbook']["id"] . ")\"" . (OC_Contacts_Addressbook::isActive($_['addressbook']["id"]) ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['addressbook']["id"] . "\">" . $_['addressbook']["displayname"] . "</label></td>";
echo "<td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.showCardDAVUrl('" . OC_User::getUser() . "', '" . $_['addressbook']["uri"] . "');\" title=\"" . $l->t("CardDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?bookid=" . $_['addressbook']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Contacts.UI.Addressbooks.editAddressbook(this, " . $_['addressbook']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Contacts.UI.Addressbooks.deleteAddressbook('" . $_['addressbook']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";

Просмотреть файл

@ -1,3 +1,3 @@
<?php foreach( $_['contacts'] as $contact ): ?>
<li data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['name']; ?></a> </li>
<li book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['fullname']; ?></a> </li>
<?php endforeach; ?>

Просмотреть файл

@ -0,0 +1,31 @@
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
?>
<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>addressbook_dialog" title="<?php echo $_['new'] ? $l->t("New Address Book") : $l->t("Edit Address Book"); ?>" colspan="6">
<table width="100%" style="border: 0;">
<tr>
<th><?php echo $l->t('Displayname') ?></th>
<td>
<input id="displayname_<?php echo $_['addressbook']['id'] ?>" type="text" value="<?php echo $_['addressbook']['displayname'] ?>">
</td>
</tr>
<?php if (!$_['new']): ?>
<tr>
<td></td>
<td>
<input id="edit_active_<?php echo $_['addressbook']['id'] ?>" type="checkbox"<?php echo OC_Contacts_Addressbook::isActive($_['addressbook']['id']) ? ' checked="checked"' : '' ?>>
<label for="edit_active_<?php echo $_['addressbook']['id'] ?>">
<?php echo $l->t('Active') ?>
</label>
</td>
</tr>
<?php endif; ?>
</table>
<input style="float: left;" type="button" onclick="Contacts.UI.Addressbooks.submit(this, <?php echo $_['new'] ? "'new'" : $_['addressbook']['id'] ?>);" value="<?php echo $_['new'] ? $l->t("Save") : $l->t("Submit"); ?>">
<input style="float: left;" type="button" onclick="Contacts.UI.Addressbooks.cancel(this, <?php echo $_['new'] ? "'new'" : $_['addressbook']['id'] ?>);" value="<?php echo $l->t("Cancel"); ?>">
</td>

Просмотреть файл

@ -100,14 +100,15 @@ else {
$error = true;
}
}
// The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
elseif(isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"])){
if (OC_User::login($_SERVER["PHP_AUTH_USER"],$_SERVER["PHP_AUTH_PW"])) {
OC_User::unsetMagicInCookie();
OC_Util::redirectToDefaultPage();
}else{
$error = true;
}
// The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
elseif(isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"])){
if (OC_User::login($_SERVER["PHP_AUTH_USER"],$_SERVER["PHP_AUTH_PW"])) {
//OC_Log::write('core',"Logged in with HTTP Authentication",OC_Log::DEBUG);
OC_User::unsetMagicInCookie();
OC_Util::redirectToDefaultPage();
}else{
$error = true;
}
}
OC_Template::printGuestPage('', 'login', array('error' => $error, 'redirect' => isset($_REQUEST['redirect_url'])?$_REQUEST['redirect_url']:'' ));
}