1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
25 | { |
---|
26 | die ("Hacking attempt!"); |
---|
27 | } |
---|
28 | |
---|
29 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
30 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
31 | |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | Check Access and exit when user status is not ok | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | |
---|
36 | check_status(ACCESS_ADMINISTRATOR); |
---|
37 | |
---|
38 | // +-----------------------------------------------------------------------+ |
---|
39 | // | variable initialization | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | |
---|
42 | $page['cat'] = $category['id']; |
---|
43 | |
---|
44 | // +-----------------------------------------------------------------------+ |
---|
45 | // | form submission | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | |
---|
48 | // info by email to an access granted group of category informations |
---|
49 | if (isset($_POST['submitEmail']) and !empty($_POST['group'])) |
---|
50 | { |
---|
51 | set_make_full_url(); |
---|
52 | |
---|
53 | /* TODO: if $category['representative_picture_id'] |
---|
54 | is empty find child representative_picture_id */ |
---|
55 | if (!empty($category['representative_picture_id'])) |
---|
56 | { |
---|
57 | $query = ' |
---|
58 | SELECT id, file, path, representative_ext |
---|
59 | FROM '.IMAGES_TABLE.' |
---|
60 | WHERE id = '.$category['representative_picture_id'].' |
---|
61 | ;'; |
---|
62 | |
---|
63 | $result = pwg_query($query); |
---|
64 | if (pwg_db_num_rows($result) > 0) |
---|
65 | { |
---|
66 | $element = pwg_db_fetch_assoc($result); |
---|
67 | |
---|
68 | $img_url = '<a href="'. |
---|
69 | make_picture_url(array( |
---|
70 | 'image_id' => $element['id'], |
---|
71 | 'image_file' => $element['file'], |
---|
72 | 'category' => $category |
---|
73 | )) |
---|
74 | .'" class="thumblnk"><img src="'.DerivativeImage::url(IMG_THUMB, $element).'"></a>'; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | if (!isset($img_url)) |
---|
79 | { |
---|
80 | $img_url = ''; |
---|
81 | } |
---|
82 | |
---|
83 | pwg_mail_group( |
---|
84 | $_POST['group'], |
---|
85 | array( |
---|
86 | 'subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], $category['name']), |
---|
87 | // TODO : change this language variable to 'Visit album %s' |
---|
88 | // TODO : 'language_selected' => .... |
---|
89 | ), |
---|
90 | array( |
---|
91 | 'filename' => 'cat_group_info', |
---|
92 | 'assign' => array( |
---|
93 | 'IMG_URL' => $img_url, |
---|
94 | 'CAT_NAME' => $category['name'], |
---|
95 | 'LINK' => make_index_url(array( |
---|
96 | 'category' => array( |
---|
97 | 'id' => $category['id'], |
---|
98 | 'name' => $category['name'], |
---|
99 | 'permalink' => $category['permalink'] |
---|
100 | ) |
---|
101 | )), |
---|
102 | 'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']), |
---|
103 | ) |
---|
104 | ) |
---|
105 | ); |
---|
106 | |
---|
107 | unset_make_full_url(); |
---|
108 | |
---|
109 | $query = ' |
---|
110 | SELECT |
---|
111 | name |
---|
112 | FROM '.GROUPS_TABLE.' |
---|
113 | WHERE id = '.$_POST['group'].' |
---|
114 | ;'; |
---|
115 | list($group_name) = pwg_db_fetch_row(pwg_query($query)); |
---|
116 | |
---|
117 | $page['infos'][] = l10n('An information email was sent to group "%s"', $group_name); |
---|
118 | } |
---|
119 | |
---|
120 | // +-----------------------------------------------------------------------+ |
---|
121 | // | template initialization | |
---|
122 | // +-----------------------------------------------------------------------+ |
---|
123 | |
---|
124 | $template->set_filename('album_notification', 'album_notification.tpl'); |
---|
125 | |
---|
126 | $template->assign( |
---|
127 | array( |
---|
128 | 'CATEGORIES_NAV' => |
---|
129 | get_cat_display_name_from_id( |
---|
130 | $page['cat'], |
---|
131 | 'admin.php?page=album-' |
---|
132 | ), |
---|
133 | 'F_ACTION' => $admin_album_base_url.'-notification', |
---|
134 | 'PWG_TOKEN' => get_pwg_token(), |
---|
135 | ) |
---|
136 | ); |
---|
137 | |
---|
138 | // +-----------------------------------------------------------------------+ |
---|
139 | // | form construction | |
---|
140 | // +-----------------------------------------------------------------------+ |
---|
141 | |
---|
142 | $query = ' |
---|
143 | SELECT |
---|
144 | id AS group_id |
---|
145 | FROM '.GROUPS_TABLE.' |
---|
146 | ;'; |
---|
147 | $all_group_ids = array_from_query($query, 'group_id'); |
---|
148 | |
---|
149 | if (count($all_group_ids) == 0) |
---|
150 | { |
---|
151 | $template->assign('no_group_in_gallery', true); |
---|
152 | } |
---|
153 | else |
---|
154 | { |
---|
155 | if ('private' == $category['status']) |
---|
156 | { |
---|
157 | $query = ' |
---|
158 | SELECT |
---|
159 | group_id |
---|
160 | FROM '.GROUP_ACCESS_TABLE.' |
---|
161 | WHERE cat_id = '.$category['id'].' |
---|
162 | ;'; |
---|
163 | $group_ids = array_from_query($query, 'group_id'); |
---|
164 | |
---|
165 | if (count($group_ids) == 0) |
---|
166 | { |
---|
167 | $template->assign('permission_url', $admin_album_base_url.'-permissions'); |
---|
168 | } |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | $group_ids = $all_group_ids; |
---|
173 | } |
---|
174 | |
---|
175 | if (count($group_ids) > 0) |
---|
176 | { |
---|
177 | $query = ' |
---|
178 | SELECT |
---|
179 | id, |
---|
180 | name |
---|
181 | FROM '.GROUPS_TABLE.' |
---|
182 | WHERE id IN ('.implode(',', $group_ids).') |
---|
183 | ORDER BY name ASC |
---|
184 | ;'; |
---|
185 | $template->assign( |
---|
186 | 'group_mail_options', |
---|
187 | simple_hash_from_query($query, 'id', 'name') |
---|
188 | ); |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | // +-----------------------------------------------------------------------+ |
---|
193 | // | sending html code | |
---|
194 | // +-----------------------------------------------------------------------+ |
---|
195 | |
---|
196 | $template->assign_var_from_handle('ADMIN_CONTENT', 'album_notification'); |
---|
197 | ?> |
---|