Changeset 179

Show
Ignore:
Timestamp:
12/29/06 00:46:10 (2 years ago)
Author:
syrus
Message:

edition du user

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wifidog/wifidog-auth/wifidog/classes/User.php

    r176 r179  
    741741                $html = ''; 
    742742                $name = "{$user_prefix}"; 
    743                 $sql = "SELECT user_id, username, account_origin, account_status, reg_date from users WHERE 1=1 $sql_additional_where ORDER BY user_id"; 
     743                $sql = "SELECT user_id, username, account_origin, account_status, reg_date, network from users WHERE 1=1 $sql_additional_where ORDER BY reg_date DESC"; 
    744744                $user_rows = null; 
    745745                $db->execSql($sql, $user_rows, false); 
     
    750750                                $html .= _("User"); 
    751751                                $html .=  ": "; 
    752                                 // Naturally-sorting by user_id 
     752                                // Naturally-sorting by user_idgooglemaps/ 
    753753                                $i = 0; 
    754754                                foreach ($user_rows as $user_row) 
     
    767767                                $html .= "\t<div id='node_list_div' class='node_admin tableContainer'>\n"; 
    768768                                $html .= "\t\t<table id='nodes_list' class='node_admin filterable scrollable sortable'>\n\n"; 
    769                                 $html .= "\t\t\t<thead class='fixedHeader'>\n\t\t\t\t<tr class='nofilter'>\n\t\t\t\t\t<th>User Name</th>\n\t\t\t\t\t<th>Account&nbsp;Status</th>\n\t\t\t\t\t<th>Register&nbsp;Date</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; 
     769                                $html .= "\t\t\t<thead class='fixedHeader'>\n\t\t\t\t<tr class='nofilter'>\n\t\t\t\t\t<th>User Name</th>\n\t\t\t\t\t<th>Account&nbsp;Status</th>\n\t\t\t\t\t<th>Register&nbsp;Date</th><th>Network</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; 
    770770 
    771771                                $i = 0; 
     
    774774                                        $account_status = $user_row['account_status']; 
    775775                                        $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$user_row['user_id']}&object_class=User&action=edit"; 
    776                                         $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$user_row['username']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>". self::getAccountStatusText($account_status) . "</td>\n\t\t\t\t\t<td>{$user_row['reg_date']}</td>\n\t\t\t\t</tr>\n"; 
     776                                        $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$user_row['username']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>". self::getAccountStatusText($account_status) . "</td>\n\t\t\t\t\t<td>{$user_row['reg_date']}</td><td>{$user_row['network']}</td>\n\t\t\t\t</tr>\n"; 
    777777                                } 
    778778                                $html .= "\t\t\t</tbody>\n\t\t</table>\n"; 
     
    816816    public function getAdminUI() 
    817817    { 
     818 
     819        // todo: put fields into a table 
     820 
    818821        global $db; 
    819822        $currentUser= self::getCurrentUser(); 
    820823        $html = ''; 
    821824        $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; 
    822         $html .= "<ul class='admin_element_list'>\n"; 
     825        $html .= "<legend>"._("User administration")."</legend><table>\n"; 
    823826if($this==$currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) 
    824827{ 
    825828    //username 
    826         $html .= "<li class='admin_element_item_container'>\n"; 
    827         $html .= "<div class='admin_element_label'>"._("Username")." : </div>\n"; 
    828         $html .= "<div class='admin_element_data'>\n"; 
     829        $html .= "<tr><td>"._("Username")." : </td>\n"; 
    829830        $name = "user_".$this->getId()."_username"; 
    830         $html .= "<input type='text' name='$name' value='".htmlentities($this->getUsername())."' size=30>\n"; 
     831        $html .= "<td><input type='text' name='$name' value='".htmlentities($this->getUsername())."' size=30>\n"; 
     832        $html .= "</td><tr><td colspan=2>\n"; 
    831833        $html .= _("Be carefull when changing this: it's the username you use to log in!"); 
    832         $html .= "</div>\n"; 
    833         $html .= "</li>\n"; 
     834        $html .= "</td></tr>\n"; 
    834835} 
    835836 
    836         $html .= "<li class='admin_element_item_container'>\n"; 
    837         $html .= "<div class='admin_element_label'>"._("Real name")." : </div>\n"; 
    838         $html .= "<div class='admin_element_data'>\n"; 
    839         $name = "user_".$this->getId()."_real_name"; 
     837        $html .= "<tr>\n"; 
     838        $html .= "<td>"._("Real name")." : </td>\n"; 
     839        $html .= "<td>\n"; 
     840        $name = "user_".$this->getId()."_realname"; 
    840841        $html .= "<input type='text' name='$name' value='".htmlentities($this->getRealName())."' size=30>\n"; 
    841         $html .= "</div>\n"; 
    842         $html .= "</li>\n"; 
    843  
    844         $html .= "<li class='admin_element_item_container'>\n"; 
    845         $html .= "<div class='admin_element_label'>"._("Website URL")." : </div>\n"; 
    846         $html .= "<div class='admin_element_data'>\n"; 
     842        $html .= "</td>\n"; 
     843        $html .= "</tr>\n"; 
     844 
     845        $html .= "<tr>\n"; 
     846        $html .= "<td>"._("Website URL")." : </td>\n"; 
     847        $html .= "<td>\n"; 
    847848        $name = "user_".$this->getId()."_website"; 
    848849        $html .= "<input type='text' name='$name' value='".htmlentities($this->getWebsiteURL())."' size=30>\n"; 
    849         $html .= "</div>\n"; 
    850         $html .= "</li>\n"; 
     850        $html .= "</td>\n"; 
     851        $html .= "</tr>\n"; 
     852 
     853        $html .= "<tr>\n"; 
     854        $html .= "<td>"._("Your email address")." : </td>\n"; 
     855        $html .= "<td>\n"; 
     856        $name = "user_".$this->getId()."_email"; 
     857        $html .= "<input type='text' name='$name' value='".htmlentities($this->getEmail())."' size=30>\n"; 
     858        $html .= "</td>\n"; 
     859        $html .= "</tr>\n"; 
     860 
     861        $html .= "<tr>\n"; 
     862        $html .= "<td>"._("Date de naissance (AAAA-MM-JJ)")." : </td>\n"; 
     863        $html .= "<td>\n"; 
     864        $name = "user_".$this->getId()."_birthday"; 
     865        $html .= "<input type='text' name='$name' value='".htmlentities($this->getBirthday())."' size=30>\n"; 
     866        $html .= "</td>\n"; 
     867        $html .= "</tr>\n"; 
     868 
     869        $html .= "<tr>\n"; 
     870        $html .= "<td>"._("Street address")." : </td>\n"; 
     871        $html .= "<td>\n"; 
     872        $name = "user_".$this->getId()."_address"; 
     873        $html .= "<input type='text' name='$name' value='".htmlentities($this->getAddress())."' size=30>\n"; 
     874        $html .= "</td>\n"; 
     875        $html .= "</tr>\n"; 
     876 
     877        $html .= "<tr>\n"; 
     878        $html .= "<td>"._("Postal code")." : </td>\n"; 
     879        $html .= "<td>\n"; 
     880        $name = "user_".$this->getId()."_postalcode"; 
     881        $html .= "<input type='text' name='$name' value='".htmlentities($this->getPostalCode())."' size=30>\n"; 
     882        $html .= "</td>\n"; 
     883        $html .= "</tr>\n"; 
     884 
     885        $html .= "<tr>\n"; 
     886        $html .= "<td>"._("City")." : </td>\n"; 
     887        $html .= "<td>\n"; 
     888        $name = "user_".$this->getId()."_city"; 
     889        $html .= "<input type='text' name='$name' value='".htmlentities($this->getCity())."' size=30>\n"; 
     890        $html .= "</td>\n"; 
     891        $html .= "</tr>\n";     
     892 
     893 
     894        $html .= "<tr>\n"; 
     895        $html .= "<td>"._("Country")." : </td>\n"; 
     896        $html .= "<td>\n"; 
     897        $name = "user_".$this->getId()."_country"; 
     898        $html .= "<input type='text' name='$name' value='".htmlentities($this->getCountry())."' size=30>\n"; 
     899        $html .= "</td>\n"; 
     900        $html .= "</tr>\n"; 
     901 
     902        $html .= "<tr>\n"; 
     903        $html .= "<td>"._("Public phone number")." : </td>\n"; 
     904        $html .= "<td>\n"; 
     905        $name = "user_".$this->getId()."_phone"; 
     906        $html .= "<input type='text' name='$name' value='".htmlentities($this->getPhone())."' size=30>\n"; 
     907        $html .= "</td>\n"; 
     908        $html .= "</tr>\n"; 
     909 
     910 
     911 
    851912 
    852913                if($this->getNetwork()->HasAdminAccess($currentUser)) 
    853914                { 
    854                         $html .= "<li class='admin_element_item_container'>\n"; 
    855                 $html .= "<div class='admin_element_label'>"._("Account Status")." : </div>\n"; 
    856             $html .= "<div class='admin_element_data'>\n"; 
     915                        $html .= "<tr>\n"; 
     916                $html .= "<td>"._("Account Status")." : </td>\n"; 
     917            $html .= "<td>\n"; 
    857918                $name = "user_".$this->getId()."_account_status"; 
    858919                        $html .= $this->getSelectAccountStatus($name); 
    859 //              $html .= "<input type='text' name='$name' value='".htmlentities($this->getAccountStatus())."' size=30 readonly>\n"; 
    860                 $html .= "</div>\n"; 
    861                 $html .= "</li>\n"; 
     920                $html .= "</td>\n"; 
     921                $html .= "</tr>\n"; 
     922 
     923// todo: list networks here 
     924 
     925 
    862926                } 
    863927 
    864         $html .= "</fieldset>\n"; 
     928        $html .= "</table></fieldset>\n"; 
    865929        return $html; 
    866930    } 
     931 
     932    public function setWebsite($website) 
     933    { 
     934      $website_str = $this->mDb->escapeString($website); 
     935      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET website='{$website_str}' WHERE user_id='{$this->id}'"))) 
     936        { 
     937          throw new Exception(_("Could not update Website URL.")); 
     938        } 
     939      $this->mRow['website'] = $website; // unescaped 
     940    } 
     941 
     942   public function setRealName($realname) 
     943    { 
     944      $realname_str = $this->mDb->escapeString($realname); 
     945      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET real_name='{$realname_str}' WHERE user_id='{$this->id}'"))) 
     946        { 
     947          throw new Exception(_("Could not update realname.")); 
     948        } 
     949      $this->mRow['real_name'] = $realname; // unescaped 
     950    } 
     951 
     952 
     953   public function setAddress($address) 
     954    { 
     955      $address_str = $this->mDb->escapeString($address); 
     956      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET address='{$address_str}' WHERE user_id='{$this->id}'"))) 
     957        { 
     958          throw new Exception(_("Could not update address.")); 
     959        } 
     960      $this->mRow['address'] = $address; // unescaped 
     961    } 
     962 
     963   public function setPostalCode($postalcode) 
     964    { 
     965      $postalcode_str = $this->mDb->escapeString($postalcode); 
     966      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET postalcode='{$postalcode_str}' WHERE user_id='{$this->id}'"))) 
     967        { 
     968          throw new Exception(_("Could not postal code.")); 
     969        } 
     970      $this->mRow['postalcode'] = $postalcode; // unescaped 
     971    } 
     972 
     973   public function setCity($city) 
     974    { 
     975      $city_str = $this->mDb->escapeString($city); 
     976      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET city='{$city_str}' WHERE user_id='{$this->id}'"))) 
     977        { 
     978          throw new Exception(_("Could not update city.")); 
     979        } 
     980      $this->mRow['city'] = $city; // unescaped 
     981    } 
     982 
     983   public function setCountry($country) 
     984    { 
     985      $country_str = $this->mDb->escapeString($country); 
     986      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET country='{$country_str}' WHERE user_id='{$this->id}'"))) 
     987        { 
     988          throw new Exception(_("Could not update country.")); 
     989        } 
     990      $this->mRow['country'] = $country; // unescaped 
     991    } 
     992 
     993   public function setPhone($phone) 
     994    { 
     995      $phone_str = $this->mDb->escapeString($phone); 
     996      if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET phone='{$phone_str}' WHERE user_id='{$this->id}'"))) 
     997        { 
     998          throw new Exception(_("Could not update phone.")); 
     999        } 
     1000      $this->mRow['phone'] = $phone; // unescaped 
     1001    } 
     1002 
     1003 
     1004 
    8671005 
    8681006    public function processAdminUI() 
     
    8761014        $this->setUsername($_REQUEST[$name]); 
    8771015                 
    878                // realname to code 
     1016        // realname to code 
    8791017        $realname = "user_".$this->getId()."_realname"; 
    8801018        $this->setRealname($_REQUEST[$realname]); 
    8811019 
    882  
     1020    // website 
     1021        $website = "user_".$this->getId()."_website"; 
     1022        $this->setWebsite($_REQUEST[$website]); 
     1023 
     1024    // email 
     1025        $email = "user_".$this->getId()."_email"; 
     1026        $this->setEmail($_REQUEST[$email]); 
     1027 
     1028    // address 
     1029        $address = "user_".$this->getId()."_address"; 
     1030        $this->setAddress($_REQUEST[$address]); 
     1031 
     1032   // postalcode 
     1033        $postalcode = "user_".$this->getId()."_postalcode"; 
     1034        $this->setPostalCode($_REQUEST[$postalcode]); 
     1035 
     1036   // city 
     1037        $city = "user_".$this->getId()."_city"; 
     1038        $this->setCity($_REQUEST[$city]); 
     1039 
     1040   // country 
     1041        $country = "user_".$this->getId()."_country"; 
     1042        $this->setCountry($_REQUEST[$country]); 
     1043 
     1044   // phone 
     1045        $phone = "user_".$this->getId()."_phone"; 
     1046        $this->setPhone($_REQUEST[$phone]); 
     1047 
     1048    // account_status 
     1049        $account = "user_".$this->getId()."_account_status"; 
     1050        $this->setAccountStatus($_REQUEST[$account]); 
    8831051 
    8841052 } 
     
    8971065        { 
    8981066                return $this->mRow['website']; 
    899         } 
    900  
     1067        }    
     1068 
     1069    public function getBirthday() 
     1070        { 
     1071                return $this->mRow['birthday']; 
     1072        } 
     1073 
     1074    public function getAddress() 
     1075        { 
     1076                return $this->mRow['address']; 
     1077        } 
     1078 
     1079    public function getCity() 
     1080        { 
     1081                return $this->mRow['city']; 
     1082        } 
     1083 
     1084    public function getPostalCode() 
     1085        { 
     1086                return $this->mRow['postalcode']; 
     1087        } 
     1088 
     1089    public function getCountry() 
     1090        { 
     1091                return $this->mRow['country']; 
     1092        } 
     1093 
     1094    public function getPhone() 
     1095        { 
     1096                return $this->mRow['phone']; 
     1097        } 
     1098   
    9011099    public function getUserUI() 
    9021100        {