aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2003-07-25 21:33:41 +0000
committerz0rglub <z0rglub@piwigo.org>2003-07-25 21:33:41 +0000
commit963e1ef71418bdad2e81e78b983f57633dbf3c18 (patch)
tree53a64ea75ff14228f3a16da3f07ca5b996f15d4c
parent1400807269662dfe7e4bc015c5d1385113c50418 (diff)
Adding support of independant uploadable categories
git-svn-id: http://piwigo.org/svn/trunk@38 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/cat_modify.php55
-rw-r--r--category.php4
-rw-r--r--include/functions_category.inc.php18
-rw-r--r--language/francais.php5
-rw-r--r--template/default/admin/cat_modify.vtp18
-rw-r--r--template/default/category.vtp6
-rw-r--r--upload.php10
7 files changed, 80 insertions, 36 deletions
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 3e171139f..a10655975 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -20,7 +20,8 @@ include_once( './include/isadmin.inc.php' );
$sub = $vtp->Open( '../template/'.$user['template'].'/admin/cat_modify.vtp' );
$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
'editcat_name','editcat_comment','editcat_status',
- 'editcat_visible','editcat_status_info', 'submit' );
+ 'editcat_visible','editcat_visible_info', 'submit',
+ 'editcat_uploadable' );
templatize_array( $tpl, 'lang', $sub );
//---------------------------------------------------------------- verification
if ( !is_numeric( $_GET['cat'] ) )
@@ -53,25 +54,23 @@ if ( isset( $_POST['submit'] ) )
}
$query = 'UPDATE '.PREFIX_TABLE.'categories';
+
+ $query.= ' SET name = ';
if ( $_POST['name'] == '' )
- {
- $query.= ' SET name = NULL';
- }
+ $query.= 'NULL';
else
- {
- $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'";
- }
+ $query.= "'".htmlentities( $_POST['name'], ENT_QUOTES)."'";
+
+ $query.= ', comment = ';
if ( $_POST['comment'] == '' )
- {
- $query.= ', comment = NULL';
- }
+ $query.= 'NULL';
else
- {
- $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
- }
+ $query.= "'".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
+
$query.= ", status = '".$_POST['status']."'";
$query.= ", visible = '".$_POST['visible']."'";
- $query.= " WHERE id = '".$_GET['cat']."'";
+ $query.= ", uploadable = '".$_POST['uploadable']."'";
+ $query.= ' WHERE id = '.$_GET['cat'];
$query.= ';';
mysql_query( $query );
@@ -93,7 +92,7 @@ if ( isset( $_POST['submit'] ) )
$form_action = './admin.php?page=cat_modify&amp;cat='.$_GET['cat'];
$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
-$query = 'SELECT a.id,name,dir,status,comment';
+$query = 'SELECT a.id,name,dir,status,comment,uploadable';
$query.= ',id_uppercat,site_id,galleries_url,visible';
$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
$query.= ' WHERE a.id = '.$_GET['cat'];
@@ -148,6 +147,32 @@ if ( $row['visible'] == 'false' )
}
$vtp->setVar( $sub, 'visible_option.checked', $checked );
$vtp->closeSession( $sub, 'visible_option' );
+// uploadable : true or false
+if ( $conf['upload_available'] )
+{
+ $vtp->addSession( $sub, 'uploadable' );
+ $vtp->addSession( $sub, 'uploadable_option' );
+ $vtp->setVar( $sub, 'uploadable_option.value', 'true' );
+ $vtp->setVar( $sub, 'uploadable_option.option', $lang['yes'] );
+ $checked = '';
+ if ( $row['uploadable'] == 'true' )
+ {
+ $checked = ' checked="checked"';
+ }
+ $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
+ $vtp->closeSession( $sub, 'uploadable_option' );
+ $vtp->addSession( $sub, 'uploadable_option' );
+ $vtp->setVar( $sub, 'uploadable_option.value', 'false' );
+ $vtp->setVar( $sub, 'uploadable_option.option', $lang['no'] );
+ $checked = '';
+ if ( $row['uploadable'] == 'false' )
+ {
+ $checked = ' checked="checked"';
+ }
+ $vtp->setVar( $sub, 'uploadable_option.checked', $checked );
+ $vtp->closeSession( $sub, 'uploadable_option' );
+ $vtp->closeSession( $sub, 'uploadable' );
+}
//----------------------------------------------------------- sending html code
$vtp->Parse( $handle , 'sub', $sub );
?> \ No newline at end of file
diff --git a/category.php b/category.php
index 517642e22..5fe713adc 100644
--- a/category.php
+++ b/category.php
@@ -436,7 +436,9 @@ if ( isset ( $page['cat'] ) )
$vtp->setVar( $handle, 'cat_infos.cat_name', $page['title'] );
}
// upload a picture in the category
- if ( $page['cat_site_id'] == 1 and $conf['upload_available'] )
+ if ( $page['cat_site_id'] == 1
+ and $conf['upload_available']
+ and $page['cat_uploadable'] )
{
$vtp->addSession( $handle, 'upload' );
$url = './upload.php?cat='.$page['cat'].'&amp;expand='.$page['expand'];
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index f0b825381..f2ec5652a 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -282,7 +282,7 @@ function get_cat_info( $id )
$cat['name'] = array();
$query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir';
- $query.= ',date_last';
+ $query.= ',date_last,uploadable';
$query.= ' FROM '.PREFIX_TABLE.'categories AS a';
$query.= ', '.PREFIX_TABLE.'sites AS b';
$query.= ' WHERE a.id = '.$id;
@@ -294,8 +294,9 @@ function get_cat_info( $id )
$cat['nb_images'] = $row['nb_images'];
$cat['last_dir'] = $row['dir'];
$cat['date_last'] = $row['date_last'];
+ $cat['uploadable'] = get_boolean( $row['uploadable'] );
$galleries_url = $row['galleries_url'];
-
+
$cat['dir'] = "";
$i = 0;
$is_root = false;
@@ -379,7 +380,7 @@ function get_cat_display_name( $array_cat_names, $separation, $style )
function initialize_category( $calling_page = 'category' )
{
global $page,$lang,$user,$conf;
-
+
if ( isset( $page['cat'] ) )
{
// $page['nb_image_page'] is the number of picture to display on this page
@@ -391,11 +392,12 @@ function initialize_category( $calling_page = 'category' )
if ( is_numeric( $page['cat'] ) )
{
$result = get_cat_info( $page['cat'] );
- $page['comment'] = $result['comment'];
- $page['cat_dir'] = $result['dir'];
- $page['cat_name'] = $result['name'];
- $page['cat_nb_images'] = $result['nb_images'];
- $page['cat_site_id'] = $result['site_id'];
+ $page['comment'] = $result['comment'];
+ $page['cat_dir'] = $result['dir'];
+ $page['cat_name'] = $result['name'];
+ $page['cat_nb_images'] = $result['nb_images'];
+ $page['cat_site_id'] = $result['site_id'];
+ $page['cat_uploadable'] = $result['uploadable'];
$page['title'] = get_cat_display_name( $page['cat_name'], ' - ', '' );
$page['where'] = ' WHERE cat_id = '.$page['cat'];
}
diff --git a/language/francais.php b/language/francais.php
index b6f29a012..d0d4b736f 100644
--- a/language/francais.php
+++ b/language/francais.php
@@ -485,9 +485,12 @@ if ( $isadmin )
$lang['editcat_name'] = 'Nom';
$lang['editcat_comment'] = 'Commentaire';
$lang['editcat_status'] = 'Status';
- $lang['editcat_status_info'] = '(invisible sauf pour les administrateurs)';
// start version 1.3
+ // $lang['editcat_status_info'] = '(invisible sauf pour les administrateurs)';
+// $lang['editcat_status_info'] => $lang['editcat_visible_info']
+ $lang['editcat_visible_info'] = '(invisible sauf pour les administrateurs)';
$lang['editcat_visible'] = 'Visible';
+ $lang['editcat_uploadable'] = 'Ajout d\'images par les visiteurs';
// end version 1.3
// page info images
// start version 1.3
diff --git a/template/default/admin/cat_modify.vtp b/template/default/admin/cat_modify.vtp
index 90dcc093f..392919bf6 100644
--- a/template/default/admin/cat_modify.vtp
+++ b/template/default/admin/cat_modify.vtp
@@ -20,13 +20,13 @@
</td>
</tr>
<tr>
- <td style="width:20%;">{#editcat_comment}</td>
+ <td>{#editcat_comment}</td>
<td class="row2">
<textarea name="comment" rows="5" cols="50" style="overflow:auto">{#comment}</textarea>
</td>
</tr>
<tr>
- <td style="width:20%;">{#editcat_status}</td>
+ <td>{#editcat_status}</td>
<td class="row2">
<!--VTP_status_option-->
<input type="radio" name="status" value="{#value}"{#checked} />{#option}
@@ -34,14 +34,24 @@
</td>
</tr>
<tr>
- <td style="width:20%;">{#editcat_visible}</td>
+ <td>{#editcat_visible}</td>
<td class="row2">
<!--VTP_visible_option-->
<input type="radio" name="visible" value="{#value}"{#checked} />{#option}
<!--/VTP_visible_option-->
- {#editcat_status_info}
+ {#editcat_visible_info}
</td>
</tr>
+ <!--VTP_uploadable-->
+ <tr>
+ <td>{#editcat_uploadable}</td>
+ <td class="row2">
+ <!--VTP_uploadable_option-->
+ <input type="radio" name="uploadable" value="{#value}"{#checked} />{#option}
+ <!--/VTP_uploadable_option-->
+ </td>
+ </tr>
+ <!--/VTP_uploadable-->
<tr>
<td colspan="2">&nbsp;</td>
</tr>
diff --git a/template/default/category.vtp b/template/default/category.vtp
index f74847c60..b14b30f81 100644
--- a/template/default/category.vtp
+++ b/template/default/category.vtp
@@ -30,6 +30,9 @@
<!--VTP_summary-->
&nbsp;<img src="{#lien_collapsed}" alt="&gt;"/>&nbsp;<a href="{#url}" title="{#title}">{#name}</a><br />
<!--/VTP_summary-->
+ <!--VTP_upload-->
+ <br />&nbsp;<img src="{#lien_collapsed}" alt="&gt;"/>&nbsp;<a href="{#url}" class="back">{#upload_picture}</a>
+ <!--/VTP_upload-->
</div>
{#frame_end}
</td>
@@ -77,9 +80,6 @@
<!--/VTP_comment-->
<div class="infoCat">
{#nb_image_category} "{#cat_name}" : {#cat_nb_images}
- <!--VTP_upload-->
- <br /><a href="{#url}" class="back">{#upload_picture}</a>
- <!--/VTP_upload-->
</div>
<!--/VTP_cat_infos-->
</td>
diff --git a/upload.php b/upload.php
index 7e320c1fa..b6f65014f 100644
--- a/upload.php
+++ b/upload.php
@@ -103,9 +103,10 @@ if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
{
check_restrictions( $page['cat'] );
$result = get_cat_info( $page['cat'] );
- $page['cat_dir'] = $result['dir'];
- $page['cat_site_id'] = $result['site_id'];
- $page['cat_name'] = $result['name'];
+ $page['cat_dir'] = $result['dir'];
+ $page['cat_site_id'] = $result['site_id'];
+ $page['cat_name'] = $result['name'];
+ $page['cat_uploadable'] = $result['uploadable'];
}
else
{
@@ -113,7 +114,8 @@ else
}
if ( $access_forbidden == true
or $page['cat_site_id'] != 1
- or !$conf['upload_available'] )
+ or !$conf['upload_available']
+ or !$page['cat_uploadable'] )
{
echo '<div style="text-align:center;">'.$lang['upload_forbidden'].'<br />';
echo '<a href="'.add_session_id( './category.php' ).'">';