nextcloud/apps/contacts/index.php

79 lines
2.8 KiB
PHP
Raw Normal View History

2011-08-07 00:32:06 +04:00
<?php
/**
2012-02-14 04:47:18 +04: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-07 00:32:06 +04:00
*/
2011-08-07 00:32:06 +04:00
// Check if we are a user
2012-05-02 00:59:38 +04:00
OCP\User::checkLoggedIn();
2012-05-02 21:08:37 +04:00
OCP\App::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
2012-05-01 20:50:31 +04:00
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
$allcontacts = OC_Contacts_VCard::all($ids);
$contacts = array();
foreach($allcontacts as $contact) { // try to conserve some memory
$contacts[] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'fullname' => $contact['fullname']);
}
unset($allcontacts);
2012-05-01 20:50:31 +04:00
$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
2011-08-07 01:29:25 +04:00
2011-08-07 00:32:06 +04:00
// Load the files we need
2012-05-02 02:50:26 +04:00
OCP\App::setActiveNavigationEntry( 'contacts_index' );
2011-08-07 00:32:06 +04:00
// Load a specific user?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
$details = array();
if(is_null($id) && count($contacts) > 0) {
$id = $contacts[0]['id'];
2011-08-07 00:32:06 +04:00
}
if(!is_null($id)) {
$vcard = OC_Contacts_App::getContactVCard($id);
2012-02-14 04:47:18 +04:00
$details = OC_Contacts_VCard::structureContact($vcard);
}
$property_types = OC_Contacts_App::getAddPropertyOptions();
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
$categories = OC_Contacts_App::getCategories();
2012-05-02 02:20:45 +04: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 04:47:18 +04: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 22:03:41 +04:00
OCP\Util::addscript('','jquery.multiselect');
OCP\Util::addscript('','oc-vcategories');
OCP\Util::addscript('contacts','contacts');
OCP\Util::addscript('contacts','expanding');
2012-05-01 22:03:41 +04: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 11:49:22 +04: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 04:47:18 +04:00
2012-05-07 01:00:36 +04:00
$tmpl = new OCP\Template( "contacts", "index", "user" );
2012-02-14 04:47:18 +04:00
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
2012-05-02 02:20:45 +04:00
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
2012-04-13 00:38:09 +04:00
$tmpl->assign('property_types', $property_types);
$tmpl->assign('phone_types', $phone_types);
$tmpl->assign('email_types', $email_types);
2012-04-13 00:38:09 +04:00
$tmpl->assign('categories', $categories);
2011-08-07 01:29:25 +04:00
$tmpl->assign('addressbooks', $addressbooks);
2011-08-07 00:32:06 +04:00
$tmpl->assign('contacts', $contacts);
$tmpl->assign('details', $details );
$tmpl->assign('id',$id);
$tmpl->printPage();
2012-02-14 04:47:18 +04:00
?>