Changeset 2255 for trunk/admin/plugins_list.php
- Timestamp:
- Mar 6, 2008, 3:29:29 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/plugins_list.php
r2243 r2255 29 29 } 30 30 31 32 // +-----------------------------------------------------------------------+ 33 // | perform requested actions | 34 // +-----------------------------------------------------------------------+ 35 if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser()) 36 { 37 $plugin_id = $_GET['plugin']; 38 $crt_db_plugin = get_db_plugins('', $plugin_id); 39 if (!empty($crt_db_plugin)) 40 { 41 $crt_db_plugin = $crt_db_plugin[0]; 42 } 43 else 44 { 45 unset($crt_db_plugin); 46 } 47 48 $errors = array(); 49 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php'; 50 51 switch ($_GET['action']) 52 { 53 case 'install': 54 if (!empty($crt_db_plugin)) 55 { 56 array_push($errors, 'CANNOT install - ALREADY INSTALLED'); 57 break; 58 } 59 $fs_plugins = get_fs_plugins(); 60 if (!isset($fs_plugins[$plugin_id])) 61 { 62 array_push($errors, 'CANNOT install - NO SUCH PLUGIN'); 63 break; 64 } 65 if (file_exists($file_to_include)) 66 { 67 include_once($file_to_include); 68 if (function_exists('plugin_install')) 69 { 70 plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors); 71 } 72 } 73 if (empty($errors)) 74 { 75 $query = ' 76 INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("' 77 . $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '" 78 )'; 79 pwg_query($query); 80 } 81 break; 82 83 case 'activate': 84 activate_plugin($plugin_id, $errors); 85 break; 86 case 'deactivate': 87 deactivate_plugin($plugin_id, $errors); 88 break; 89 90 case 'uninstall': 91 if (!isset($crt_db_plugin)) 92 { 93 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED'); 94 } 95 $query = ' 96 DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"'; 97 pwg_query($query); 98 if (file_exists($file_to_include)) 99 { 100 include_once($file_to_include); 101 if (function_exists('plugin_uninstall')) 102 { 103 plugin_uninstall($plugin_id); 104 } 105 } 106 break; 107 108 case 'delete': 109 if (!empty($crt_db_plugin)) 110 { 111 array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED'); 112 } 113 elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) 114 { 115 send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id); 116 } 117 break; 118 } 119 if (empty($errors)) 120 { 121 redirect( 122 get_root_url() 123 .'admin.php' 124 .get_query_string_diff( array('action', 'plugin') ) 125 ); 126 } 127 else 128 { 129 $page['errors'] = array_merge($page['errors'], $errors); 130 } 131 } 132 133 134 $fs_plugins = get_fs_plugins(); 135 $db_plugins = get_db_plugins(); 136 $db_plugins_by_id = array(); 137 foreach ($db_plugins as $db_plugin) 138 { 139 $db_plugins_by_id[$db_plugin['id']] = $db_plugin; 140 } 141 142 143 // +-----------------------------------------------------------------------+ 144 // | start template output | 145 // +-----------------------------------------------------------------------+ 146 31 147 $template->set_filenames(array('plugins' => 'admin/plugins_list.tpl')); 32 148 149 $base_url = get_root_url().'admin.php'; 150 33 151 //----------------------------------------------------------------sort options 34 $order = isset($_GET['order']) ? $_GET['order'] : 'name'; 35 36 $template->assign('order', 37 array(htmlentities($my_base_url.'&order=name') => l10n('Name'), 38 htmlentities($my_base_url.'&order=status') => l10n('Status') 152 $selected_order = isset($_GET['order']) ? $_GET['order'] : 'name'; 153 154 $url = $base_url.get_query_string_diff( array('action', 'plugin', 'order')); 155 156 $template->assign('order', 157 array( 158 $url.'&order=name' => l10n('Name'), 159 $url.'&order=status' => l10n('Status'), 160 $url.'&order=author' => l10n('Author'), 161 $url.'&order=id' => l10n('Id'), 39 162 ) 40 163 ); 41 42 $template->assign('selected', htmlentities($my_base_url.'&order=').$order); 43 44 45 // +-----------------------------------------------------------------------+ 46 // | start template output | 47 // +-----------------------------------------------------------------------+ 48 49 if ($order == 'status') 50 { 51 $fs_plugins = sort_plugins_by_state($fs_plugins, $db_plugins_by_id); 52 } 164 165 $template->assign('selected', $url.'&order='.$selected_order); 166 167 switch ($selected_order) 168 { 169 case 'name': 170 uasort($fs_plugins, 'name_compare'); 171 break; 172 case 'id': 173 uksort($fs_plugins, 'strcasecmp'); 174 break; 175 case 'author': 176 uasort($fs_plugins, 'plugin_author_compare'); 177 break; 178 case 'status': 179 $fs_plugins = sort_plugins_by_state($fs_plugins, $db_plugins_by_id); 180 break; 181 } 182 183 184 //--------------------------------------------------------------display plugins 185 186 $url = $base_url.get_query_string_diff( array('action', 'plugin') ); 53 187 54 188 foreach($fs_plugins as $plugin_id => $fs_plugin) … … 81 215 'DESCRIPTION' => $desc); 82 216 83 $action_url = htmlentities($my_base_url) . '&plugin=' .$plugin_id;217 $action_url = $url.'&plugin='.$plugin_id; 84 218 85 219 if (isset($db_plugins_by_id[$plugin_id])) 86 { 220 { 87 221 switch ($db_plugins_by_id[$plugin_id]['state']) 88 222 { 89 223 case 'active': 90 $tpl_plugin['actions'][] = 224 $tpl_plugin['actions'][] = 91 225 array('U_ACTION' => $action_url . '&action=deactivate', 92 226 'L_ACTION' => l10n('Deactivate')); … … 94 228 95 229 case 'inactive': 96 $tpl_plugin['actions'][] = 230 $tpl_plugin['actions'][] = 97 231 array('U_ACTION' => $action_url . '&action=activate', 98 232 'L_ACTION' => l10n('Activate')); 99 $tpl_plugin['actions'][] = 233 $tpl_plugin['actions'][] = 100 234 array('U_ACTION' => $action_url . '&action=uninstall', 101 235 'L_ACTION' => l10n('Uninstall'), … … 106 240 else 107 241 { 108 $tpl_plugin['actions'][] = 242 $tpl_plugin['actions'][] = 109 243 array('U_ACTION' => $action_url . '&action=install', 110 244 'L_ACTION' => l10n('Install'), 111 245 'CONFIRM' => l10n('Are you sure?')); 112 $tpl_plugin['actions'][] = 246 $tpl_plugin['actions'][] = 113 247 array('U_ACTION' => $action_url . '&action=delete', 114 248 'L_ACTION' => l10n('plugins_delete'), … … 124 258 foreach($missing_plugin_ids as $plugin_id) 125 259 { 126 $action_url = $ my_base_url.'&plugin='.$plugin_id;260 $action_url = $url.'&plugin='.$plugin_id; 127 261 128 262 $template->append( 'plugins', … … 139 273 } 140 274 275 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugins'); 141 276 ?>
Note: See TracChangeset
for help on using the changeset viewer.