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