Changeset 2253 for trunk/admin
- Timestamp:
- Mar 5, 2008, 6:54:32 PM (17 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/plugins.php
r2243 r2253 36 36 37 37 // +-----------------------------------------------------------------------+ 38 // | perform requested actions |39 // +-----------------------------------------------------------------------+40 if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())41 {42 $plugin_id = $_GET['plugin'];43 $crt_db_plugin = get_db_plugins('', $plugin_id);44 if (!empty($crt_db_plugin))45 {46 $crt_db_plugin = $crt_db_plugin[0];47 }48 else49 {50 unset($crt_db_plugin);51 }52 53 $errors = array();54 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';55 56 switch ($_GET['action'])57 {58 case 'install':59 if (!empty($crt_db_plugin))60 {61 array_push($errors, 'CANNOT install - ALREADY INSTALLED');62 break;63 }64 $fs_plugins = get_fs_plugins();65 if (!isset($fs_plugins[$plugin_id]))66 {67 array_push($errors, 'CANNOT install - NO SUCH PLUGIN');68 break;69 }70 if (file_exists($file_to_include))71 {72 include_once($file_to_include);73 if (function_exists('plugin_install'))74 {75 plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors);76 }77 }78 if (empty($errors))79 {80 $query = '81 INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("'82 . $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '"83 )';84 pwg_query($query);85 }86 break;87 88 case 'activate':89 if (!isset($crt_db_plugin))90 {91 array_push($errors, 'CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');92 break;93 }94 if ($crt_db_plugin['state'] != 'inactive')95 {96 array_push($errors, 'invalid current state ' . $crt_db_plugin['state']);97 break;98 }99 if (file_exists($file_to_include))100 {101 include_once($file_to_include);102 if (function_exists('plugin_activate'))103 {104 plugin_activate($plugin_id, $crt_db_plugin['version'], $errors);105 }106 }107 if (empty($errors))108 {109 $query = '110 UPDATE ' . PLUGINS_TABLE . ' SET state="active" WHERE id="' . $plugin_id . '"';111 pwg_query($query);112 }113 break;114 115 case 'deactivate':116 if (!isset($crt_db_plugin))117 {118 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');119 }120 if ($crt_db_plugin['state'] != 'active')121 {122 die('invalid current state ' . $crt_db_plugin['state']);123 }124 $query = '125 UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"';126 pwg_query($query);127 if (file_exists($file_to_include))128 {129 include_once($file_to_include);130 if (function_exists('plugin_deactivate'))131 {132 plugin_deactivate($plugin_id);133 }134 }135 break;136 137 case 'uninstall':138 if (!isset($crt_db_plugin))139 {140 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');141 }142 $query = '143 DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';144 pwg_query($query);145 if (file_exists($file_to_include))146 {147 include_once($file_to_include);148 if (function_exists('plugin_uninstall'))149 {150 plugin_uninstall($plugin_id);151 }152 }153 break;154 155 case 'delete':156 if (!deltree(PHPWG_PLUGINS_PATH . $plugin_id))157 {158 send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id);159 }160 break;161 }162 if (empty($errors))163 {164 $my_base_url .= isset($_GET['upgrade']) ?165 '&plugin='.$plugin_id.'&upgrade='.$_GET['upgrade'].'&reactivate=true':'';166 167 $my_base_url .= isset($_GET['upgradestatus']) ?168 '&plugin='.$plugin_id.'&upgradestatus='.$_GET['upgradestatus']:'';169 170 redirect($my_base_url);171 }172 else173 {174 $page['errors'] = array_merge($page['errors'], $errors);175 }176 }177 178 179 // +-----------------------------------------------------------------------+180 38 // | Sections definitions | 181 39 // +-----------------------------------------------------------------------+ … … 206 64 207 65 // +-----------------------------------------------------------------------+ 66 // | perform requested actions | 67 // +-----------------------------------------------------------------------+ 68 if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser()) 69 { 70 $plugin_id = $_GET['plugin']; 71 $crt_db_plugin = get_db_plugins('', $plugin_id); 72 if (!empty($crt_db_plugin)) 73 { 74 $crt_db_plugin = $crt_db_plugin[0]; 75 } 76 else 77 { 78 unset($crt_db_plugin); 79 } 80 81 $errors = array(); 82 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php'; 83 84 switch ($_GET['action']) 85 { 86 case 'install': 87 if (!empty($crt_db_plugin)) 88 { 89 array_push($errors, 'CANNOT install - ALREADY INSTALLED'); 90 break; 91 } 92 $fs_plugins = get_fs_plugins(); 93 if (!isset($fs_plugins[$plugin_id])) 94 { 95 array_push($errors, 'CANNOT install - NO SUCH PLUGIN'); 96 break; 97 } 98 if (file_exists($file_to_include)) 99 { 100 include_once($file_to_include); 101 if (function_exists('plugin_install')) 102 { 103 plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors); 104 } 105 } 106 if (empty($errors)) 107 { 108 $query = ' 109 INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("' 110 . $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '" 111 )'; 112 pwg_query($query); 113 } 114 break; 115 116 case 'activate': 117 if (!isset($crt_db_plugin)) 118 { 119 array_push($errors, 'CANNOT ' . $_GET['action'] . ' - NOT INSTALLED'); 120 break; 121 } 122 if ($crt_db_plugin['state'] != 'inactive') 123 { 124 array_push($errors, 'invalid current state ' . $crt_db_plugin['state']); 125 break; 126 } 127 if (file_exists($file_to_include)) 128 { 129 include_once($file_to_include); 130 if (function_exists('plugin_activate')) 131 { 132 plugin_activate($plugin_id, $crt_db_plugin['version'], $errors); 133 } 134 } 135 if (empty($errors)) 136 { 137 $query = ' 138 UPDATE ' . PLUGINS_TABLE . ' SET state="active" WHERE id="' . $plugin_id . '"'; 139 pwg_query($query); 140 } 141 break; 142 143 case 'deactivate': 144 if (!isset($crt_db_plugin)) 145 { 146 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED'); 147 } 148 if ($crt_db_plugin['state'] != 'active') 149 { 150 die('invalid current state ' . $crt_db_plugin['state']); 151 } 152 $query = ' 153 UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"'; 154 pwg_query($query); 155 if (file_exists($file_to_include)) 156 { 157 include_once($file_to_include); 158 if (function_exists('plugin_deactivate')) 159 { 160 plugin_deactivate($plugin_id); 161 } 162 } 163 break; 164 165 case 'uninstall': 166 if (!isset($crt_db_plugin)) 167 { 168 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED'); 169 } 170 $query = ' 171 DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"'; 172 pwg_query($query); 173 if (file_exists($file_to_include)) 174 { 175 include_once($file_to_include); 176 if (function_exists('plugin_uninstall')) 177 { 178 plugin_uninstall($plugin_id); 179 } 180 } 181 break; 182 183 case 'delete': 184 if (!empty($crt_db_plugin)) 185 { 186 array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED'); 187 } 188 elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) 189 { 190 send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id); 191 } 192 break; 193 } 194 if (empty($errors)) 195 { 196 $my_base_url .= isset($_GET['upgrade']) ? 197 '&plugin='.$plugin_id.'&upgrade='.$_GET['upgrade'].'&reactivate=true':''; 198 199 $my_base_url .= isset($_GET['upgradestatus']) ? 200 '&plugin='.$plugin_id.'&upgradestatus='.$_GET['upgradestatus']:''; 201 202 redirect($my_base_url); 203 } 204 else 205 { 206 $page['errors'] = array_merge($page['errors'], $errors); 207 } 208 } 209 210 211 // +-----------------------------------------------------------------------+ 208 212 // | start template output | 209 213 // +-----------------------------------------------------------------------+ -
trunk/admin/user_list.php
r2201 r2253 451 451 // +-----------------------------------------------------------------------+ 452 452 453 $groups = array();453 $groups[-1] = '------------'; 454 454 455 455 $query = ' … … 482 482 } 483 483 484 $template->assign _vars(484 $template->assign( 485 485 array( 486 486 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=user_list', … … 491 491 )); 492 492 493 if (isset($_GET['id']))494 {495 $template->assign_block_vars('session', array('ID' => $_GET['id']));496 }497 498 493 // Hide radio-button if not allow to assign adviser 499 494 if ($conf['allow_adviser']) 500 495 { 501 $template->assign_block_vars('adviser', array()); 502 } 503 504 foreach ($page['order_by_items'] as $item => $label) 505 { 506 $selected = (isset($_GET['order_by']) and $_GET['order_by'] == $item) ? 507 'selected="selected"' : ''; 508 $template->assign_block_vars( 509 'order_by', 510 array( 511 'VALUE' => $item, 512 'CONTENT' => $label, 513 'SELECTED' => $selected 514 )); 515 } 516 517 foreach ($page['direction_items'] as $item => $label) 518 { 519 $selected = (isset($_GET['direction']) and $_GET['direction'] == $item) ? 520 'selected="selected"' : ''; 521 $template->assign_block_vars( 522 'direction', 523 array( 524 'VALUE' => $item, 525 'CONTENT' => $label, 526 'SELECTED' => $selected 527 )); 528 } 529 530 $blockname = 'group_option'; 531 532 $template->assign_block_vars( 533 $blockname, 534 array( 535 'VALUE'=> -1, 536 'CONTENT' => '------------', 537 'SELECTED' => '' 538 )); 539 540 foreach ($groups as $group_id => $group_name) 541 { 542 $selected = (isset($_GET['group']) and $_GET['group'] == $group_id) ? 543 'selected="selected"' : ''; 544 $template->assign_block_vars( 545 $blockname, 546 array( 547 'VALUE' => $group_id, 548 'CONTENT' => $group_name, 549 'SELECTED' => $selected 550 )); 551 } 552 553 $blockname = 'status_option'; 554 555 $template->assign_block_vars( 556 $blockname, 557 array( 558 'VALUE'=> -1, 559 'CONTENT' => '------------', 560 'SELECTED' => '' 561 )); 562 496 $template->assign('adviser', true); 497 } 498 499 // Filter status options 500 $status_options[-1] = '------------'; 563 501 foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) 564 502 { 565 $selected = (isset($_GET['status']) and $_GET['status'] == $status) ? 566 'selected="selected"' : ''; 567 $template->assign_block_vars( 568 $blockname, 569 array( 570 'VALUE' => $status, 571 'CONTENT' => l10n('user_status_'.$status), 572 'SELECTED' => $selected 573 )); 574 } 503 $status_options[$status] = l10n('user_status_'.$status); 504 } 505 $template->assign('status_options', $status_options); 506 $template->assign('status_selected', 507 isset($_GET['status']) ? $_GET['status'] : ''); 508 509 // Filter group options 510 $template->assign('group_options', $groups); 511 $template->assign('group_selected', 512 isset($_GET['group']) ? $_GET['group'] : ''); 513 514 // Filter order options 515 $template->assign('order_options', $page['order_by_items']); 516 $template->assign('order_selected', 517 isset($_GET['order_by']) ? $_GET['order_by'] : ''); 518 519 // Filter direction options 520 $template->assign('direction_options', $page['direction_items']); 521 $template->assign('direction_selected', 522 isset($_GET['direction']) ? $_GET['direction'] : ''); 523 575 524 576 525 if (isset($_POST['pref_submit'])) 577 526 { 578 527 // echo '<pre>'; print_r($_POST); echo '</pre>'; 579 $template->assign _vars(528 $template->assign( 580 529 array( 581 530 'ADVISER_YES' => 'true' == (isset($_POST['adviser']) and $_POST['adviser']) ? 'checked="checked"' : '', … … 588 537 'EXPAND_YES' => 'true' == $_POST['expand'] ? 'checked="checked"' : '', 589 538 'EXPAND_NO' => 'false' == $_POST['expand'] ? 'checked="checked"' : '', 590 'SHOW_NB_COMMENTS_YES' => 591 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', 592 'SHOW_NB_COMMENTS_NO' => 593 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', 594 'SHOW_NB_HITS_YES' => 595 'true' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', 596 'SHOW_NB_HITS_NO' => 597 'false' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', 539 'SHOW_NB_COMMENTS_YES' => 'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', 540 'SHOW_NB_COMMENTS_NO' => 'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '', 541 'SHOW_NB_HITS_YES' => 'true' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', 542 'SHOW_NB_HITS_NO' => 'false' == $_POST['show_nb_hits'] ? 'checked="checked"' : '', 598 543 'ENABLED_HIGH_YES' => 'true' == $_POST['enabled_high'] ? 'checked="checked"' : '', 599 544 'ENABLED_HIGH_NO' => 'false' == $_POST['enabled_high'] ? 'checked="checked"' : '', 545 546 'STATUS_ACTION_SET' => 'set' == $_POST['status_action'] ? 'checked="checked"' : '', 547 'LEVEL_ACTION_SET' => 'set' == $_POST['level_action'] ? 'checked="checked"' : '', 548 'NB_IMAGE_LINE_ACTION_SET' => 'set' == $_POST['nb_image_line_action'] ? 'checked="checked"' : '', 549 'NB_LINE_PAGE_ACTION_SET' => 'set' == $_POST['nb_line_page_action'] ? 'checked="checked"' : '', 550 'TEMPLATE_ACTION_SET' => 'set' == $_POST['template_action'] ? 'checked="checked"' : '', 551 'LANGUAGE_ACTION_SET' => 'set' == $_POST['language_action'] ? 'checked="checked"' : '', 552 'RECENT_PERIOD_ACTION_SET' => 'set' == $_POST['recent_period_action'] ? 'checked="checked"' : '', 553 'MAXWIDTH_ACTION_SET' => 'set' == $_POST['maxwidth_action'] ? 'checked="checked"' : '', 554 'MAXHEIGHT_ACTION_SET' => 'set' == $_POST['maxheight_action'] ? 'checked="checked"' : '', 600 555 )); 601 556 } … … 603 558 { 604 559 $default_user = get_default_user_info(true); 605 $template->assign _vars(560 $template->assign( 606 561 array( 607 562 'NB_IMAGE_LINE' => $default_user['nb_image_line'], … … 613 568 } 614 569 615 $blockname = 'template_option'; 616 617 foreach (get_pwg_themes() as $pwg_template) 618 { 619 if (isset($_POST['pref_submit'])) 620 { 621 $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : ''; 622 } 623 else if (get_default_template() == $pwg_template) 624 { 625 $selected = 'selected="selected"'; 626 } 627 else 628 { 629 $selected = ''; 630 } 631 632 $template->assign_block_vars( 633 $blockname, 634 array( 635 'VALUE'=> $pwg_template, 636 'CONTENT' => $pwg_template, 637 'SELECTED' => $selected 638 )); 639 } 640 641 $blockname = 'language_option'; 642 643 foreach (get_languages() as $language_code => $language_name) 644 { 645 if (isset($_POST['pref_submit'])) 646 { 647 $selected = $_POST['language']==$language_code ? 'selected="selected"':''; 648 } 649 else if (get_default_language() == $language_code) 650 { 651 $selected = 'selected="selected"'; 652 } 653 else 654 { 655 $selected = ''; 656 } 657 658 $template->assign_block_vars( 659 $blockname, 660 array( 661 'VALUE'=> $language_code, 662 'CONTENT' => $language_name, 663 'SELECTED' => $selected 664 )); 665 } 666 667 $blockname = 'pref_status_option'; 668 570 // Template Options 571 $template->assign('template_options', get_pwg_themes()); 572 $template->assign('template_selected', 573 isset($_POST['pref_submit']) ? $_POST['template'] : get_default_template()); 574 575 // Language options 576 $template->assign('language_options', get_languages()); 577 $template->assign('language_selected', 578 isset($_POST['pref_submit']) ? $_POST['language'] : get_default_language()); 579 580 // Status options 669 581 foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) 670 582 { 671 if (isset($_POST['pref_submit']))672 {673 $selected = $_POST['status'] == $status ? 'selected="selected"' : '';674 }675 else if ('normal' == $status)676 {677 $selected = 'selected="selected"';678 }679 else680 {681 $selected = '';682 }683 684 583 // Only status <= can be assign 685 584 if (is_autorize_status(get_access_type_status($status))) 686 585 { 687 $template->assign_block_vars( 688 $blockname, 689 array( 690 'VALUE' => $status, 691 'CONTENT' => l10n('user_status_'.$status), 692 'SELECTED' => $selected 693 )); 694 } 695 } 696 697 // associate 698 $blockname = 'associate_option'; 699 700 $template->assign_block_vars( 701 $blockname, 702 array( 703 'VALUE'=> -1, 704 'CONTENT' => '------------', 705 'SELECTED' => '' 706 )); 707 708 foreach ($groups as $group_id => $group_name) 709 { 710 if (isset($_POST['pref_submit'])) 711 { 712 $selected = $_POST['associate'] == $group_id ? 'selected="selected"' : ''; 713 } 714 else 715 { 716 $selected = ''; 717 } 718 719 $template->assign_block_vars( 720 $blockname, 721 array( 722 'VALUE' => $group_id, 723 'CONTENT' => $group_name, 724 'SELECTED' => $selected 725 )); 726 } 727 728 // dissociate 729 $blockname = 'dissociate_option'; 730 731 $template->assign_block_vars( 732 $blockname, 733 array( 734 'VALUE'=> -1, 735 'CONTENT' => '------------', 736 'SELECTED' => '' 737 )); 738 739 foreach ($groups as $group_id => $group_name) 740 { 741 if (isset($_POST['pref_submit'])) 742 { 743 $selected = $_POST['dissociate'] == $group_id ? 'selected="selected"' : ''; 744 } 745 else 746 { 747 $selected = ''; 748 } 749 750 $template->assign_block_vars( 751 $blockname, 752 array( 753 'VALUE' => $group_id, 754 'CONTENT' => $group_name, 755 'SELECTED' => $selected 756 )); 757 } 586 $pref_status_options[$status] = l10n('user_status_'.$status); 587 } 588 } 589 $template->assign('pref_status_options', $pref_status_options); 590 $template->assign('pref_status_selected', 591 isset($_POST['pref_submit']) ? $_POST['status'] : 'normal'); 592 593 // associate and dissociate options 594 $template->assign('association_options', $groups); 595 $template->assign('associate_selected', 596 isset($_POST['pref_submit']) ? $_POST['associate'] : ''); 597 $template->assign('dissociate_selected', 598 isset($_POST['pref_submit']) ? $_POST['dissociate'] : ''); 599 758 600 759 601 // user level options 760 $blockname = 'level_option';761 602 foreach ($conf['available_permission_levels'] as $level) 762 603 { 763 $template->assign_block_vars( 764 $blockname, 765 array( 766 'VALUE' => $level, 767 'CONTENT' => l10n( sprintf('Level %d', $level) ), 768 'SELECTED' => $level==$default_user['level'] ? 'selected="selected"' : '', 769 )); 770 } 604 $level_options[$level] = l10n(sprintf('Level %d', $level)); 605 } 606 $template->assign('level_options', $level_options); 607 $template->assign('level_selected', 608 isset($_POST['pref_submit']) ? $_POST['level'] : $default_user['level']); 771 609 772 610 // +-----------------------------------------------------------------------+ … … 783 621 ); 784 622 785 $template->assign _vars(array('NAVBAR' => $navbar));623 $template->assign('NAVBAR', $navbar); 786 624 787 625 // +-----------------------------------------------------------------------+ … … 841 679 ? l10n('is_high_enabled') : l10n('is_high_disabled'); 842 680 843 $template->a ssign_block_vars(844 'user ',681 $template->append( 682 'users', 845 683 array( 846 'CLASS' => ($num % 2 == 1) ? 'row2' : 'row1',847 684 'ID' => $local_user['id'], 848 685 'CHECKED' => $checked, … … 862 699 ) 863 700 ); 864 trigger_action('loc_a ssign_block_var_local_user_list', $local_user);701 trigger_action('loc_append_user_list', $local_user); 865 702 } 866 703
Note: See TracChangeset
for help on using the changeset viewer.