Changeset 183

Show
Ignore:
Timestamp:
01/02/07 21:53:01 (2 years ago)
Author:
syrus
Message:

ajout/edition du reseau d inscription

Files:

Legend:

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

    r60 r183  
    9999    } 
    100100 
     101 
    101102    /** Get the default network 
    102103     * @return a Network object, NEVER returns null. 
     
    114115        return $retval; 
    115116    } 
     117 
     118 
     119// to finish 
     120 
     121   public static function getNetworkNameById($id) { 
     122        $retval = null; 
     123        global $db; 
     124        if(empty ($id)) 
     125        { 
     126                $retval = ""; 
     127        } 
     128        else { 
     129                $sql =   "SELECT name FROM networks WHERE network_id = '$id' LIMIT 1"; 
     130                $db->execSqlUniqueRes($sql, $network_row, false); 
     131                if ($network_row == null) { 
     132                        $retval = ""; 
     133                } 
     134                else $retval = $network_row['name']; 
     135        } 
     136        return $retval; 
     137         
     138   } 
    116139 
    117140    /** Get the current network for which the portal is displayed or to which a user is physically connected. 
     
    185208            $selected_id = null; 
    186209        } 
     210        global $db; 
     211        $additional_where = $db->escapeString($additional_where); 
     212        $sql = "SELECT network_id, name FROM networks WHERE 1=1 $additional_where ORDER BY is_default_network DESC"; 
     213        $network_rows = null; 
     214        $db->execSql($sql, $network_rows, false); 
     215        if ($network_rows == null) { 
     216            throw new Exception(_("Network::getAllNetworks:  Fatal error: No networks in the database!")); 
     217        } 
     218 
     219        $number_of_networks = count($network_rows); 
     220        if ($number_of_networks > 1) { 
     221            $i = 0; 
     222            foreach ($network_rows as $network_row) { 
     223                $tab[$i][0] = $network_row['network_id']; 
     224                $tab[$i][1] = $network_row['name']; 
     225                $i ++; 
     226            } 
     227            $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, false); 
     228 
     229        } 
     230        else { 
     231            foreach ($network_rows as $network_row) //iterates only once... 
     232                { 
     233                $html .= " $network_row[name] "; 
     234                $html .= "<input type='hidden' name='$name' value='".htmlspecialchars($network_row['network_id'], ENT_QUOTES, 'UTF-8')."'>"; 
     235            } 
     236        } 
     237 
     238        return $html; 
     239    } 
     240 
     241   public static function getSelectNetworkByNameUI($user_prefix, $selected_id = null, $additional_where = null) { 
     242        $html = ''; 
     243        $name = $user_prefix; 
     244        $html .= _("Network:")." \n"; 
     245 
    187246        global $db; 
    188247        $additional_where = $db->escapeString($additional_where); 
  • wifidog/wifidog-auth/wifidog/classes/User.php

    r179 r183  
    215215     * @return the newly created User object, or null if there was an error 
    216216     */ 
    217     static function createUser($id, $username, Network $account_origin, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network
     217    static function createUser($id, $username, Network $account_origin, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network_id
    218218    { 
    219219        global $db; 
     
    237237        $token = User :: generateToken(); 
    238238 
    239         $db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date,real_name,birthday,address,postalcode,city,country,phone,network) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW(),'$realname_str','$birthday_str','$address_str','$postalcode_str','$city_str','$country_str','$phone_str','$network')"); 
     239        $db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date,real_name,birthday,address,postalcode,city,country,phone,network) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW(),'$realname_str','$birthday_str','$address_str','$postalcode_str','$city_str','$country_str','$phone_str','$network_id')"); 
    240240 
    241241        $object = new self($id); 
     
    746746                if ($user_rows != null) 
    747747                { 
    748                         Utils :: natsort2d($user_rows, "user_id"); 
     748                        // Utils :: natsort2d($user_rows, "user_id"); 
    749749                        if ($type_interface != "table") { 
    750750                                $html .= _("User"); 
     
    760760                                $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false); 
    761761                        } else { 
    762                                 $html .= "<fieldset>\n\t<legend>Users List</legend>\n"; 
     762                                $html .= "<fieldset>\n\t<legend>Liste des utilisateurs</legend>\n"; 
    763763                                $html .= "\t<span class='node_admin'>"._("Filter:")."<input type=\"text\" tabindex=\"1\" maxlength=\"40\" size=\"40\" id=\"nodes_list_filter\" name=\"nodes_list_filter\" /></span>\n\t<br/>\n"; 
    764764                                $html .= "\t<!--[if IE]><style type='text/css'>#user_list_div table.scrollable>tbody { height: 15px; }</style><![endif]-->\n"; 
     
    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><th>Network</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>"._("Username")."</th>\n\t\t\t\t\t<th>"._("Account Status")."</th>\n\t\t\t\t\t<th>"._("Registered On")."</th><th>"._("Network")."</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; 
    770770 
    771771                                $i = 0; 
     
    773773                                { 
    774774                                        $account_status = $user_row['account_status']; 
     775                    $network_name = Network::getNetworkNameById($user_row['network']); 
    775776                                        $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><td>{$user_row['network']}</td>\n\t\t\t\t</tr>\n"; 
     777                                        $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>$network_name</td>\n\t\t\t\t</tr>\n"; 
    777778                                } 
    778779                                $html .= "\t\t\t</tbody>\n\t\t</table>\n"; 
     
    923924// todo: list networks here 
    924925 
    925  
     926            $html .= "<tr>\n"; 
     927            $html .= "<td colspan=2>"; 
     928            $name = "user_".$this->getId()."_network"; 
     929            $html .= Network::getSelectNetworkByNameUI($name, $this->mRow['network']); 
     930            $html .= "</td>\n"; 
     931            $html .= "</tr>\n"; 
    926932                } 
    927933 
     
    930936    } 
    931937 
     938    public function getNetworkName() 
     939    { 
     940        return $this->mRow['network']; 
     941    } 
     942 
    932943    public function setWebsite($website) 
    933944    { 
     
    10011012    } 
    10021013 
    1003  
    1004  
     1014    public function setNetwork($network_id) 
     1015    { 
     1016       if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET network='{$network_id}' WHERE user_id='{$this->id}'"))) 
     1017                { 
     1018                    throw new Exception(_("Could not update network.")); 
     1019                } 
     1020       $this->mRow['network'] = $network_id; 
     1021    } 
    10051022 
    10061023    public function processAdminUI() 
     
    10091026        $currentUser= self::getCurrentUser(); 
    10101027        if($this==$currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) 
    1011 
     1028       
    10121029    //username 
    10131030        $name = "user_".$this->getId()."_username"; 
     
    10501067        $this->setAccountStatus($_REQUEST[$account]); 
    10511068 
    1052  } 
     1069    // Network 
     1070        $network = "user_".$this->getId()."_network"; 
     1071        $this->setNetwork($_REQUEST[$network]); 
     1072 
     1073        } 
    10531074    } 
    10541075 
  • wifidog/wifidog-auth/wifidog/signup.php

    r174 r183  
    5858require_once('classes/MainUI.php'); 
    5959require_once('classes/Mail.php'); 
     60require_once('classes/Network.php'); 
    6061 
    6162/** 
     
    216217 
    217218    $network = Network::getObject($_REQUEST['auth_source']); 
     219    $network_node = Network::getCurrentNetwork(); 
    218220         
    219221    try { 
     
    270272 
    271273        // Create user and send him the validation email 
    272         $created_user = User::createUser(get_guid(), $username, $network, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network->getName()); 
     274        $created_user = User::createUser(get_guid(), $username, $network, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network_node->getId()); 
    273275        $created_user->sendValidationEmail(); 
    274276