source: sandbox/filemanager/inc/class.user.inc.php @ 1891

Revision 1891, 3.9 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Melhoria do FM. melhorias na interface, Cartao do usuario

  • 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                        $account_info = $GLOBALS['phpgw']->accounts->get_list('accounts',0,1,1,base64_decode($this->lid),1,'lid');
103                        echo $account_info[0]['account_firstname'].' '.$account_info[0]['account_lastname']."<br>";
104                        echo $account_info[0]['account_email'];
105                        /*
106                        // TODO: PHOTO, ONLY FOR FOOL LDAP
107                        if (isset($GLOBALS['phpgw_info']['server']['ldap_root_pw'])){
108                        }
109                        */
110                }
111                function get_preferences(){
112                         echo(serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']));
113                }
114                function save_preferences(){
115                        /* See if preferences exists or not */
116                        $query = "SELECT count(preference_owner) FROM phpgw_preferences WHERE preference_app = 'filemanager' AND preference_owner = ".$this->user_id." LIMIT 1";
117                        if ($GLOBALS['phpgw']->db->query($query) && $GLOBALS['phpgw']->db->next_record())
118                                $val = $GLOBALS['phpgw']->db->row();
119                        else
120                        {
121                                echo $GLOBALS['phpgw']->db->error;
122                                return false;
123                        }
124
125                        $string_serial = addslashes($this->preferences);
126                        if ($val['count'] == '1')
127                        {
128                                $query = "UPDATE phpgw_preferences set preference_value = '".$string_serial.
129                                        "' where preference_app = 'filemanager'".
130                                        " and preference_owner = '".$this->user_id."'";
131                                if (!$GLOBALS['phpgw']->db->query($query)){
132                                        echo $GLOBALS['phpgw']->db->error;
133                                        return false;
134                                }
135                                else{
136                                        echo "True";
137                                        return;
138                                }
139                        }
140                        else
141                        {
142                                /*preferences does not exist*/
143                                $query = "INSERT INTO phpgw_preferences values (".$this->user_id.",'filemanager','".$string_serial."')";
144                                if (!$GLOBALS['phpgw']->db->query($query)){
145                                        echo $GLOBALS['phpgw']->db->error;
146                                        return false;
147                                }
148                                else{
149                                        echo "True";
150                                        return;
151                                }
152
153                        }
154                }
155
156        }
157?>
Note: See TracBrowser for help on using the repository browser.