Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    /**
4
     * @package   Content-management
5
     * @author    Lars Tiefland <tiefland@weban.de>
6
     * @copyright 2010 Webagentur Niewerth
7
     * @license   propietary http://www.weban.de
8
     * @version   $Rev: 3361 $
9
     * @filesource
10
     *
11
     */
12
 
13
    /**
14
     *
15
     * @package   Content-management
16
     * @author    Lars Tiefland <tiefland@weban.de>
17
     * @copyright 2010 Webagentur Niewerth
18
     */
19
 
20
    // SVN: $Id: admin_user_rechte.php 3361 2011-02-24 15:34:41Z tiefland $
21
 
22
    $self = basename( $PHP_SELF );
23
    $Tab = "Access";
24
    require_once  "connect2.php";
25
    require_once  "webs.php";
26
    require_once  "Weban_Smarty.class.php";
27
    $GLOBALS["ui"] = new Weban_Smarty();
28
    $GLOBALS["ui"]->compile_dir = $_SERVER["DOCUMENT_ROOT"] .
29
        "/templates_c/";
30
    $GLOBALS["ui"]->use_sub_dirs = true;
31
 
32
    if ( $MySQL_Host_write )
33
    {
34
        //echo "schreibe in Haupt-DB";
35
        $w_conn = @mysql_connect( $MySQL_Host_write, $MySQL_User, $MySQL_Passwd );
36
        if ( !$w_conn )
37
        {
38
            $error = true;
39
            $meld =
40
                "Leider können keine Bentzer bearbeitet werden, da keine Verbindung zur Datenbank möglich ist.";
41
        }
42
        $r = @mysql_select_db( $database_name );
43
        if ( !$r )
44
        {
45
            $meld =
46
                "Leider können keine Bentzer bearbeitet werden, da keine Verbindung zur Datenbank möglich ist.";
47
            $error = true;
48
        }
49
    }
50
    else
51
    {
52
        $w_conn = $localhost_dbh;
53
    }
54
    if ( $w_conn )
55
    {
56
        if ( $action == "update" )
57
        {
58
            /*$query = "delete from user_properties where Access = $ID";
59
            $result = mysql_query( $query ) or die( mysql_errno() . ": " . mysql_error() );*/
60
 
61
            if ( isset( $modules ) )
62
            {
63
                foreach ( $modules as $tools )
64
                {
65
                    foreach ( $tools as $properties )
66
                    {
67
                        foreach ( $properties as $elem => $val )
68
                        {
69
                            $query = "
70
                                SELECT
71
                                    *
72
                                FROM
73
                                    user_properties
74
                                WHERE
75
                                    Access=$ID
76
                                AND
77
                                    properties=$elem
78
                            ";
79
                            $result = mysql_query( $query );
80
                            $anz = mysql_num_rows( $result );
81
                            if ( $anz && !$val )
82
                            {
83
                                $query = "
84
                                    DELETE FROM
85
                                        user_properties
86
                                    WHERE
87
                                        Access = $ID
88
                                    AND
89
                                        properties=$elem
90
                                ";
91
                            } elseif ( $val && !$anz )
92
                            {
93
                                $query = "
94
                                    INSERT INTO
95
                                        user_properties
96
                                    (
97
                                        Access,
98
                                        properties
99
                                    )
100
                                    VALUES
101
                                    (
102
                                        $ID,
103
                                        $elem
104
                                    )
105
                                ";
106
                            }
107
                            $result = mysql_query( $query ) or die( mysql_errno
108
                                () . ": " . mysql_error() . "<hr>$query<hr>" );
109
                        }
110
                    }
111
                }
112
            }
113
            unset( $modules, $tools, $properties );
114
        }
115
        require_once  "get_rechte.php";
116
 
117
        if ( $ID )
118
        {
119
            $sql = "
120
                SELECT
121
                    *
122
                FROM
123
                    user_properties
124
                WHERE
125
                    Access = $ID
126
            ";
127
            $result = mysql_query( $sql ) or die( mysql_errno() . ": " .
128
                mysql_error() );
129
            while ( $zeile = mysql_fetch_array( $result ) )
130
            {
131
                $user_properties[$zeile["properties"]] = 1;
132
            }
133
 
134
            $sql = "
135
                SELECT
136
                    *
137
                FROM
138
                    Access
139
                WHERE
140
                    ID = $ID
141
            ";
142
            $result = mysql_query( $sql ) or die( mysql_errno() . ": " .
143
                mysql_error() );
144
            $zeile = mysql_fetch_array( $result );
145
            list( $user_name, $user_site ) = explode( "@", $zeile["user"] );
146
            $user = $zeile;
147
            $user["site"] = $user_site;
148
            $user["properties"] = $user_properties;
149
        }
150
        $query = "
151
            SELECT
152
                *
153
            FROM
154
                modules
155
            ORDER by
156
                rang
157
        ";
158
        $result_modules = mysql_query( $query ) or die( mysql_errno() . ": " .
159
            mysql_error() );
160
        while ( $module = mysql_fetch_assoc( $result_modules ) )
161
        {
162
            if ( isset( $web_rechte[$module["interner_name"]] ) )
163
            {
164
                $query = "
165
                    SELECT
166
                        tools.*
167
                    FROM
168
                        tools
169
                    WHERE
170
                        tools.modules = $module[ID]
171
                    ORDER BY
172
                        tools.rang
173
                ";
174
                $result_tools = mysql_query( $query ) or die( mysql_errno() .
175
                    ": " . mysql_error() );
176
                while ( $tool = mysql_fetch_assoc( $result_tools ) )
177
                {
178
                    if ( isset( $web_rechte[$module["interner_name"]][$tool["button_name"]] ) )
179
                    {
180
                        $query = "
181
                            SELECT
182
                                properties.*
183
                            FROM
184
                                properties
185
                            WHERE
186
                                properties.tools = $tool[ID]
187
                            AND
188
                                hidden = 'false'
189
                            ORDER BY
190
                                properties.rang
191
                        ";
192
                        $result_properties = mysql_query( $query ) or die( mysql_errno
193
                            () . ": " . mysql_error() );
194
                        while ( $property = mysql_fetch_assoc( $result_properties ) )
195
                        {
196
                            if ( isset( $web_rechte[$module["interner_name"]][$tool["button_name"]][$property["interner_name"]] ) )
197
                            {
198
                                if ( $web_rechte[$module["interner_name"]][$tool["button_name"]][$property["interner_name"]] )
199
                                {
200
                                    $property["web_name"] = $web_rechte[$module["interner_name"]][$tool["button_name"]][$property["interner_name"]];
201
                                    if ( ( $property["web_name"] ) )
202
                                    {
203
                                        if ( stristr( $property["web_name"],
204
                                            ";" ) )
205
                                        {
206
                                            $name = explode( ";", $property["web_name"] );
207
                                            if ( stristr( $name[0], ":" ) )
208
                                            {
209
                                                $property["name"] = $name[0];
210
                                            }
211
                                        }
212
                                        elseif ( $property["web_name"][strlen($property["web_name"])]==":" )
213
                                        {
214
                                            $property["name"]=$property["web_name"];
215
                                        }
216
                                    }
217
                                }
218
                                $tool["properties"][] = $property;
219
                            }
220
                        }
221
                        $module["tools"][] = $tool;
222
                    }
223
                }
224
                $modules[] = $module;
225
            }
226
        }
227
    }
228
    $GLOBALS["ui"]->assign( "modules", $modules );
229
    $GLOBALS["ui"]->assign( "user", $user );
230
    $GLOBALS["ui"]->assign( "webs", $webs );
231
    $GLOBALS["ui"]->assign( "meld", $meld );
232
    $GLOBALS["ui"]->assign( "error", $error );
233
    $GLOBALS["ui"]->display( "admin_user_rechte.tpl" );
234
?>