Subversion-Projekte lars-tiefland.ci

Revision

Revision 1005 | Revision 1220 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
851 lars 1
<?php
2
 
3
/**
4
 *
5
 * @package WebanOS CI
6
 * @author Lars Tiefland <ltiefland@gmail.com>
7
 * @copyright 2016
8
 * @version $Rev: 1096 $
9
 */
10
 
11
class Weban_backend
12
{
13
	public function __construct()
14
	{
928 lars 15
		if (!isset($_SESSION['username']))
16
		{
929 lars 17
			if (!isset($_SESSION["redirected"]))
18
			{
19
				$_SESSION["redirected"] = true;
20
				header("Location:/backend/Login/");
21
				exit;
22
			}
928 lars 23
		}
851 lars 24
		$CI = &get_instance();
940 lars 25
		$csrf_name = $CI->security->get_csrf_token_name();
941 lars 26
		$csrf_value = $CI->security->get_csrf_hash();
939 lars 27
		$CI->smarty->assign('csrf_name', $csrf_name);
28
		$CI->smarty->assign('csrf_value', $csrf_value);
851 lars 29
		$web_rechte = array();
871 lars 30
		$user_rechte = array();
851 lars 31
		$sql = "SELECT
883 lars 32
				*
33
			FROM
34
				webs
35
			WHERE
36
				domain='".__SHOP__."'
37
		";
38
		$res = $GLOBALS["db_red"]->query($sql);
39
		$GLOBALS["webs"] = $res->row_array();
1005 lars 40
		$CI->smarty->assign("webs", $GLOBALS["webs"]);
883 lars 41
 
42
		$sql = "SELECT
851 lars 43
				modules.interner_name AS m_name,
44
				tools.button_name AS t_name,
45
				properties.interner_name AS p_name,
46
				webs_properties.Bezeichnung
47
			FROM
48
				webs,
49
		        webs_properties,
50
		        properties,
51
		        tools,
52
		        modules
53
		    WHERE
54
		        webs.domain='".__SHOP__."'
55
		    AND
56
		        webs_properties.webs=webs.ID
57
		    AND
58
		        webs_properties.properties=properties.ID
59
		    AND
60
		        properties.tools = tools.ID
61
		    AND
62
		        tools.modules = modules.ID
63
		    ORDER BY
64
		        properties.Rang
65
		";
66
 
67
		$result = $GLOBALS["db_red"]->query($sql);
68
		while ($zeile = $result->unbuffered_row('array'))
69
		{
70
			//var_dump($zeile);
71
			//exit;
72
			if (!$zeile["Bezeichnung"])
73
			{
74
				$zeile["Bezeichnung"] = "";
75
			}
76
			$zeile["Bezeichnung"] = explode("|", $zeile["Bezeichnung"]);
77
 
78
			if (count($zeile["Bezeichnung"]) == 1)
79
			{
80
				$zeile["Bezeichnung"] = $zeile["Bezeichnung"][0];
81
			}
82
 
83
			$web_rechte[$zeile["m_name"]][$zeile["t_name"]][$zeile["p_name"]] = $zeile["Bezeichnung"];
84
		}
85
 
86
		foreach (array_keys($web_rechte) as $a)
87
		{
88
			foreach (array_keys($web_rechte[$a]) as $b)
89
			{
90
				foreach (array_keys($web_rechte[$a][$b]) as $c)
91
				{
92
					if (is_array($web_rechte[$a][$b][$c]))
93
					{
94
						//if (in_array($_SESSION[language], $web_rechte[$a][$b][$c]))
95
						{
96
							$web_rechte[$a][$b][$c] = $web_rechte[$a][$b][$c][array_search($_SESSION["language"],
97
								array_keys($web_rechte["online_shop"]["language"]))];
98
						}
99
						if ($web_rechte[$a][$b][$c] == "./.")
100
						{
101
							unset($web_rechte[$a][$b][$c]);
102
						}
103
					}
104
				}
105
			}
106
		}
107
 
108
		unset($query);
109
		unset($result);
110
		unset($zeile);
111
		$CI->smarty->assign("web_rechte", $web_rechte);
853 lars 112
		if ($CI->session->user_data["user"] == "admin")
113
		{
870 lars 114
			$user_rechte = $web_rechte;
853 lars 115
		}
870 lars 116
		else
117
		{
118
			$sql = "
119
				SELECT
120
					modules.interner_name AS module,
121
					tools.button_name AS tool,
122
					properties.interner_name AS property
123
				FROM
124
					webs,
125
					Access,
126
					webs_properties,
127
					user_properties,
128
					properties,
129
					tools,
130
					modules
131
				WHERE
132
					webs.domain='".__SHOP__."'
133
				AND
134
					webs_properties.webs=webs.ID
135
				AND
136
					webs_properties.properties=properties.ID
137
				AND
1096 lars 138
					Access.user='".$CI->session->user_data["user"]."'
870 lars 139
				AND
140
					user_properties.Access=Access.ID
141
				AND
142
					user_properties.properties=properties.ID
143
				AND
144
					properties.tools = tools.ID
145
				AND
146
					tools.modules = modules.ID
147
			";
148
			$result = $GLOBALS["db_red"]->query($sql);
149
			while ($zeile = $result->unbuffered_row('array'))
150
			{
151
				$user_rechte[$zeile["module"]][$zeile["tool"]][$zeile["property"]] = 1;
152
			}
153
		}
154
		$CI->smarty->assign("user_rechte", $user_rechte);
851 lars 155
		$GLOBALS["web_rechte"] = $web_rechte;
870 lars 156
		$GLOBALS["user_rechte"] = $user_rechte;
851 lars 157
	}
158
}
159
 
160
?>