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
|
|
|
*/
|
2012-04-17 21:31:29 +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');
|
2012-02-16 22:16:31 +04:00
|
|
|
|
2011-12-11 19:26:00 +04:00
|
|
|
// 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());
|
2012-08-21 08:22:33 +04:00
|
|
|
$has_contacts = (count(OC_Contacts_VCard::all($ids, 0, 1)) > 0
|
|
|
|
? true
|
2012-07-20 19:09:03 +04:00
|
|
|
: false); // just to check if there are any contacts.
|
2012-07-12 04:28:29 +04:00
|
|
|
if($has_contacts === false) {
|
2012-08-21 08:22:33 +04:00
|
|
|
OCP\Util::writeLog('contacts',
|
|
|
|
'index.html: No contacts found.',
|
2012-07-20 19:09:03 +04:00
|
|
|
OCP\Util::DEBUG);
|
2012-06-26 19:54:00 +04:00
|
|
|
}
|
2011-08-07 01:29:25 +04:00
|
|
|
|
2011-08-07 00:32:06 +04:00
|
|
|
// Load the files we need
|
2012-07-20 19:09:03 +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;
|
2012-08-22 20:50:50 +04:00
|
|
|
$impp_types = OC_Contacts_App::getTypesOfProperty('IMPP');
|
2011-12-07 01:31:04 +04:00
|
|
|
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
|
2012-04-30 00:10:16 +04:00
|
|
|
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
|
2012-08-22 20:50:50 +04:00
|
|
|
$ims = OC_Contacts_App::getIMOptions();
|
|
|
|
$im_protocols = array();
|
|
|
|
foreach($ims as $name => $values) {
|
|
|
|
$im_protocols[$name] = $values['displayname'];
|
|
|
|
}
|
2012-03-29 20:54:06 +04:00
|
|
|
$categories = OC_Contacts_App::getCategories();
|
2011-11-18 02:54:14 +04:00
|
|
|
|
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('/');
|
2012-07-20 19:09:03 +04:00
|
|
|
$freeSpace=max($freeSpace, 0);
|
|
|
|
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
|
|
|
|
|
|
|
|
OCP\Util::addscript('', 'jquery.multiselect');
|
|
|
|
OCP\Util::addscript('', 'oc-vcategories');
|
|
|
|
OCP\Util::addscript('contacts', 'contacts');
|
|
|
|
OCP\Util::addscript('contacts', 'expanding');
|
|
|
|
OCP\Util::addscript('contacts', 'jquery.combobox');
|
2012-07-15 06:15:57 +04:00
|
|
|
OCP\Util::addscript('files', 'jquery.fileupload');
|
2012-07-20 19:09:03 +04:00
|
|
|
OCP\Util::addscript('contacts', 'jquery.inview');
|
|
|
|
OCP\Util::addscript('contacts', 'jquery.Jcrop');
|
|
|
|
OCP\Util::addscript('contacts', 'jquery.multi-autocomplete');
|
|
|
|
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-07-09 21:34:10 +04:00
|
|
|
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize, false);
|
2012-08-21 08:22:33 +04:00
|
|
|
$tmpl->assign('uploadMaxHumanFilesize',
|
2012-07-20 19:09:03 +04:00
|
|
|
OCP\Util::humanFileSize($maxUploadFilesize), false);
|
2012-07-09 21:34:10 +04:00
|
|
|
$tmpl->assign('phone_types', $phone_types, false);
|
|
|
|
$tmpl->assign('email_types', $email_types, false);
|
2012-08-22 20:50:50 +04:00
|
|
|
$tmpl->assign('impp_types', $impp_types, false);
|
2012-07-09 21:34:10 +04:00
|
|
|
$tmpl->assign('categories', $categories, false);
|
2012-08-22 20:50:50 +04:00
|
|
|
$tmpl->assign('im_protocols', $im_protocols, false);
|
2012-07-09 21:34:10 +04:00
|
|
|
$tmpl->assign('has_contacts', $has_contacts, false);
|
2012-07-20 19:09:03 +04:00
|
|
|
$tmpl->assign('id', $id, false);
|
2011-08-07 00:32:06 +04:00
|
|
|
$tmpl->printPage();
|