2011-08-06 22:32:06 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2012-02-14 01:47:18 +01:00
|
|
|
* Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
|
|
|
|
* Copyright (c) 2011 Jakob Sack mail@jakobsack.de
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
2011-08-06 22:32:06 +02:00
|
|
|
*/
|
2012-04-17 19:31:29 +02:00
|
|
|
|
2011-08-06 22:32:06 +02:00
|
|
|
|
|
|
|
// Check if we are a user
|
2012-05-01 22:59:38 +02:00
|
|
|
OCP\User::checkLoggedIn();
|
2012-05-02 19:08:37 +02:00
|
|
|
OCP\App::checkAppEnabled('contacts');
|
2012-02-16 19:16:31 +01:00
|
|
|
|
2011-12-11 16:26:00 +01:00
|
|
|
// Get active address books. This creates a default one if none exists.
|
2012-05-01 18:50:31 +02:00
|
|
|
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
|
2011-12-30 21:07:16 +01:00
|
|
|
$contacts = OC_Contacts_VCard::all($ids);
|
|
|
|
|
2012-05-01 18:50:31 +02:00
|
|
|
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
|
2011-08-06 23:29:25 +02:00
|
|
|
|
2011-08-06 22:32:06 +02:00
|
|
|
// Load the files we need
|
2012-05-02 00:50:26 +02:00
|
|
|
OCP\App::setActiveNavigationEntry( 'contacts_index' );
|
2011-08-06 22:32:06 +02:00
|
|
|
|
|
|
|
// Load a specific user?
|
|
|
|
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
|
2011-12-06 22:33:20 +01:00
|
|
|
$details = array();
|
2011-12-30 21:07:16 +01:00
|
|
|
|
2012-01-02 23:14:58 +01:00
|
|
|
if(is_null($id) && count($contacts) > 0) {
|
|
|
|
$id = $contacts[0]['id'];
|
2011-08-06 22:32:06 +02:00
|
|
|
}
|
2012-06-25 17:26:44 +02:00
|
|
|
unset($contacts);
|
2012-01-04 22:36:34 +01:00
|
|
|
if(!is_null($id)) {
|
|
|
|
$vcard = OC_Contacts_App::getContactVCard($id);
|
2012-02-14 01:47:18 +01:00
|
|
|
$details = OC_Contacts_VCard::structureContact($vcard);
|
2012-01-04 22:36:34 +01:00
|
|
|
}
|
2011-12-18 23:04:45 +01:00
|
|
|
$property_types = OC_Contacts_App::getAddPropertyOptions();
|
2011-12-06 22:31:04 +01:00
|
|
|
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
|
2012-04-29 22:10:16 +02:00
|
|
|
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
|
2012-03-29 18:54:06 +02:00
|
|
|
$categories = OC_Contacts_App::getCategories();
|
2011-11-17 23:54:14 +01:00
|
|
|
|
2012-05-02 00:20:45 +02:00
|
|
|
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
|
|
|
|
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
|
2012-02-14 01:47:18 +01:00
|
|
|
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
|
|
|
|
|
|
|
$freeSpace=OC_Filesystem::free_space('/');
|
|
|
|
$freeSpace=max($freeSpace,0);
|
|
|
|
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
|
|
|
|
|
2012-05-01 20:03:41 +02:00
|
|
|
OCP\Util::addscript('','jquery.multiselect');
|
|
|
|
OCP\Util::addscript('','oc-vcategories');
|
|
|
|
OCP\Util::addscript('contacts','contacts');
|
2012-05-04 15:47:19 +02:00
|
|
|
OCP\Util::addscript('contacts','expanding');
|
2012-05-01 20:03:41 +02:00
|
|
|
OCP\Util::addscript('contacts','jquery.combobox');
|
|
|
|
OCP\Util::addscript('contacts','jquery.inview');
|
|
|
|
OCP\Util::addscript('contacts','jquery.Jcrop');
|
|
|
|
OCP\Util::addscript('contacts','jquery.multi-autocomplete');
|
2012-05-01 09:49:22 +02:00
|
|
|
OCP\Util::addStyle('','jquery.multiselect');
|
|
|
|
OCP\Util::addStyle('contacts','jquery.combobox');
|
|
|
|
OCP\Util::addStyle('contacts','jquery.Jcrop');
|
|
|
|
OCP\Util::addStyle('contacts','contacts');
|
2012-02-14 01:47:18 +01:00
|
|
|
|
2012-05-06 23:00:36 +02:00
|
|
|
$tmpl = new OCP\Template( "contacts", "index", "user" );
|
2012-02-14 01:47:18 +01:00
|
|
|
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
2012-05-02 00:20:45 +02:00
|
|
|
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
2012-04-12 22:38:09 +02:00
|
|
|
$tmpl->assign('property_types', $property_types);
|
|
|
|
$tmpl->assign('phone_types', $phone_types);
|
2012-04-29 22:10:16 +02:00
|
|
|
$tmpl->assign('email_types', $email_types);
|
2012-04-12 22:38:09 +02:00
|
|
|
$tmpl->assign('categories', $categories);
|
2011-08-06 23:29:25 +02:00
|
|
|
$tmpl->assign('addressbooks', $addressbooks);
|
2011-08-06 22:32:06 +02:00
|
|
|
$tmpl->assign('details', $details );
|
|
|
|
$tmpl->assign('id',$id);
|
|
|
|
$tmpl->printPage();
|
2012-02-14 01:47:18 +01:00
|
|
|
|
|
|
|
?>
|