source: trunk/admin/album_notification.php @ 25085

Last change on this file since 25085 was 25018, checked in by mistic100, 11 years ago

remove all array_push (50% slower than []) + some changes missing for feature:2978

File size: 6.5 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  $page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
117}
118
119// +-----------------------------------------------------------------------+
120// |                       template initialization                         |
121// +-----------------------------------------------------------------------+
122
123$template->set_filename('album_notification', 'album_notification.tpl');
124
125$template->assign(
126  array(
127    'CATEGORIES_NAV' =>
128      get_cat_display_name_from_id(
129        $page['cat'],
130        'admin.php?page=album-'
131        ),
132    'F_ACTION' => $admin_album_base_url.'-notification',
133    'PWG_TOKEN' => get_pwg_token(),
134    )
135  );
136
137// +-----------------------------------------------------------------------+
138// |                          form construction                            |
139// +-----------------------------------------------------------------------+
140
141$query = '
142SELECT
143    id AS group_id
144  FROM '.GROUPS_TABLE.'
145;';
146$all_group_ids = array_from_query($query, 'group_id');
147
148if (count($all_group_ids) == 0)
149{
150  $template->assign('no_group_in_gallery', true);
151}
152else
153{
154  if ('private' == $category['status'])
155  {
156    $query = '
157SELECT
158    group_id
159  FROM '.GROUP_ACCESS_TABLE.'
160  WHERE cat_id = '.$category['id'].'
161;';
162    $group_ids = array_from_query($query, 'group_id');
163
164    if (count($group_ids) == 0)
165    {
166      $template->assign('permission_url', $admin_album_base_url.'-permissions');
167    }
168  }
169  else
170  {
171    $group_ids = $all_group_ids;
172  }
173
174  if (count($group_ids) > 0)
175  {
176    $query = '
177SELECT
178    id,
179    name
180  FROM '.GROUPS_TABLE.'
181  WHERE id IN ('.implode(',', $group_ids).')
182  ORDER BY name ASC
183;';
184    $template->assign(
185      'group_mail_options',
186      simple_hash_from_query($query, 'id', 'name')
187      );
188  }
189}
190
191// +-----------------------------------------------------------------------+
192// |                           sending html code                           |
193// +-----------------------------------------------------------------------+
194
195$template->assign_var_from_handle('ADMIN_CONTENT', 'album_notification');
196?>
Note: See TracBrowser for help on using the repository browser.