Changeset 836
- Timestamp:
- 01/19/07 13:29:46 (2 years ago)
- Files:
-
- devel/_invite/index.php (modified) (1 diff)
- devel/_invite/join.php (modified) (1 diff)
- devel/config-dist.php (modified) (2 diffs)
- devel/lib/elgglib.php (modified) (5 diffs)
- devel/units/invite/invite_actions.php (modified) (2 diffs)
- devel/units/invite/invite_join.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/_invite/index.php
r659 r836 15 15 // You must be logged on to view this! 16 16 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' => $body27 )28 );29 30 echo templates_page_draw( array(31 $title, $body32 )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 } 37 37 38 38 ?> devel/_invite/join.php
r659 r836 8 8 9 9 run("invite:init"); 10 templates_page_setup(); 10 templates_page_setup(); 11 11 12 12 $title = sprintf(__gettext("Join %s"),sitename); devel/config-dist.php
r804 r836 187 187 188 188 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. 190 191 191 192 // $CFG->admin 192 // $CFG->allowobjectembed 193 // $CFG->aspellpath 193 // $CFG->allowobjectembed // boolean - whether to allow <object> and <embed> tags through input-cleaning 194 194 // $CFG->auth 195 195 // $CFG->cachetext … … 197 197 // $CFG->dbsessions 198 198 // $CFG->detect_unchecked_vars 199 // $CFG->editorbackgroundcolor200 // $CFG->editorfontfamily201 // $CFG->editorfontlist202 // $CFG->editorfontsize203 // $CFG->editorhidebuttons204 // $CFG->editorkillword205 // $CFG->editorspelling206 199 // $CFG->filterall 207 200 // $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 213 203 // $CFG->logsql 214 204 // $CFG->maxbytes 215 // $CFG->newsclient_lastcron216 205 // $CFG->openid_comments_allowed 217 206 // $CFG->opentogoogle devel/lib/elgglib.php
r793 r836 358 358 function report_session_error() { 359 359 global $CFG, $FULLME; 360 if (empty($CFG->lang)) {361 $CFG->lang = "en";362 }363 360 364 361 //clear session cookies … … 375 372 } 376 373 374 // never called 377 375 /** 378 376 * For security purposes, this function will check that the currently … … 383 381 * @return bool 384 382 */ 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 parameters394 }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 // } 402 400 403 401 … … 2886 2884 2887 2885 /** 2888 * Prints a basic textarea field.2889 *2890 * @uses $CFG2891 * @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 mincols2895 * @param null $height <b>Legacy field no longer used!</b> Set to zero to get control over minrows2896 * @param string $name ?2897 * @param string $value ?2898 * @param int $courseid ?2899 * @todo Finish documenting this function2900 */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 context2913 $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 calls2932 if ($rows < $minrows) {2933 $rows = $minrows;2934 }2935 }2936 if ($width) { // Usually with legacy calls2937 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 name2958 * @todo Finish documenting this function2959 */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 be2968 * applied to that field - otherwise it will be used2969 * on every textarea in the page.2970 *2971 * In most cases no arguments need to be supplied2972 *2973 * @param string $name Form element to replace with HTMl editor by name2974 */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 /**2988 2886 * Prints form items with the names $day, $month and $year 2989 2887 * … … 3267 3165 return $text; 3268 3166 } 3269 3270 3271 /**3272 * Prints out the HTML editor config.3273 *3274 * @uses $CFG3275 */3276 function print_editor_config($editorhidebuttons='') {3277 3278 global $CFG;3279 3280 // print new config3281 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 $CFG3333 * @param boolean $usehtmleditor ?3334 * @todo Finish documenting this function3335 */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 disabled3363 */3364 function print_speller_button () {3365 echo '<input type="button" value="Check spelling" onclick="openSpellChecker();" />'."\n";3366 }3367 3368 3167 3369 3168 devel/units/invite/invite_actions.php
r834 r836 21 21 if (logged_on || ($CFG->publicinvite == true)) { 22 22 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); 35 55 } 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 56 } 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. "); 55 58 } 56 59 } 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."); 58 61 } 59 62 } 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."); 61 64 } 62 } else {63 $messages[] = __gettext("Error: This community has reached its maximum number of users.");64 }65 65 } else { 66 66 $messages[] = __gettext("Invitation failed: you are not logged in."); … … 81 81 if (!($CFG->maxusers == 0 || (count_users('person') < $CFG->maxusers))) { 82 82 $messages[] = __gettext("Unfortunately this community has reached its account limit and you are unable to join at this time."); 83 break; 83 84 } 84 85 if (empty($over13)) { devel/units/invite/invite_join.php
r659 r836 3 3 global $CFG; 4 4 // Join 5 5 6 6 $sitename = sitename; 7 7 $textlib = textlib_get_instance(); … … 11 11 if ($details = get_record('invitations','code',$code)) { 12 12 $name = optional_param('join_name',$details->name); 13 14 13 $username = optional_param('join_username'); 15 14 if (empty($username)) { … … 32 31 $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 33 32 $run_result .= <<< END 34 33 35 34 <p> 36 35 $thankYou … … 43 42 $age 44 43 </p> 45 46 44 <form action="" method="post"> 47 45 48 46 END; 49 47 50 48 $run_result .= templates_draw(array( 51 49 'context' => 'databoxvertical', … … 83 81 </p> 84 82 </form> 85 86 83 END; 87 84 88 85 } else { 89 86 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 91 96 $run_result .= <<< END 92 97 93 98 <p> 94 99 $invalid 95 100 </p> 96 101 97 102 END; 98 103 99 104 } 100 105 101 106 } 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 } 103 112 $run_result .= <<< END 104 113 105 114 <p> 106 115 $invite 107 116 </p> 108 117 109 118 END; 110 119 111 120 } 112 121
