Changeset 836

Show
Ignore:
Timestamp:
01/19/07 13:29:46 (2 years ago)
Author:
sven
Message:

fix and extra messages for invite.
strip out a bunch of dead code from elgglib.

Files:

Legend:

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

    r659 r836  
    1515    // You must be logged on to view this! 
    1616        if (logged_on && $CFG->publicinvite == true) { 
    17          
    18         $title = __gettext("Invite a Friend"); 
    19          
    20         $body = run("content:invite:invite"); 
    21         $body .= run("invite:invite"); 
    22          
    23         $body = templates_draw(array( 
    24                         'context' => 'contentholder', 
    25                         'title' => $title, 
    26                         'body' => $body 
    27                    
    28                     ); 
    29          
    30         echo templates_page_draw( array( 
    31                         $title, $body 
    32                    
    33                     ); 
    34                 } else { 
    35                     header("Location: " . $CFG->wwwroot); 
    36                
     17             
     18            $title = __gettext("Invite a Friend"); 
     19             
     20            $body = run("content:invite:invite"); 
     21            $body .= run("invite:invite"); 
     22             
     23            $body = templates_draw(array( 
     24                            'context' => 'contentholder', 
     25                            'title' => $title, 
     26                            'body' => $body 
     27                       
     28                        ); 
     29             
     30            echo templates_page_draw( array( 
     31                            $title, $body 
     32                       
     33                        ); 
     34        } else { 
     35            header("Location: " . $CFG->wwwroot); 
     36       
    3737 
    3838?> 
  • devel/_invite/join.php

    r659 r836  
    88         
    99        run("invite:init"); 
    10         templates_page_setup();         
     10        templates_page_setup(); 
    1111         
    1212        $title = sprintf(__gettext("Join %s"),sitename); 
  • devel/config-dist.php

    r804 r836  
    187187 
    188188 
    189 // Some other $CFG variables found in codebase 
     189// Some other $CFG variables found in codebase. 
     190// They may or may not be config options. Some are just used for holding global data. 
    190191 
    191192// $CFG->admin 
    192 // $CFG->allowobjectembed 
    193 // $CFG->aspellpath 
     193// $CFG->allowobjectembed // boolean - whether to allow <object> and <embed> tags through input-cleaning 
    194194// $CFG->auth 
    195195// $CFG->cachetext 
     
    197197// $CFG->dbsessions 
    198198// $CFG->detect_unchecked_vars 
    199 // $CFG->editorbackgroundcolor 
    200 // $CFG->editorfontfamily 
    201 // $CFG->editorfontlist 
    202 // $CFG->editorfontsize 
    203 // $CFG->editorhidebuttons 
    204 // $CFG->editorkillword 
    205 // $CFG->editorspelling 
    206199// $CFG->filterall 
    207200// $CFG->framename 
    208 // $CFG->handlebounces 
    209 // $CFG->ignoresesskey 
    210 // $CFG->lang 
    211 // $CFG->lastcron 
    212 // $CFG->libdir 
     201// $CFG->handlebounces // in commented-out code 
     202// $CFG->ignoresesskey // in commented-out code 
    213203// $CFG->logsql 
    214204// $CFG->maxbytes 
    215 // $CFG->newsclient_lastcron 
    216205// $CFG->openid_comments_allowed 
    217206// $CFG->opentogoogle 
  • devel/lib/elgglib.php

    r793 r836  
    358358function report_session_error() { 
    359359    global $CFG, $FULLME; 
    360     if (empty($CFG->lang)) { 
    361         $CFG->lang = "en"; 
    362     } 
    363360 
    364361    //clear session cookies 
     
    375372} 
    376373 
     374// never called 
    377375/** 
    378376 * For security purposes, this function will check that the currently 
     
    383381 * @return bool 
    384382 */ 
    385 function confirm_sesskey($sesskey=NULL) { 
    386     global $USER; 
    387  
    388     if (!empty($USER->ignoresesskey) || !empty($CFG->ignoresesskey)) { 
    389         return true; 
    390     } 
    391  
    392     if (empty($sesskey)) { 
    393         $sesskey = required_param('sesskey');  // Check script parameters 
    394     } 
    395  
    396     if (!isset($USER->sesskey)) { 
    397         return false; 
    398     } 
    399  
    400     return ($USER->sesskey === $sesskey); 
    401 
     383// function confirm_sesskey($sesskey=NULL) { 
     384//     global $USER; 
     385 
     386//     if (!empty($USER->ignoresesskey) || !empty($CFG->ignoresesskey)) { 
     387//         return true; 
     388//     } 
     389 
     390//     if (empty($sesskey)) { 
     391//         $sesskey = required_param('sesskey');  // Check script parameters 
     392//     } 
     393 
     394//     if (!isset($USER->sesskey)) { 
     395//         return false; 
     396//     } 
     397 
     398//     return ($USER->sesskey === $sesskey); 
     399//
    402400 
    403401 
     
    28862884 
    28872885/** 
    2888  * Prints a basic textarea field. 
    2889  * 
    2890  * @uses $CFG 
    2891  * @param boolean $usehtmleditor ? 
    2892  * @param int $rows ? 
    2893  * @param int $cols ? 
    2894  * @param null $width <b>Legacy field no longer used!</b>  Set to zero to get control over mincols 
    2895  * @param null $height <b>Legacy field no longer used!</b>  Set to zero to get control over minrows 
    2896  * @param string $name ? 
    2897  * @param string $value ? 
    2898  * @param int $courseid ? 
    2899  * @todo Finish documenting this function 
    2900  */ 
    2901 function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0) { 
    2902 /// $width and height are legacy fields and no longer used as pixels like they used to be. 
    2903 /// However, you can set them to zero to override the mincols and minrows values below. 
    2904  
    2905     global $CFG, $course; 
    2906     static $scriptcount; // For loading the htmlarea script only once. 
    2907  
    2908     $mincols = 65; 
    2909     $minrows = 10; 
    2910  
    2911     if (empty($courseid)) { 
    2912         if (!empty($course->id)) {  // search for it in global context 
    2913             $courseid = $course->id; 
    2914         } 
    2915     } 
    2916  
    2917     if (empty($scriptcount)) { 
    2918         $scriptcount = 0; 
    2919     } 
    2920  
    2921     if ($usehtmleditor) { 
    2922  
    2923         if (!empty($courseid) and isteacher($courseid)) { 
    2924             echo ($scriptcount < 1) ? '<script type="text/javascript" src="'. $CFG->wwwroot .'lib/editor/htmlarea.php?id='. $courseid .'"></script>'."\n" : ''; 
    2925         } else { 
    2926             echo ($scriptcount < 1) ? '<script type="text/javascript" src="'. $CFG->wwwroot .'lib/editor/htmlarea.php"></script>'."\n" : ''; 
    2927         } 
    2928         echo ($scriptcount < 1) ? '<script type="text/javascript" src="'. $CFG->wwwroot .'lib/editor/lang/en.php"></script>'."\n" : ''; 
    2929         $scriptcount++; 
    2930  
    2931         if ($height) {    // Usually with legacy calls 
    2932             if ($rows < $minrows) { 
    2933                 $rows = $minrows; 
    2934             } 
    2935         } 
    2936         if ($width) {    // Usually with legacy calls 
    2937             if ($cols < $mincols) { 
    2938                 $cols = $mincols; 
    2939             } 
    2940         } 
    2941     } 
    2942  
    2943     echo '<textarea id="edit-'. $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'; 
    2944     if ($usehtmleditor) { 
    2945         echo htmlspecialchars(stripslashes_safe($value), ENT_COMPAT, 'utf-8'); // needed for editing of cleaned text! 
    2946     } else { 
    2947         p ($value); 
    2948     } 
    2949     echo '</textarea>'."\n"; 
    2950 } 
    2951  
    2952 /** 
    2953  * Legacy function, provided for backward compatability. 
    2954  * This method now simply calls {@link use_html_editor()} 
    2955  * 
    2956  * @deprecated Use {@link use_html_editor()} instead. 
    2957  * @param string $name Form element to replace with HTMl editor by name 
    2958  * @todo Finish documenting this function 
    2959  */ 
    2960 function print_richedit_javascript($form, $name, $source='no') { 
    2961     use_html_editor($name); 
    2962 } 
    2963  
    2964  
    2965 /** 
    2966  * Sets up the HTML editor on textareas in the current page. 
    2967  * If a field name is provided, then it will only be 
    2968  * applied to that field - otherwise it will be used 
    2969  * on every textarea in the page. 
    2970  * 
    2971  * In most cases no arguments need to be supplied 
    2972  * 
    2973  * @param string $name Form element to replace with HTMl editor by name 
    2974  */ 
    2975 function use_html_editor($name='', $editorhidebuttons='') { 
    2976     echo '<script language="javascript" type="text/javascript" defer="defer">'."\n"; 
    2977     print_editor_config($editorhidebuttons); 
    2978     if (empty($name)) { 
    2979         echo "\n".'HTMLArea.replaceAll(config);'."\n"; 
    2980     } else { 
    2981         echo "\nHTMLArea.replace('edit-$name', config);\n"; 
    2982     } 
    2983     echo '</script>'."\n"; 
    2984 } 
    2985  
    2986  
    2987 /** 
    29882886 * Prints form items with the names $day, $month and $year 
    29892887 * 
     
    32673165    return $text; 
    32683166} 
    3269  
    3270  
    3271 /** 
    3272  * Prints out the HTML editor config. 
    3273  * 
    3274  * @uses $CFG 
    3275  */ 
    3276  function print_editor_config($editorhidebuttons='') { 
    3277  
    3278     global $CFG; 
    3279  
    3280     // print new config 
    3281     echo 'var config = new HTMLArea.Config();'."\n"; 
    3282     echo "config.pageStyle = \"body {"; 
    3283     if(!(empty($CFG->editorbackgroundcolor))) { 
    3284         echo " background-color: $CFG->editorbackgroundcolor;"; 
    3285     } 
    3286  
    3287     if(!(empty($CFG->editorfontfamily))) { 
    3288         echo " font-family: $CFG->editorfontfamily;"; 
    3289     } 
    3290  
    3291     if(!(empty($CFG->editorfontsize))) { 
    3292         echo " font-size: $CFG->editorfontsize;"; 
    3293     } 
    3294  
    3295     echo " }\";\n"; 
    3296     echo "config.killWordOnPaste = "; 
    3297     echo(empty($CFG->editorkillword)) ? "false":"true"; 
    3298     echo ';'."\n"; 
    3299     echo 'config.fontname = {'."\n"; 
    3300  
    3301     $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array(); 
    3302     $i = 1;                     // Counter is used to get rid of the last comma. 
    3303  
    3304     foreach($fontlist as $fontline) { 
    3305         if(!empty($fontline)) { 
    3306             if ($i > 1) { 
    3307                 echo ','."\n"; 
    3308             } 
    3309             list($fontkey, $fontvalue) = split(':', $fontline); 
    3310             echo '"'. $fontkey ."\":\t'". $fontvalue ."'"; 
    3311  
    3312             $i++; 
    3313         } 
    3314     } 
    3315     echo '};'; 
    3316  
    3317     if (!empty($editorhidebuttons)) { 
    3318         echo "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n"; 
    3319     } else if (!empty($CFG->editorhidebuttons)) { 
    3320         echo "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n"; 
    3321     } 
    3322  
    3323     if(!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) { 
    3324         print_speller_code($usehtmleditor=true); 
    3325     } 
    3326 } 
    3327  
    3328 /** 
    3329  * Prints out code needed for spellchecking. 
    3330  * Original idea by Ludo (Marc Alier). 
    3331  * 
    3332  * @uses $CFG 
    3333  * @param boolean $usehtmleditor ? 
    3334  * @todo Finish documenting this function 
    3335  */ 
    3336 function print_speller_code ($usehtmleditor=false) { 
    3337     global $CFG; 
    3338  
    3339     if(!$usehtmleditor) { 
    3340         echo "\n".'<script language="javascript" type="text/javascript">'."\n"; 
    3341         echo 'function openSpellChecker() {'."\n"; 
    3342         echo "\tvar speller = new spellChecker();\n"; 
    3343         echo "\tspeller.popUpUrl = \"" . $CFG->wwwroot ."lib/speller/spellchecker.html\";\n"; 
    3344         echo "\tspeller.spellCheckScript = \"". $CFG->wwwroot ."lib/speller/server-scripts/spellchecker.php\";\n"; 
    3345         echo "\tspeller.spellCheckAll();\n"; 
    3346         echo '}'."\n"; 
    3347         echo '</script>'."\n"; 
    3348     } else { 
    3349         echo "\nfunction spellClickHandler(editor, buttonId) {\n"; 
    3350         echo "\teditor._textArea.value = editor.getHTML();\n"; 
    3351         echo "\tvar speller = new spellChecker( editor._textArea );\n"; 
    3352         echo "\tspeller.popUpUrl = \"" . $CFG->wwwroot ."lib/speller/spellchecker.html\";\n"; 
    3353         echo "\tspeller.spellCheckScript = \"". $CFG->wwwroot ."lib/speller/server-scripts/spellchecker.php\";\n"; 
    3354         echo "\tspeller._moogle_edit=1;\n"; 
    3355         echo "\tspeller._editor=editor;\n"; 
    3356         echo "\tspeller.openChecker();\n"; 
    3357         echo '}'."\n"; 
    3358     } 
    3359 } 
    3360  
    3361 /** 
    3362  * Print button for spellchecking when editor is disabled 
    3363  */ 
    3364 function print_speller_button () { 
    3365     echo '<input type="button" value="Check spelling" onclick="openSpellChecker();" />'."\n"; 
    3366 } 
    3367  
    33683167 
    33693168 
  • devel/units/invite/invite_actions.php

    r834 r836  
    2121             if (logged_on || ($CFG->publicinvite == true)) { 
    2222                 if (($CFG->maxusers == 0 || (count_users('person') < $CFG->maxusers))) { 
    23                  if (validate_email(stripslashes($invite->email))) { 
    24                      $strippedname = stripslashes($invite->name); // for the message text. 
    25                      $invitations = count_records('invitations','email',$invite->email); 
    26                      if ($invitations == 0) { 
    27                          if (!$account = get_record('users','email',$invite->email)) { 
    28                              $invite->code = 'i' . substr(base_convert(md5(time() . $USER->username), 16, 36), 0, 7); 
    29                              $invite->added = time(); 
    30                              $invite->owner = $USER->ident; 
    31                              insert_record('invitations',$invite); 
    32                              $invitetext = trim(optional_param('invite_text')); 
    33                              if (!empty($invitetext)) { 
    34                                  $invitetext = __gettext("They included the following message:") . "\n\n----------\n" . stripslashes($invitetext) . "\n----------"; 
     23                     if (validate_email(stripslashes($invite->email))) { 
     24                         $strippedname = stripslashes($invite->name); // for the message text. 
     25                         $invitations = count_records('invitations','email',$invite->email); 
     26                         if ($invitations == 0) { 
     27                             if (!$account = get_record('users','email',$invite->email)) { 
     28                                 $invite->code = 'i' . substr(base_convert(md5(time() . $USER->username), 16, 36), 0, 7); 
     29                                 $invite->added = time(); 
     30                                 $invite->owner = $USER->ident; 
     31                                 insert_record('invitations',$invite); 
     32                                 $invitetext = trim(optional_param('invite_text')); 
     33                                 if (!empty($invitetext)) { 
     34                                     $invitetext = __gettext("They included the following message:") . "\n\n----------\n" . stripslashes($invitetext) . "\n----------"; 
     35                                 } 
     36                                 $url = url . "_invite/join.php?invitecode=" . $invite->code; 
     37                                 if (!logged_on) { 
     38                                     $greetingstext = sprintf(__gettext("Thank you for registering with %s."),$sitename); 
     39                                     $subjectline = sprintf(__gettext("%s account verification"),$sitename); 
     40                                     $from_email = email; 
     41                                 } else { 
     42                                     $greetingstext = $USER->name . " " . __gettext("has invited you to join") ." $sitename, ". __gettext("a learning landscape system.") .""; 
     43                                     $subjectline = $USER->name . " " . __gettext("has invited you to join") ." $sitename"; 
     44                                     $from_email = $USER->email; 
     45                                 } 
     46                                 $emailmessage = sprintf(__gettext("Dear %s,\n\n%s %s\n\nTo join, visit the following URL:\n\n\t%s\n\n" 
     47                                                                 ."Your email address has not been passed onto any third parties," 
     48                                                                 ." and will be removed from our system within seven days.\n\nRegards,\n\nThe %s team.") 
     49                                                         ,$strippedname,$greetingstext,$invitetext,$url, $sitename); 
     50                                 $emailmessage = wordwrap($emailmessage); 
     51                                 $messages[] = sprintf(__gettext("Your invitation was sent to %s at %s. It will be valid for seven days."),$strippedname,$invite->email); 
     52                                 email_to_user($invite,null,$subjectline,$emailmessage); 
     53                             } else { 
     54                                 $messages[] = sprintf(__gettext("User %s already has that email address. Invitation not sent."),$account->username); 
    3555                             } 
    36                              $url = url . "_invite/join.php?invitecode=" . $invite->code; 
    37                              if (!logged_on) { 
    38                                  $greetingstext = sprintf(__gettext("Thank you for registering with %s."),$sitename); 
    39                                  $subjectline = sprintf(__gettext("%s account verification"),$sitename); 
    40                                  $from_email = email; 
    41                              } else { 
    42                                  $greetingstext = $USER->name . " " . __gettext("has invited you to join") ." $sitename, ". __gettext("a learning landscape system.") .""; 
    43                                  $subjectline = $USER->name . " " . __gettext("has invited you to join") ." $sitename"; 
    44                                  $from_email = $USER->email; 
    45                              } 
    46                              $emailmessage = sprintf(__gettext("Dear %s,\n\n%s %s\n\nTo join, visit the following URL:\n\n\t%s\n\n" 
    47                                                              ."Your email address has not been passed onto any third parties," 
    48                                                              ." and will be removed from our system within seven days.\n\nRegards,\n\nThe %s team.") 
    49                                                      ,$strippedname,$greetingstext,$invitetext,$url, $sitename); 
    50                              $emailmessage = wordwrap($emailmessage); 
    51                              $messages[] = sprintf(__gettext("Your invitation was sent to %s at %s. It will be valid for seven days."),$strippedname,$invite->email); 
    52                              email_to_user($invite,null,$subjectline,$emailmessage); 
    5356                         } else { 
    54                              $messages[] = sprintf(__gettext("User %s already has that email address. Invitation not sent."),$account->username); 
     57                             $messages[] = __gettext("Someone with that email address has already been invited to the system. "); 
    5558                         } 
    5659                     } else { 
    57                          $messages[] = __gettext("Someone with that email address has already been invited to the system. "); 
     60                         $messages[] = __gettext("Invitation failed: The email address was not valid."); 
    5861                     } 
    5962                 } else { 
    60                      $messages[] = __gettext("Invitation failed: The email address was not valid."); 
     63                     $messages[] = __gettext("Error: This community has reached its maximum number of users."); 
    6164                 } 
    62              } else { 
    63                  $messages[] = __gettext("Error: This community has reached its maximum number of users."); 
    64              } 
    6565             } else { 
    6666                 $messages[] = __gettext("Invitation failed: you are not logged in."); 
     
    8181             if (!($CFG->maxusers == 0 || (count_users('person') < $CFG->maxusers))) { 
    8282                 $messages[] = __gettext("Unfortunately this community has reached its account limit and you are unable to join at this time."); 
     83                 break; 
    8384             } 
    8485             if (empty($over13)) { 
  • devel/units/invite/invite_join.php

    r659 r836  
    33global $CFG; 
    44// Join 
    5          
     5 
    66$sitename = sitename; 
    77$textlib = textlib_get_instance(); 
     
    1111    if ($details = get_record('invitations','code',$code)) { 
    1212        $name = optional_param('join_name',$details->name); 
    13  
    1413        $username = optional_param('join_username'); 
    1514        if (empty($username)) { 
     
    3231        $age = __gettext("Submitting the form below indicates acceptance of these terms. Please note that currently you must be at least 13 years of age to join the site."); // gettext variable 
    3332        $run_result .= <<< END 
    34              
     33         
    3534    <p> 
    3635        $thankYou 
     
    4342        $age 
    4443    </p> 
    45  
    4644    <form action="" method="post"> 
    47                  
     45         
    4846END; 
    49                  
     47         
    5048        $run_result .= templates_draw(array( 
    5149                                            'context' => 'databoxvertical', 
     
    8381            </p> 
    8482        </form> 
    85                  
    8683END; 
    87  
     84         
    8885    } else { 
    8986         
    90         $invalid = sprintf(__gettext("Your invitation code appears to be invalid. Codes only last for seven days; it's possible that yours is older. If you still want to join %s, it may be worth getting in touch with the person who invited you."),$sitename); 
     87        $invalid = __gettext("Your invitation code appears to be invalid. Codes only last for seven days; it's possible that yours is older."); 
     88         
     89        if ($CFG->publicreg) { 
     90            $invalid .= sprintf(__gettext("If you still want to join %s, click the Register link."),$sitename); 
     91        } else { 
     92            $invalid .= sprintf(__gettext("If you still want to join %s, it may be worth getting in touch with the person who invited you."),$sitename); 
     93        } 
     94         
     95         
    9196        $run_result .= <<< END 
    92              
     97         
    9398    <p> 
    9499        $invalid 
    95100    </p> 
    96                  
     101         
    97102END; 
    98                  
     103         
    99104    } 
    100105     
    101106} else { 
    102     $invite = sprintf(__gettext("For the moment, joining %s requires a specially tailored invite code. If you know someone who's a member, it may be worth asking them for one."),$sitename); 
     107    if ($CFG->publicreg) { 
     108        $invite = sprintf(__gettext("To join %s, click the Register link."),$sitename); 
     109    } else { 
     110        $invite = sprintf(__gettext("For the moment, joining %s requires a specially tailored invite code. If you know someone who's a member, it may be worth asking them for one."),$sitename); 
     111    } 
    103112    $run_result .= <<< END 
    104                  
     113     
    105114    <p> 
    106115        $invite 
    107116    </p> 
    108                  
     117     
    109118END; 
    110              
     119     
    111120} 
    112121