source: trunk/filemanager/inc/class.user.inc.php @ 5509

Revision 5509, 5.0 KB checked in by gustavo, 12 years ago (diff)

Ticket #2488 - Adicionar cabecalho de licenca em arquivos que nao o possuem

Line 
1<?php
2                /***************************************************************************
3                * Expresso Livre                                                           *
4                * http://www.expressolivre.org                                             *
5                * --------------------------------------------                             *
6                *  This program is free software; you can redistribute it and/or modify it *
7                *  under the terms of the GNU General Public License as published by the   *
8                *  Free Software Foundation; either version 2 of the License, or (at your  *
9                *  option) any later version.                                              *
10                \**************************************************************************/
11               
12        class user
13        {
14                var $public_functions = array(
15                        'save_preferences' => True,
16                        'get_preferences' => True,
17                        'card'  =>      True
18                );
19
20                var $bo;
21                var $user_id;
22
23                var $target;
24
25                var $prefs;//array
26
27                var $current_config;
28                // this ones must be checked thorougly;
29                var $fileman = Array();
30                var $path;
31                var $file;
32                var $debug = false;
33                var $now;
34
35                function user()
36                {
37                        $this->now = date('Y-m-d');
38
39                        $this->bo = CreateObject('filemanager.bofilemanager');
40
41                        $c = CreateObject('phpgwapi.config','filemanager');
42                        $c->read_repository();
43                        $this->current_config = $c->config_data;
44                        $this->user_id = $GLOBALS['phpgw_info']['user']['account_id'];
45
46                        // here local vars are created from the HTTP vars
47                        @reset($GLOBALS['HTTP_POST_VARS']);
48                        while(list($name,) = @each($GLOBALS['HTTP_POST_VARS']))
49                        {
50                                $this->$name = $GLOBALS['HTTP_POST_VARS'][$name];
51                        }
52
53                        @reset($GLOBALS['HTTP_GET_VARS']);
54                        while(list($name,) = @each($GLOBALS['HTTP_GET_VARS']))
55                        {
56                                $$name = $GLOBALS['HTTP_GET_VARS'][$name];
57                                $this->$name = $GLOBALS['HTTP_GET_VARS'][$name];
58
59                        }
60
61                        $to_decode = array
62                        (
63                                'preferences'   => array('preferences' => '')
64                        );
65
66                        reset($to_decode);
67                        while(list($var, $conditions) = each($to_decode))
68                        {
69                                while(list($condvar, $condvalue) = each($conditions))
70                                {
71                                        if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue))
72                                        {
73                                                if(is_array($$var))
74                                                {
75                                                        $temp = array();
76                                                        while(list($varkey, $varvalue) = each($$var))
77                                                        {
78                                                                if(is_int($varkey))
79                                                                {
80                                                                        $temp[$varkey] = stripslashes(base64_decode(urldecode(($varvalue))));
81                                                                }
82                                                                else
83                                                                {
84                                                                        $temp[stripslashes(base64_decode(urldecode(($varkey))))] = $varvalue;
85                                                                }
86                                                        }
87                                                        $this->$var = $temp;
88                                                }
89                                                elseif(isset($$var))
90                                                {
91                                                        $this->$var = stripslashes(base64_decode(urldecode($$var)));
92                                                }
93                                        }
94                                }
95                        }
96
97                        // get appl. and user prefs
98                        $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']);
99                        $pref->read_repository();
100                        $pref->save_repository(True);
101                        $pref_array = $pref->read_repository();
102                        $this->prefs = $pref_array[$this->bo->appname];
103
104                        //always show name
105
106                        $this->prefs[name] =1;         
107                       
108                }
109
110                function card(){
111                        header('Content-Type: text/html');
112                        $expires = 60*60*24*10; /* 10 days */
113                        header("Cache-Control: maxage=".$expires);
114                        header("Pragma: public");
115                        header("Expires: ".gmdate('D, d M Y H:i:s', time()+$expires));
116                        $account_info = $GLOBALS['phpgw']->accounts->get_list('accounts',0,1,1,base64_decode($this->lid),1,'exact');
117                        echo $account_info[0]['account_firstname'].' '.$account_info[0]['account_lastname']."<br>";
118                        echo '<a target="_blank" href="../expressoMail1_2/index.php?to='
119                                .$account_info[0]['account_email'].'">'.$account_info[0]['account_email'];
120                        /*
121                        // TODO: PHOTO, ONLY FOR FOOL LDAP
122                        if (isset($GLOBALS['phpgw_info']['server']['ldap_root_pw'])){
123                        }
124                        */
125                }
126                function get_preferences(){
127                         echo(serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']));
128                }
129                function save_preferences(){
130
131                        $_SESSION['phpgw_info']['user']['preferences']['filemanager'] = unserialize($this->preferences);
132                        /* See if preferences exists or not */
133                        $query = "SELECT count(preference_owner) FROM phpgw_preferences WHERE preference_app = 'filemanager' AND preference_owner = ".$this->user_id." LIMIT 1";
134                        if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record())
135                                $val = $GLOBALS['phpgw']->db->row();
136                        else
137                        {
138                                echo $GLOBALS['phpgw']->db->error;
139                                return false;
140                        }
141
142                        $string_serial = addslashes($this->preferences);
143                        if ($val['count'] == '1')
144                        {
145                                $query = "UPDATE phpgw_preferences set preference_value = '".$string_serial.
146                                        "' where preference_app = 'filemanager'".
147                                        " and preference_owner = '".$this->user_id."'";
148                                if (!$GLOBALS['phpgw']->db->query($query)){
149                                        echo $GLOBALS['phpgw']->db->error;
150                                        return false;
151                                }
152                                else{
153                                        echo "True";
154                                        return;
155                                }
156                        }
157                        else
158                        {
159                                /*preferences does not exist*/
160                                $query = "INSERT INTO phpgw_preferences values (".$this->user_id.",'filemanager','".$string_serial."')";
161                                if (!$GLOBALS['phpgw']->db->query($query)){
162                                        echo $GLOBALS['phpgw']->db->error;
163                                        return false;
164                                }
165                                else{
166                                        echo "True";
167                                        return;
168                                }
169
170                        }
171                }
172
173        }
174?>
Note: See TracBrowser for help on using the repository browser.