Changeset 985

Show
Ignore:
Timestamp:
02/20/07 15:20:41 (2 years ago)
Author:
sven
Message:

add option to hide password-changing stuff. ideally auth modules could handle password changing too.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/_invite/new_password.php

    r796 r985  
    88         
    99        run("invite:init"); 
    10         templates_page_setup();                 
     10        templates_page_setup(); 
    1111        $title = sprintf(__gettext("Get new %s password"), sitename); 
    1212         
  • devel/config-dist.php

    r942 r985  
    198198$CFG->curlpath = false; 
    199199 
     200// Whether to prevent users from changing their passwords. 
     201// For use with an external authentication system that doesn't look at the elgg user's password. 
     202// You'll probably want to disable registration and invites too. 
     203$CFG->disable_passwordchanging = false; 
    200204 
    201205// Some other $CFG variables found in codebase. 
     
    204208// $CFG->admin 
    205209// $CFG->allowobjectembed // boolean - whether to allow <object> and <embed> tags through input-cleaning 
    206 // $CFG->auth 
     210// $CFG->auth // string - which auth plugin to use 
    207211// $CFG->cachetext 
    208212// $CFG->currenttextiscacheable 
  • devel/lib/elgglib.php

    r983 r985  
    41784178 * @return integer 
    41794179 */ 
    4180  function page_owner() { 
    4181      
    4182     static $owner, $called; 
    4183     if (!$called) { 
    4184          
    4185         $owner = optional_param('owner',-1,PARAM_INT); 
    4186         if ($allmods = get_list_of_plugins('mod') ) { 
    4187             foreach ($allmods as $mod) { 
    4188                 $mod_page_owner = $mod . '_page_owner'; 
    4189                 if (function_exists($mod_page_owner)) { 
    4190                     if ($value = $mod_page_owner()) { 
    4191                          
    4192                         $owner = $value; 
    4193                          
    4194                    
    4195                
    4196          
    4197        
    4198         $called = true; 
    4199    
    4200      
    4201     return $owner; 
    4202 
     4180function page_owner() { 
     4181     
     4182    static $owner, $called; 
     4183    if (!$called) { 
     4184         
     4185        $owner = optional_param('owner',-1,PARAM_INT); 
     4186        if ($allmods = get_list_of_plugins('mod') ) { 
     4187           foreach ($allmods as $mod) { 
     4188               $mod_page_owner = $mod . '_page_owner'; 
     4189               if (function_exists($mod_page_owner)) { 
     4190                   if ($value = $mod_page_owner()) { 
     4191                        
     4192                       $owner = $value; 
     4193                        
     4194                   
     4195               
     4196         
     4197       
     4198       $called = true; 
     4199   
     4200     
     4201    return $owner; 
     4202
    42034203 
    42044204?> 
  • devel/lib/setup.php

    r902 r985  
    6868if (empty($CFG->disable_publiccomments)) { 
    6969    $CFG->disable_publiccomments = false; 
     70} 
     71 
     72if (empty($CFG->disable_passwordchanging)) { 
     73    $CFG->disable_passwordchanging = false; 
    7074} 
    7175 
  • devel/mod/template/templates/Default_Template/css

    r962 r985  
    101101        width:100%; 
    102102        height:120px; 
    103        
     103
    104104 
    105105/* 
     
    171171        overflow:hidden; 
    172172        position:relative; 
    173        
     173
    174174 
    175175div#content-holder a:hover { 
     
    240240        width: 200px; 
    241241        margin:0 0 0 20px; 
    242        
     242
    243243 
    244244div#splitpane-sidebar ul { 
     
    255255 
    256256div#splitpane-sidebar ul li ul li a { 
    257         padding:0 0 0 5px; 
     257        padding:0 0 0 5px; 
    258258} 
    259259 
     
    292292div#footer a:hover { 
    293293        text-decoration:underline; 
    294        
     294
    295295 
    296296div#footer a:link, div#footer a:visited { 
     
    313313        padding:0px; 
    314314        margin:2px; 
    315        
     315
    316316 
    317317/* 
  • devel/units/communities/userdetails_actions.php

    r758 r985  
    1313        case "userdetails:update": 
    1414         
    15                                         $community_owner = trim(optional_param('community_owner')); 
    16                                         if (!empty($community_owner)) { 
    17                                             if ($new_owner = user_info_username("ident",$community_owner)) { 
    18                                                 if (user_info("user_type",$new_owner) != "community") { 
    19                                                     if ($info = get_record('users','ident',$id)) { 
    20                                                          
    21                                                         $info->owner = $new_owner; 
    22                                                         update_record('users',$info); 
    23                                                         $messages[] = sprintf(__gettext("Community ownership transferred to %s."),$community_owner); 
    24                                                          
    25                                                     } else { 
    26                                                         $messages[] = __gettext("Could not retrieve community details."); 
    27                                                     } 
    28                                                 } 
    29                                             } 
    30                                         } 
    31                                         break; 
     15        $community_owner = trim(optional_param('community_owner')); 
     16        if (!empty($community_owner)) { 
     17            if ($new_owner = user_info_username("ident",$community_owner)) { 
     18                if (user_info("user_type",$new_owner) != "community") { 
     19                    if ($info = get_record('users','ident',$id)) { 
     20                         
     21                        $info->owner = $new_owner; 
     22                        update_record('users',$info); 
     23                        $messages[] = sprintf(__gettext("Community ownership transferred to %s."),$community_owner); 
     24                         
     25                    } else { 
     26                        $messages[] = __gettext("Could not retrieve community details."); 
     27                    } 
     28                } else { 
     29                    $messages[] = sprintf(__gettext("Could not find new owner %s. Community owner not changed."),$community_owner); 
     30                } 
     31            } 
     32        } 
     33        break; 
    3234         
    3335    } 
  • devel/units/gettext/library.php

    r780 r985  
    481481                    } 
    482482                } 
    483                 else 
    484                 { 
    485                     $messages[] .= __gettext("Preferred language") . " " . __gettext("not changed") ."."; 
    486                 } 
    487483            } 
    488484        } 
  • devel/units/invite/new_password.php

    r861 r985  
    22global $CFG; 
    33// Generate a new password 
    4          
     4 
    55$sitename = sitename; 
    66 
  • devel/units/invite/password_request.php

    r659 r985  
    11<?php 
    22 
     3global $CFG; 
     4 
     5if (!empty($CFG->disable_passwordchanging)) { 
     6     
     7    $nope = __gettext('The site administrator has disabled password changing.'); 
     8    $run_result .= '<p>' . $nope . '</p>'; 
     9     
     10} else { 
     11     
    312    // Join 
    4         $sitename = sitename; 
    5         $desc = sprintf(__gettext("To generate a new password at %s!, enter your username below. We will send the address of a unique verification page to you via email click on the link in the body of the message and a new password will be sent to you."), $sitename); // gettext variable 
    6         $thismethod = __gettext("This method reduces the chance of a mistakenly reset password."); 
    7                              
    8                 $run_result .= <<< END 
     13    $sitename = sitename; 
     14    $desc = sprintf(__gettext("To generate a new password at %s!, enter your username below. We will send the address of a unique verification page to you via email click on the link in the body of the message and a new password will be sent to you."), $sitename); // gettext variable 
     15    $thismethod = __gettext("This method reduces the chance of a mistakenly reset password."); 
     16     
     17    $run_result .= <<< END 
    918                 
    1019    <p> 
     
    1726                 
    1827END; 
    19                  
    20                 $run_result .= templates_draw(array( 
    21                                                 'context' => 'databoxvertical', 
    22                                                 'name' => __gettext("Your username"), 
    23                                                 'contents' => display_input_field(array("password_request_name","","text")) 
    24                    
    25                     ); 
    26                 $request = __gettext("Request new password"); // gettext variable 
    27                 $run_result .= <<< END 
     28     
     29    $run_result .= templates_draw(array( 
     30                                    'context' => 'databoxvertical', 
     31                                    'name' => __gettext("Your username"), 
     32                                    'contents' => display_input_field(array("password_request_name","","text")) 
     33       
     34        ); 
     35    $request = __gettext("Request new password"); // gettext variable 
     36    $run_result .= <<< END 
    2837            <p align="center"> 
    2938                <input type="hidden" name="action" value="invite_password_request" /> 
     
    3140            </p> 
    3241        </form> 
    33                  
     42         
    3443END; 
    3544 
     45} 
     46 
    3647?> 
  • devel/units/users/userdetails_actions.php

    r703 r985  
    1111     
    1212    switch ($action) { 
     13     
     14    // Update user details 
     15    case "userdetails:update": 
    1316         
    14         // Update user details 
    15     case "userdetails:update": 
     17        $usertype = user_type($page_owner); 
     18         
    1619        $name = trim(optional_param('name')); 
    1720        if (!empty($name)) { 
    18             $userdetails_ok = "yes"; 
    1921            if (strlen($name) > 64) { 
    2022                $messages[] = __gettext("Your suggested name was too long. Please try something shorter."); 
    21                 $userdetails_ok = "no"; 
    22             } 
    23              
    24             $usertype = user_type($page_owner); 
    25             $email = trim(optional_param('email')); 
    26             if ($usertype == 'person' && !empty($email)) { 
    27                 if (!validate_email($email)) { 
    28                     $messages[] = __gettext("Your suggested email address $email doesn't appear to be valid."); 
    29                      
    30                     $userdetails_ok = "no"; 
    31                 } else { 
    32                     $u = new StdClass; 
    33                     $u->email = $email; 
    34                     $u->ident = $id; 
    35                     update_record('users',$u); 
    36                     if ($USER->ident == $page_owner) { 
    37                         $USER->email = $email; 
    38                         $_SESSION['email'] = $email; 
    39                     } 
    40                     $messages[] = __gettext("Email address updated."); 
    41                 } 
    42             } 
    43              
    44             $moderation = optional_param('moderation'); 
    45             if (!empty($moderation) && in_array($moderation,array('yes','no','priv'))) { 
    46                 set_field('users','moderation',$moderation,'ident',$id); 
    47                 $messages[] = __gettext("Your moderation preferences have been changed."); 
    48             } 
    49  
    50             if (!$CFG->disable_publiccomments) { 
    51                 $publiccomments = optional_param('publiccomments'); 
    52                 if ($usertype == 'person' && !empty($publiccomments)) { 
    53                     if ($publiccomments == "yes") { 
    54                         user_flag_set("publiccomments", "1", $id); 
    55                         $messages[] = __gettext("Public comments and discussion set to 'on'."); 
    56                     } else { 
    57                         user_flag_unset("publiccomments",$id); 
    58                         $messages[] = __gettext("Public comments and discussion set to 'off'."); 
    59                     } 
    60                 } 
    61             } 
    62              
    63             $receiveemails = optional_param('receiveemails'); 
    64             if ($usertype == 'person' && isset($receiveemails)) { 
    65                 if ($receiveemails == "yes") { 
    66                     user_flag_set("emailreplies", "1", $id); 
    67                     $messages[] = __gettext("Email comments and discussion set to 'on'."); 
    68                 } else { 
    69                     user_flag_unset("emailreplies",$id); 
    70                     $messages[] = __gettext("Email comments and discussion set to 'off'."); 
    71                 } 
    72             } 
    73              
    74             $receiveemails = optional_param('receivenotifications'); 
    75             if ($usertype == 'person' && isset($receiveemails)) { 
    76                 if ($receiveemails == "yes") { 
    77                     user_flag_set("emailnotifications", "1", $id); 
    78                     $messages[] = __gettext("Email notifications set to 'on'."); 
    79                 } else { 
    80                     user_flag_unset("emailnotifications",$id); 
    81                     $messages[] = __gettext("Email notifications set to 'off'."); 
    82                 } 
    83             } 
    84              
    85             if ($userdetails_ok == "yes") { 
    86                 $messages[] = "Name updated."; 
     23            } elseif ($name != $USER->name) { 
    8724                $u = new StdClass; 
    8825                $u->name = $name; 
     
    9027                update_record('users',$u); 
    9128                if ($USER->ident == $page_owner) { 
    92                     $USER->name = stripslashes($name)
    93                     $_SESSION['name'] = stripslashes($name)
     29                    $USER->name = $name
     30                    $_SESSION['name'] = $name
    9431                } 
     32                $messages[] = "Name updated."; 
     33            } 
     34        } 
     35         
     36        $email = trim(optional_param('email')); 
     37        if ($usertype == 'person' && !empty($email)) { 
     38            if (!validate_email($email)) { 
     39                $messages[] = __gettext("Your suggested email address $email doesn't appear to be valid."); 
     40            } elseif ($email != $USER->email) { 
     41                $u = new StdClass; 
     42                $u->email = $email; 
     43                $u->ident = $id; 
     44                update_record('users',$u); 
     45                if ($USER->ident == $page_owner) { 
     46                    $USER->email = $email; 
     47                    $_SESSION['email'] = $email; 
     48                } 
     49                $messages[] = __gettext("Email address updated."); 
     50            } 
     51        } 
     52         
     53        $moderation = optional_param('moderation'); 
     54        if (!empty($moderation) && in_array($moderation,array('yes','no','priv'))) { 
     55            set_field('users','moderation',$moderation,'ident',$id); 
     56            $messages[] = __gettext("Your moderation preferences have been changed."); 
     57        } 
     58         
     59        if (!$CFG->disable_publiccomments) { 
     60            $publiccomments = optional_param('publiccomments'); 
     61            if ($usertype == 'person' && !empty($publiccomments)) { 
     62                if ($publiccomments == "yes") { 
     63                    user_flag_set("publiccomments", "1", $id); 
     64                    $messages[] = __gettext("Public comments and discussion set to 'on'."); 
     65                } else { 
     66                    user_flag_unset("publiccomments",$id); 
     67                    $messages[] = __gettext("Public comments and discussion set to 'off'."); 
     68                } 
     69            } 
     70        } 
     71         
     72        $receiveemails = optional_param('receiveemails'); 
     73        if ($usertype == 'person' && isset($receiveemails)) { 
     74            if ($receiveemails == "yes") { 
     75                user_flag_set("emailreplies", "1", $id); 
     76                $messages[] = __gettext("Email comments and discussion set to 'on'."); 
    9577            } else { 
    96                 $messages[] = __gettext("Details were not changed."); 
     78                user_flag_unset("emailreplies",$id); 
     79                $messages[] = __gettext("Email comments and discussion set to 'off'."); 
    9780            } 
     81        } 
     82         
     83        $receiveemails = optional_param('receivenotifications'); 
     84        if ($usertype == 'person' && isset($receiveemails)) { 
     85            if ($receiveemails == "yes") { 
     86                user_flag_set("emailnotifications", "1", $id); 
     87                $messages[] = __gettext("Email notifications set to 'on'."); 
     88            } else { 
     89                user_flag_unset("emailnotifications",$id); 
     90                $messages[] = __gettext("Email notifications set to 'off'."); 
     91            } 
     92        } 
     93         
     94        if (empty($CFG->disable_passwordchanging)) { 
     95            $password1 = optional_param('password1'); 
     96            $password2 = optional_param('password2'); 
    9897             
    99         } 
    100  
    101         $password1 = optional_param('password1'); 
    102         $password2 = optional_param('password2'); 
    103  
    104         if (!empty($password1) || !empty($password2)) { 
    105             if (($password1 == $password2)) { 
    106                 if (strlen($password1) < 4 || strlen($password1) > 32) { 
    107                     $messages[] = __gettext("Password not changed: Your password is either too short or too long. It must be between 4 and 32 characters in length."); 
    108                 } else if (!preg_match("/^[a-zA-Z0-9]*$/i",$password1)) { 
    109                     $messages[] = __gettext("Password not changed: Your password can only consist of letters or numbers."); 
     98            if (!empty($password1) || !empty($password2)) { 
     99                if (($password1 == $password2)) { 
     100                    if (strlen($password1) < 4 || strlen($password1) > 32) { 
     101                        $messages[] = __gettext("Password not changed: Your password is either too short or too long. It must be between 4 and 32 characters in length."); 
     102                    } else if (!preg_match("/^[a-zA-Z0-9]*$/i",$password1)) { 
     103                        $messages[] = __gettext("Password not changed: Your password can only consist of letters or numbers."); 
     104                    } else { 
     105                        $messages[] = __gettext("Your password was updated."); 
     106                        $u = new StdClass; 
     107                        $u->password = md5($password1); 
     108                        $u->ident = $page_owner; 
     109                        update_record('users',$u); 
     110                    } 
    110111                } else { 
    111                     $messages[] = __gettext("Your password was updated."); 
    112                     $u = new StdClass; 
    113                     $u->password = md5($password1); 
    114                     $u->ident = $page_owner; 
    115                     update_record('users',$u); 
     112                    $messages[] = __gettext("Password not changed: The password and its verification string did not match."); 
    116113                } 
    117             } else { 
    118                 $messages[] = __gettext("Password not changed: The password and its verification string did not match."); 
    119114            } 
    120115        } 
  • devel/units/users/userdetails_edit.php

    r979 r985  
    149149    } 
    150150     
    151     $password = __gettext("Change your password:"); // gettext variable 
    152     $passwordRules = __gettext("Leave this blank if you're happy to leave your password as it is."); // gettext variable 
    153     $body .= <<< END 
     151    if (empty($CFG->disable_passwordchanging)) { 
     152        $password = __gettext("Change your password:"); // gettext variable 
     153        $passwordRules = __gettext("Leave this blank if you're happy to leave your password as it is."); // gettext variable 
     154        $body .= <<< END 
    154155     
    155156    <h2> 
     
    162163END; 
    163164     
    164     $body .= templates_draw(array( 
    165             'context' => 'databox', 
    166             'name' => __gettext("Your password: "), 
    167             'column1' => "<input type=\"password\" name=\"password1\" value=\"\" />" 
    168         ) 
    169         ); 
    170          
    171     $body .= templates_draw(array( 
    172             'context' => 'databox', 
    173             'name' => __gettext("Again for verification purposes: "), 
    174             'column1' => "<input type=\"password\" name=\"password2\" value=\"\" />" 
    175         ) 
    176         ); 
     165        $body .= templates_draw(array( 
     166                'context' => 'databox', 
     167                'name' => __gettext("Your password: "), 
     168                'column1' => "<input type=\"password\" name=\"password1\" value=\"\" />" 
     169            ) 
     170            ); 
     171             
     172        $body .= templates_draw(array( 
     173                'context' => 'databox', 
     174                'name' => __gettext("Again for verification purposes: "), 
     175                'column1' => "<input type=\"password\" name=\"password2\" value=\"\" />" 
     176            ) 
     177            ); 
     178    } 
    177179     
    178180    // Allow plug-ins to add stuff ...