summaryrefslogtreecommitdiff
path: root/includes/module_controls_inc.php
blob: 860467446ae41e1e66f84c317f590c9ba2bed334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
 * @version $Header$
 *
 * Copyright (c) 2004 bitweaver.org
 * Copyright (c) 2003 tikwiki.org
 * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 *
 * $Id$
 * @package kernel
 * @subpackage functions
 */

/**
 * Initialization
 */
include_once '../kernel/includes/setup_inc.php';

if (!$gBitUser->hasPermission( 'p_tidbits_configure_modules' )) {
	$gBitSmarty->assign('msg', tra("You dont have permission to use this feature"));
	$gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
	die;
}
/*if (!$gBitSystem->isFeatureActive( 'site_user_assigned_modules' ) && $check_req) {
	$gBitSmarty->assign('msg', tra("This feature is disabled").": site_user_assigned_modules");
	$gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
	die;
}*/
if (!$gBitUser->isRegistered()) {
	$gBitSmarty->assign('msg', tra("You must log in to use this feature"));
	$gBitSystem->display( 'error.tpl' , null, array( 'display_mode' => 'display' ));
	die;
}

$url = $_SERVER["HTTP_REFERER"];

//    global $debugger;
//    $debugger->msg('Module control clicked: '.$check_req);
    // Make defaults if user still ot configure modules for himself
//    if (!$usermoduleslib->user_has_assigned_modules($user))
//        $usermoduleslib->create_user_assigned_modules($user);

//$user_id = $gBitUser->getUserId();
$user_id = ROOT_USER_ID;

// Handle control icon click
if( isset( $_REQUEST['fMove'] ) && isset(  $_REQUEST['fPackage'] ) && isset(  $_REQUEST['fModule'] ) ) {
	switch( $_REQUEST['fMove'] ) {
		case "unassign":
			$gBitThemes->unassignModule( $_REQUEST['fModule'], $user_id, $_REQUEST['fPackage'] );
			break;
		case "up":
			$gBitThemes->moduleUp( $_REQUEST['fModule'], $user_id, $_REQUEST['fPackage'] );
			break;
		case "down":
			$gBitThemes->moduleDown( $_REQUEST['fModule'], $user_id, $_REQUEST['fPackage'] );
			break;
		case "left":
			$gBitThemes->modulePosition( $_REQUEST['fModule'], $user_id, $_REQUEST['fPackage'], 'r' );
			break;
		case "right":
			$gBitThemes->modulePosition( $_REQUEST['fModule'], $user_id, $_REQUEST['fPackage'], 'l' );
			break;
	}
}

// Remove module movemet paramaters from an URL
// \todo What if 'mc_xxx' arg was not at the end? (if smbd fix URL by hands...)
//       should I handle this very special (hack?) case?
//    $url = preg_replace('/(.*)(\?|&)[1](mc_up|mc_down|mc_move|mc_unassign)=[^&]*/','\1', $url);

// Fix locaton if parameter was removed...
header('Location: '.$url);