[763] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[3049] | 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[763] | 23 | |
---|
| 24 | /** |
---|
| 25 | * Management of elements set. Elements can belong to a category or to the |
---|
| 26 | * user caddie. |
---|
[1609] | 27 | * |
---|
[763] | 28 | */ |
---|
[1609] | 29 | |
---|
[763] | 30 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 31 | { |
---|
| 32 | die('Hacking attempt!'); |
---|
| 33 | } |
---|
| 34 | |
---|
[1072] | 35 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 36 | |
---|
[763] | 37 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 38 | // | Check Access and exit when user status is not ok | |
---|
| 39 | // +-----------------------------------------------------------------------+ |
---|
| 40 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 41 | |
---|
| 42 | // +-----------------------------------------------------------------------+ |
---|
[763] | 43 | // | unit mode form submission | |
---|
| 44 | // +-----------------------------------------------------------------------+ |
---|
| 45 | |
---|
| 46 | if (isset($_POST['submit'])) |
---|
| 47 | { |
---|
[2249] | 48 | $collection = explode(',', $_POST['element_ids']); |
---|
[1609] | 49 | |
---|
[763] | 50 | $datas = array(); |
---|
[1609] | 51 | |
---|
[763] | 52 | $query = ' |
---|
| 53 | SELECT id, date_creation |
---|
| 54 | FROM '.IMAGES_TABLE.' |
---|
| 55 | WHERE id IN ('.implode(',', $collection).') |
---|
| 56 | ;'; |
---|
| 57 | $result = pwg_query($query); |
---|
| 58 | |
---|
| 59 | while ($row = mysql_fetch_array($result)) |
---|
| 60 | { |
---|
| 61 | $data = array(); |
---|
[836] | 62 | |
---|
| 63 | $data{'id'} = $row['id']; |
---|
| 64 | $data{'name'} = $_POST['name-'.$row['id']]; |
---|
| 65 | $data{'author'} = $_POST['author-'.$row['id']]; |
---|
| 66 | |
---|
| 67 | foreach (array('name', 'author') as $field) |
---|
[763] | 68 | { |
---|
| 69 | if (!empty($_POST[$field.'-'.$row['id']])) |
---|
| 70 | { |
---|
[836] | 71 | $data{$field} = strip_tags($_POST[$field.'-'.$row['id']]); |
---|
[763] | 72 | } |
---|
| 73 | } |
---|
[1609] | 74 | |
---|
[836] | 75 | if ($conf['allow_html_descriptions']) |
---|
| 76 | { |
---|
| 77 | $data{'comment'} = @$_POST['description-'.$row['id']]; |
---|
| 78 | } |
---|
| 79 | else |
---|
| 80 | { |
---|
| 81 | $data{'comment'} = strip_tags(@$_POST['description-'.$row['id']]); |
---|
| 82 | } |
---|
[763] | 83 | |
---|
[836] | 84 | if (isset($_POST['date_creation_action-'.$row['id']])) |
---|
[763] | 85 | { |
---|
[836] | 86 | if ('set' == $_POST['date_creation_action-'.$row['id']]) |
---|
| 87 | { |
---|
| 88 | $data{'date_creation'} = |
---|
| 89 | $_POST['date_creation_year-'.$row['id']] |
---|
| 90 | .'-'.$_POST['date_creation_month-'.$row['id']] |
---|
| 91 | .'-'.$_POST['date_creation_day-'.$row['id']]; |
---|
| 92 | } |
---|
| 93 | else if ('unset' == $_POST['date_creation_action-'.$row['id']]) |
---|
| 94 | { |
---|
| 95 | $data{'date_creation'} = ''; |
---|
| 96 | } |
---|
[763] | 97 | } |
---|
[836] | 98 | else |
---|
[763] | 99 | { |
---|
[836] | 100 | $data{'date_creation'} = $row['date_creation']; |
---|
[763] | 101 | } |
---|
[1609] | 102 | |
---|
[1119] | 103 | array_push($datas, $data); |
---|
[763] | 104 | |
---|
[1119] | 105 | // tags management |
---|
| 106 | if (isset($_POST[ 'tags-'.$row['id'] ])) |
---|
[836] | 107 | { |
---|
[1119] | 108 | set_tags($_POST[ 'tags-'.$row['id'] ], $row['id']); |
---|
[836] | 109 | } |
---|
[763] | 110 | } |
---|
[1609] | 111 | |
---|
[836] | 112 | mass_updates( |
---|
| 113 | IMAGES_TABLE, |
---|
| 114 | array( |
---|
| 115 | 'primary' => array('id'), |
---|
[1119] | 116 | 'update' => array('name','author','comment','date_creation') |
---|
[836] | 117 | ), |
---|
| 118 | $datas |
---|
| 119 | ); |
---|
[1609] | 120 | |
---|
[836] | 121 | array_push($page['infos'], l10n('Picture informations updated')); |
---|
[763] | 122 | } |
---|
| 123 | |
---|
| 124 | // +-----------------------------------------------------------------------+ |
---|
| 125 | // | template init | |
---|
| 126 | // +-----------------------------------------------------------------------+ |
---|
| 127 | |
---|
| 128 | $template->set_filenames( |
---|
[2530] | 129 | array('element_set_unit' => 'element_set_unit.tpl')); |
---|
[763] | 130 | |
---|
| 131 | $base_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
| 132 | |
---|
[2249] | 133 | $month_list = $lang['month']; |
---|
| 134 | $month_list[0]='------------'; |
---|
| 135 | ksort($month_list); |
---|
[763] | 136 | |
---|
[2249] | 137 | $template->assign( |
---|
[763] | 138 | array( |
---|
[834] | 139 | 'CATEGORIES_NAV'=>$page['title'], |
---|
[764] | 140 | |
---|
[763] | 141 | 'U_ELEMENTS_PAGE' |
---|
| 142 | =>$base_url.get_query_string_diff(array('display','start')), |
---|
[1609] | 143 | |
---|
[763] | 144 | 'U_GLOBAL_MODE' |
---|
[764] | 145 | => |
---|
| 146 | $base_url |
---|
| 147 | .get_query_string_diff(array('mode','display')) |
---|
| 148 | .'&mode=global', |
---|
[1609] | 149 | |
---|
[763] | 150 | 'F_ACTION'=>$base_url.get_query_string_diff(array()), |
---|
[2249] | 151 | |
---|
| 152 | 'month_list' => $month_list |
---|
[763] | 153 | ) |
---|
| 154 | ); |
---|
| 155 | |
---|
| 156 | // +-----------------------------------------------------------------------+ |
---|
| 157 | // | global mode thumbnails | |
---|
| 158 | // +-----------------------------------------------------------------------+ |
---|
| 159 | |
---|
[875] | 160 | // how many items to display on this page |
---|
| 161 | if (!empty($_GET['display'])) |
---|
| 162 | { |
---|
| 163 | if ('all' == $_GET['display']) |
---|
| 164 | { |
---|
| 165 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
| 166 | } |
---|
| 167 | else |
---|
| 168 | { |
---|
| 169 | $page['nb_images'] = intval($_GET['display']); |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | else |
---|
| 173 | { |
---|
| 174 | $page['nb_images'] = 5; |
---|
| 175 | } |
---|
[763] | 176 | |
---|
[764] | 177 | |
---|
[875] | 178 | |
---|
[764] | 179 | if (count($page['cat_elements_id']) > 0) |
---|
| 180 | { |
---|
| 181 | $nav_bar = create_navigation_bar( |
---|
| 182 | $base_url.get_query_string_diff(array('start')), |
---|
| 183 | count($page['cat_elements_id']), |
---|
| 184 | $page['start'], |
---|
[1084] | 185 | $page['nb_images'] |
---|
| 186 | ); |
---|
[3172] | 187 | $template->assign(array('navbar' => $nav_bar)); |
---|
[764] | 188 | |
---|
[1119] | 189 | // tags |
---|
| 190 | $all_tags = get_all_tags(); |
---|
[1609] | 191 | |
---|
[764] | 192 | $element_ids = array(); |
---|
| 193 | |
---|
| 194 | $query = ' |
---|
[1119] | 195 | SELECT id,path,tn_ext,name,date_creation,comment,author,file |
---|
[764] | 196 | FROM '.IMAGES_TABLE.' |
---|
| 197 | WHERE id IN ('.implode(',', $page['cat_elements_id']).') |
---|
[763] | 198 | '.$conf['order_by'].' |
---|
| 199 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
| 200 | ;'; |
---|
[764] | 201 | $result = pwg_query($query); |
---|
[763] | 202 | |
---|
[1609] | 203 | while ($row = mysql_fetch_assoc($result)) |
---|
[763] | 204 | { |
---|
[764] | 205 | // echo '<pre>'; print_r($row); echo '</pre>'; |
---|
| 206 | array_push($element_ids, $row['id']); |
---|
[1119] | 207 | |
---|
[1609] | 208 | $src = get_thumbnail_url($row); |
---|
| 209 | |
---|
[1119] | 210 | $query = ' |
---|
| 211 | SELECT tag_id |
---|
| 212 | FROM '.IMAGE_TAG_TABLE.' |
---|
| 213 | WHERE image_id = '.$row['id'].' |
---|
| 214 | ;'; |
---|
| 215 | $selected_tags = array_from_query($query, 'tag_id'); |
---|
[1609] | 216 | |
---|
[764] | 217 | // creation date |
---|
| 218 | if (!empty($row['date_creation'])) |
---|
| 219 | { |
---|
| 220 | list($year,$month,$day) = explode('-', $row['date_creation']); |
---|
| 221 | } |
---|
| 222 | else |
---|
| 223 | { |
---|
[2249] | 224 | list($year,$month,$day) = array('',0,0); |
---|
[764] | 225 | } |
---|
[1314] | 226 | |
---|
| 227 | if (count($all_tags) > 0) |
---|
| 228 | { |
---|
| 229 | $tag_selection = get_html_tag_selection( |
---|
| 230 | $all_tags, |
---|
| 231 | 'tags-'.$row['id'], |
---|
| 232 | $selected_tags |
---|
| 233 | ); |
---|
| 234 | } |
---|
| 235 | else |
---|
| 236 | { |
---|
| 237 | $tag_selection = |
---|
| 238 | '<p>'. |
---|
| 239 | l10n('No tag defined. Use Administration>Pictures>Tags'). |
---|
| 240 | '</p>'; |
---|
| 241 | } |
---|
[1609] | 242 | |
---|
[2249] | 243 | $template->append( |
---|
| 244 | 'elements', |
---|
[764] | 245 | array( |
---|
[2249] | 246 | 'ID' => $row['id'], |
---|
| 247 | 'TN_SRC' => $src, |
---|
[836] | 248 | 'LEGEND' => |
---|
| 249 | !empty($row['name']) ? |
---|
| 250 | $row['name'] : get_name_from_file($row['file']), |
---|
| 251 | 'U_EDIT' => |
---|
| 252 | PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. |
---|
[1004] | 253 | '&image_id='.$row['id'], |
---|
[764] | 254 | 'NAME' => @$row['name'], |
---|
| 255 | 'AUTHOR' => @$row['author'], |
---|
[836] | 256 | 'DESCRIPTION' => @$row['comment'], |
---|
[764] | 257 | 'DATE_CREATION_YEAR' => $year, |
---|
[2249] | 258 | 'DATE_CREATION_MONTH' => (int)$month, |
---|
| 259 | 'DATE_CREATION_DAY' => (int)$day, |
---|
[1609] | 260 | |
---|
[1314] | 261 | 'TAG_SELECTION' => $tag_selection, |
---|
[764] | 262 | ) |
---|
| 263 | ); |
---|
[763] | 264 | } |
---|
| 265 | |
---|
[2249] | 266 | $template->assign('ELEMENT_IDS', implode(',', $element_ids)); |
---|
[763] | 267 | } |
---|
| 268 | |
---|
| 269 | // +-----------------------------------------------------------------------+ |
---|
| 270 | // | sending html code | |
---|
| 271 | // +-----------------------------------------------------------------------+ |
---|
| 272 | |
---|
| 273 | $template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit'); |
---|
| 274 | ?> |
---|