tiki-user_contacts_prefs.php 2.81 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
changi67's avatar
changi67 committed
6 7
// $Id$

8 9 10
$section = 'mytiki';
require_once ('tiki-setup.php');
require_once ('lib/webmail/contactlib.php');
11 12 13 14

$access->check_feature('feature_contacts', '', 'community');
$access->check_user($user);

15
if (!isset($cookietab)) { $cookietab = '1'; }
16 17
if (isset($_REQUEST['prefs'])) {
	$tikilib->set_user_preference($user, 'user_contacts_default_view', $_REQUEST['user_contacts_default_view']);
18
	$cookietab = '1';
19 20
}
$smarty->assign('user_contacts_default_view', $tikilib->get_user_preference($user, 'user_contacts_default_view'), 'group');
changi67's avatar
changi67 committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
if (isset($_REQUEST['ext_remove'])) {
	$contactlib->remove_ext($user, $_REQUEST['ext_remove']);
	$cookietab = 2;
}
if (isset($_REQUEST['ext_add'])) {
	$contactlib->add_ext($user, $_REQUEST['ext_add']);
	$cookietab = 2;
}
if (isset($_REQUEST['ext_show'])) {
	$contactlib->modify_ext($user, $_REQUEST['ext_show'], array('show' => 'y'));
	$cookietab = 2;
}
if (isset($_REQUEST['ext_hide'])) {
	$contactlib->modify_ext($user, $_REQUEST['ext_hide'], array('show' => 'n'));
	$cookietab = 2;
}
37 38 39 40 41 42 43 44
if (isset($_REQUEST['ext_public'])) {
	$contactlib->modify_ext($user, $_REQUEST['ext_public'], array('flagsPublic' => 'y'));
	$cookietab = 2;
}
if (isset($_REQUEST['ext_private'])) {
	$contactlib->modify_ext($user, $_REQUEST['ext_private'], array('flagsPublic' => 'n'));
	$cookietab = 2;
}
changi67's avatar
changi67 committed
45
$exts = & $contactlib->get_ext_list($user);
46 47
$nb_exts = count($exts);
// consistancy check
changi67's avatar
changi67 committed
48
foreach($exts as $k => $ext) if ($ext['order'] != $k) $contactlib->modify_ext($user, $ext['fieldId'], array('order' => $k));
49
if (isset($_REQUEST['ext_up'])) {
changi67's avatar
changi67 committed
50 51
	if (is_array($exts)) foreach($exts as $k => $ext) {
		if ($k > 0 && $ext['fieldId'] == $_REQUEST['ext_up']) {
52
			$contactlib->modify_ext($user, $_REQUEST['ext_up'], array('order' => $k - 1));
changi67's avatar
changi67 committed
53
			$contactlib->modify_ext($user, $exts[$k - 1]['fieldId'], array('order' => $k));
54 55 56
			break;
		}
	}
57
	$cookietab = 2;
58 59
}
if (isset($_REQUEST['ext_down'])) {
changi67's avatar
changi67 committed
60 61
	if (is_array($exts)) foreach($exts as $k => $ext) {
		if ($k < $nb_exts && $ext['fieldId'] == $_REQUEST['ext_down']) {
62
			$contactlib->modify_ext($user, $_REQUEST['ext_down'], array('order' => $k + 1));
changi67's avatar
changi67 committed
63
			$contactlib->modify_ext($user, $exts[$k + 1]['fieldId'], array('order' => $k));
64 65 66
			break;
		}
	}
67
	$cookietab = 2;
68
}
69
$exts = $contactlib->get_ext_list($user);
70
$smarty->assign('exts', $exts);
changi67's avatar
changi67 committed
71 72
setcookie('tab', $cookietab);
$smarty->assign_by_ref('cookietab', $cookietab);
73 74
include_once ('tiki-mytiki_shared.php');
//ask_ticket('user-contacts_prefs');
changi67's avatar
changi67 committed
75
include_once ('tiki-section_options.php');
76 77 78
// Display the template
$smarty->assign('mid', 'tiki-user_contacts_prefs.tpl');
$smarty->display("tiki.tpl");