diff --git a/admin/configuration.php b/admin/configuration.php index 0a89f6e4b..8e69d9c16 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -51,7 +51,6 @@ $main_checkboxes = array( 'rate', 'rate_anonymous', 'email_admin_on_new_user', - 'email_admin_on_picture_uploaded', ); $history_checkboxes = array( @@ -60,6 +59,11 @@ $history_checkboxes = array( 'history_guest' ); +$upload_checkboxes = array( + 'upload_link_everytime', + 'email_admin_on_picture_uploaded', + ); + $comments_checkboxes = array( 'comments_forall', 'comments_validation', @@ -110,6 +114,14 @@ if (isset($_POST['submit']) and !is_adviser()) } break; } + case 'upload' : + { + foreach( $upload_checkboxes as $checkbox) + { + $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; + } + break; + } case 'default' : { // Never go here @@ -160,6 +172,7 @@ $tabsheet = new tabsheet(); $tabsheet->add('main', l10n('conf_main_title'), $conf_link.'main'); $tabsheet->add('history', l10n('conf_history_title'), $conf_link.'history'); $tabsheet->add('comments', l10n('conf_comments_title'), $conf_link.'comments'); +$tabsheet->add('upload', l10n('conf_upload_title'), $conf_link.'upload'); $tabsheet->add('default', l10n('conf_display'), $conf_link.'default'); // TabSheet selection $tabsheet->select($page['section']); @@ -187,7 +200,7 @@ switch ($page['section']) 'CONF_GALLERY_URL' => $conf['gallery_url'], )); - foreach( $main_checkboxes as $checkbox) + foreach ($main_checkboxes as $checkbox) { $template->append( 'main', @@ -202,7 +215,7 @@ switch ($page['section']) case 'history' : { //Necessary for merge_block_vars - foreach( $history_checkboxes as $checkbox) + foreach ($history_checkboxes as $checkbox) { $template->append( 'history', @@ -222,7 +235,7 @@ switch ($page['section']) 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], )); - foreach( $comments_checkboxes as $checkbox) + foreach ($comments_checkboxes as $checkbox) { $template->append( 'comments', @@ -234,6 +247,28 @@ switch ($page['section']) } break; } + case 'upload' : + { + $template->assign( + 'upload', + array( + 'upload_user_access_options'=> get_user_access_level_html_options(ACCESS_GUEST), + 'upload_user_access_options_selected' => array($conf['upload_user_access']) + ) + ); + //Necessary for merge_block_vars + foreach ($upload_checkboxes as $checkbox) + { + $template->append( + 'upload', + array( + $checkbox => $conf[$checkbox] + ), + true + ); + } + break; + } case 'default' : { $edit_user = build_user($conf['default_user_id'], false); diff --git a/admin/include/functions.php b/admin/include/functions.php index 94ac4c962..5cb81e9cb 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1837,4 +1837,20 @@ function create_table_add_character_set($query) } return $query; } + +/** + * Returns array use on template with html_options method + * @param Min and Max access to use + * @return array of user access level + */ +function get_user_access_level_html_options($MinLevelAccess = ACCESS_FREE, $MaxLevelAccess = ACCESS_CLOSED) +{ + $tpl_options = array(); + for ($level = $MinLevelAccess; $level <= $MaxLevelAccess; $level++) + { + $tpl_options[$level] = l10n(sprintf('ACCESS_%d', $level)); + } + return $tpl_options; +} + ?> \ No newline at end of file diff --git a/identification.php b/identification.php index 7e9585eab..877e51a65 100644 --- a/identification.php +++ b/identification.php @@ -28,7 +28,7 @@ include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); // +-----------------------------------------------------------------------+ // | Check Access and exit when user status is not ok | // +-----------------------------------------------------------------------+ -check_status(ACCESS_NONE); +check_status(ACCESS_FREE); //-------------------------------------------------------------- identification $errors = array(); diff --git a/include/constants.php b/include/constants.php index 814d18f3e..6b05d683a 100644 --- a/include/constants.php +++ b/include/constants.php @@ -36,11 +36,12 @@ define('CRITICAL_MESSAGE', 203); define('CRITICAL_ERROR', 204); // Access codes -define('ACCESS_NONE', 0); +define('ACCESS_FREE', 0); define('ACCESS_GUEST', 1); define('ACCESS_CLASSIC', 2); define('ACCESS_ADMINISTRATOR', 3); define('ACCESS_WEBMASTER', 4); +define('ACCESS_CLOSED', 5); // Table names if (!defined('CATEGORIES_TABLE')) diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 2adbb200a..94b2411d2 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -452,4 +452,59 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_ return $display_text; } +/** + * returns the link of upload menu + * + * @param null + * @return string or null + */ +function get_upload_menu_link() +{ + global $conf, $page, $user; + + $show_link = false; + $arg_link = null; + + if (is_autorize_status($conf['upload_user_access'])) + { + if (isset($page['category']) and $page['category']['uploadable'] ) + { + // upload a picture in the category + $show_link = true; + $arg_link = 'cat='.$page['category']['id']; + } + else + if ($conf['upload_link_everytime']) + { + // upload a picture in the category + $query = ' +SELECT + 1 +FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' + ON id = cat_id and user_id = '.$user['id'].' +WHERE + uploadable = \'true\' + '.get_sql_condition_FandF + ( + array + ( + 'visible_categories' => 'id', + ), + 'AND' + ).' +LIMIT 1'; + + $show_link = mysql_num_rows(pwg_query($query)) <> 0; + } + } + if ($show_link) + { + return get_root_url().'upload.php'.(empty($arg_link) ? '' : '?'.$arg_link); + } + else + { + return; + } +} + ?> diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 6630e2dae..d2c9530e2 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -1088,7 +1088,7 @@ function get_user_status($user_status) } /* - * Return access_type definition of uuser + * Return access_type definition of user * Test does with user status * @return bool */ @@ -1101,7 +1101,7 @@ function get_access_type_status($user_status='') case 'guest': { $access_type_status = - ($conf['guest_access'] ? ACCESS_GUEST : ACCESS_NONE); + ($conf['guest_access'] ? ACCESS_GUEST : ACCESS_FREE); break; } case 'generic': @@ -1126,7 +1126,7 @@ function get_access_type_status($user_status='') } default: { - $access_type_status = ACCESS_NONE; + $access_type_status = ACCESS_FREE; break; } } diff --git a/include/menubar.inc.php b/include/menubar.inc.php index 4f7b5fe61..03e941226 100644 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -39,6 +39,7 @@ $template->assign( 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), 'U_CATEGORIES' => make_index_url(array('section' => 'categories')), 'U_LOST_PASSWORD' => get_root_url().'password.php', + 'U_UPLOAD' => get_upload_menu_link() ) ); @@ -304,12 +305,7 @@ $template->append( ) ); -if (isset($page['category']) and $page['category']['uploadable'] ) -{ // upload a picture in the category - $url = get_root_url().'upload.php?cat='.$page['category']['id']; - $template->assign('U_UPLOAD', $url); -} - trigger_action('loc_end_menubar'); $template->assign_var_from_handle('MENUBAR', 'menubar'); + ?> diff --git a/include/upload.class.php b/include/upload.class.php new file mode 100644 index 000000000..f9587ddb8 --- /dev/null +++ b/include/upload.class.php @@ -0,0 +1,41 @@ + diff --git a/install/config.sql b/install/config.sql index 01793eb94..bf7dd0d6b 100644 --- a/install/config.sql +++ b/install/config.sql @@ -25,3 +25,5 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_c INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('email_admin_on_picture_uploaded','false','Send an email to the administrators when a picture is uploaded'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('obligatory_user_mail_address','false','Mail address is obligatory for users'); INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('c13y_ignore',null,'List of ignored anomalies'); +INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('upload_link_everytime','false','Show upload link every time'); +INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('upload_user_access',2 /*ACCESS_CLASSIC*/,'User access level to upload'); diff --git a/install/db/70-database.php b/install/db/70-database.php new file mode 100644 index 000000000..50dfc161b --- /dev/null +++ b/install/db/70-database.php @@ -0,0 +1,53 @@ + diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index c9b2abe13..d231d2798 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -634,5 +634,15 @@ $lang['plugins_check_chmod'] = 'Please check "plugins" folder and sub-folders pe $lang['plugins_server_error'] = 'Can\'t connect to server.'; // --------- Starting below: New or revised $lang ---- from Butterfly (1.8) $lang['Purge compiled templates'] = 'Purge compiled templates'; -/* TODO */ $lang['Caddie is currently empty'] = 'Caddie is currently empty'; +$lang['Caddie is currently empty'] = 'Caddie is currently empty'; +$lang['conf_upload_title'] = 'Upload'; +$lang['Show upload link every time'] = 'Show upload link every time'; +$lang['User access level to upload'] = 'User access level to upload'; +$lang['ACCESS_0'] = 'Free access'; +$lang['ACCESS_1'] = 'Access to all'; +$lang['ACCESS_2'] = 'Access to subscribed'; +$lang['ACCESS_3'] = 'Access to administrators'; +$lang['ACCESS_4'] = 'Access to webmasters'; +$lang['ACCESS_5'] = 'No access'; + ?> diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php index 43c78de97..e8abb3d3a 100644 --- a/language/en_UK/common.lang.php +++ b/language/en_UK/common.lang.php @@ -306,7 +306,6 @@ $lang['title_send_mail'] = 'A comment on your site'; $lang['today'] = 'today'; $lang['update_rate'] = 'Update your rating'; $lang['update_wrong_dirname'] = 'wrong filename'; -$lang['upload_advise'] = 'Choose an image to place in the category : '; $lang['upload_advise_filesize'] = 'the filesize of the picture must not exceed : '; $lang['upload_advise_filetype'] = 'the picture must be to the fileformat jpg, gif or png'; $lang['upload_advise_height'] = 'the height of the picture must not exceed : '; @@ -364,4 +363,6 @@ $lang['%d element are also linked to current tags'] = '%d image is also linked t $lang['%d elements are also linked to current tags'] = '%d images are also linked to current tags'; $lang['See elements linked to this tag only'] = 'See images linked to this tag only'; $lang['elements posted during the last %d days'] = 'images posted during the last %d days'; +$lang['Choose an image'] = 'Choose an image'; + ?> diff --git a/language/en_UK/help/configuration.html b/language/en_UK/help/configuration.html index c722be2e4..cb9f1f7c0 100644 --- a/language/en_UK/help/configuration.html +++ b/language/en_UK/help/configuration.html @@ -34,8 +34,6 @@ page.
Here you can change display options used by default, when guest is not diff --git a/language/es_ES/admin.lang.php b/language/es_ES/admin.lang.php index acee9a7bf..fadce5427 100644 --- a/language/es_ES/admin.lang.php +++ b/language/es_ES/admin.lang.php @@ -639,5 +639,15 @@ $lang['plugins_check_chmod'] = 'Verifique los autorizaciones del expediente " pl $lang['plugins_server_error'] = 'Imposible conectarse al servidor.'; // --------- Starting below: New or revised $lang ---- from Butterfly (1.8) $lang['Purge compiled templates'] = 'Purgar el templates compilado'; -$lang['Caddie is currently empty'] = 'Caddie is currently empty'; +/* TODO */ $lang['Caddie is currently empty'] = 'Caddie is currently empty'; +/* TODO */ $lang['conf_upload_title'] = 'Upload'; +/* TODO */ $lang['Show upload link every time'] = 'Show upload link every time'; +/* TODO */ $lang['User access level to upload'] = 'User access level to upload'; +/* TODO */ $lang['ACCESS_0'] = 'Free access'; +/* TODO */ $lang['ACCESS_1'] = 'Access to all'; +/* TODO */ $lang['ACCESS_2'] = 'Access to subscribed'; +/* TODO */ $lang['ACCESS_3'] = 'Access to administrators'; +/* TODO */ $lang['ACCESS_4'] = 'Access to webmasters'; +/* TODO */ $lang['ACCESS_5'] = 'No access'; + ?> diff --git a/language/es_ES/common.lang.php b/language/es_ES/common.lang.php index 99d1ac42d..96d4a8a5f 100644 --- a/language/es_ES/common.lang.php +++ b/language/es_ES/common.lang.php @@ -306,7 +306,6 @@ $lang['title_send_mail'] = 'Una opinión sobre esta pagina'; $lang['today'] = 'hoy'; $lang['update_rate'] = 'Actualizar nota'; $lang['update_wrong_dirname'] = 'Mal nombre de repertorio'; -$lang['upload_advise'] = 'Elegir una imagen para agregar en esta categoría : '; $lang['upload_advise_filesize'] = 'El peso de la imagen debe sobrepasar : '; $lang['upload_advise_filetype'] = 'El tamaño de la imagen debe ser jpg, png ou gif'; $lang['upload_advise_height'] = 'La altura de la imagen no debe sobrepasar : '; @@ -364,4 +363,6 @@ $lang['%d element are also linked to current tags'] = '%d imagen es también vin $lang['%d elements are also linked to current tags'] = '%d imagenes son igualmente vinculadas a los tags corrientes'; $lang['See elements linked to this tag only'] = 'Ver las imágenes relacionadas únicamente a este tag'; $lang['elements posted during the last %d days'] = 'esta imagen tiene menos de %d dias'; +$lang['Choose an image'] = 'Elegir una imagen'; + ?> diff --git a/language/es_ES/help/configuration.html b/language/es_ES/help/configuration.html index 1623b3365..f2aa3d1fe 100644 --- a/language/es_ES/help/configuration.html +++ b/language/es_ES/help/configuration.html @@ -24,8 +24,6 @@ cass="filename">include/config_default.inc.php
Modificar las opciones de fijación por defecto: para los visitadores no conectados. Una vez conectado, estas opciones son sobrecargadas por las del utilizador, a las que puede modificar en la pantalla perfila.
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index b13c81b10..76f241bee 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -635,4 +635,14 @@ $lang['plugins_server_error'] = 'Impossible de se connecter au serveur.'; // --------- Starting below: New or revised $lang ---- from Butterfly (1.8) $lang['Purge compiled templates'] = 'Purger les templates compilés'; $lang['Caddie is currently empty'] = 'Le panier est actuellement vide.'; +$lang['conf_upload_title'] = 'Téléchargement'; +$lang['Show upload link every time'] = 'Afficher le lien d\'ajout d\'image tout le temps'; +$lang['User access level to upload'] = 'Niveau d\'accès utilisateur pour télécharger'; +$lang['ACCESS_0'] = 'Accès libre'; +$lang['ACCESS_1'] = 'Accès à tous'; +$lang['ACCESS_2'] = 'Accès aux inscrits'; +$lang['ACCESS_3'] = 'Accès aux administrateurs'; +$lang['ACCESS_4'] = 'Accès aux webmestres'; +$lang['ACCESS_5'] = 'Pas d\'accès'; + ?> diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php index 06af0ee76..af5aed3d5 100644 --- a/language/fr_FR/common.lang.php +++ b/language/fr_FR/common.lang.php @@ -306,7 +306,6 @@ $lang['title_send_mail'] = 'Un commentaire sur le site'; $lang['today'] = 'aujourd\'hui'; $lang['update_rate'] = 'Mettre à jour votre note'; $lang['update_wrong_dirname'] = 'mauvais nom de répertoire'; -$lang['upload_advise'] = 'Choisir une image à ajouter dans cette catégorie : '; $lang['upload_advise_filesize'] = 'le poids de l\'image ne doit dépasser : '; $lang['upload_advise_filetype'] = 'le format de l\'image doit être jpg, png ou gif'; $lang['upload_advise_height'] = 'la hauteur de l\'image ne doit pas dépasser : '; @@ -364,4 +363,6 @@ $lang['%d element are also linked to current tags'] = '%d image est également l $lang['%d elements are also linked to current tags'] = '%d images sont également liées aux tags courants'; $lang['See elements linked to this tag only'] = 'Voir les images liées uniquement à ce tag'; $lang['elements posted during the last %d days'] = 'images ajoutées au cours de %d derniers jours'; +$lang['Choose an image'] = 'Choisir une image à ajouter'; + ?> diff --git a/language/fr_FR/help/configuration.html b/language/fr_FR/help/configuration.html index 4f2a9f3d7..086b78e40 100644 --- a/language/fr_FR/help/configuration.html +++ b/language/fr_FR/help/configuration.html @@ -34,8 +34,6 @@ galerie.