source: trunk/admin/album_notification.php @ 22950

Last change on this file since 22950 was 19703, checked in by plg, 12 years ago

update Piwigo headers to 2013 (the end of the world didn't occur as expected on r12922)

File size: 6.6 KB
Line 
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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
30include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
31
32// +-----------------------------------------------------------------------+
33// | Check Access and exit when user status is not ok                      |
34// +-----------------------------------------------------------------------+
35
36check_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
49if (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 = '
58SELECT 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  // TODO Mettre un array pour traduction subjet
84  pwg_mail_group(
85    $_POST['group'],
86    get_str_email_format(true), /* TODO add a checkbox in order to choose format*/
87    get_l10n_args('[%s] Visit album %s',
88      array($conf['gallery_title'], $category['name'])),
89    'cat_group_info',
90    array
91    (
92      'IMG_URL' => $img_url,
93      'CAT_NAME' => $category['name'],
94      'LINK' => make_index_url(
95          array(
96            'category' => array(
97              'id' => $category['id'],
98              'name' => $category['name'],
99              'permalink' => $category['permalink']
100              ))),
101      'CPL_CONTENT' => empty($_POST['mail_content'])
102                          ? '' : stripslashes($_POST['mail_content'])
103    ),
104    '' /* TODO Add listbox in order to choose Language selected */);
105
106  unset_make_full_url();
107
108  $query = '
109SELECT
110    name
111  FROM '.GROUPS_TABLE.'
112  WHERE id = '.$_POST['group'].'
113;';
114  list($group_name) = pwg_db_fetch_row(pwg_query($query));
115
116  array_push(
117    $page['infos'],
118    sprintf(
119      l10n('An information email was sent to group "%s"'),
120      $group_name
121      )
122    );
123}
124
125// +-----------------------------------------------------------------------+
126// |                       template initialization                         |
127// +-----------------------------------------------------------------------+
128
129$template->set_filename('album_notification', 'album_notification.tpl');
130
131$template->assign(
132  array(
133    'CATEGORIES_NAV' =>
134      get_cat_display_name_from_id(
135        $page['cat'],
136        'admin.php?page=album-'
137        ),
138    'F_ACTION' => $admin_album_base_url.'-notification',
139    'PWG_TOKEN' => get_pwg_token(),
140    )
141  );
142
143// +-----------------------------------------------------------------------+
144// |                          form construction                            |
145// +-----------------------------------------------------------------------+
146
147$query = '
148SELECT
149    id AS group_id
150  FROM '.GROUPS_TABLE.'
151;';
152$all_group_ids = array_from_query($query, 'group_id');
153
154if (count($all_group_ids) == 0)
155{
156  $template->assign('no_group_in_gallery', true);
157}
158else
159{
160  if ('private' == $category['status'])
161  {
162    $query = '
163SELECT
164    group_id
165  FROM '.GROUP_ACCESS_TABLE.'
166  WHERE cat_id = '.$category['id'].'
167;';
168    $group_ids = array_from_query($query, 'group_id');
169
170    if (count($group_ids) == 0)
171    {
172      $template->assign('permission_url', $admin_album_base_url.'-permissions');
173    }
174  }
175  else
176  {
177    $group_ids = $all_group_ids;
178  }
179
180  if (count($group_ids) > 0)
181  {
182    $query = '
183SELECT
184    id,
185    name
186  FROM '.GROUPS_TABLE.'
187  WHERE id IN ('.implode(',', $group_ids).')
188  ORDER BY name ASC
189;';
190    $template->assign(
191      'group_mail_options',
192      simple_hash_from_query($query, 'id', 'name')
193      );
194  }
195}
196
197// +-----------------------------------------------------------------------+
198// |                           sending html code                           |
199// +-----------------------------------------------------------------------+
200
201$template->assign_var_from_handle('ADMIN_CONTENT', 'album_notification');
202?>
Note: See TracBrowser for help on using the repository browser.