Changeset 119
- Timestamp:
- 03/29/2009 03:17:58 PM (3 years ago)
- Location:
- trunk/WordPress/plugin/transposh
- Files:
-
- 3 edited
-
transposh.php (modified) (4 diffs)
-
transposh_admin.php (modified) (2 diffs)
-
transposh_db.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/transposh.php
r117 r119 238 238 $home_url_quoted = preg_replace("/\//", "\\/", $home_url_quoted); 239 239 240 $enable_auto_translate = get_option(ENABLE_AUTO_TRANSLATE,1) && is_translat or();240 $enable_auto_translate = get_option(ENABLE_AUTO_TRANSLATE,1) && is_translation_allowed(); 241 241 242 242 if($wp_rewrite->using_permalinks() && get_option(ENABLE_PERMALINKS_REWRITE)) … … 478 478 */ 479 479 function add_transposh_css() { 480 global $plugin_url, $wp_query; 481 if (!isset($wp_query->query_vars[LANG_PARAM])) 482 { 480 global $plugin_url; 481 482 if(!is_translation_allowed()) 483 { 484 //translation not allowed - no need for the transposh.css 483 485 return; 484 486 } 485 486 $lang = $wp_query->query_vars[LANG_PARAM];487 $editable_langs = get_option(EDITABLE_LANGS);488 489 if(strpos($editable_langs, $lang) === FALSE)490 {491 //not an editable language - no need for any css.492 return;493 }494 495 487 //include the transposh.css 496 488 wp_enqueue_style("transposh","$plugin_url/transposh.css",array(),'1.0.1'); … … 505 497 global $plugin_url, $wp_query, $lang, $home_url, $enable_auto_translate; 506 498 507 if (!isset($wp_query->query_vars[LANG_PARAM])) 508 { 499 if(!is_translation_allowed()) 500 { 501 //translation not allowed - no need for any js. 509 502 return; 510 503 } 511 $lang = $wp_query->query_vars[LANG_PARAM]; 512 $editable_langs = get_option(EDITABLE_LANGS); 513 514 if(strpos($editable_langs, $lang) === FALSE) 515 { 516 //not an editable language - no need for any js. 517 return; 518 } 519 504 520 505 $is_edit_param_enabled = $wp_query->query_vars[EDIT_PARAM]; 521 522 506 if (!$is_edit_param_enabled && ! $enable_auto_translate) 523 507 { 524 //TODO: check permission later - for now just make sure we don't load the 525 //js code when it is not needed 508 //Not in any translation mode - no need for any js. 526 509 return; 527 510 } … … 548 531 } 549 532 533 534 /** 535 * Determine if the currently selected language (taken from the query parameters) is in the admin's list 536 * of editable languages and the current user is allowed to translate. 537 * 538 * @return TRUE if translation allowed otherwise FALSE 539 */ 540 function is_translation_allowed() 541 { 542 global $wp_query; 543 544 if(!is_translator()) 545 { 546 return FALSE; 547 } 548 549 if (!isset($wp_query->query_vars[LANG_PARAM])) 550 { 551 return FALSE; 552 } 553 554 $lang = $wp_query->query_vars[LANG_PARAM]; 555 return is_editable_lang($lang); 556 } 557 558 /** 559 * Determine if the given language in on the list of editable languages 560 * @return TRUE if editable othewise FALSE 561 */ 562 function is_editable_lang($lang) 563 { 564 $editable_langs = get_option(EDITABLE_LANGS); 565 566 if(strpos($editable_langs, $lang) === FALSE) 567 { 568 //not an editable language 569 return FALSE; 570 } 571 572 return TRUE; 573 } 574 550 575 //Register callbacks 551 576 add_filter('query_vars', 'parameter_queryvars' ); -
trunk/WordPress/plugin/transposh/transposh_admin.php
r101 r119 140 140 $langs = get_option(EDITABLE_LANGS); 141 141 142 if(str str($langs, $code))142 if(strpos($langs, $code) !== FALSE) 143 143 { 144 144 return 'checked="checked"'; … … 155 155 { 156 156 $langs = get_option(VIEWABLE_LANGS); 157 if(str str($langs, $code))157 if(strpos($langs, $code) !== FALSE) 158 158 { 159 159 return 'checked="checked"'; -
trunk/WordPress/plugin/transposh/transposh_db.php
r117 r119 118 118 } 119 119 120 //Check that use is allowed to translate121 if(!is_translator() )120 //Check that user is allowed to translate this language 121 if(!is_translator() || !is_editable_lang($lang)) 122 122 { 123 123 logger("Unauthorized translation attempt " . $_SERVER['REMOTE_ADDR'] , 1); 124 header("HTTP/1.0 401 Unauthorized translation"); 125 exit; 124 126 } 125 127
Note: See TracChangeset
for help on using the changeset viewer.
