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

Revision 2000, 4.4 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implementação do módulo gerenciador de arquivos

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