mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-11 19:23:01 +02:00
Applying coding style guidelines to r1018 and r1019.
New function get_webmaster_mail_address used in include/page_tail.php and include/functions_mail.inc.php. Nothing else than functions in include/functions*, init_conf_mail() was useless in include/functions_mail.inc.php because $conf_mail is only used in function pwg_mail. bug fixed: files include/functions_mail.inc.php and include/functions_notification.inc.php had been commited in DOS format! Unix file format is the only file format authorized. git-svn-id: http://piwigo.org/svn/trunk@1021 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -182,8 +182,8 @@ $conf['users_page'] = 20;
|
||||
// "options" parameter missing on mail() function execution.
|
||||
$conf['mail_options'] = false;
|
||||
|
||||
// Send bcc mail to webmaster
|
||||
// Set true for debug or test
|
||||
// send_bcc_mail_webmaster: send bcc mail to webmaster. Set true for debug
|
||||
// or test.
|
||||
$conf['send_bcc_mail_webmaster'] = false;
|
||||
|
||||
// check_upgrade_feed: check if there are database upgrade required. Set to
|
||||
|
||||
@@ -953,4 +953,23 @@ function get_sql_search_clause($search_id)
|
||||
|
||||
return $search_clause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns webmaster mail address depending on $conf['webmaster_id']
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_webmaster_mail_address()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['email'].'
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
|
||||
;';
|
||||
list($email) = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
return $email;
|
||||
}
|
||||
?>
|
||||
|
||||
+110
-83
@@ -1,68 +1,92 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 958 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// Extract mail fonctions of password.php
|
||||
// And Modify pwg_mail (add pararameters + news fonctionnalities)
|
||||
// And var conf_mail, function init_conf_mail, function format_email
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 958 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* - Extract mail fonctions of password.php
|
||||
* - Modify pwg_mail (add pararameters + news fonctionnalities)
|
||||
* - Var conf_mail, function init_conf_mail, function format_email
|
||||
*/
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
|
||||
/*
|
||||
* Initialization of global variable $conf_mail
|
||||
* Returns an array of mail configuration parameters :
|
||||
*
|
||||
* - mail_options: see $conf['mail_options']
|
||||
* - send_bcc_mail_webmaster: see $conf['send_bcc_mail_webmaster']
|
||||
* - email_webmaster: mail corresponding to $conf['webmaster_id']
|
||||
* - formated_email_webmaster: the name of webmaster is $conf['gallery_title']
|
||||
* - text_footer: PhpWebGallery and version
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function init_conf_mail()
|
||||
{
|
||||
global $conf, $conf_mail;
|
||||
|
||||
if (count($conf_mail) == 0)
|
||||
{
|
||||
$conf_mail['mail_options'] = $conf['mail_options'];
|
||||
$conf_mail['send_bcc_mail_webmaster'] = ($conf['send_bcc_mail_webmaster'] == true ? true : false);
|
||||
list($conf_mail['email_webmaster']) = mysql_fetch_array(pwg_query('select '.$conf['user_fields']['email'].' from '.USERS_TABLE.' where '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].';'));
|
||||
$conf_mail['formated_email_webmaster'] = format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
|
||||
$conf_mail['text_footer'] = "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function format_email($name, $email)
|
||||
{
|
||||
if (strpos($email, '<') === false)
|
||||
return $name.' <'.$email.'>';
|
||||
else
|
||||
return $name.$email;
|
||||
}
|
||||
function get_mail_configuration()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$conf_mail = array(
|
||||
'mail_options' => $conf['mail_options'],
|
||||
'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
|
||||
);
|
||||
|
||||
// we have webmaster id among user list, what's his email address ?
|
||||
$conf_mail['email_webmaster'] = get_webmaster_mail_address();
|
||||
|
||||
// name of the webmaster is the title of the gallery
|
||||
$conf_mail['formated_email_webmaster'] =
|
||||
format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
|
||||
|
||||
// what to display at the bottom of each mail ?
|
||||
$conf_mail['text_footer'] =
|
||||
"\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
|
||||
|
||||
return $conf_mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an email address with an associated real name
|
||||
*
|
||||
* @param string name
|
||||
* @param string email
|
||||
*/
|
||||
function format_email($name, $email)
|
||||
{
|
||||
if (strpos($email, '<') === false)
|
||||
{
|
||||
return $name.' <'.$email.'>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return $name.$email;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sends an email, using PhpWebGallery specific informations
|
||||
@@ -70,40 +94,43 @@ function format_email($name, $email)
|
||||
function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '')
|
||||
{
|
||||
global $conf, $conf_mail;
|
||||
|
||||
$to = format_email('', $to);
|
||||
|
||||
if ($from =='')
|
||||
$from = $conf_mail['formated_email_webmaster'];
|
||||
else
|
||||
$from = format_email('', $from);
|
||||
|
||||
|
||||
if (!isset($conf_mail))
|
||||
{
|
||||
$conf_mail = get_mail_configuration();
|
||||
}
|
||||
|
||||
$to = format_email('', $to);
|
||||
|
||||
if ($from == '')
|
||||
{
|
||||
$from = $conf_mail['formated_email_webmaster'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$from = format_email('', $from);
|
||||
}
|
||||
|
||||
$headers = 'From: '.$from."\n";
|
||||
$headers.= 'Reply-To: '.$from."\n";
|
||||
if ($conf_mail['send_bcc_mail_webmaster'])
|
||||
$headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
|
||||
|
||||
|
||||
$options = '-f '.$from;
|
||||
|
||||
$headers.= 'Reply-To: '.$from."\n";
|
||||
|
||||
if ($conf_mail['send_bcc_mail_webmaster'])
|
||||
{
|
||||
$headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
|
||||
}
|
||||
|
||||
$content = $infos;
|
||||
$content.= $conf_mail['text_footer'];
|
||||
|
||||
if ($conf_mail['mail_options'])
|
||||
{
|
||||
$options = '-f '.$from;
|
||||
|
||||
return mail($to, $subject, $content, $headers, $options);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mail($to, $subject, $content, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Global Variables
|
||||
// +-----------------------------------------------------------------------+
|
||||
$conf_mail = array();
|
||||
|
||||
init_conf_mail();
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -1,227 +1,226 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 958 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
|
||||
// Extract news fonctions of feed.php
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* new comments between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function new_comments($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT c.id AS comment_id
|
||||
FROM '.COMMENTS_TABLE.' AS c
|
||||
, '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||
WHERE c.image_id = ic.image_id
|
||||
AND c.validation_date > \''.$start.'\'
|
||||
AND c.validation_date <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'comment_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* unvalidated at a precise date
|
||||
*
|
||||
* Comments that are registered and not validated yet on a precise date
|
||||
*
|
||||
* @param string date (mysql datetime format)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function unvalidated_comments($date)
|
||||
{
|
||||
$query = '
|
||||
SELECT DISTINCT id
|
||||
FROM '.COMMENTS_TABLE.'
|
||||
WHERE date <= \''.$date.'\'
|
||||
AND (validated = \'false\'
|
||||
OR validation_date > \''.$date.'\')
|
||||
;';
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new elements between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function new_elements($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT image_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* updated categories between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function updated_categories($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT category_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new registered users between two dates
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @return array user ids
|
||||
*/
|
||||
function new_users($start, $end)
|
||||
{
|
||||
$query = '
|
||||
SELECT user_id
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE registration_date > \''.$start.'\'
|
||||
AND registration_date <= \''.$end.'\'
|
||||
;';
|
||||
return array_from_query($query, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* currently waiting pictures
|
||||
*
|
||||
* @return array waiting ids
|
||||
*/
|
||||
function waiting_elements()
|
||||
{
|
||||
$query = '
|
||||
SELECT id
|
||||
FROM '.WAITING_TABLE.'
|
||||
WHERE validated = \'false\'
|
||||
;';
|
||||
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* What's new between two dates ?
|
||||
*
|
||||
* Informations : number of new comments, number of new elements, number of
|
||||
* updated categories. Administrators are also informed about : number of
|
||||
* unvalidated comments, number of new users (TODO : number of unvalidated
|
||||
* elements)
|
||||
*
|
||||
* @param string start date (mysql datetime format)
|
||||
* @param string end date (mysql datetime format)
|
||||
*/
|
||||
function news($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$news = array();
|
||||
|
||||
$nb_new_comments = count(new_comments($start, $end));
|
||||
if ($nb_new_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new comments'), $nb_new_comments));
|
||||
}
|
||||
|
||||
$nb_new_elements = count(new_elements($start, $end));
|
||||
if ($nb_new_elements > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
|
||||
}
|
||||
|
||||
$nb_updated_categories = count(updated_categories($start, $end));
|
||||
if ($nb_updated_categories > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d categories updated'),
|
||||
$nb_updated_categories));
|
||||
}
|
||||
|
||||
if ('admin' == $user['status'])
|
||||
{
|
||||
$nb_unvalidated_comments = count(unvalidated_comments($end));
|
||||
if ($nb_unvalidated_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d comments to validate'),
|
||||
$nb_unvalidated_comments));
|
||||
}
|
||||
|
||||
$nb_new_users = count(new_users($start, $end));
|
||||
if ($nb_new_users > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new users'), $nb_new_users));
|
||||
}
|
||||
|
||||
$nb_waiting_elements = count(waiting_elements());
|
||||
if ($nb_waiting_elements > 0)
|
||||
{
|
||||
array_push(
|
||||
$news,
|
||||
sprintf(
|
||||
l10n('%d waiting elements'),
|
||||
$nb_waiting_elements
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $news;
|
||||
}
|
||||
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2005-11-26 21:15:50 +0100 (sam., 26 nov. 2005) $
|
||||
// | last modifier : $Author: plg $
|
||||
// | revision : $Revision: 958 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
|
||||
/**
|
||||
* Extract news fonctions of feed.php
|
||||
*/
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | functions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* new comments between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function new_comments($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT c.id AS comment_id
|
||||
FROM '.COMMENTS_TABLE.' AS c
|
||||
, '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||
WHERE c.image_id = ic.image_id
|
||||
AND c.validation_date > \''.$start.'\'
|
||||
AND c.validation_date <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'comment_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* unvalidated at a precise date
|
||||
*
|
||||
* Comments that are registered and not validated yet on a precise date
|
||||
*
|
||||
* @param string date (mysql datetime format)
|
||||
* @return array comment ids
|
||||
*/
|
||||
function unvalidated_comments($date)
|
||||
{
|
||||
$query = '
|
||||
SELECT DISTINCT id
|
||||
FROM '.COMMENTS_TABLE.'
|
||||
WHERE date <= \''.$date.'\'
|
||||
AND (validated = \'false\'
|
||||
OR validation_date > \''.$date.'\')
|
||||
;';
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new elements between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function new_elements($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT image_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'image_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* updated categories between two dates, according to authorized categories
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @param string forbidden categories (comma separated)
|
||||
* @return array element ids
|
||||
*/
|
||||
function updated_categories($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$query = '
|
||||
SELECT DISTINCT category_id
|
||||
FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||
WHERE date_available > \''.$start.'\'
|
||||
AND date_available <= \''.$end.'\'
|
||||
AND category_id NOT IN ('.$user['forbidden_categories'].')
|
||||
;';
|
||||
return array_from_query($query, 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* new registered users between two dates
|
||||
*
|
||||
* @param string start (mysql datetime format)
|
||||
* @param string end (mysql datetime format)
|
||||
* @return array user ids
|
||||
*/
|
||||
function new_users($start, $end)
|
||||
{
|
||||
$query = '
|
||||
SELECT user_id
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE registration_date > \''.$start.'\'
|
||||
AND registration_date <= \''.$end.'\'
|
||||
;';
|
||||
return array_from_query($query, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* currently waiting pictures
|
||||
*
|
||||
* @return array waiting ids
|
||||
*/
|
||||
function waiting_elements()
|
||||
{
|
||||
$query = '
|
||||
SELECT id
|
||||
FROM '.WAITING_TABLE.'
|
||||
WHERE validated = \'false\'
|
||||
;';
|
||||
|
||||
return array_from_query($query, 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* What's new between two dates ?
|
||||
*
|
||||
* Informations : number of new comments, number of new elements, number of
|
||||
* updated categories. Administrators are also informed about : number of
|
||||
* unvalidated comments, number of new users (TODO : number of unvalidated
|
||||
* elements)
|
||||
*
|
||||
* @param string start date (mysql datetime format)
|
||||
* @param string end date (mysql datetime format)
|
||||
*/
|
||||
function news($start, $end)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$news = array();
|
||||
|
||||
$nb_new_comments = count(new_comments($start, $end));
|
||||
if ($nb_new_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new comments'), $nb_new_comments));
|
||||
}
|
||||
|
||||
$nb_new_elements = count(new_elements($start, $end));
|
||||
if ($nb_new_elements > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new elements'), $nb_new_elements));
|
||||
}
|
||||
|
||||
$nb_updated_categories = count(updated_categories($start, $end));
|
||||
if ($nb_updated_categories > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d categories updated'),
|
||||
$nb_updated_categories));
|
||||
}
|
||||
|
||||
if ('admin' == $user['status'])
|
||||
{
|
||||
$nb_unvalidated_comments = count(unvalidated_comments($end));
|
||||
if ($nb_unvalidated_comments > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d comments to validate'),
|
||||
$nb_unvalidated_comments));
|
||||
}
|
||||
|
||||
$nb_new_users = count(new_users($start, $end));
|
||||
if ($nb_new_users > 0)
|
||||
{
|
||||
array_push($news, sprintf(l10n('%d new users'), $nb_new_users));
|
||||
}
|
||||
|
||||
$nb_waiting_elements = count(waiting_elements());
|
||||
if ($nb_waiting_elements > 0)
|
||||
{
|
||||
array_push(
|
||||
$news,
|
||||
sprintf(
|
||||
l10n('%d waiting elements'),
|
||||
$nb_waiting_elements
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $news;
|
||||
}
|
||||
|
||||
?>
|
||||
+13
-19
@@ -36,6 +36,19 @@ $template->assign_vars(
|
||||
'L_TITLE_MAIL' => $lang['title_send_mail'],
|
||||
'L_POWERED_BY'=>$lang['powered_by']
|
||||
));
|
||||
|
||||
//--------------------------------------------------------------------- contact
|
||||
|
||||
if (!$user['is_the_guest'])
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'contact',
|
||||
array(
|
||||
'MAIL' => get_webmaster_mail_address()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------- generation time
|
||||
if ($conf['show_gt'])
|
||||
{
|
||||
@@ -62,25 +75,6 @@ if ($conf['show_queries'])
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------- contact
|
||||
|
||||
if (!$user['is_the_guest'])
|
||||
{
|
||||
$query = '
|
||||
SELECT '.$conf['user_fields']['email'].'
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
|
||||
;';
|
||||
list($email) = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
$template->assign_block_vars(
|
||||
'contact',
|
||||
array(
|
||||
'MAIL' => $email
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Generate the page
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user