1############################################################################### 2# Settings_ExtendedProfiles.pm # 3# $Date: 12.02.14 $ # 4############################################################################### 5# YaBB: Yet another Bulletin Board # 6# Version: YaBB 2.6.11 # 7# Packaged: December 2, 2014 # 8# Distributed by: http://www.yabbforum.com # 9# =========================================================================== # 10# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved. # 11# Software by: The YaBB Development Team # 12# with assistance from the YaBB community. # 13############################################################################### 14# This file was part of the Extended Profiles Mod which has been created by # 15# Michael Prager. Last modification by him: 15.11.07 # 16# Added to the YaBB default code on 07. September 2008 # 17############################################################################### 18our $VERSION = '2.6.11'; 19 20$settings_extendedprofilespmver = 'YaBB 2.6.11 $Revision: 1611 $'; 21if ( $action eq 'detailedversion' ) { return 1; } 22 23LoadLanguage('ExtendedProfiles'); 24 25$ext_spacer_hr = q~<hr class="hr" />~; 26$ext_spacer_br = q~<br />~; 27$ext_max_email_length = 60; 28$ext_max_url_length = 100; 29$ext_max_image_length = 100; 30 31my %field; 32 33# outputs the value of a user's extended profile field 34## USAGE: $value = ext_get("admin","my_custom_fieldname"); 35## or $value_raw = ext_get("admin","my_custom_fieldname",1); 36## pass the third argument if you want to get the raw content e.g. an unformatted date 37sub ext_get { 38 my ( 39 $pusername, $fieldname, $no_parse, @ext_profile, 40 @options, $field, $id, $value, 41 $width, $height, @allowed_extensions, $extension, 42 $match 43 ) = ( shift, shift, shift ); 44 45 ext_get_profile($pusername); 46 $id = ext_get_field_id($fieldname); 47 $value = ${ $uid . $pusername }{ 'ext_' . $id }; 48 if ( $no_parse eq q{} || $no_parse == 0 ) { 49 $field = ext_get_field($id); 50 if ( $field{'type'} eq 'text' ) { 51 @options = split /\^/xsm, $field{'options'}; 52 if ( $options[3] ne q{} && $value eq q{} ) { $value = $options[3]; } 53 if ( $options[4] == 1 ) { 54 $value = ext_parse_ubbc( $value, $pusername ); 55 } 56 57 } 58 elsif ( $field{'type'} eq 'text_multi' && $value ne q{} ) { 59 @options = split /\^/xsm, $field{'options'}; 60 if ( $options[3] == 1 ) { 61 $value = ext_parse_ubbc( $value, $pusername ); 62 } 63 64 } 65 elsif ( $field{'type'} eq 'select' ) { 66 @options = split /\^/xsm, $field{'options'}; 67 if ( $value > $#options || $value eq q{} ) { $value = 0; } 68 $value = $options[$value]; 69 70 } 71 elsif ( $field{'type'} eq 'radiobuttons' ) { 72 @options = split /\^/xsm, $field{'options'}; 73 if ( $value > $#options ) { $value = 0; } 74 if ( !$field{'radiounselect'} && $value eq q{} ) { $value = 0; } 75 if ( $value ne q{} ) { $value = $options[$value]; } 76 77 } 78 elsif ( $field{'type'} eq 'date' && $value ne q{} ) { 79 $value = ext_timeformat($value); 80 81 } 82 elsif ( $field{'type'} eq 'checkbox' ) { 83 if ( $value == 1 ) { $value = $lang_ext{'true'} } 84 else { $value = $lang_ext{'false'} } 85 } 86 elsif ( $field{'type'} eq 'spacer' ) { 87 @options = split /\^/xsm, $field{'options'}; 88 if ( $options[0] == 1 ) { $value = qq~$ext_spacer_br~; } 89 else { $value = qq~$ext_spacer_hr~; } 90 } 91 elsif ( $field{'type'} eq 'url' && $value ne q{} ) { 92 if ( $value !~ m{\Ahttp://}sm ) { $value = "http://$value"; } 93 } 94 elsif ( $field{'type'} eq 'image' && $value ne q{} ) { 95 @options = split /\^/xsm, $field{'options'}; 96 if ( $options[2] ne q{} ) { 97 @allowed_extensions = split /\ /xsm, $options[2]; 98 $match = 0; 99 foreach my $extension (@allowed_extensions) { 100 if ( grep { /$extension$/ism } $value ) { 101 $match = 1; 102 last; 103 } 104 } 105 if ( $match == 0 ) { return q{}; } 106 } 107 if ( $options[0] ne q{} && $options[0] != 0 ) { 108 $width = q~ width="~ . ( $options[0] + 0 ) . q~"~; 109 } 110 else { $width = q{}; } 111 if ( $options[1] ne q{} && $options[1] != 0 ) { 112 $height = q~ height="~ . ( $options[1] + 0 ) . q~"~; 113 } 114 else { $height = q{}; } 115 if ( $value !~ m{\Ahttp://}sm ) { $value = "http://$value"; } 116 $value = qq~<img src="$value" class="vtop"$width$height alt=q{} />~; 117 } 118 } 119 120 return $value; 121} 122 123sub ext_get_profile { 124 LoadUser(shift); 125 return; 126} 127 128# returns an array of the form qw(ext_0 ext_1 ext_2 ...) 129sub ext_get_fields_array { 130 my ( $count, @result ) = (0); 131 foreach (@ext_prof_fields) { 132 push @result, "ext_$count"; 133 $count++; 134 } 135 return @result; 136} 137 138# returns the id of a field through the fieldname 139sub ext_get_field_id { 140 my ( $fieldname, $count, $id, $current, $currentname, $dummy ) = 141 ( shift, 0 ); 142 foreach my $current (@ext_prof_fields) { 143 ( $currentname, $dummy ) = split /\|/xsm, $current; 144 if ( $currentname eq $fieldname ) { $id = $count; last; } 145 $count++; 146 } 147 return $id; 148} 149 150# returns all settings of a specific field 151sub ext_get_field { 152 $field{'id'} = shift; 153 ( 154 $field{'name'}, $field{'type'}, 155 $field{'options'}, $field{'active'}, 156 $field{'comment'}, $field{'required_on_reg'}, 157 $field{'visible_in_viewprofile'}, $field{'v_users'}, 158 $field{'v_groups'}, $field{'visible_in_posts'}, 159 $field{'p_users'}, $field{'p_groups'}, 160 $field{'p_displayfieldname'}, $field{'visible_in_memberlist'}, 161 $field{'m_users'}, $field{'m_groups'}, 162 $field{'editable_by_user'}, $field{'visible_in_posts_popup'}, 163 $field{'pp_users'}, $field{'pp_groups'}, 164 $field{'pp_displayfieldname'}, $field{'radiounselect'}, 165 undef 166 ) = split /\|/xsm, $ext_prof_fields[ $field{'id'} ]; 167 return; 168} 169 170# formats a MM/DD/YYYY string to the user's preferred format, ignores time completely! 171sub ext_timeformat { 172 my ( 173 $mytimeselected, $oldformat, $mytimeformat, $newday, 174 $newday2, $newmonth, $newmonth2, $newyear, 175 $newshortyear, $oldmonth, $oldday, $oldyear, 176 $newweekday, $newyearday, $newweek, $dummy, 177 $usefullmonth 178 ); 179 180 if ( ${ $uid . $username }{'timeselect'} > 0 ) { 181 $mytimeselected = ${ $uid . $username }{'timeselect'}; 182 } 183 else { $mytimeselected = $timeselected; } 184 185 $oldformat = shift; 186 if ( $oldformat eq q{} || $oldformat eq "\n" ) { return $oldformat; } 187 188 $oldmonth = substr $oldformat, 0, 2; 189 $oldday = substr $oldformat, 3, 2; 190 $oldyear = substr $oldformat, 6, 4; 191 192 if ( $oldformat ne q{} ) { 193 $newday = $oldday + 0; 194 $newmonth = $oldmonth + 0; 195 $newyear = $oldyear + 0; 196 $newshortyear = substr $newyear, 2, 2; 197 if ( $newmonth < 10 ) { $newmonth = "0$newmonth"; } 198 if ( $newday < 10 && $mytimeselected != 4 ) { $newday = "0$newday"; } 199 200 if ( $mytimeselected == 1 ) { 201 qq~$newmonth/$newday/$newshortyear~; 202 203 } 204 elsif ( $mytimeselected == 2 ) { 205 $newformat = qq~$newday.$newmonth.$newshortyear~; 206 return $newformat; 207 208 } 209 elsif ( $mytimeselected == 3 ) { 210 $newformat = qq~$newday.$newmonth.$newyear~; 211 return $newformat; 212 213 } 214 elsif ( $mytimeselected == 4 || $mytimeselected == 8 ) { 215 $newmonth--; 216 $newmonth2 = $months[$newmonth]; 217 if ( $newday > 10 && $newday < 20 ) { 218 $newday2 = "$timetxt{'4'}"; 219 } 220 elsif ( $newday % 10 == 1 ) { 221 $newday2 = "$timetxt{'1'}"; 222 } 223 elsif ( $newday % 10 == 2 ) { 224 $newday2 = "$timetxt{'2'}"; 225 } 226 elsif ( $newday % 10 == 3 ) { 227 $newday2 = "$timetxt{'3'}"; 228 } 229 else { $newday2 = "$timetxt{'4'}"; } 230 $newformat = qq~$newmonth2 $newday$newday2, $newyear~; 231 return $newformat; 232 233 } 234 elsif ( $mytimeselected == 5 ) { 235 $newformat = qq~$newmonth/$newday/$newshortyear~; 236 return $newformat; 237 238 } 239 elsif ( $mytimeselected == 6 ) { 240 $newmonth2 = $months[ $newmonth - 1 ]; 241 $newformat = qq~$newday. $newmonth2 $newyear~; 242 return $newformat; 243 244 } 245 elsif ( $mytimeselected == 7 ) { 246 ( 247 $dummy, $dummy, $dummy, 248 $dummy, $dummy, $dummy, 249 $newweekday, $newyearday, $dummy 250 ) = gmtime $oldformat; 251 $newweek = int( ( $newyearday + 1 - $newweekday ) / 7 ) + 1; 252 253 $mytimeformat = ${ $uid . $username }{'timeformat'}; 254 if ( $mytimeformat =~ m/MM/sm ) { $usefullmonth = 1; } 255 $mytimeformat =~ s/(?:\s)*\@(?:\s)*//gxsm; 256 $mytimeformat =~ s/HH(?:\s)?//gxsm; 257 $mytimeformat =~ s/mm(?:\s)?//gxsm; 258 $mytimeformat =~ s/ss(?:\s)?//gxsm; 259 $mytimeformat =~ s/://gxsm; 260 $mytimeformat =~ s/ww(?:\s)?//gxsm; 261 $mytimeformat =~ s/(.*?)(?:\s)*$/$1/gxsm; 262 263 if ( $mytimeformat =~ m/\+/sm ) { 264 if ( $newday > 10 && $newday < 20 ) { 265 $dayext = "$timetxt{'4'}"; 266 } 267 elsif ( $newday % 10 == 1 ) { 268 $dayext = "$timetxt{'1'}"; 269 } 270 elsif ( $newday % 10 == 2 ) { 271 $dayext = "$timetxt{'2'}"; 272 } 273 elsif ( $newday % 10 == 3 ) { 274 $dayext = "$timetxt{'3'}"; 275 } 276 else { $dayext = "$timetxt{'4'}"; } 277 } 278 $mytimeformat =~ s/YYYY/$newyear/gxsm; 279 $mytimeformat =~ s/YY/$newshortyear/gxsm; 280 $mytimeformat =~ s/DD/$newday/gxsm; 281 $mytimeformat =~ s/D/$newday/gxsm; 282 $mytimeformat =~ s/\+/$dayext/gxsm; 283 if ( $usefullmonth == 1 ) { 284 $mytimeformat =~ s/MM/$months[$newmonth-1]/gxsm; 285 } 286 else { 287 $mytimeformat =~ s/M/$newmonth/gxsm; 288 } 289 290 $mytimeformat =~ s/\*//gxsm; 291 return $mytimeformat; 292 } 293 } 294 else { return q{}; } 295 296 #no return; 297} 298 299 300# returns the output for the Extended Profile Controls in admin center 301sub ext_admin { 302 my ( $id, $output, $fieldname, @options, $active, @selected, @contents ); 303 304 is_admin_or_gmod(); 305 306 $yymain .= qq~ 307<div class="bordercolor rightboxdiv"> 308 <table class="border-space pad-cell" style="margin-bottom: .5em;"> 309 <tr> 310 <td class="titlebg">$admin_img{'profile'} <b>$lang_ext{'Profiles_Controls'}</b></td> 311 </tr><tr> 312 <td class="windowbg2">$lang_ext{'admin_description'}</td> 313 </tr> 314 </table> 315</div> 316<div class="bordercolor rightboxdiv"> 317 <table class="border-space pad-cell" style="margin-bottom: .5em;"> 318 <tr> 319 <td class="titlebg">$admin_img{'profile'} <b>$lang_ext{'edit_title'}</b></td> 320 </tr><tr> 321 <td class="windowbg2">$lang_ext{'edit_description'}</td> 322 </tr><tr> 323 <td class="windowbg2"> 324 <table class="windowbg2 pad-cell"> 325 <colgroup> 326 <col style="width:25%" span="4" /> 327 </colgroup> 328 <tr> 329 <td class="center">$lang_ext{'active'}</td> 330 <td class="center">$lang_ext{'field_name'}</td> 331 <td class="center">$lang_ext{'field_type'}</td> 332 <td class="center">$lang_ext{'actions'}</td> 333 </tr>~; 334 if ( !@ext_prof_order ) { 335 $yymain .= qq~<tr> 336 <td class="windowbg2 center" style="padding:.5em 0 1em 0;" colspan="4"><i>$lang_ext{'no_additional_fields_set'}</i></td> 337 </tr> 338 </table>~; 339 } 340 else { 341 $yymain .= q~ </table>~; 342 foreach my $fieldname (@ext_prof_order) { 343 $id = ext_get_field_id($fieldname); 344 ext_get_field($id); 345 my @typelist = qw( text text_multi select radiobuttons checkbox date email url spacer image ); 346 foreach my $i (0 .. 9) { 347 if ($field{'type'} eq $typelist[$i]) { 348 $selected[$i] = ' selected="selected"'; 349 } 350 else { $selected[$i] = q{}; } 351 } 352 if ( $field{'active'} == 1 ) { $active = ' checked="checked"'; } 353 else { $active = q{}; } 354 355 $yymain .= qq~ 356 <form action="$adminurl?action=ext_edit" method="post"> 357 <table class="windowbg2 pad-cell"> 358 <colgroup> 359 <col style="width:25%" span="4" /> 360 </colgroup> 361 <tr> 362 <td class="windowbg2 center"> 363 <input name="id" type="hidden" value="$id" /> 364 <input type="checkbox" name="active" value="1"$active /> 365 </td> 366 <td class="windowbg2 center"> 367 <input name="name" value="$field{'name'}" size="20" /> 368 </td> 369 <td class="windowbg2 center"> 370 <select name="type" size="1"> 371 <option value="text"$selected[0]>$lang_ext{'text'}</option> 372 <option value="text_multi"$selected[1]>$lang_ext{'text_multi'}</option> 373 <option value="select"$selected[2]>$lang_ext{'select'}</option> 374 <option value="radiobuttons"$selected[3]>$lang_ext{'radiobuttons'}</option> 375 <option value="checkbox"$selected[4]>$lang_ext{'checkbox'}</option> 376 <option value="date"$selected[5]>$lang_ext{'date'}</option> 377 <option value="email"$selected[6]>$lang_ext{'email'}</option> 378 <option value="url"$selected[7]>$lang_ext{'url'}</option> 379 <option value="spacer"$selected[8]>$lang_ext{'spacer'}</option> 380 <option value="image"$selected[9]>$lang_ext{'image'}</option> 381 </select> 382 </td> 383 <td class="windowbg2 center"> 384 <input type="submit" name="apply" value="$lang_ext{'apply'}" /> 385 <input type="submit" name="options" value="$lang_ext{'options'}" /> 386 <input type="submit" name="delete" value="$lang_ext{'delete'}" /> 387 </td> 388 </tr> 389 </table> 390 </form>~; 391 } 392 } 393 394 $yymain .= qq~ 395 </td> 396 </tr> 397</table> 398</div> 399<div class="bordercolor rightboxdiv"> 400<table class="border-space pad-cell" style="margin-bottom: .5em;"> 401 <tr> 402 <td class="titlebg">$admin_img{'profile'} <b>$lang_ext{'create_new_title'}</b></td> 403 </tr><tr> 404 <td class="windowbg2">$lang_ext{'create_new_description'}</td> 405 </tr><tr> 406 <td class="windowbg2"> 407 <form action="$adminurl?action=ext_create" method="Post"> 408 <table class="pad-cell"> 409 <tr> 410 <td class="windowbg2 center"><label for="name">$lang_ext{'field_name'}</label></td> 411 <td class="windowbg2 center"><label for="type">$lang_ext{'field_type'}</label></td> 412 <td class="windowbg2 center">$lang_ext{'actions'}</td> 413 </tr><tr> 414 <td class="windowbg2 center"> 415 <input name="name" id="name" size="30" /> 416 </td> 417 <td class="windowbg2 center"> 418 <select name="type" id="type" size="1"> 419 <option value="text" selected="selected">$lang_ext{'text'}</option> 420 <option value="text_multi">$lang_ext{'text_multi'}</option> 421 <option value="select">$lang_ext{'select'}</option> 422 <option value="radiobuttons">$lang_ext{'radiobuttons'}</option> 423 <option value="checkbox">$lang_ext{'checkbox'}</option> 424 <option value="date">$lang_ext{'date'}</option> 425 <option value="email">$lang_ext{'email'}</option> 426 <option value="url">$lang_ext{'url'}</option> 427 <option value="spacer">$lang_ext{'spacer'}</option> 428 <option value="image">$lang_ext{'image'}</option> 429 </select> 430 </td> 431 <td class="windowbg2 center"> 432 <input type="submit" name="create" value="$lang_ext{'create_field'}" /> 433 </td> 434 </tr> 435 </table> 436 </form> 437 </td> 438 </tr> 439 </table> 440</div> 441<div class="bordercolor rightboxdiv"> 442<form action="$adminurl?action=ext_reorder" method="post"> 443<table class="border-space pad-cell" style="margin-bottom: .5em;"> 444 <tr> 445 <td class="titlebg">$admin_img{'profile'} <b>$lang_ext{'reorder_title'}</b></td> 446 </tr><tr> 447 <td class="windowbg2"> 448 <table class="pad_6px"> 449 <tr> 450 <td class="windowbg2 vtop"> 451 <textarea name="reorder" cols="30" rows="6">~; 452 453 foreach my $fieldname (@ext_prof_order) { $yymain .= $fieldname . "\n"; } 454 455 $yymain .= qq~</textarea> 456 </td> 457 <td class="windowbg2 vtop"> 458 $lang_ext{'reorder_description'}<br /><br /> 459 <input type="submit" name="reorder_submit" value="$lang_ext{'reorder'}" /> 460 </td> 461 </tr> 462 </table> 463 464 </td> 465 </tr> 466 </table> 467</form> 468</div> 469~; 470 if ( -e "$vardir/Extended.lock" ) { $yymain .= FoundExtLock();} 471 else { 472 if ( -e "$vardir/ConvSettings.txt" ) { 473 require "$vardir/ConvSettings.txt"; 474 } 475 else { 476 $convmemberdir = './Convert/Members'; 477 $convvardir = './Convert/Variables'; 478 } 479 480 $yymain .= qq~ 481<div class="bordercolor rightboxdiv"> 482 <table class="border-space pad-cell"> 483 <tr> 484 <td class="titlebg"><img src="$imagesdir/profile.gif" alt="" /> <b>$lang_ext{'converter_title'}</b></td> 485 </tr><tr> 486 <td class="windowbg2">$lang_ext{'converter_description'} 487 <form action="$adminurl?action=ext_convert" method="post"> 488 <p class="center"><br /> 489 <label for="members">$lang_ext{'path_old_members_folder'}:</label> <input name="members" id="members" value="$convmemberdir" /><br /> 490 <label for="vars">$lang_ext{'path_old_variables_folder'}:</label> <input name="vars" id="vars" value="$convvardir" /><br /><br /> 491 <input type="submit" name="convert" value="$lang_ext{'converter_button'}" /><br /><br /></p> 492 </form> 493 </td> 494 </tr> 495 </table> 496</div> 497~; 498} 499 $yytitle = $lang_ext{'Profiles_Controls'}; 500 $action_area = 'ext_admin'; 501 AdminTemplate(); 502 return; 503} 504 505# reorders the fields as submitted 506sub ext_admin_reorder { 507 is_admin_or_gmod(); 508 509 $FORM{'reorder'} =~ tr/\r//d; 510 $FORM{'reorder'} =~ s/\A[\s\n]+//xsm; 511 $FORM{'reorder'} =~ s/[\s\n]+\Z//xsm; 512 $FORM{'reorder'} =~ s/\n\s*\n/\n/gxsm; 513 ToHTML( $FORM{'reorder'} ); 514 515 @ext_prof_order = split /\n/xsm, $FORM{'reorder'}; 516 517 require Admin::NewSettings; 518 SaveSettingsTo('Settings.pm'); 519 520 $yySetLocation = qq~$adminurl?action=ext_admin~; 521 redirectexit(); 522 return; 523} 524 525# creates a new field as submitted 526sub ext_admin_create { 527 is_admin_or_gmod(); 528 529 ToHTML( $FORM{'name'} ); 530 531 push @ext_prof_order, $FORM{'name'}; 532 push @ext_prof_fields, 533 "$FORM{'name'}|$FORM{'type'}||1||0|1|||0|||0|0|||1|0|||0|0"; 534 535 require Admin::NewSettings; 536 SaveSettingsTo('Settings.pm'); 537 538 $yySetLocation = qq~$adminurl?action=ext_admin~; 539 redirectexit(); 540 return; 541} 542 543# will generate us a nicely formated table row for the input form 544sub ext_admin_gen_inputfield { 545 my ( $var1, $var2, $var3, $output ) = ( shift, shift, shift ); 546 $output = qq~<tr> 547 <td class="windowbg2 vtop"><b>$var1: </b> 548 <br /><span class="small">$var2</span></td> 549 <td class="windowbg2 vtop">$var3</td> 550 </tr>~; 551 552 return $output; 553} 554 555# generate html form option list depending on the passed groups string 556sub ext_admin_gen_groupslist { 557 my ( $groups, $output, $groupid, @groups, %groupcheck ) = ( shift, q{} ); 558 559 @groups = split /\s*\,\s*/xsm, $groups; 560 foreach (@groups) { 561 $groupcheck{$_} = ' selected="selected"'; 562 } 563 my @grps = ( 'Administrator','Global Moderator','Mid Moderator','Moderator',); 564 my $output = q{}; 565 foreach (@grps) { 566 $output .= qq~<option value="$_"$groupcheck{$_}>~ 567 . ( split /\|/xsm, $Group{$_} )[0] 568 . qq~</option>\n~; 569 } 570 571 foreach ( sort { $a <=> $b } keys %NoPost ) { 572 $groupid = $_; 573 $output .= 574qq~<option value="NoPost{$groupid}"$groupcheck{'NoPost{'.$groupid.'}'}>~ 575 . ( split /\|/xsm, ( split /\|/xsm, $NoPost{$groupid} )[0] )[0] 576 . qq~</option>\n~; 577 } 578 foreach ( reverse sort { $a <=> $b } keys %Post ) { 579 $groupid = $_; 580 $output .= 581 qq~<option value="Post{$groupid}"$groupcheck{'Post{'.$groupid.'}'}>~ 582 . ( split /\|/xsm, ( split /\|/xsm, $Post{$groupid} )[0] )[0] 583 . qq~</option>\n~; 584 } 585 586 return $output; 587} 588 589# performs all actions done in the edit profile field panel 590sub ext_admin_edit { 591 @x = @_; 592 my ( 593 @fields, @order, $type, $active, 594 $id, $name, $oldname, $req1, 595 $req2, $req3, $v_check, $p_check, 596 $p_d_check, $m_check, @editable_check, $is_numeric, 597 $ubbc, @options, $check1, $check2, 598 @contents, @old_content, $new_content, $output 599 ); 600 $oldname = $x[0]; 601 is_admin_or_gmod(); 602 603 if ( $FORM{'apply'} ne q{} ) { 604 ToHTML( $FORM{'name'} ); 605 $name = $FORM{'name'}; 606 $id = $FORM{'id'}; 607 $type = $FORM{'type'}; 608 $active = $FORM{'active'} ne q{} ? 1 : 0; 609 610 @fields = @ext_prof_fields; 611 @_ = split /\|/xsm, $fields[ $FORM{'id'} ]; 612 $fields[ $FORM{'id'} ] = 613"$name|$type|$x[2]|$active|$x[4]|$x[5]|$x[6]|$x[7]|$x[8]|$x[9]|$x[10]|$x[11]|$x[12]|$x[13]|$x[14]|$x[15]|$x[16]|$x[17]|$x[18]|$x[19]|$x[20]|$x[21]"; 614 @ext_prof_fields = @fields; 615 616 @order = @ext_prof_order; 617 $id = 0; 618 foreach (@order) { 619 if ( $oldname eq $_ ) { $order[$id] = $name; last; } 620 $id++; 621 } 622 @ext_prof_order = @order; 623 624 require Admin::NewSettings; 625 SaveSettingsTo('Settings.pm'); 626 627 $yySetLocation = qq~$adminurl?action=ext_admin~; 628 redirectexit(); 629 630 } 631 elsif ( $FORM{'options'} ne q{} ) { 632 ext_get_field( $FORM{'id'} ); 633 if ( $field{'active'} == 1 ) { $active = $lang_ext{'true'}; } 634 else { $active = $lang_ext{'false'}; } 635 if ( $field{'required_on_reg'} == 1 ) { 636 $req1 = q{}; 637 $req2 = ' checked="checked"'; 638 $req3 = q{}; 639 } 640 elsif ( $field{'required_on_reg'} == 2 ) { 641 $req1 = q{}; 642 $req2 = q{}; 643 $req3 = ' checked="checked"'; 644 } 645 else { $req1 = ' checked="checked"'; $req2 = q{}; $req3 = q{}; } 646 if ( $field{'visible_in_viewprofile'} == 1 ) { 647 $v_check = ' checked="checked"'; 648 } 649 else { $v_check = q{}; } 650 if ( $field{'visible_in_posts'} == 1 ) { 651 $p_check = ' checked="checked"'; 652 } 653 else { $p_check = q{}; } 654 if ( $field{'visible_in_posts_popup'} == 1 ) { 655 $pp_check = ' checked="checked"'; 656 } 657 else { $pp_check = q{}; } 658 if ( $field{'p_displayfieldname'} == 1 ) { 659 $p_d_check = ' checked="checked"'; 660 } 661 else { $p_d_check = q{}; } 662 if ( $field{'pp_displayfieldname'} == 1 ) { 663 $pp_d_check = ' checked="checked"'; 664 } 665 else { $pp_d_check = q{}; } 666 if ( $field{'visible_in_memberlist'} == 1 ) { 667 $m_check = ' checked="checked"'; 668 } 669 else { $m_check = q{}; } 670 if ( $field{'radiounselect'} == 1 ) { 671 $radiounselect = ' checked="checked"'; 672 } 673 else { $radiounselect = q{}; } 674 $editable_check[ $field{'editable_by_user'} ] = ' selected="selected"'; 675 $yymain .= qq~ 676<form action="$adminurl?action=ext_edit2" method="post" accept-charset="$yymycharset"> 677<div class="bordercolor rightboxdiv"> 678<table class="border-space pad-cell" style="margin-bottom: .5em;"> 679 <tr> 680 <td class="titlebg">$admin_img{'profile'} <b>$lang_ext{'options_title'}</b></td> 681 </tr><tr> 682 <td class="catbg small">$lang_ext{'options_description'}</td> 683 </tr><tr> 684 <td class="windowbg2"> 685<table class="windowbg2 pad_6px"> 686 <tr> 687 <td><b>$lang_ext{'active'}:</b> $active</td> 688 <td class="center"><b>$lang_ext{'field_name'}:</b> $field{'name'}</td> 689 <td class="center"><b>$lang_ext{'field_type'}:</b> $lang_ext{$field{'type'}}</td> 690 <td class="right"><a href="$adminurl?action=ext_admin"><-- $lang_ext{'change_these_settings'}</a></td> 691 </tr> 692</table> 693 </td> 694 </tr><tr> 695 <td class="windowbg2"> 696 <table class="bordercolor borderstyle border-space pad-cell"> 697~; 698 if ( $field{'type'} eq 'text' ) { 699 @options = split /\^/xsm, $field{'options'}; 700 if ( $options[2] == 1 ) { $is_numeric = ' checked="checked"' } 701 else { $is_numeric = q{} } 702 if ( $options[4] == 1 ) { $ubbc = ' checked="checked"' } 703 else { $ubbc = q{} } 704 $yymain .= ext_admin_gen_inputfield( 705 qq~<label for="limit_len">$lang_ext{'limit_len'}</label>~, 706qq~<label for="limit_len">$lang_ext{'limit_len_description'}</label>~, 707qq~<input name="limit_len" id="limit_len" size="5" value='$options[0]' />~ 708 ) 709 . ext_admin_gen_inputfield( 710 qq~<label for="width">$lang_ext{'width'}</label>~, 711 qq~<label for="width">$lang_ext{'width_description'}</label>~, 712qq~<input name="width" id="width" size="5" value='$options[1]' />~ 713 ) 714 . ext_admin_gen_inputfield( 715 qq~<label for="is_numeric">$lang_ext{'is_numeric'}</label>~, 716qq~<label for="is_numeric">$lang_ext{'is_numeric_description'}</label>~, 717qq~<input name="is_numeric" id="is_numeric" type="checkbox" value="1"$is_numeric />~ 718 ) 719 . ext_admin_gen_inputfield( 720 qq~<label for="default">$lang_ext{'default'}</label>~, 721qq~<label for="default">$lang_ext{'default_description'}</label>~, 722qq~<input name="default" id="default" size="50" value='$options[3]' />~ 723 ) 724 . ext_admin_gen_inputfield( 725 qq~<label for="ubbc">$lang_ext{'ubbc'}</label>~, 726 qq~<label for="ubbc">$lang_ext{'ubbc_description'}</label>~, 727qq~<input name="ubbc" id="ubbc" type="checkbox" value="1"$ubbc />~ 728 ); 729 } 730 elsif ( $field{'type'} eq 'text_multi' ) { 731 @options = split /\^/xsm, $field{'options'}; 732 if ( $options[3] == 1 ) { $ubbc = ' checked="checked"' } 733 else { $ubbc = q{} } 734 $yymain .= ext_admin_gen_inputfield( 735 qq~<label for="limit_len">$lang_ext{'limit_len'}</label>~, 736qq~<label for="limit_len">$lang_ext{'limit_len_description'}</label>~, 737qq~<input name="limit_len" id="limit_len" size="5" value='$options[0]' />~ 738 ) 739 . ext_admin_gen_inputfield( 740 qq~<label for="rows">$lang_ext{'rows'}</label>~, 741 qq~<label for="rows">$lang_ext{'rows_description'}</label>~, 742 qq~<input name="rows" id="rows" size="5" value='$options[1]' />~ 743 ) 744 . ext_admin_gen_inputfield( 745 qq~<label for="cols">$lang_ext{'cols'}</label>~, 746 qq~<label for="cols">$lang_ext{'cols_description'}</label>~, 747 qq~<input name="cols" id="cols" size="5" value='$options[2]' />~ 748 ) 749 . ext_admin_gen_inputfield( 750 qq~<label for="ubbc">$lang_ext{'ubbc'}</label>~, 751 qq~<label for="ubbc">$lang_ext{'ubbc_description'}</label>~, 752qq~<input name="ubbc" id="ubbc" type="checkbox" value="1"$ubbc />~ 753 ); 754 } 755 elsif ( $field{'type'} eq 'select' ) { 756 @options = split /\^/xsm, $field{'options'}; 757 $output = q{}; 758 foreach (@options) { $output .= qq~$_\n~; } 759 $yymain .= ext_admin_gen_inputfield( 760 qq~<label for="options">$lang_ext{'s_options'}</label>~, 761qq~<label for="options">$lang_ext{'s_options_description'}</label>~, 762qq~<textarea name="options" id="options" cols="30" rows="3">$output</textarea>~ 763 ); 764 } 765 elsif ( $field{'type'} eq 'radiobuttons' ) { 766 @options = split /\^/xsm, $field{'options'}; 767 $output = q{}; 768 foreach (@options) { $output .= qq~$_\n~; } 769 $yymain .= ext_admin_gen_inputfield( 770 qq~<label for="options">$lang_ext{'s_options'}</label>~, 771qq~<label for="options">$lang_ext{'s_options_description'}</label>~, 772qq~<textarea name="options" id="options" cols="30" rows="3">$output</textarea>~ 773 ) 774 . ext_admin_gen_inputfield( 775qq~<label for="radiounselect">$lang_ext{'radiounselect'}</label>~, 776qq~<label for="radiounselect">$lang_ext{'radiounselect_description'}</label>~, 777qq~<input name="radiounselect" id="radiounselect" type="checkbox" value="1"$radiounselect />~ 778 ); 779 } 780 elsif ( $field{'type'} eq 'spacer' ) { 781 @options = split /\^/xsm, $field{'options'}; 782 if ( $options[0] == 1 ) { 783 $check2 = ' checked="checked"'; 784 $check1 = q{}; 785 } 786 else { $check2 = q{}; $check1 = ' checked="checked"'; } 787 if ( $options[1] == 1 ) { $options[1] = ' checked="checked"'; } 788 else { $options[1] = q{}; } 789 $yymain .= ext_admin_gen_inputfield( 790 qq~<label for="hr_or_br">$lang_ext{'hr_or_br'}</label>~, 791qq~<label for="hr_or_br">$lang_ext{'hr_or_br_description'}</label>~, 792qq~<input name="hr_or_br" id="hr_or_br" type="radio" value="0"$check1 />$lang_ext{'hr'}\n~ 793 . qq~<input name="hr_or_br" type="radio" value="1"$check2 />$lang_ext{'br'}~ 794 ) 795 . ext_admin_gen_inputfield( 796qq~<label for="visible_in_editprofile">$lang_ext{'visible_in_editprofile'}</label>~, 797qq~<label for="visible_in_editprofile">$lang_ext{'visible_in_editprofile_description'}</label>~, 798qq~<input name="visible_in_editprofile" id="visible_in_editprofile" type="checkbox" value="1"$options[1] />~ 799 ); 800 801 } 802 elsif ( $field{'type'} eq 'image' ) { 803 @options = split /\^/xsm, $field{'options'}; 804 805 #if ($options[3] == 1) { $ubbc = ' checked="checked"' } else { $ubbc = q{} } 806 $yymain .= ext_admin_gen_inputfield( 807 qq~<label for="image_width">$lang_ext{'image_width'}</label>~, 808qq~<label for="image_width">$lang_ext{'image_width_description'}</label>~, 809qq~<input name="image_width" id="image_width" size="5" value='$options[0]' />~ 810 ) 811 . ext_admin_gen_inputfield( 812 qq~<label for="image_height">$lang_ext{'image_height'}</label>~, 813qq~<label for="image_height">$lang_ext{'image_height_description'}</label>~, 814qq~<input name="image_height" id="image_height" size="5" value='$options[1]' />~ 815 ) 816 . ext_admin_gen_inputfield( 817qq~<label for="allowed_extensions">$lang_ext{'allowed_extensions'}</label>~, 818qq~<label for="allowed_extensions">$lang_ext{'allowed_extensions_description'}</label>~, 819qq~<input name="allowed_extensions" id="allowed_extensions" size="30" value='$options[2]' />~ 820 ); 821 } 822 823 $yymain .= ext_admin_gen_inputfield( 824 qq~<label for="comment">$lang_ext{'comment'}</label>~, 825 qq~<label for="comment">$lang_ext{'comment_description'}</label>~, 826qq~<input name="comment" id="comment" size="50" value='$field{'comment'}' />~ 827 ) 828 . ext_admin_gen_inputfield( 829qq~<label for="required_on_reg">$lang_ext{'required_on_reg'}</label>~, 830qq~<label for="required_on_reg">$lang_ext{'required_on_reg_description'}</label>~, 831qq~<input name="required_on_reg" type="radio" value="1"$req2 /> $lang_ext{'req1'}<br />\n~ 832 . qq~<input name="required_on_reg" id="required_on_reg" type="radio" value="0"$req1 /> $lang_ext{'req0'}<br />\n~ 833 . qq~<input name="required_on_reg" type="radio" value="2"$req3 /> $lang_ext{'req2'}\n~ 834 ) 835 . ext_admin_gen_inputfield( 836qq~<label for="visible_in_viewprofile">$lang_ext{'visible_in_viewprofile'}</label>~, 837qq~<label for="visible_in_viewprofile">$lang_ext{'visible_in_viewprofile_description'}</label>~, 838qq~<input name="visible_in_viewprofile" id="visible_in_viewprofile" type="checkbox" value="1"$v_check /><br />\n~ 839 . qq~<table class="windowbg2 pad-cell">\n~ 840 . qq~ <tr><td><label for="v_users">$lang_ext{'v_users'}:</label> </td><td><input name="v_users" id="v_users" value="$field{'v_users'}" /></td></tr>\n~ 841 . qq~ <tr><td class="vtop"><label for="v_groups">$lang_ext{'v_groups'}:</label> </td><td>\n~ 842 . qq~ <select multiple="multiple" name="v_groups" id="v_groups" size="4">\n~ 843 . ext_admin_gen_groupslist( $field{'v_groups'} ) 844 . qq~ </select>\n~ 845 . qq~ </td></tr>\n~ 846 . qq~</table>\n~ 847 ) 848 . ext_admin_gen_inputfield( 849qq~<label for="visible_in_posts">$lang_ext{'visible_in_posts'}</label>~, 850qq~<label for="visible_in_posts">$lang_ext{'visible_in_posts_description'}</label>~, 851qq~<input name="visible_in_posts" id="visible_in_posts" type="checkbox" value="1"$p_check /><br />\n~ 852 . qq~<table class="windowbg2 pad-cell">\n~ 853 . qq~ <tr><td><label for="p_displayfieldname">$lang_ext{'display_fieldname'}:</label> </td><td><input name="p_displayfieldname" id="p_displayfieldname" type="checkbox" value="1"$p_d_check /></td></tr>\n~ 854 . qq~ <tr><td><label for="p_users">$lang_ext{'p_users'}:</label> </td><td><input name="p_users" id="p_users" value="$field{'p_users'}" /></td></tr>\n~ 855 . qq~ <tr><td class="vtop"><label for="p_groups">$lang_ext{'p_groups'}:</label> </td><td>\n~ 856 . qq~ <select multiple="multiple" name="p_groups" id="p_groups" size="4">\n~ 857 . ext_admin_gen_groupslist( $field{'p_groups'} ) 858 . qq~ </select>\n~ 859 . qq~ </td></tr>\n~ 860 . qq~</table>\n~ 861 ) 862 . ext_admin_gen_inputfield( 863qq~<label for="visible_in_posts_popup">$lang_ext{'visible_in_posts_popup'}</label>~, 864qq~<label for="visible_in_posts_popup">$lang_ext{'visible_in_posts_popup_description'}</label>~, 865qq~<input name="visible_in_posts_popup" id="visible_in_posts_popup" type="checkbox" value="1"$pp_check /><br />\n~ 866 . qq~<table class="windowbg2 pad-cell">\n~ 867 . qq~ <tr><td><label for="pp_displayfieldname">$lang_ext{'display_fieldname'}:</label> </td><td><input name="pp_displayfieldname" id="pp_displayfieldname" type="checkbox" value="1"$pp_d_check /></td></tr>\n~ 868 . qq~ <tr><td><label for="pp_users">$lang_ext{'p_users'}:</label> </td><td><input name="pp_users" id="pp_users" value="$field{'pp_users'}" /></td></tr>\n~ 869 . qq~ <tr><td class="vtop"><label for="pp_groups">$lang_ext{'p_groups'}:</label> </td><td>\n~ 870 . qq~ <select multiple="multiple" name="pp_groups" id="pp_groups" size="4">\n~ 871 . ext_admin_gen_groupslist( $field{'pp_groups'} ) 872 . qq~ </select>\n~ 873 . qq~ </td></tr>\n~ 874 . qq~</table>\n~ 875 ) 876 . ext_admin_gen_inputfield( 877qq~<label for="visible_in_memberlist">$lang_ext{'visible_in_memberlist'}</label>~, 878qq~<label for="visible_in_memberlist">$lang_ext{'visible_in_memberlist_description'}</label>~, 879qq~<input name="visible_in_memberlist" id="visible_in_memberlist" type="checkbox" value="1"$m_check /><br />\n~ 880 . qq~<table class="windowbg2 pad-cell">\n~ 881 . qq~ <tr><td><label for="m_users">$lang_ext{'m_users'}:</label> </td><td><input name="m_users" id="m_users" value="$field{'m_users'}" /></td></tr>\n~ 882 . qq~ <tr><td class="vtop"><label for="m_groups">$lang_ext{'m_groups'}:</label> </td><td>\n~ 883 . qq~ <select multiple="multiple" name="m_groups" id="m_groups" size="4">\n~ 884 . ext_admin_gen_groupslist( $field{'m_groups'} ) 885 . qq~ </select>\n~ 886 . qq~ </td></tr>\n~ 887 . qq~</table>\n~ 888 ); 889 890 if ( $field{'type'} ne 'spacer' ) { 891 $yymain .= ext_admin_gen_inputfield( 892qq~\n <label for="editable_by_user">$lang_ext{'editable_by_user'}</label>~, 893qq~\n <label for="editable_by_user">$lang_ext{'editable_by_user_description'}</label>~, 894qq~\n <select name="editable_by_user" id="editable_by_user" size="1">\n~ 895 . qq~ <option value="0"$editable_check[0]>$lang_ext{'page_admin'}</option>\n~ 896 . qq~ <option value="1"$editable_check[1]>$lang_ext{'page_edit'}</option>\n~ 897 . qq~ <option value="2"$editable_check[2]>$lang_ext{'page_contact'}</option>\n~ 898 . qq~ <option value="3"$editable_check[3]>$lang_ext{'page_options'}</option>\n~ 899 . qq~ <option value="4"$editable_check[4]>$lang_ext{'page_im'}</option>\n~ 900 . qq~</select>\n~ 901 ); 902 } 903 $yymain .= qq~ 904 </table> 905 <input name="id" type="hidden" value="$FORM{'id'}" /> 906 <input name="name" type="hidden" value="$FORM{'name'}" /> 907 <input name="type" type="hidden" value="$FORM{'type'}" /> 908 <input name="active" type="hidden" value="$FORM{'active'}" /> 909 ~; 910 if ( $field{'type'} eq 'spacer' ) { 911 $yymain .= 912 q~<input name="editable_by_user" type="hidden" value="1" /> 913 ~; 914 } 915 $yymain .= qq~ 916 </td> 917 </tr> 918</table> 919</div> 920<div class="bordercolor rightboxdiv"> 921<table class="border-space pad-cell"> 922 <tr> 923 <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th> 924 </tr><tr> 925 <td class="catbg center"> 926 <input type="submit" name="save" value="$lang_ext{'Save'}" /> 927 </td> 928 </tr> 929</table> 930</div> 931</form> 932~; 933 $yytitle = 934 "$lang_ext{'Profiles_Controls'} - $lang_ext{'options_title'}"; 935 $action_area = 'ext_admin'; 936 AdminTemplate(); 937 938 } 939 elsif ( $FORM{'delete'} ne q{} ) { 940 $id = 0; 941 ext_get_field( $FORM{'id'} ); 942 @fields = @ext_prof_fields; 943 @ext_prof_fields = (); 944 foreach (@fields) { 945 if ( $FORM{'id'} != $id ) { push @ext_prof_fields, $_; } 946 $id++; 947 } 948 949 @order = @ext_prof_order; 950 @ext_prof_order = (); 951 foreach (@order) { 952 if ( $_ ne $field{'name'} ) { push @ext_prof_order, $_; } 953 } 954 955 require Admin::NewSettings; 956 SaveSettingsTo('Settings.pm'); 957 958 opendir EXT_DIR, "$memberdir"; 959 @contents = grep { /\.vars$/sm } readdir EXT_DIR; 960 closedir EXT_DIR; 961 962 foreach (@contents) { 963 fopen( EXT_FILE, "+<$memberdir/$_" ) 964 || fatal_error( 'cannot_open', "$memberdir/$_" ); 965 seek EXT_FILE, 0, 0; 966 @old_content = <EXT_FILE>; 967 $new_content = join q{}, @old_content; 968 $new_content =~ s/\n'ext_$FORM{'id'}',"(?:.*?)"\n/\n/igsm; 969 seek EXT_FILE, 0, 0; 970 truncate EXT_FILE, 0; 971 print {EXT_FILE} $new_content or croak "$croak{'print'} EXT_FILE"; 972 fclose(EXT_FILE); 973 } 974 975 $yySetLocation = qq~$adminurl?action=ext_admin~; 976 redirectexit(); 977 } 978 else { 979 $yySetLocation = qq~$adminurl?action=ext_admin~; 980 redirectexit(); 981 } 982 return; 983} 984 985# modifies a field as submitted 986sub ext_admin_edit2 { 987 my ( @fields, @options ); 988 is_admin_or_gmod(); 989 990 ToHTML( $FORM{'name'} ); 991 ToHTML( $FORM{'comment'} ); 992 if ( $FORM{'active'} eq q{} ) { $FORM{'active'} = 0; } 993 if ( $FORM{'required_on_reg'} eq q{} ) { $FORM{'required_on_reg'} = 0; } 994 if ( $FORM{'visible_in_viewprofile'} eq q{} ) { 995 $FORM{'visible_in_viewprofile'} = 0; 996 } 997 if ( $FORM{'visible_in_posts'} eq q{} ) { $FORM{'visible_in_posts'} = 0; } 998 if ( $FORM{'visible_in_posts_popup'} eq q{} ) { 999 $FORM{'visible_in_posts_popup'} = 0; 1000 } 1001 if ( $FORM{'p_displayfieldname'} eq q{} ) { 1002 $FORM{'p_displayfieldname'} = 0; 1003 } 1004 if ( $FORM{'pp_displayfieldname'} eq q{} ) { 1005 $FORM{'pp_displayfieldname'} = 0; 1006 } 1007 if ( $FORM{'visible_in_memberlist'} eq q{} ) { 1008 $FORM{'visible_in_memberlist'} = 0; 1009 } 1010 if ( $FORM{'editable_by_user'} eq q{} ) { $FORM{'editable_by_user'} = 0; } 1011 $FORM{'v_users'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1012 $FORM{'v_groups'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1013 $FORM{'p_users'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1014 $FORM{'p_groups'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1015 $FORM{'pp_users'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1016 $FORM{'pp_groups'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1017 $FORM{'m_users'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1018 $FORM{'m_groups'} =~ s/^(\s)*(.+?)(\s)*$/$2/xsm; 1019 $FORM{'v_groups'} = join q{,}, split /\s*\,\s*/xsm, $FORM{'v_groups'}; 1020 $FORM{'p_groups'} = join q{,}, split /\s*\,\s*/xsm, $FORM{'p_groups'}; 1021 $FORM{'pp_groups'} = join q{,}, split /\s*\,\s*/xsm, $FORM{'pp_groups'}; 1022 $FORM{'m_groups'} = join q{,}, split /\s*\,\s*/xsm, $FORM{'m_groups'}; 1023 1024 if ( $FORM{'type'} eq 'text' ) { 1025 if ( $FORM{'width'} == 0 ) { $FORM{'width'} = q{}; } 1026 if ( $FORM{'is_numeric'} eq q{} ) { $FORM{'is_numeric'} = 0; } 1027 if ( $FORM{'ubbc'} eq q{} ) { $FORM{'ubbc'} = 0; } 1028 $FORM{'options'} = 1029"$FORM{'limit_len'}^$FORM{'width'}^$FORM{'is_numeric'}^$FORM{'default'}^$FORM{'ubbc'}"; 1030 1031 } 1032 elsif ( $FORM{'type'} eq 'text_multi' ) { 1033 if ( $FORM{'rows'} == 0 ) { $FORM{'rows'} = q{}; } 1034 if ( $FORM{'cols'} == 0 ) { $FORM{'cols'} = q{}; } 1035 if ( $FORM{'ubbc'} eq q{} ) { $FORM{'ubbc'} = 0; } 1036 $FORM{'options'} = 1037 "$FORM{'limit_len'}^$FORM{'rows'}^$FORM{'cols'}^$FORM{'ubbc'}"; 1038 } 1039 elsif ( $FORM{'type'} eq 'select' ) { 1040 $FORM{'options'} =~ tr/\r//d; 1041 $FORM{'options'} =~ s/\A[\s\n]+/ \n/xsm; 1042 $FORM{'options'} =~ s/[\s\n]+\Z//xsm; 1043 $FORM{'options'} =~ s/\n\s*\n/\n/gxsm; 1044 @options = split /\n/xsm, $FORM{'options'}; 1045 $FORM{'options'} = q{}; 1046 foreach (@options) { $FORM{'options'} .= q{\^} . $_; } 1047 $FORM{'options'} =~ s/^\^//xsm; 1048 } 1049 elsif ( $FORM{'type'} eq 'radiobuttons' ) { 1050 $FORM{'options'} =~ tr/\r//d; 1051 $FORM{'options'} =~ s/\A[\s\n]+//xsm; 1052 $FORM{'options'} =~ s/[\s\n]+\Z//xsm; 1053 $FORM{'options'} =~ s/\n\s*\n/\n/gxsm; 1054 @options = split /\n/xsm, $FORM{'options'}; 1055 $FORM{'options'} = q{}; 1056 foreach (@options) { $FORM{'options'} .= q{\^} . $_; } 1057 $FORM{'options'} =~ s/^\^//xsm; 1058 if ( $FORM{'radiounselect'} eq q{} ) { $FORM{'radiounselect'} = 0; } 1059 } 1060 elsif ( $FORM{'type'} eq 'spacer' ) { 1061 if ( $FORM{'visible_in_editprofile'} eq q{} ) { 1062 $FORM{'visible_in_editprofile'} = 0; 1063 } 1064 $FORM{'options'} = "$FORM{'hr_or_br'}^$FORM{'visible_in_editprofile'}"; 1065 } 1066 elsif ( $FORM{'type'} eq 'image' ) { 1067 if ( $FORM{'image_width'} == 0 ) { $FORM{'image_width'} = q{}; } 1068 if ( $FORM{'image_height'} == 0 ) { $FORM{'image_height'} = q{}; } 1069 $FORM{'options'} = 1070"$FORM{'image_width'}^$FORM{'image_height'}^$FORM{'allowed_extensions'}"; 1071 } 1072 1073 @fields = @ext_prof_fields; 1074 $fields[ $FORM{'id'} ] = 1075"$FORM{'name'}|$FORM{'type'}|$FORM{'options'}|$FORM{'active'}|$FORM{'comment'}|$FORM{'required_on_reg'}|$FORM{'visible_in_viewprofile'}|$FORM{'v_users'}|$FORM{'v_groups'}|$FORM{'visible_in_posts'}|$FORM{'p_users'}|$FORM{'p_groups'}|$FORM{'p_displayfieldname'}|$FORM{'visible_in_memberlist'}|$FORM{'m_users'}|$FORM{'m_groups'}|$FORM{'editable_by_user'}|$FORM{'visible_in_posts_popup'}|$FORM{'pp_users'}|$FORM{'pp_groups'}|$FORM{'pp_displayfieldname'}|$FORM{'radiounselect'}"; 1076 1077 @ext_prof_fields = @fields; 1078 1079 require Admin::NewSettings; 1080 SaveSettingsTo('Settings.pm'); 1081 1082 $yySetLocation = qq~$adminurl?action=ext_admin~; 1083 redirectexit(); 1084 return; 1085} 1086 1087# converts a user's .ext file to Y2 format 1088sub ext_user_convert { 1089 my ( $pusername, $old_membersdir, @ext_profile, $id ) = ( shift, shift ); 1090 is_admin_or_gmod(); 1091 1092 if ( -e "$old_membersdir/$pusername.ext" ) { 1093 if ( -e "$memberdir/$pusername.vars" ) { 1094 ext_get_profile($pusername); 1095 1096 fopen( EXT_FILE, "$old_membersdir/$pusername.ext" ) 1097 || admin_fatal_error( 'cannot_open', 1098 "$old_membersdir/$pusername.ext" ); 1099 @ext_profile = <EXT_FILE>; 1100 fclose(EXT_FILE); 1101 chomp @ext_profile; 1102 1103 $id = 0; 1104 foreach (@ext_prof_fields) { 1105 ${ $uid . $pusername }{ 'ext_' . $id } = $ext_profile[$id]; 1106 $id++; 1107 } 1108 UserAccount( $pusername, 'update' ); 1109 1110 # don't delete old .ext files anymore, user can do that himself now. 1111 #unlink "$old_membersdir/$pusername.ext"; 1112 } 1113 } 1114 return; 1115} 1116 1117# convert a string of usergroup names from the old YaBB format into Y2's new format 1118sub ext_admin_convert_fixgroupnames { 1119 my ( $input, $done, $j, @groups, $group, $groupid, %checkdoubles ) = 1120 ( shift, 0 ); 1121 1122 @groups = split /\s*\,\s*/xsm, $input; 1123 for my $j ( 0 .. ( @groups - 1 ) ) { 1124 1125 # if groupname is in old format 1126 if ( $groups[$j] ne 'Administrator' 1127 && $groups[$j] ne 'Global Moderator' 1128 && $groups[$j] ne 'Moderator' 1129 && $groups[$j] !~ m/^(?:No)?Post{\d+}$/sm ) 1130 { 1131 1132 # find best matching usergroup 1133 foreach my $groupid ( sort { $a <=> $b } keys %NoPost ) { 1134 if ( $groups[$j] eq 1135 ( split /\|/xsm, ( split /\|/xsm, $NoPost{$groupid} )[0] ) 1136 [0] ) 1137 { 1138 $groups[$j] = "NoPost{$groupid}"; 1139 1140 # check for doubles 1141 if ( $checkdoubles{ $groups[$j] } == 1 ) { 1142 splice @groups, $j, 1; 1143 $j--; 1144 $done = 1; 1145 last; 1146 } 1147 else { 1148 $checkdoubles{ $groups[$j] } = 1; 1149 } 1150 } 1151 } 1152 if ( $done == 1 ) { $done = 0; next; } 1153 foreach my $groupid ( reverse sort { $a <=> $b } keys %Post ) { 1154 if ( $groups[$j] eq 1155 ( split /\|/xsm, ( split /\|/xsm, $Post{$groupid} )[0] )[0] 1156 ) 1157 { 1158 $groups[$j] = "Post{$groupid}"; 1159 1160 # check for doubles 1161 if ( $checkdoubles{ $groups[$j] } == 1 ) { 1162 splice @groups, $j, 1; 1163 $done = 1; 1164 $j--; 1165 last; 1166 } 1167 else { 1168 $checkdoubles{ $groups[$j] } = 1; 1169 } 1170 } 1171 } 1172 if ( $done == 1 ) { $done = 0; next; } 1173 } 1174 else { 1175 $checkdoubles{ $groups[$j] } = 1; 1176 } 1177 1178 # if still not matching, get rid of it! 1179 if ( $groups[$j] ne 'Administrator' 1180 && $groups[$j] ne 'Global Moderator' 1181 && $groups[$j] ne 'Moderator' 1182 && $groups[$j] !~ m/^(?:No)?Post{\d+}$/sm ) 1183 { 1184 1185 #delete $groups[$j]; 1186 splice @groups, $j, 1; 1187 $j--; 1188 } 1189 } 1190 join q{,}, @groups; 1191 return; 1192} 1193 1194# converts ALL old .ext files into the the YaBB 2 file format 1195sub ext_admin_convert { 1196 my ( @contents, $filename, $old_membersdir, $old_vardir, $i ); 1197 is_admin_or_gmod(); 1198 1199 $old_membersdir = $FORM{'members'}; 1200 $old_vardir = $FORM{'vars'}; 1201 1202 if ( !-e $old_vardir ) { 1203 admin_fatal_error( 'extended_profiles_convert', 1204 $lang_ext{'converter_missing_vars'} ); 1205 } 1206 if ( !-e "$old_vardir/extended_profiles_order.txt" ) { 1207 admin_fatal_error( 'extended_profiles_convert', 1208 $lang_ext{'converter_missing_order'} ); 1209 } 1210 if ( !-e "$old_vardir/extended_profiles_fields.txt" ) { 1211 admin_fatal_error( 'extended_profiles_convert', 1212 $lang_ext{'converter_missing_fields'} ); 1213 } 1214 1215 fopen( CONVERTER, "$old_vardir/extended_profiles_order.txt" ) 1216 || admin_fatal_error( 'cannot_open', 1217 "$old_vardir/extended_profiles_order.txt" ); 1218 @ext_prof_order = <CONVERTER>; 1219 fclose(CONVERTER); 1220 chomp @ext_prof_order; 1221 1222 # copy old extended_profiles_fields and extended_profiles_order files 1223 fopen( CONVERTER, "$old_vardir/extended_profiles_fields.txt" ) 1224 || admin_fatal_error( 'cannot_open', 1225 "$old_vardir/extended_profiles_fields.txt" ); 1226 @ext_prof_fields = <CONVERTER>; 1227 fclose(CONVERTER); 1228 chomp @ext_prof_fields; 1229 1230 #check if used membergroups still exist + convert to YaBB new format 1231 for my $i ( 0 .. ( @ext_prof_fields - 1 ) ) { 1232 my @field = split /\|/xsm, $ext_prof_fields[$i]; 1233 $field[8] = ext_admin_convert_fixgroupnames( $field[8] ); 1234 $field[11] = ext_admin_convert_fixgroupnames( $field[11] ); 1235 $field[15] = ext_admin_convert_fixgroupnames( $field[15] ); 1236 $field[19] = ext_admin_convert_fixgroupnames( $field[19] ); 1237 $ext_prof_fields[$i] = join q{|}, @field; 1238 } 1239 1240 require Admin::NewSettings; 1241 SaveSettingsTo('Settings.pm'); 1242 1243 opendir EXT_DIR, "$old_membersdir"; 1244 @contents = grep { /\.ext$/xsm } readdir EXT_DIR; 1245 closedir EXT_DIR; 1246 1247 foreach my $filename (@contents) { 1248 $filename =~ s/.ext$//xsm; 1249 ext_user_convert( $filename, $old_membersdir ); 1250 } 1251 1252 $yymain .= $lang_ext{'converter_succeeded'}; 1253 CreateExtLock(); 1254 $yytitle = "$lang_ext{'Profiles_Controls'} - $lang_ext{'options_title'}"; 1255 $action_area = 'ext_admin'; 1256 AdminTemplate(); 1257 return; 1258} 1259 1260sub ext_viewprofile_r { 1261 my ( 1262 $pusername, @ext_profile, $id, $output, 1263 $fieldname, @options, $value, $previous, 1264 $count, $last_field_id, $pre_output 1265 ) = (shift); 1266 1267 if ( $#ext_prof_order > 0 ) { 1268 $last_field_id = ext_get_field_id( $ext_prof_order[-1] ); 1269 } 1270 1271 foreach my $fieldname (@ext_prof_order) { 1272 $id = ext_get_field_id($fieldname); 1273 ext_get_field($id); 1274 $value = ext_get( $pusername, $fieldname ); 1275 if ( $field{'required_on_reg'} == 1 ) { 1276 1277 if ( $output eq q{} && $previous != 1 ) { 1278 $pre_output = q~<tr> 1279 <td class="windowbg2 vtop" colspan="2">~; 1280 $previous = 1; 1281 } 1282 1283 # format the output dependent on the field type 1284 if ( ( $field{'type'} eq 'text' && $value ne q{} ) 1285 || ( $field{'type'} eq 'text_multi' && $value ne q{} ) 1286 || ( $field{'type'} eq 'select' && $value ne q{ } ) 1287 || ( $field{'type'} eq 'radiobuttons' && $value ne q{} ) 1288 || ( $field{'type'} eq 'date' && $value ne q{} ) 1289 || $field{'type'} eq 'checkbox' ) 1290 { 1291 $output .= qq~<tr> 1292 <td class="windowbg2 vtop"><b>$field{'name'}:</b></td> 1293 <td class="windowbg2 vtop">$value </td> 1294 </tr>~; 1295 $previous = 0; 1296 } 1297 elsif ( $field{'type'} eq 'spacer' ) { 1298 1299# only print spacer if the previous entry was no spacer of the same type and if this is not the last entry 1300 if ( ( $previous == 0 || $field{'comment'} ne q{} ) 1301 && $id ne $last_field_id ) 1302 { 1303 if ( $value eq $ext_spacer_br ) { 1304 $output .= qq~<tr> 1305 <td class="windowbg2 vtop" colspan="2">$ext_spacer_br</td> 1306 </tr>~; 1307 $previous = 0; 1308 } 1309 else { 1310 $output .= q~ 1311 </td> 1312 </tr><tr>~; 1313 if ( $field{'comment'} ne q{} ) { 1314 $output .= qq~ 1315 <td class="catbg" colspan="2"> 1316 $admin_img{'profile'} 1317 <span class="text1"><b>$field{'comment'}</b></span> 1318 </td> 1319 </tr><tr> 1320 <td class="windowbg2 vtop" colspan="2">~; 1321 } 1322 else { 1323 $output .= q~ 1324 <td class="windowbg2 vtop" colspan="2">~; 1325 } 1326 $previous = 1; 1327 } 1328 } 1329 } 1330 elsif ( $field{'type'} eq 'email' && $value ne q{} ) { 1331 $output .= qq~<tr> 1332 <td class="windowbg2 vtop"><b>$field{'name'}:</b></td> 1333 <td class="windowbg2 vtop"> 1334 ~ . enc_eMail( $img_txt{'69'}, $value, q{}, q{} ) . q~ 1335 </td> 1336 </tr>~; 1337 $previous = 0; 1338 } 1339 elsif ( $field{'type'} eq 'url' && $value ne q{} ) { 1340 $output .= qq~<tr> 1341 <td class="windowbg2 vtop"><b>$field{'name'}:</b></td> 1342 <td class="windowbg2 vtop"><a href="$value" target="_blank">$value</a></td> 1343 </tr>~; 1344 $previous = 0; 1345 1346 } 1347 elsif ( $field{'type'} eq 'image' && $value ne q{} ) { 1348 $output .= qq~<tr> 1349 <td class="windowbg2 vtop"><b>$field{'name'}:</b></td> 1350 <td class="windowbg2 vtop">$value</td> 1351 </tr>~; 1352 $previous = 0; 1353 } 1354 } 1355 } 1356 1357 # only add spacer if there there is at least one field displayed 1358 if ( $output ne q{} ) { 1359 $output = $pre_output . $output . q~ 1360 </td> 1361 </tr>~; 1362 } 1363 return $output; 1364} 1365 1366sub CreateExtLock { 1367 fopen( LOCKFILE, ">$vardir/Extended.lock" ) 1368 || setup_fatal_error( "$maintext_23 $vardir/Extended.lock: ", 1 ); 1369 print {LOCKFILE} qq~This is a lockfile for the Extended Profiles.\n~ 1370 or croak 'cannot print to LOCKFILE'; 1371 print {LOCKFILE} 1372 qq~It prevents it being run again after it has been run once.\n~ 1373 or croak 'cannot print to LOCKFILE'; 1374 print {LOCKFILE} q~Delete this file if you want to run the Converter again.~ 1375 or croak 'cannot print to LOCKFILE'; 1376 fclose(LOCKFILE); 1377 1378 return; 1379} 1380sub FoundExtLock { 1381 $found = qq~ 1382 <div class="bordercolor rightboxdiv"> 1383 <table class="border-space pad-cell" style="margin-bottom: .5em;""> 1384 <tr> 1385 <td class="titlebg"><img src="$imagesdir/profile.gif" alt="" /> <b>$lang_ext{'convlock'}</b></td> 1386 </tr><tr> 1387 <td class="windowbg2 center" style="font-size: 11px;">$lang_ext{'convlock_desc'}</td> 1388 </tr> 1389 </table> 1390 </div> 1391 ~; 1392 return $found; 1393} 13941; 1395 1396# file formats used by this code: 1397# 1398# username.vars - contains the additional user profile information. Number is field-id 1399# ------------- 1400# ... 1401# 'ext_0',"value" 1402# 'ext_1',"value" 1403# 'ext_2',"value" 1404# ... 1405# 1406# @ext_prof_order - contains the order in which the fields will be displayed 1407# --------------------------- 1408# ("name","name","name",....) 1409# 1410# extended_profiles_fields.txt - defines the new profile fields. Uses line number as field-id 1411# ---------------------------- 1412# ("name|type|options|active|comment|required_on_reg|visible_in_viewprofile|v_users|v_groups|visible_in_posts|p_users|p_groups|p_displayfieldname|visible_in_memberlist|m_users|m_groups|editable_by_user|visible_in_posts_popup|pp_users|pp_groups|pp_displayfieldname","name|type|options|active|comment|required_on_reg|visible_in_viewprofile|v_users|v_groups|visible_in_posts|p_users|p_groups|p_displayfieldname|visible_in_memberlist|m_users|m_groups|editable_by_user|visible_in_posts_popup|pp_users|pp_groups|pp_displayfieldname","name|type|options|active|comment|required_on_reg|visible_in_viewprofile|v_users|v_groups|visible_in_posts|p_users|p_groups|p_displayfieldname|visible_in_memberlist|m_users|m_groups|editable_by_user|visible_in_posts_popup|pp_users|pp_groups|pp_displayfieldname",....) 1413# 1414# Here are all types with their possible type-specific options. If options contain multiple entries, separated by ^ 1415# - text limit_len^width^is_numberic^default_value^allow_ubbc 1416# - text_multi limit_len^rows^cols^allow_ubbc 1417# - select option1^option2^option3... (first option is default) 1418# - radiobuttons option1^option2^option3... (first option is default) 1419# - spacer br_or_hr^visible_in_editprofile 1420# - checkbox - 1421# - date - 1422# - emial - 1423# - url - 1424# - image width^height^allowed_extensions 1425# 1426# required_on_reg can have value 0 (disabled), 1 (required on registration) and 2 (not req. but display on reg. page anyway) 1427# editable_by_user can have value 0 (will only show on the "admin edits" page), 1 ("edit profile" page), 2 ("contact information" page), 3 ("Options" page) and 4 ("PM Preferences" page) 1428# allowed_extensions is a space-seperated list of file extensions, example: "jpg jpeg gif bmp png" 1429# v_groups, p_groups, m_groups, pp_groups format: "Administrator" or "Moderator" or "Global Moderator" or NoPost{...} or Post{...} 1430# 1431# NOTE: use prefix "ext_" in sub-, variable- and formnames to prevent conflicts with other mods 1432# 1433# easy mod integration: use &ext_get($username,"fieldname") go get user's field value 1434# 1435############################################################################### 1436