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
|
|
|
*/
|
|
|
|
require_once('../../lib/base.php');
|
|
|
|
|
|
|
|
// Check if we are a user
|
2011-09-18 21:31:56 +02:00
|
|
|
OC_Util::checkLoggedIn();
|
2012-02-16 19:16:31 +01:00
|
|
|
OC_Util::checkAppEnabled('contacts');
|
|
|
|
|
2011-12-11 16:26:00 +01:00
|
|
|
// Get active address books. This creates a default one if none exists.
|
2011-12-30 21:07:16 +01:00
|
|
|
$ids = OC_Contacts_Addressbook::activeIds(OC_User::getUser());
|
|
|
|
$contacts = OC_Contacts_VCard::all($ids);
|
|
|
|
|
2011-12-16 17:42:07 +01:00
|
|
|
$addressbooks = OC_Contacts_Addressbook::active(OC_User::getUser());
|
2011-08-06 23:29:25 +02:00
|
|
|
|
2011-08-06 22:32:06 +02:00
|
|
|
// Load the files we need
|
|
|
|
OC_App::setActiveNavigationEntry( 'contacts_index' );
|
|
|
|
|
|
|
|
// 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-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-03-29 18:54:06 +02:00
|
|
|
$categories = OC_Contacts_App::getCategories();
|
|
|
|
if(count($categories) == 0) {
|
|
|
|
$vcaddressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
|
|
|
|
if(count($vcaddressbooks) > 0) {
|
|
|
|
$vcaddressbookids = array();
|
|
|
|
foreach($vcaddressbooks as $vcaddressbook) {
|
|
|
|
$vcaddressbookids[] = $vcaddressbook['id'];
|
|
|
|
}
|
|
|
|
$vccontacts = OC_Contacts_VCard::all($vcaddressbookids);
|
2012-04-07 16:01:50 +02:00
|
|
|
if(count($vccontacts) > 0) {
|
|
|
|
$cards = array();
|
|
|
|
foreach($vccontacts as $vccontact) {
|
|
|
|
$cards[] = $vccontact['carddata'];
|
|
|
|
}
|
2012-03-29 18:54:06 +02:00
|
|
|
|
2012-04-07 16:01:50 +02:00
|
|
|
OC_Contacts_App::$categories->rescan($cards);
|
|
|
|
$categories = OC_Contacts_App::$categories->categories();
|
|
|
|
}
|
2012-03-29 18:54:06 +02:00
|
|
|
}
|
|
|
|
}
|
2011-11-17 23:54:14 +01:00
|
|
|
|
2012-02-14 01:47:18 +01:00
|
|
|
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
|
|
|
|
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
|
|
|
|
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
|
|
|
|
|
|
|
$freeSpace=OC_Filesystem::free_space('/');
|
|
|
|
$freeSpace=max($freeSpace,0);
|
|
|
|
$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
|
|
|
|
|
|
|
|
OC_Util::addScript('','jquery.multiselect');
|
2012-03-12 14:12:27 +01:00
|
|
|
OC_Util::addScript('','oc-vcategories');
|
2012-02-14 01:47:18 +01:00
|
|
|
OC_Util::addScript('contacts','contacts');
|
|
|
|
OC_Util::addScript('contacts','jquery.combobox');
|
|
|
|
OC_Util::addScript('contacts','jquery.inview');
|
|
|
|
OC_Util::addScript('contacts','jquery.Jcrop');
|
2012-03-07 21:50:55 +01:00
|
|
|
OC_Util::addScript('contacts','jquery.multi-autocomplete');
|
2012-02-14 01:47:18 +01:00
|
|
|
OC_Util::addStyle('','jquery.multiselect');
|
2012-03-12 14:12:27 +01:00
|
|
|
OC_Util::addStyle('','oc-vcategories');
|
2012-02-14 01:47:18 +01:00
|
|
|
OC_Util::addStyle('contacts','jquery.combobox');
|
|
|
|
OC_Util::addStyle('contacts','jquery.Jcrop');
|
|
|
|
OC_Util::addStyle('contacts','contacts');
|
|
|
|
|
|
|
|
$tmpl = new OC_Template( "contacts", "index", "user" );
|
|
|
|
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
|
|
|
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
|
2011-12-18 23:04:45 +01:00
|
|
|
$tmpl->assign('property_types',$property_types);
|
2011-11-17 23:54:14 +01:00
|
|
|
$tmpl->assign('phone_types',$phone_types);
|
2012-03-07 16:39:56 +01: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('contacts', $contacts);
|
|
|
|
$tmpl->assign('details', $details );
|
|
|
|
$tmpl->assign('id',$id);
|
|
|
|
$tmpl->printPage();
|
2012-02-14 01:47:18 +01:00
|
|
|
|
|
|
|
?>
|