-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassHeaders.php
92 lines (87 loc) · 3.51 KB
/
classHeaders.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
classHeaders.php - loads common classes
Copyright (C) 2002-2004 Stephen Lawrence Jr., Khoa Nguyen
Copyright (C) 2005-2010 Stephen Lawrence Jr.
*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (!defined('classHeader')) {
define('classHeader', 'true', false);
include_once('databaseData_class.php');
include_once('User_class.php');
include_once('Department_class.php');
include_once('User_Perms_class.php');
include_once('FileData_class.php');
include_once('Department_class.php');
include_once('Dept_Perms_class.php');
include_once('UserPermission_class.php');
/*
* @param $hi_priority_array array
* @param $hi_postfix
* @param $low_priority_array
* @param $low_postfix
*/
function advanceCombineArrays($hi_priority_array, $hi_postfix, $low_priority_array, $low_postfix)
{
//merge higher priority onto lower priority one.
$user_rights = array();
$k = 0;
$foundFlag = false;
//create a multidimension array: element of view and right of view
for ($i = 0; $i<sizeof($low_priority_array); $i++) {
$user_rights[$i] = array($low_priority_array[$i], $low_postfix);
}
$k = sizeof($user_rights);
for ($m = 0; $m<sizeof($hi_priority_array); $m++) {
for ($u = 0; $u<sizeof($user_rights); $u++) {
if ($user_rights[$u][0] == $hi_priority_array[$m] and $hi_postfix!='NULL') {
$user_rights[$u][1] = $hi_postfix;
$foundFlag = true;
}
if ($user_rights[$u][0] == $hi_priority_array[$m][0] and $hi_postfix =='NULL') {
$user_rights[$u][1] = $hi_priority_array[$m][1];
$foundFlag = true;
}
}
if ($foundFlag==false & $hi_postfix != 'NULL') {
$user_rights[$k++]= array($hi_priority_array[$m], $hi_postfix);
}
if ($foundFlag==false & $hi_postfix == 'NULL') {
$user_rights[$k++]= $hi_priority_array[$m];
}
$foundFlag = false;
}
return $user_rights;
}
function combineArrays($high_priority_array, $low_priority_array)
{
$found = false;
$result_array = array();
$result_array = $high_priority_array;
$result_array_index = sizeof($high_priority_array);
for ($l = 0 ; $l<sizeof($low_priority_array); $l++) {
for ($r = 0; $r<sizeof($result_array); $r++) {
if ($result_array[$r] == $low_priority_array[$l] && $high_priority_array[$r] == true) {
$r = sizeof($result_array);
$found = true;
}
}
if (!$found) {
$result_array[$result_array_index++] = $low_priority_array[$l];
}
$found = false;
}
return $result_array;
}
}