Changeset 9383 for extensions/PWG_Stuffs/admin
- Timestamp:
- Feb 26, 2011, 4:28:24 PM (13 years ago)
- Location:
- extensions/PWG_Stuffs/admin
- Files:
-
- 2 added
- 1 deleted
- 3 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
extensions/PWG_Stuffs/admin/add_module.inc.php
r9369 r9383 30 30 $desc = !empty($_POST['module_desc']) ? '"' . $_POST['module_desc'] . '"' : 'NULL'; 31 31 $groups = !empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL'; 32 $users = !empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : 'NULL'; 32 $users = 'NULL'; 33 if ($conf['Stuffs']['user_perm']) 34 { 35 $users = !empty($_POST['users']) ? '"' . implode(',', $_POST['users']) . '"' : '""'; 36 } 33 37 $show_title = isset($_POST['show_title']) ? '"true"' : '"false"'; 34 38 $on_home = isset($_POST['on_home']) ? '"true"' : '"false"'; 39 $on_root = isset($_POST['on_root']) ? '"true"' : '"false"'; 35 40 $on_cats = isset($_POST['on_cats']) ? '"true"' : '"false"'; 36 41 $on_picture = isset($_POST['on_picture']) ? '"true"' : '"false"'; … … 49 54 show_title=' . $show_title .', 50 55 on_home=' . $on_home .', 56 on_root=' . $on_root .', 51 57 on_cats=' . $on_cats . ', 52 58 on_picture='. $on_picture . ' … … 66 72 67 73 $query = ' 68 INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, path, parent, datas, users, groups, show_title, on_home, on_ cats, on_picture, id_line, width )74 INSERT INTO ' . STUFFS_TABLE . ' ( id, pos, name, descr, path, parent, datas, users, groups, show_title, on_home, on_root, on_cats, on_picture, id_line, width ) 69 75 VALUES (' . $next_element_id . ' , 70 76 ' . $pos . ', … … 78 84 ' . $show_title . ', 79 85 ' . $on_home . ', 86 ' . $on_root . ', 80 87 ' . $on_cats . ', 81 88 ' . $on_picture . ', … … 94 101 $module['users'] = array('guest', 'generic', 'normal', 'admin', 'webmaster'); 95 102 $module['groups'] = array(); 103 96 104 $template->assign(array( 97 105 'STUFFS_TITLE' => l10n('stuffs_add_mod'), 98 106 'MODULE_NAME' => $modules[$module_path]['name'], 99 'show_title_CHECKED' => 'checked="checked"', 100 'on_home_CHECKED' => 'checked="checked"')); 107 'show_title_CHECKED' => true, 108 ) 109 ); 110 111 $template->assign('selected_options', array( 112 'on_home' => true, 113 'on_root' => true, 114 'on_cats' => false, 115 'on_picture' => false, 116 ) 117 ); 101 118 } 102 119 103 120 // Users perm 104 $template->assign('user_perm', array( 105 'GUEST' => (in_array('guest', $module['users']) ? 'checked="checked"' : ''), 106 'GENERIC' => (in_array('generic', $module['users']) ? 'checked="checked"' : ''), 107 'NORMAL' => (in_array('normal', $module['users']) ? 'checked="checked"' : ''), 108 'ADMIN' => (in_array('admin', $module['users']) ? 'checked="checked"' : ''), 109 'WEBMASTER' => (in_array('webmaster', $module['users']) ? 'checked="checked"' : ''))); 121 if ($conf['Stuffs']['user_perm']) 122 { 123 $users_id = array('guest', 'generic', 'normal', 'admin', 'webmaster'); 124 $users = array(); 125 foreach ($users_id as $id) 126 { 127 $users[$id] = l10n('user_status_'.$id); 128 } 129 $template->assign(array( 130 'users' => $users, 131 'selected_users' => isset($module['users']) ? $module['users'] : $users_id, 132 ) 133 ); 134 } 110 135 111 136 // Groups perm 112 $groups = get_all_groups(); 113 if (!empty($groups)) 137 if ($conf['Stuffs']['group_perm']) 114 138 { 115 $template->assign('group_perm', array('GROUPSELECTION' => get_html_groups_selection($groups, 'groups', $module['groups']))); 139 $query = 'SELECT id, name FROM '.GROUPS_TABLE.' ORDER BY name ASC;'; 140 $result = pwg_query($query); 141 $groups = array(); 142 while ($row = pwg_db_fetch_assoc($result)) 143 { 144 $groups[$row['id']] = $row['name']; 145 } 146 $template->assign(array( 147 'groups' => $groups, 148 'selected_groups' => isset($module['groups']) ? $module['groups'] : array(), 149 ) 150 ); 116 151 } 152 153 // Level perm 154 if ($conf['Stuffs']['level_perm']) 155 { 156 foreach ($conf['available_permission_levels'] as $level) 157 { 158 $level_options[$level] = l10n(sprintf('Level %d', $level)); 159 } 160 $template->assign(array( 161 'level_perm' => $level_options, 162 'level_selected' => isset($module['level']) ? $module['level'] : 0, 163 ) 164 ); 165 } 166 167 // Display options 168 $template->assign('display_options', array( 169 'on_home' => true, 170 'on_root' => true, 171 'on_cats' => true, 172 'on_picture' => true, 173 ) 174 ); 117 175 118 176 // Module configuration -
extensions/PWG_Stuffs/admin/admin.php
r9369 r9383 8 8 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 9 9 include_once(STUFFS_PATH . 'include/functions.inc.php'); 10 include_once(STUFFS_PATH . 'admin/functions.inc.php');11 10 $my_base_url = get_admin_plugin_menu_link(__FILE__); 12 11 … … 28 27 if ($page['tab'] == 'edit_module') 29 28 { 30 $tabsheet->add('edit_module', l10n('stuffs_edit_mod'), $my_base_url.'&tab=edit_module ');29 $tabsheet->add('edit_module', l10n('stuffs_edit_mod'), $my_base_url.'&tab=edit_module&edit='.$_GET['edit']); 31 30 } 31 $tabsheet->add('config', l10n('Configuration'), $my_base_url.'&tab=config'); 32 32 $tabsheet->select($page['tab']); 33 33 $tabsheet->assign(); … … 51 51 52 52 // Include file 53 include(STUFFS_PATH.'admin/'.$page['tab'].'. php');53 include(STUFFS_PATH.'admin/'.$page['tab'].'.inc.php'); 54 54 55 55 ?> -
extensions/PWG_Stuffs/admin/edit_module.inc.php
r9369 r9383 16 16 'MODULE_NAME' => $module['name'], 17 17 'DESC_VALUE' => (isset($module['descr']) ? $module['descr'] : ''), 18 'show_title_CHECKED' => ($module['show_title'] == 'true' ? 'checked="checked"' : ''), 19 'on_home_CHECKED' => ($module['on_home'] == 'true' ? 'checked="checked"' : ''), 20 'on_cats_CHECKED' => ($module['on_cats'] == 'true' ? 'checked="checked"' : ''), 21 'on_picture_CHECKED' => ($module['on_picture'] == 'true' ? 'checked="checked"' : ''), 18 'show_title_CHECKED' => ($module['show_title'] == 'true'), 19 ) 20 ); 21 22 $template->assign('selected_options', array( 23 'on_home' => ($module['on_home'] == 'true'), 24 'on_root' => ($module['on_root'] == 'true'), 25 'on_cats' => ($module['on_cats'] == 'true'), 26 'on_picture' => ($module['on_picture'] == 'true'), 22 27 ) 23 28 ); … … 25 30 $module_path = $module['path']; 26 31 27 include('add_module. php');32 include('add_module.inc.php'); 28 33 29 34 ?> -
extensions/PWG_Stuffs/admin/template/add_module.tpl
r7855 r9383 1 {known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"} 1 2 {include file='include/autosize.inc.tpl'} 2 3 {$TINYMCE_SCRIPT} 3 {html_head}{literal} 4 <style type="text/css"> 5 .groups { margin-top:15px; } 6 .groups input { margin-right:5px; } 7 .groups label { margin-right:10px; display: inline-block; overflow: hidden; white-space: nowrap; line-height:1.3em;} 8 .groups div { float:right; width:74%; line-height:1.3em;} 9 </style> 10 {/literal}{/html_head} 4 11 5 12 <div class="titrePage"> … … 7 14 </div> 8 15 9 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 16 <form method="post" action="" class="properties" ENCTYPE="multipart/form-data"> 17 <fieldset id="mainConf" > 18 <legend>{'stuffs_module_config'|@translate}</legend> 19 <ul> 20 <li> 21 <span class="property"> 22 <label for="module_name">{'stuffs_module_title'|@translate}</label> 23 </span> 24 <textarea rows="2" name="module_name" id="module_name" class="description" style="height:2em; width:500px;">{$MODULE_NAME}</textarea> 25 </li> 26 <li> 27 <span class="property"> 28 <label for="module_desc">{'stuffs_desc'|@translate}<br> </label> 29 </span> 30 <input type="text" maxlength="255" value="{$DESC_VALUE}" name="module_desc" id="module_desc" style="width:500px;"/><br><i>{'stuffs_only_for_admin'|@translate}</i> 31 </li> 32 <li> 33 <span class="property"> 34 <label for="show_title">{'stuffs_show_title'|@translate}</label> 35 </span> 36 <input type="checkbox" name="show_title" id="show_title" value="1" {if $show_title_CHECKED}checked="checked"{/if}> 37 </li> 10 38 11 <fieldset> 12 <legend>{'stuffs_module_config'|@translate}</legend> 13 <table> 14 15 <tr><td colspan="3"><br></td></tr> 16 17 <tr> 18 <td><b>{'stuffs_module_title'|@translate} </b></td> 19 <td colspan="2"><textarea cols="50" rows="2" name="module_name" id="module_name" class="description" style="height: 2em">{$MODULE_NAME}</textarea></td> 20 </tr> 21 22 <tr><td colspan="3"><br></td></tr> 23 24 <tr> 25 <td><b>{'stuffs_desc'|@translate} </b></td> 26 <td colspan="2"><input type="text" size="65" maxlength="255" value="{$DESC_VALUE}" name="module_desc"/></td> 27 </tr> 28 <tr> 29 <td></td> 30 <td colspan="2">{'stuffs_only_for_admin'|@translate}</td> 31 </tr> 32 33 <tr><td colspan="3"><br></td></tr> 34 <tr> 35 <td><b>{'stuffs_authorized_users'|@translate} </b></td> 36 <td colspan="2"> 37 <div id="users"> 38 <input type="checkbox" name="users[]" id="guest" value="guest" {$user_perm.GUEST}><label> {'user_status_guest'|@translate}</label> 39 <input type="checkbox" name="users[]" id="generic" value="generic" {$user_perm.GENERIC}><label> {'user_status_generic'|@translate}</label> 40 <input type="checkbox" name="users[]" id="normal" value="normal" {$user_perm.NORMAL}><label> {'user_status_normal'|@translate}</label> 41 <input type="checkbox" name="users[]" id="admin" value="admin" {$user_perm.ADMIN}><label> {'user_status_admin'|@translate}</label> 42 <input type="checkbox" name="users[]" id="webmaster" value="webmaster" {$user_perm.WEBMASTER}><label> {'user_status_webmaster'|@translate}</label> 43 </div> 44 </td> 45 </tr> 46 47 {if isset($group_perm)} 48 <tr><td colspan="3"><br></td></tr> 49 <tr> 50 <td><b>{'stuffs_authorized_group'|@translate} </b></td> 51 <td colspan="2">{$group_perm.GROUPSELECTION}</td> 52 </tr> 53 <tr> 54 <td></td> 55 <td colspan="2"><i>{'stuffs_public_module'|@translate}</i></td> 56 </tr> 39 {if isset($level_perm)} 40 <li style="margin-top:15px;"> 41 <span class="property"> 42 <label for="level">{'Privacy level'|@translate}</label> 43 </span> 44 <select name="level" id="level" size="1">{html_options options=$level_perm selected=$level_selected id=privacy}</select> 45 </li> 57 46 {/if} 58 47 59 <tr><td colspan="3"><br></td></tr> 60 </table> 48 49 {if isset($users)} 50 <li class="groups" style="margin-top:15px;"> 51 <span class="property"> 52 <label for="users">{'stuffs_authorized_users'|@translate}</label> 53 </span> 54 {html_checkboxes options=$users selected=$selected_users name=users} 55 </li> 56 {/if} 57 58 {if isset($groups)} 59 <li class="groups" style="margin-top:15px;"> 60 <span class="property"> 61 <label for="groups">{'stuffs_authorized_group'|@translate}</label> 62 </span> 63 <div>{html_checkboxes options=$groups selected=$selected_groups name=groups}</div> 64 </li> 65 <li class="groups"> 66 <div> 67 <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', 'checked');return false;">{'stuffs_select_all'|@translate}</a> / 68 <a href="#" onClick="jQuery('input[name^=\'groups\']').attr('checked', '');return false;">{'stuffs_unselect_all'|@translate}</a> 69 <i>{'stuffs_guest'|@translate}</i> 70 </div> 71 </li> 72 {/if} 73 </ul> 61 74 </fieldset> 62 75 63 <fieldset> 64 <legend>{'stuffs_visual_config'|@translate}</legend> 65 <table> 66 <tr><td colspan="2"><br></td></tr> 67 <tr> 68 <td colspan="2"><input type="checkbox" name="show_title" value="1" {$show_title_CHECKED}> {'stuffs_show_title'|@translate}</td> 69 </tr> 70 <tr><td><br></td></tr> 71 <tr> 72 <td>{'stuffs_show_module_on'|@translate}</td> 73 <td> <input type="checkbox" name="on_home" value="1" {$on_home_CHECKED}> <i>{'stuffs_show_on_home'|@translate}</i></td> 74 </tr> 75 <tr><td></td> 76 <td> <input type="checkbox" name="on_cats" value="1" {$on_cats_CHECKED}> <i>{'stuffs_show_on_cats'|@translate}</i></td> 77 </tr> 78 <tr><td></td> 79 <td> <input type="checkbox" name="on_picture" value="1" {$on_picture_CHECKED}> <i>{'stuffs_show_on_pictures'|@translate}</i></td> 80 </tr> 81 <tr><td colspan="2"><br></td></tr> 82 </table> 83 84 76 <fieldset id="indexDisplayConf"> 77 <legend>{'stuffs_show_module_on'|@translate}</legend> 78 <ul> 79 {foreach from=$display_options key=option item=value} 80 {if $value} 81 <li> 82 <label> 83 <span class="property">{'stuffs_show_'|@cat:$option|@translate}</span> 84 <input type="checkbox" name="{$option}" value="1" {if $selected_options[$option]}checked="checked"{/if}> 85 </label> 86 </li> 87 {/if} 88 {/foreach} 89 </ul> 85 90 </fieldset> 86 91 -
extensions/PWG_Stuffs/admin/upgrade.inc.php
r9369 r9383 92 92 $query = 'ALTER TABLE ' . $prefixeTable . 'stuffs 93 93 CHANGE `type` `path` VARCHAR( 255 ) NULL DEFAULT NULL, 94 ADD `parent` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `path` 94 ADD `parent` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `path`, 95 ADD `level` TINYINT( 3 ) NOT NULL default "0" AFTER `groups`, 96 ADD `on_root` enum(\'true\',\'false\') NOT NULL AFTER `on_home` 97 ;'; 98 pwg_query($query); 99 100 $query = 'UPDATE ' . $prefixeTable . 'stuffs 101 SET on_root = "false" 102 WHERE on_cats = "false" 95 103 ;'; 96 104 pwg_query($query); … … 107 115 ;'; 108 116 pwg_query($query); 117 118 $conf['Stuffs'] = array('level_perm' => false); 119 120 $query = 'SELECT id 121 FROM '.$prefixeTable.'stuffs 122 WHERE users <> "guest,generic,normal,admin,webmaster" 123 ;'; 124 $ids = array_from_query($query, 'id'); 125 $conf['Stuffs']['user_perm'] = !empty($ids); 126 127 $query = 'SELECT id 128 FROM '.$prefixeTable.'stuffs 129 WHERE groups IS NOT NULL 130 ;'; 131 $ids = array_from_query($query, 'id'); 132 $conf['Stuffs']['group_perm'] = !empty($ids); 133 134 $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) 135 VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($conf['Stuffs'])).'" , "PWG Stuffs configuration");'; 136 pwg_query($query); 109 137 } 110 138 111 $query = '112 UPDATE ' . PLUGINS_TABLE . '113 SET version=\''.STUFFS_VERSION.'\'114 WHERE id=\'PWG_Stuffs\'';115 pwg_query($query);116 117 139 ?>
Note: See TracChangeset
for help on using the changeset viewer.