[763] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 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 | |
---|
[5933] | 42 | trigger_action('loc_begin_element_set_unit'); |
---|
| 43 | |
---|
[1072] | 44 | // +-----------------------------------------------------------------------+ |
---|
[763] | 45 | // | unit mode form submission | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | |
---|
| 48 | if (isset($_POST['submit'])) |
---|
| 49 | { |
---|
[2249] | 50 | $collection = explode(',', $_POST['element_ids']); |
---|
[1609] | 51 | |
---|
[763] | 52 | $datas = array(); |
---|
[1609] | 53 | |
---|
[763] | 54 | $query = ' |
---|
| 55 | SELECT id, date_creation |
---|
| 56 | FROM '.IMAGES_TABLE.' |
---|
| 57 | WHERE id IN ('.implode(',', $collection).') |
---|
| 58 | ;'; |
---|
| 59 | $result = pwg_query($query); |
---|
| 60 | |
---|
[4325] | 61 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[763] | 62 | { |
---|
| 63 | $data = array(); |
---|
[836] | 64 | |
---|
[5955] | 65 | $data['id'] = $row['id']; |
---|
| 66 | $data['name'] = $_POST['name-'.$row['id']]; |
---|
| 67 | $data['author'] = $_POST['author-'.$row['id']]; |
---|
| 68 | $data['level'] = $_POST['level-'.$row['id']]; |
---|
[836] | 69 | |
---|
[6714] | 70 | foreach (array('name', 'level') as $field) |
---|
[763] | 71 | { |
---|
| 72 | if (!empty($_POST[$field.'-'.$row['id']])) |
---|
| 73 | { |
---|
[5955] | 74 | $data[$field] = strip_tags($_POST[$field.'-'.$row['id']]); |
---|
[763] | 75 | } |
---|
| 76 | } |
---|
[1609] | 77 | |
---|
[836] | 78 | if ($conf['allow_html_descriptions']) |
---|
| 79 | { |
---|
[5955] | 80 | $data['comment'] = @$_POST['description-'.$row['id']]; |
---|
[836] | 81 | } |
---|
| 82 | else |
---|
| 83 | { |
---|
[5955] | 84 | $data['comment'] = strip_tags(@$_POST['description-'.$row['id']]); |
---|
[836] | 85 | } |
---|
[763] | 86 | |
---|
[836] | 87 | if (isset($_POST['date_creation_action-'.$row['id']])) |
---|
[763] | 88 | { |
---|
[836] | 89 | if ('set' == $_POST['date_creation_action-'.$row['id']]) |
---|
| 90 | { |
---|
[5955] | 91 | $data['date_creation'] = |
---|
[836] | 92 | $_POST['date_creation_year-'.$row['id']] |
---|
| 93 | .'-'.$_POST['date_creation_month-'.$row['id']] |
---|
| 94 | .'-'.$_POST['date_creation_day-'.$row['id']]; |
---|
| 95 | } |
---|
| 96 | else if ('unset' == $_POST['date_creation_action-'.$row['id']]) |
---|
| 97 | { |
---|
[5955] | 98 | $data['date_creation'] = ''; |
---|
[836] | 99 | } |
---|
[763] | 100 | } |
---|
[836] | 101 | else |
---|
[763] | 102 | { |
---|
[5955] | 103 | $data['date_creation'] = $row['date_creation']; |
---|
[763] | 104 | } |
---|
[1609] | 105 | |
---|
[1119] | 106 | array_push($datas, $data); |
---|
[763] | 107 | |
---|
[1119] | 108 | // tags management |
---|
| 109 | if (isset($_POST[ 'tags-'.$row['id'] ])) |
---|
[836] | 110 | { |
---|
[5188] | 111 | $tag_ids = get_fckb_tag_ids($_POST[ 'tags-'.$row['id'] ]); |
---|
| 112 | set_tags($tag_ids, $row['id']); |
---|
[836] | 113 | } |
---|
[763] | 114 | } |
---|
[1609] | 115 | |
---|
[836] | 116 | mass_updates( |
---|
| 117 | IMAGES_TABLE, |
---|
| 118 | array( |
---|
| 119 | 'primary' => array('id'), |
---|
[5955] | 120 | 'update' => array('name','author','level','comment','date_creation') |
---|
[836] | 121 | ), |
---|
| 122 | $datas |
---|
| 123 | ); |
---|
[1609] | 124 | |
---|
[836] | 125 | array_push($page['infos'], l10n('Picture informations updated')); |
---|
[763] | 126 | } |
---|
| 127 | |
---|
| 128 | // +-----------------------------------------------------------------------+ |
---|
| 129 | // | template init | |
---|
| 130 | // +-----------------------------------------------------------------------+ |
---|
| 131 | |
---|
| 132 | $template->set_filenames( |
---|
[2530] | 133 | array('element_set_unit' => 'element_set_unit.tpl')); |
---|
[763] | 134 | |
---|
| 135 | $base_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
| 136 | |
---|
[2249] | 137 | $month_list = $lang['month']; |
---|
| 138 | $month_list[0]='------------'; |
---|
| 139 | ksort($month_list); |
---|
[763] | 140 | |
---|
[2249] | 141 | $template->assign( |
---|
[763] | 142 | array( |
---|
[834] | 143 | 'CATEGORIES_NAV'=>$page['title'], |
---|
[763] | 144 | 'U_ELEMENTS_PAGE' |
---|
| 145 | =>$base_url.get_query_string_diff(array('display','start')), |
---|
| 146 | 'U_GLOBAL_MODE' |
---|
[764] | 147 | => |
---|
| 148 | $base_url |
---|
| 149 | .get_query_string_diff(array('mode','display')) |
---|
| 150 | .'&mode=global', |
---|
[5955] | 151 | 'F_ACTION'=>$base_url.get_query_string_diff(array()), |
---|
| 152 | 'month_list' => $month_list, |
---|
[6025] | 153 | 'level_options' => get_privacy_level_options(), |
---|
[763] | 154 | ) |
---|
| 155 | ); |
---|
| 156 | |
---|
| 157 | // +-----------------------------------------------------------------------+ |
---|
| 158 | // | global mode thumbnails | |
---|
| 159 | // +-----------------------------------------------------------------------+ |
---|
| 160 | |
---|
[875] | 161 | // how many items to display on this page |
---|
| 162 | if (!empty($_GET['display'])) |
---|
| 163 | { |
---|
| 164 | if ('all' == $_GET['display']) |
---|
| 165 | { |
---|
| 166 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
| 167 | } |
---|
| 168 | else |
---|
| 169 | { |
---|
| 170 | $page['nb_images'] = intval($_GET['display']); |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | $page['nb_images'] = 5; |
---|
| 176 | } |
---|
[763] | 177 | |
---|
[764] | 178 | |
---|
[875] | 179 | |
---|
[764] | 180 | if (count($page['cat_elements_id']) > 0) |
---|
| 181 | { |
---|
| 182 | $nav_bar = create_navigation_bar( |
---|
| 183 | $base_url.get_query_string_diff(array('start')), |
---|
| 184 | count($page['cat_elements_id']), |
---|
| 185 | $page['start'], |
---|
[1084] | 186 | $page['nb_images'] |
---|
| 187 | ); |
---|
[3172] | 188 | $template->assign(array('navbar' => $nav_bar)); |
---|
[764] | 189 | |
---|
[1119] | 190 | // tags |
---|
| 191 | $all_tags = get_all_tags(); |
---|
[1609] | 192 | |
---|
[764] | 193 | $element_ids = array(); |
---|
| 194 | |
---|
| 195 | $query = ' |
---|
[5955] | 196 | SELECT id,path,tn_ext,name,date_creation,comment,author,level,file |
---|
[764] | 197 | FROM '.IMAGES_TABLE.' |
---|
| 198 | WHERE id IN ('.implode(',', $page['cat_elements_id']).') |
---|
[763] | 199 | '.$conf['order_by'].' |
---|
[4334] | 200 | LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].' |
---|
[763] | 201 | ;'; |
---|
[764] | 202 | $result = pwg_query($query); |
---|
[763] | 203 | |
---|
[4325] | 204 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[763] | 205 | { |
---|
[764] | 206 | array_push($element_ids, $row['id']); |
---|
[1119] | 207 | |
---|
[1609] | 208 | $src = get_thumbnail_url($row); |
---|
| 209 | |
---|
[764] | 210 | // creation date |
---|
| 211 | if (!empty($row['date_creation'])) |
---|
| 212 | { |
---|
| 213 | list($year,$month,$day) = explode('-', $row['date_creation']); |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | { |
---|
[2249] | 217 | list($year,$month,$day) = array('',0,0); |
---|
[764] | 218 | } |
---|
[1314] | 219 | |
---|
[5188] | 220 | $query = ' |
---|
| 221 | SELECT |
---|
| 222 | tag_id, |
---|
| 223 | name AS tag_name |
---|
| 224 | FROM '.IMAGE_TAG_TABLE.' AS it |
---|
| 225 | JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id |
---|
| 226 | WHERE image_id = '.$row['id'].' |
---|
| 227 | ;'; |
---|
| 228 | $tag_selection = get_fckb_taglist($query); |
---|
[1609] | 229 | |
---|
[2249] | 230 | $template->append( |
---|
| 231 | 'elements', |
---|
[764] | 232 | array( |
---|
[2249] | 233 | 'ID' => $row['id'], |
---|
| 234 | 'TN_SRC' => $src, |
---|
[5955] | 235 | 'LEGEND' => !empty($row['name']) ? |
---|
[836] | 236 | $row['name'] : get_name_from_file($row['file']), |
---|
| 237 | 'U_EDIT' => |
---|
| 238 | PHPWG_ROOT_PATH.'admin.php?page=picture_modify'. |
---|
[1004] | 239 | '&image_id='.$row['id'], |
---|
[5955] | 240 | 'NAME' => !empty($row['name'])?$row['name']:'', |
---|
[6714] | 241 | 'AUTHOR' => !empty($row['author'])?htmlspecialchars($row['author']):'', |
---|
[6025] | 242 | 'LEVEL' => !empty($row['level'])?$row['level']:'0', |
---|
[5955] | 243 | 'DESCRIPTION' => !empty($row['comment'])?$row['comment']:'', |
---|
[764] | 244 | 'DATE_CREATION_YEAR' => $year, |
---|
[2249] | 245 | 'DATE_CREATION_MONTH' => (int)$month, |
---|
| 246 | 'DATE_CREATION_DAY' => (int)$day, |
---|
[5188] | 247 | 'TAGS' => $tag_selection, |
---|
[764] | 248 | ) |
---|
| 249 | ); |
---|
[763] | 250 | } |
---|
| 251 | |
---|
[2249] | 252 | $template->assign('ELEMENT_IDS', implode(',', $element_ids)); |
---|
[763] | 253 | } |
---|
| 254 | |
---|
[5933] | 255 | trigger_action('loc_end_element_set_unit'); |
---|
| 256 | |
---|
[763] | 257 | // +-----------------------------------------------------------------------+ |
---|
| 258 | // | sending html code | |
---|
| 259 | // +-----------------------------------------------------------------------+ |
---|
| 260 | |
---|
| 261 | $template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_unit'); |
---|
| 262 | ?> |
---|