Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[ticket/729] Add option to change the image author #15

Merged
merged 1 commit into from

1 participant

This page is out of date. Refresh to see the latest.
View
2  root/adm/style/gallery_main.html
@@ -225,7 +225,7 @@
</dl>
<p class="submit-buttons">
- <input class="button1" type="submit" id="submit" name="submit" value="{L_CHANGE_AUTHOR}" />
+ <input class="button1" type="submit" id="submit" name="submit" value="{L_CHANGE_AUTHOR_TO_GUEST}" />
<input class="button1" type="submit" id="delete" name="delete" value="{L_DELETE}" />
</p>
</fieldset>
View
43 root/gallery/posting.php
@@ -703,6 +703,43 @@ function gallery_not_authorised($backlink, $user, $loginlink, $login_explain = '
unset($sql_ary['image_allow_comments']);
}
+ $album_sql_ary = array();
+ if (phpbb_gallery::$auth->acl_check('m_edit', $album_id, $album_data['album_user_id']))
+ {
+ $user_data = phpbb_gallery_image::get_new_author_info(request_var('change_author', '', true));
+ if ($user_data)
+ {
+ $sql_ary = array_merge($sql_ary, array(
+ 'image_user_id' => $user_data['user_id'],
+ 'image_username' => $user_data['username'],
+ 'image_username_clean' => utf8_clean_string($user_data['username']),
+ 'image_user_colour' => $user_data['user_colour'],
+ ));
+ if ($album_data['album_last_image_id'] == $image_id)
+ {
+ $album_sql_ary = array(
+ 'album_last_user_id' => $user_data['user_id'],
+ 'album_last_username' => $user_data['username'],
+ 'album_last_user_colour' => $user_data['user_colour'],
+ );
+ $sql = 'UPDATE ' . GALLERY_ALBUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $album_sql_ary) . '
+ WHERE ' . $db->sql_in_set('album_id', $image_data['image_album_id']);
+ $db->sql_query($sql);
+ }
+ if ($image_data['image_status'] != phpbb_gallery_image::STATUS_UNAPPROVED)
+ {
+ $new_user = new phpbb_gallery_user($db, $user_data['user_id'], false);
+ $new_user->update_images(1);
+ $old_user = new phpbb_gallery_user($db, $image_data['image_user_id'], false);
+ $old_user->update_images(-1);
+ }
+ }
+ else if (request_var('change_author', '', true))
+ {
+ trigger_error('INVALID_USERNAME');
+ }
+ }
+
$move_to_personal = request_var('move_to_personal', 0);
if ($move_to_personal)
{
@@ -733,9 +770,9 @@ function gallery_not_authorised($backlink, $user, $loginlink, $login_explain = '
}
else if ($album_data['album_last_image_id'] == $image_id)
{
- $album_sql_ary = array(
+ $album_sql_ary = array_merge($album_sql_ary, array(
'album_last_image_name' => $image_name,
- );
+ ));
$sql = 'UPDATE ' . GALLERY_ALBUMS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $album_sql_ary) . '
WHERE ' . $db->sql_in_set('album_id', $image_data['image_album_id']);
$db->sql_query($sql);
@@ -797,6 +834,8 @@ function gallery_not_authorised($backlink, $user, $loginlink, $login_explain = '
'IMAGE_RSZ_WIDTH' => phpbb_gallery_config::get('medium_width'),
'IMAGE_RSZ_HEIGHT' => phpbb_gallery_config::get('medium_height'),
+ 'S_CHANGE_AUTHOR' => phpbb_gallery::$auth->acl_check('m_edit', $album_id, $album_data['album_user_id']),
+ 'U_FIND_USERNAME' => phpbb_gallery_url::append_sid('phpbb', 'memberlist', 'mode=searchuser&amp;form=postform&amp;field=change_author&amp;select_single=true'),
'S_COMMENTS_ENABLED'=> phpbb_gallery_config::get('allow_comments') && phpbb_gallery_config::get('comment_user_control'),
'S_ALLOW_COMMENTS' => $image_data['image_allow_comments'],
View
36 root/includes/gallery/image/image.php
@@ -139,6 +139,40 @@ static public function add_image(&$image_data, $album_id)
return array('image_id' => $image_id, 'image_name' => $image_data['image_name']);
}
+ static public function get_new_author_info($username)
+ {
+ global $db;
+
+ // Who is the new uploader?
+ if (!$username)
+ {
+ return false;
+ }
+ $user_id = 0;
+ if ($username)
+ {
+ if (!function_exists('user_get_id_name'))
+ {
+ phpbb_gallery_url::_include('functions_user', 'phpbb');
+ }
+ user_get_id_name($user_id, $username);
+ }
+
+ if (empty($user_id))
+ {
+ return false;
+ }
+
+ $sql = 'SELECT username, user_colour, user_id
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . (int) $user_id[0];
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ return $row;
+ }
+
/**
* Delete an image completly.
*
@@ -423,7 +457,7 @@ static public function handle_counter($image_id_ary, $add, $readd = false)
$num_images = $num_images + $row['images'];
- $image_user = new phpbb_gallery_user($db, GALLERY_USERS_TABLE, $row['image_user_id'], false);
+ $image_user = new phpbb_gallery_user($db, $row['image_user_id'], false);
$image_user->update_images((($add) ? $row['images'] : 0 - $row['images']));
}
$db->sql_freeresult($result);
View
1  root/language/de/mods/gallery.php
@@ -63,6 +63,7 @@
'BROWSING_ALBUM_GUEST' => 'Mitglieder in diesem Album: %1$s und %2$d Gast',
'BROWSING_ALBUM_GUESTS' => 'Mitglieder in diesem Album: %1$s und %2$d Gäste',
+ 'CHANGE_AUTHOR' => 'Benutzer ändern',
'CHANGE_IMAGE_STATUS' => 'Bildstatus ändern',
'CLICK_RETURN_ALBUM' => 'Klicke %shier%s um zum Album zurückzukehren',
'CLICK_RETURN_IMAGE' => 'Klicke %shier%s um zum Bild zurückzukehren',
View
2  root/language/de/mods/gallery_acp.php
@@ -67,7 +67,7 @@
'ALBUMS' => 'Alben',
'CACHE_DIR_SIZE' => 'Größe des cache/-Ordners',
- 'CHANGE_AUTHOR' => 'Autor in Gast ändern',
+ 'CHANGE_AUTHOR_TO_GUEST' => 'Autor in Gast ändern',
'CHECK' => 'Überprüfen',
'CHECK_AUTHOR_EXPLAIN' => 'Keine Bilder ohne gültigen Autor gefunden.',
'CHECK_COMMENT_EXPLAIN' => 'Keine Kommentare ohne gültigen Autor gefunden.',
View
1  root/language/en/mods/gallery.php
@@ -63,6 +63,7 @@
'BROWSING_ALBUM_GUEST' => 'Users browsing this album: %1$s and %2$d guest',
'BROWSING_ALBUM_GUESTS' => 'Users browsing this album: %1$s and %2$d guests',
+ 'CHANGE_AUTHOR' => 'Change author',
'CHANGE_IMAGE_STATUS' => 'Change image-status',
'CLICK_RETURN_ALBUM' => 'Click %shere%s to return to the album',
'CLICK_RETURN_IMAGE' => 'Click %shere%s to return to the image',
View
2  root/language/en/mods/gallery_acp.php
@@ -68,7 +68,7 @@
'ALBUMS' => 'Albums',
'CACHE_DIR_SIZE' => 'cache/-directory size',
- 'CHANGE_AUTHOR' => 'Change author to guest',
+ 'CHANGE_AUTHOR_TO_GUEST' => 'Change author to guest',
'CHECK' => 'Check',
'CHECK_AUTHOR_EXPLAIN' => 'No images without valid author found.',
'CHECK_COMMENT_EXPLAIN' => 'No comments without valid author found.',
View
12 root/styles/prosilver/template/gallery/posting_body.html
@@ -163,17 +163,23 @@
//]]>
</script>
<!-- ENDIF -->
- <!-- IF S_MOVE_PERSONAL or S_COMMENTS_ENABLED --><hr /><!-- ENDIF -->
+ <!-- IF S_MOVE_PERSONAL or S_COMMENTS_ENABLED or S_CHANGE_AUTHOR --><hr /><!-- ENDIF -->
<!-- IF S_MOVE_PERSONAL -->
<dl>
<dt><label for="move_to_personal">{L_MOVE_TO_PERSONAL}:</label></dt>
- <dd><input style="inputbox checkbox" type="checkbox" name="move_to_personal" id="move_to_personal" value="1" /> <!-- IF S_MOVE_MODERATOR -->{L_MOVE_TO_PERSONAL_MOD}<!-- ELSE -->{L_MOVE_TO_PERSONAL_EXPLAIN}<!-- ENDIF --></dd>
+ <dd><input type="checkbox" class="checkbox" name="move_to_personal" id="move_to_personal" value="1" /> <!-- IF S_MOVE_MODERATOR -->{L_MOVE_TO_PERSONAL_MOD}<!-- ELSE -->{L_MOVE_TO_PERSONAL_EXPLAIN}<!-- ENDIF --></dd>
</dl>
<!-- ENDIF -->
<!-- IF S_COMMENTS_ENABLED -->
<dl>
<dt><label for="allow_comments">{L_COMMENTS}:</label></dt>
- <dd><input type="checkbox" style="inputbox checkbox" name="allow_comments" id="allow_comments"<!-- IF S_ALLOW_COMMENTS --> checked="checked"<!-- ENDIF --> value="1" /> <label for="allow_comments">{L_ALLOW_COMMENTS}</label></dd>
+ <dd><input type="checkbox" class="checkbox" name="allow_comments" id="allow_comments"<!-- IF S_ALLOW_COMMENTS --> checked="checked"<!-- ENDIF --> value="1" /> <label for="allow_comments">{L_ALLOW_COMMENTS}</label></dd>
+ </dl>
+ <!-- ENDIF -->
+ <!-- IF S_CHANGE_AUTHOR and U_FIND_USERNAME -->
+ <dl>
+ <dt><label for="change_author">{L_CHANGE_AUTHOR}:</label></dt>
+ <dd><input type="text" class="inputbox autowidth" name="change_author" id="change_author" value="" size="32" /> [ <a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a> ]</dd>
</dl>
<!-- ENDIF -->
</fieldset>
View
10 root/styles/subsilver2/template/gallery/posting_body.html
@@ -41,7 +41,7 @@
<br />
<!-- ENDIF -->
-<form name="upload" action="{S_ALBUM_ACTION}" method="post" enctype="multipart/form-data">
+<form name="postform" action="{S_ALBUM_ACTION}" method="post" enctype="multipart/form-data">
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="tablebg">
<tr>
<th colspan="2"><!-- IF S_COMMENT -->{L_POST_COMMENT}<!-- ELSEIF S_UPLOAD -->{L_UPLOAD_IMAGE}<!-- ELSEIF S_EDIT -->{L_EDIT_IMAGE}<!-- ELSEIF S_REPORT -->{L_REPORT_IMAGE}<!-- ENDIF --></th>
@@ -116,7 +116,7 @@
<td class="row2" valign="top">
<script type="text/javascript">
// <![CDATA[
- var form_name = 'upload';
+ var form_name = 'postform';
var text_name = 'message';
// ]]>
</script>
@@ -212,6 +212,12 @@
<td class="row2"><input type="checkbox" style="inputbox checkbox" name="allow_comments" id="allow_comments"<!-- IF S_ALLOW_COMMENTS --> checked="checked"<!-- ENDIF --> value="1" /> <span class="gen">{L_ALLOW_COMMENTS}</span></td>
</tr>
<!-- ENDIF -->
+ <!-- IF S_CHANGE_AUTHOR and U_FIND_USERNAME -->
+ <tr>
+ <td class="row1" height="28"><b class="genmed">{L_CHANGE_AUTHOR}:</b></td>
+ <td class="row2"><input type="text" class="inputbox autowidth" name="change_author" id="change_author" value="" size="32" /> <span class="gen">[ <a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a> ]</span></td>
+ </tr>
+ <!-- ENDIF -->
<tr>
<td class="cat" align="center" height="28" colspan="2"><input type="reset" accesskey="r" tabindex="200" value="{L_RESET}" class="btnlite" />
&nbsp;<input type="submit" accesskey="s" tabindex="201" name="submit" value="{L_SUBMIT}" class="btnmain" /></td>
Something went wrong with that request. Please try again.