Project

General

Profile

« Previous | Next » 

Revision 733

Added by thorn almost 17 years ago

fixed ticket #562, applied changes from user tavitar with some own additions

View differences:

add.php
40 40
$admin_groups = $admin->get_post('admin_groups');
41 41
$viewing_groups = $admin->get_post('viewing_groups');
42 42

  
43
// work-around: $viewing_groups contains group-numbers for both private _and_ registered - keep group-numbers which appears twice only
44
$view_groups=array(); 
45
foreach($viewing_groups as $a) {
46
	if(isset($view_groups[$a])) $view_groups[$a]++;
47
	else $view_groups[$a] = 1;
48
}
49
$viewing_groups=array();
50
foreach($view_groups as $k=>$v) {
51
	if($v==2)
52
		$viewing_groups[]=$k;
53
}
54

  
43 55
if ($parent!=0) {
44 56
	if (!$admin->get_page_permission($parent,'admin'))
45 57
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
......
54 66

  
55 67
// Setup admin groups
56 68
$admin_groups[] = 1;
57
if(!in_array(1, $admin->get_groups_id())) {
58
	$admin_groups[] = implode(",",$admin->get_groups_id());
59
}
60
$admin_groups = implode(',', $admin_groups);
69
//if(!in_array(1, $admin->get_groups_id())) {
70
//	$admin_groups[] = implode(",",$admin->get_groups_id());
71
//}
61 72
// Setup viewing groups
62 73
$viewing_groups[] = 1;
74
//if(!in_array(1, $admin->get_groups_id())) {
75
//	$viewing_groups[] = implode(",",$admin->get_groups_id());
76
//}
77

  
78
// Check to see if page created has needed permissions
63 79
if(!in_array(1, $admin->get_groups_id())) {
64
	$viewing_groups[] = implode(",",$admin->get_groups_id());
80
	$admin_perm_ok = false;
81
	foreach ($admin_groups as $adm_group) {
82
		if (in_array($adm_group, $admin->get_groups_id())) {
83
			$admin_perm_ok = true;
84
		}
85
	}
86
	if ($admin_perm_ok == false) {
87
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
88
	}
89
	$admin_perm_ok = false;
90
	foreach ($viewing_groups as $view_group) {
91
		if (in_array($view_group, $admin->get_groups_id())) {
92
			$admin_perm_ok = true;
93
		}
94
	}
95
	if ($admin_perm_ok == false) {
96
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
97
	}
65 98
}
99

  
100
$admin_groups = implode(',', $admin_groups);
66 101
$viewing_groups = implode(',', $viewing_groups);
67 102

  
68 103
// Work-out what the link and page filename should be

Also available in: Unified diff