Changeset 25845
- Timestamp:
- Dec 8, 2013, 2:53:40 PM (10 years ago)
- Location:
- extensions/AdminTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AdminTools/include/events.inc.php
r25818 r25845 8 8 function admintools_add_public_controller() 9 9 { 10 global $MultiView, $conf, $template, $page, $user; 11 12 if (!$MultiView->is_admin()) 10 global $MultiView, $conf, $template, $page, $user, $picture; 11 12 $url_root = get_root_url(); 13 $tpl_vars = array(); 14 15 if ($MultiView->is_admin()) 16 { // full options for admin 17 $tpl_vars['U_SITE_ADMIN'] = $url_root . 'admin.php?page='; 18 $tpl_vars['MULTIVIEW'] = $MultiView->get_data(); 19 $tpl_vars['USER'] = $MultiView->get_user(); 20 $tpl_vars['CURRENT_USERNAME'] = $user['id']==$conf['guest_id'] ? l10n('guest') : $user['username']; 21 $tpl_vars['DELETE_CACHE'] = isset($conf['multiview_invalidate_cache']); 22 23 include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'); 24 switch_lang_to(get_default_language()); 25 } 26 else if (script_basename() == 'picture' and $picture['current']['added_by'] == $user['id']) 27 { // only "edit" button for photo owner 28 } 29 else 13 30 { 14 31 return; 15 32 } 16 33 17 $url_root = get_root_url(); 18 19 $tpl_vars = array( 20 'U_SITE_ADMIN' => $url_root . 'admin.php?page=', 21 'MULTIVIEW' => $MultiView->get_data(), 22 'U_SELF' => $MultiView->get_clean_url(true), 23 'USER' => $MultiView->get_user(), 24 'CURRENT_USERNAME' => $user['id']==$conf['guest_id'] ? l10n('guest') : $user['username'], 25 'PWG_TOKEN' => get_pwg_token(), 26 'DELETE_CACHE' => isset($conf['multiview_invalidate_cache']), 27 ); 28 29 // switch_lang is in mail functions file 30 include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'); 31 32 switch_lang_to(get_default_language()); 33 34 // TODO : param to allow owner modification 34 $tpl_vars['U_SELF'] = $MultiView->get_clean_url(true); 35 36 // photo page 35 37 if (script_basename() == 'picture') 36 38 { 37 global $picture;38 39 include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');40 41 39 $url_self = duplicate_picture_url(); 42 43 40 $tpl_vars['IS_PICTURE'] = true; 44 41 45 $template->clear_assign(array( 46 'U_SET_AS_REPRESENTATIVE', 47 'U_PHOTO_ADMIN', 48 'U_CADDIE', 49 )); 50 51 $template->set_prefilter('picture', 'admintools_remove_privacy'); 52 53 $query = ' 42 // admin can add to caddie and set representattive 43 if ($MultiView->is_admin()) 44 { 45 $template->clear_assign(array( 46 'U_SET_AS_REPRESENTATIVE', 47 'U_PHOTO_ADMIN', 48 'U_CADDIE', 49 )); 50 51 $template->set_prefilter('picture', 'admintools_remove_privacy'); 52 53 $tpl_vars['U_CADDIE'] = add_url_params( 54 $url_self, 55 array('action'=>'add_to_caddie') 56 ); 57 58 $query = ' 54 59 SELECT element_id FROM ' . CADDIE_TABLE . ' 55 60 WHERE element_id = ' . $page['image_id'] .' 56 61 ;'; 57 $tpl_vars['IS_IN_CADDIE'] = pwg_db_num_rows(pwg_query($query)) > 0;58 59 if (isset($page['category']))60 {61 $tpl_vars['CATEGORY_ID'] = $page['category']['id'];62 63 $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params(64 $url_self,65 array('action'=>'set_as_representative')66 );67 68 $query = '62 $tpl_vars['IS_IN_CADDIE'] = pwg_db_num_rows(pwg_query($query)) > 0; 63 64 if (isset($page['category'])) 65 { 66 $tpl_vars['CATEGORY_ID'] = $page['category']['id']; 67 68 $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params( 69 $url_self, 70 array('action'=>'set_as_representative') 71 ); 72 73 $query = ' 69 74 SELECT id FROM ' . CATEGORIES_TABLE.' 70 75 WHERE id = ' . $page['category']['id'] .' 71 76 AND representative_picture_id = ' . $page['image_id'] .' 72 77 ;'; 73 $tpl_vars['IS_REPRESENTATIVE'] = pwg_db_num_rows(pwg_query($query)) > 0; 74 } 75 76 $tpl_vars['U_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id'] 77 .(isset($page['category']) ? '&cat_id=' . $page['category']['id'] : ''); 78 79 $tpl_vars['U_CADDIE'] = add_url_params( 80 $url_self, 81 array('action'=>'add_to_caddie') 78 $tpl_vars['IS_REPRESENTATIVE'] = pwg_db_num_rows(pwg_query($query)) > 0; 79 } 80 81 $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id'] 82 .(isset($page['category']) ? '&cat_id=' . $page['category']['id'] : ''); 83 } 84 85 $tpl_vars['U_DELETE'] = add_url_params( 86 $url_self, array( 87 'delete'=>'', 88 'pwg_token'=>get_pwg_token() 89 ) 82 90 ); 83 91 84 92 // gets tags (full available list is loaded in ajax) 93 include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php'); 94 85 95 $query = ' 86 96 SELECT id, name … … 102 112 ); 103 113 } 104 else if (@$page['section'] == 'categories' and isset($page['category'])) 114 // album page (admin only) 115 else if ($MultiView->is_admin() and @$page['section'] == 'categories' and isset($page['category'])) 105 116 { 106 117 $url_self = duplicate_index_url(); … … 114 125 )); 115 126 116 $tpl_vars['U_ EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id'];127 $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id']; 117 128 118 129 if (!empty($page['items'])) … … 151 162 $template->parse('ato_public_controller'); 152 163 153 switch_lang_back(); 164 if ($MultiView->is_admin()) 165 { 166 switch_lang_back(); 167 } 154 168 } 155 169 … … 170 184 function admintools_save_picture() 171 185 { 172 global $page, $conf, $MultiView; 173 174 if (!$MultiView->is_admin()) 186 global $page, $conf, $MultiView, $user, $picture; 187 188 $query = 'SELECT added_by FROM '. IMAGES_TABLE .' WHERE id = '. $page['image_id'] .';'; 189 list($added_by) = pwg_db_fetch_row(pwg_query($query)); 190 191 if (!$MultiView->is_admin() && $user['id'] != $added_by) 175 192 { 176 193 return; … … 205 222 'name' => $_POST['name'], 206 223 'author' => $_POST['author'], 207 'level' => $_POST['level'], 208 ); 224 ); 225 226 if ($MultiView->is_admin()) 227 { 228 $data['level'] = $_POST['level']; 229 } 209 230 210 231 if ($conf['allow_html_descriptions']) … … 249 270 return; 250 271 } 251 272 252 273 if (@$_POST['action'] == 'quick_edit') 253 274 { … … 270 291 array('id' => $page['category']['id']) 271 292 ); 272 293 273 294 redirect(duplicate_index_url()); 274 295 } -
extensions/AdminTools/main.inc.php
r25818 r25845 39 39 add_event_handler('register_user', array('MultiView', 'invalidate_cache')); 40 40 41 if (!defined('IN_ADMIN')) 42 { 43 add_event_handler('loc_after_page_header', 'admintools_add_public_controller'); 44 add_event_handler('loc_begin_picture', 'admintools_save_picture'); 45 add_event_handler('loc_begin_index', 'admintools_save_category'); 46 } 47 41 48 42 49 // +-----------------------------------------------------------------------+ … … 46 53 { 47 54 global $MultiView; 48 49 if (!defined('IN_ADMIN') && $MultiView->is_admin()) 50 { 51 add_event_handler('loc_after_page_header', 'admintools_add_public_controller'); 52 add_event_handler('loc_begin_picture', 'admintools_save_picture'); 53 add_event_handler('loc_begin_index', 'admintools_save_category'); 54 } 55 55 56 56 load_language('plugin.lang', ADMINTOOLS_PATH); 57 57 … … 61 61 // $maintain = new AdminTools_maintain(ADMINTOOLS_ID); 62 62 // $maintain->autoUpdate(ADMINTOOLS_VERSION, 'install'); 63 63 64 64 // $conf['AdminTools'] = unserialize($conf['AdminTools']); 65 65 } -
extensions/AdminTools/template/public_controller.tpl
r25839 r25845 33 33 {footer_script require='admintools.controller'} 34 34 AdminTools.urlWS = '{$ROOT_URL}ws.php?format=json&method='; 35 36 {if isset($ato.MULTIVIEW)} 35 37 AdminTools.multiView = { 36 38 view_as: {$ato.MULTIVIEW.view_as}, … … 38 40 lang: '{$ato.MULTIVIEW.lang}' 39 41 }; 42 {/if} 40 43 41 44 {if $ato.DELETE_CACHE} … … 67 70 <ul> 68 71 <li><a href="#" class="icon-ato-cancel close-panel"></a></li> 72 {if isset($ato.U_SITE_ADMIN)} 69 73 <li class="parent"><a href="#" class="icon-menu ato-hide-1">{'Administration'|translate}</a> 70 74 <ul> … … 77 81 </ul> 78 82 </li> 79 {if isset($ato.U_EDIT)} 83 {/if} 84 {if isset($ato.U_ADMIN_EDIT)} 80 85 <li class="parent"><a href="#" class="icon-pencil ato-hide-2">{'Edit'|translate}</a> 81 86 <ul> 82 87 <li><a href="#ato_quick_edit" class="icon-ato-flash edit-quick">{'Quick edit'|translate}</a></li> 83 <li><a class="icon-ato-doc-text-inv" href="{$ato.U_ EDIT}">{'Properties page'|translate}</a></li>84 {if isset($ato. IS_PICTURE)}85 <li style="margin-top:1em;"><a class="icon-ato-cancel" href="{$ato.U_ SELF}delete&pwg_token={$ato.PWG_TOKEN}" onclick="return confirm('{'Are you sure?'|translate|escape:javascript}')">{'delete photo'|translate|ucfirst}</a></li>88 <li><a class="icon-ato-doc-text-inv" href="{$ato.U_ADMIN_EDIT}">{'Properties page'|translate}</a></li> 89 {if isset($ato.U_DELETE)} 90 <li style="margin-top:1em;"><a class="icon-ato-cancel" href="{$ato.U_DELETE}" onclick="return confirm('{'Are you sure?'|translate|escape:javascript}')">{'delete photo'|translate|ucfirst}</a></li> 86 91 {/if} 87 92 </ul> 88 93 </li> 94 {else if isset($ato.QUICK_EDIT)} 95 <li><a href="#ato_quick_edit" class="icon-pencil edit-quick ato-hide-2">{'Edit'|translate}</a></li> 96 {if isset($ato.U_DELETE)} 97 <li><a class="icon-ato-cancel ato-hide-2" href="{$ato.U_DELETE}" onclick="return confirm('{'Are you sure?'|translate|escape:javascript}')">{'delete photo'|translate|ucfirst}</a></li> 98 {/if} 89 99 {/if} 90 100 {if isset($ato.U_SET_REPRESENTATIVE)} … … 99 109 <li class="saved"><span class="icon-ato-ok ato-hide-1">{'Saved'|translate}</span></li> 100 110 111 {if isset($ato.MULTIVIEW)} 101 112 <li class="parent right multiview"><a class="icon-cog-alt ato-hide-1" href="#">{'Tools'|translate}</a> 102 113 <ul> … … 118 129 </ul> 119 130 </li> 120 {if $ato.USER.id != $ato.MULTIVIEW.view_as}131 {if $ato.USER.id != $ato.MULTIVIEW.view_as} 121 132 <li class="right"> 122 133 {'Viewing as <b>%s</b>.'|translate:$ato.CURRENT_USERNAME} 123 134 <a href="{$ato.U_SELF}ato_view_as={$ato.USER.id}">{'Revert'|translate}</a> 124 135 </li> 136 {/if} 125 137 {/if} 126 138 </ul> … … 156 168 </select> 157 169 170 {if isset($available_permission_levels)} 158 171 <label for="quick_edit_level">{'Who can see this photo?'|@translate}</label> 159 172 <select name="level" size="1"> 160 173 {html_options options=$available_permission_levels selected=$ato.QUICK_EDIT.level} 161 174 </select> 175 {/if} 162 176 {/if} 163 177
Note: See TracChangeset
for help on using the changeset viewer.