This Modification is a Addon for
"Mod Allow users to edit their own images and thumbnails"The Mod Allow users to edit their own images and thumbnails is required.
In ACP/Session and Usersettings Activate "Images Battle Activate".
Each member can share his pictures in the "member_editimage" and "member_uploadimage" as Image Battle.
1.) Creating two new table field in the database:
ALTER TABLE 4images_images ADD image_battle TINYINT(1) DEFAULT '0' NOT NULL
ALTER TABLE 4images_images ADD image_update TEXT NOT NULL DEFAULT
Alternatively, copy the file "install_image_battle.php" from the Attachment in your root, login as Admin and call it to.
2.) search in admin/setting.php:
show_setting_row("user_delete_comments", "radio");
insert below:
show_setting_row("user_battle", "radio");
show_setting_row("user_battle_sticky", "radio");
3.) search in lang/your lang/admin.php:
(deutsch)
$setting['user_delete_comments'] = "Dürfen User Kommentare zu Ihren eigenen Bildern löschen";
insert below:
$setting['user_battle'] = "Bilder \"Battle\" Aktivieren:";
$setting['user_battle_sticky'] = "Freigegebene Bilder zum \"Battle\" zuerst Anzeigen:";
(english)
$setting['user_battle'] = "Images Battle Activate:";
$setting['user_battle_sticky'] = "Images for Battle ads first:";
4.) search in lang/your lang/main.php "?>" and insert above:
(deutsch)
$lang['image_battle'] = "Image Battle";
$lang['image_editor'] = "Zuletzt Bearbeitet von:";
(english)
$lang['image_battle'] = "Image Battle";
$lang['image_editor'] = "Last Edit:";
5.) search in lang/includes/db_field_definitions.php "?>" and insert above:
//######################## Start Mod Image Battle ###############
$additional_image_fields['image_battle'] = array($lang['image_battle'], "radio", 0);
$additional_image_fields['image_editor'] = array($lang['image_editor'], "text", 0);
//####################### End Mod Last Modifi #################
6.) search in categories.php:
$additional_sql .= ", i.".$key;
}
}
insert below:
//######################## Start Mod Image Battle ##############
$userBattleSticky = ($config['user_battle_sticky']) ? "i.image_battle = 1 DESC, " :"";
//######################## End Mod Image Battle ################
6.1) search:
ORDER BY ".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
and replace:
ORDER BY ".$userBattleSticky."".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
6.2) search:
$site_template->register_vars("thumbnails", $thumbnails);
and replace:
$site_template->register_vars(array(
"thumbnails" => $thumbnails,
"image_battle" => ($image_row['image_battle']) ? 1:0,
));
7.) search in index.php:
$num_new_images = $config['image_cells'];
insert above:
//######################## Start Mod Image Battle ##############
$userBattleSticky = ($config['user_battle_sticky']) ? "i.image_battle = 1 DESC, " :"";
//######################## End Mod Image Battle ################
7.2) search:
ORDER BY i.image_date DESC
and replace:
ORDER BY ".$userBattleSticky." i.image_date DESC
8.) search in member.php in section "if ($action == "updateimage") {" :
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
exit;
}
and replace:
//######################## Start Mod Image Battle ###############
if ($image_row || ($user_info['user_level'] >= USER) || ($image_row['image_battle'] && $config['user_battle'])) {
$image_editor = $image_row['user_id'];
}else{
$image_editor = $user_info['user_id'];
}
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($image_editor != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
show_error_page($lang['no_permission']);
exit;
}
//######################## End Mod Image Battle ###############
8.1) search in member.php in section "if ($action == "updateimage") {" :
$table_fields = $site_db->get_table_fields(IMAGES_TABLE);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
and replace:
//######################## Start Mod Image Battle ###############
$image_update = "".$user_info['user_id'].",".$user_info['user_name'].",".format_date($config['date_format']." ".$config['time_format'], time())."";
//######################## End Mod Image Battle #################
$table_fields = $site_db->get_table_fields(IMAGES_TABLE);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
//######################## Start Mod Image Battle ###############
if($key == 'image_editor'){
$additional_sql .= ", image_editor ='".(($image_row['image_editor'] != "") ? $image_update.";".$image_row['image_editor'] : $image_update )."'";
}
//######################## End Mod Image Battle #################
8.2) search in member.php in section "if ($action == "editimage") {":
$txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".format_text($image_row['image_name'], 2)."</a>".$config['category_separator'];
insert above:
//######################## Start Mod Image Battle ###############
if ($image_row || ($user_info['user_level'] >= USER) && ($image_row['image_battle'] || $config['user_battle'])) {
$image_editor = $image_row['user_id'];
}else{
$image_editor = $user_info['user_id'];
}
if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($image_editor != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
redirect($url);
}
//######################## End Mod Image Battle #################
8.3) search in member.php in section "if ($action == "editimage") {":
"edit_imagethumb" => ($config['user_edit_imagethumb']) ? 1:0,
insert above:
"image_owner" => ($config['user_battle'])?(($user_info['user_id'] == $image_row['user_id']) ? 1 :""):"",
8.4) search in member.php in section "if ($action == "uploadform") {" :
$site_template->register_vars(array(
"cat_id" => $cat_id,
and replace:
$site_template->register_vars(array(
//######################## Start Mod Image Battle ###############
"user_battle" => ($config['user_battle'] ? 1:""),
//######################## End Mod Image Battle ###############
"cat_id" => $cat_id,
9.) serach in details.php:
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
and replace:
elseif ($is_image_owner || (($user_info['user_level'] >= USER) && ($image_row['image_battle'] && $config['user_battle']))) { //########## image_battle ###########
$admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
9.1) search:
//-----------------------------------------------------
//--- Print Out ---------------------------------------
insert above:
//################### Start Mod image_battle #####################
if(($image_row['image_editor'] !='') || ($config['user_battle'])){
$imageUpdateArray = explode(";",$image_row['image_editor']);
$imageLastEditor = explode(",",$imageUpdateArray[0]);
$imageEditor = "<select class= \"imageEditor\" name=\"imageEditor\" onChange=\"window.location.href=this.value\">";
$user_link = ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$imageLastEditor[0];
$imageEditor .= "<option value=\"".$site_sess->url($user_link)."\">".$imageLastEditor[1]." am ".$imageLastEditor[2]."</option>";
foreach ($imageUpdateArray as $key => $val) {
$val = explode(",", $imageUpdateArray[$key]);
$user_profile_link[$key] = ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$val[0];
$imageEditor .= "<option value=\"".$site_sess->url($user_profile_link[$key])."\">".$val[1]." am ".$val[2]."</option>";
}
$imageEditor .= "</select>";
}
$site_template->register_vars(array(
"image_battle" => ($config['user_battle']) ? $image_row['image_battle'] :"",
"lang_image_editor" => $lang['image_editor'],
"image_editor" => $imageEditor
));
10.) search in your templates/details.html:
<td valign="top" class="row2">{user_name_link}</td>
</tr>
insert below:
{if image_battle}
<tr>
<td valign="top" class="row1"><b>{lang_image_editor}</b></td>
<td valign="top" class="row1">{image_editor}</td>
</tr>
{endif image_battle}
11.) search in your templates/member_editimage.html:
<textarea name="image_keywords" cols="30" rows="10" wrap="virtual" class="textarea">{image_keywords}</textarea>
</td>
</tr>
insert below:
{if image_owner}
<tr>
<td class="row1"><b>{lang_image_battle}</b></td>
<td class="row1">
<input type="radio" name="image_battle" value="1" {image_battle_yes} />
{lang_yes}
<input type="radio" name="image_battle" value="0" {image_battle_no} />
{lang_no}</td>
</tr>
{endif image_owner}
12.) search in your templates/member_uploadform.html:
<textarea cols="30" class="textarea" rows="10" name="image_keywords">{image_keywords}</textarea>
</td>
</tr>
insert below:
{if user_battle}
<tr>
<td class="row1"><b>{lang_image_battle}</b></td>
<td class="row1">
<input type="radio" name="image_battle" value="1" {image_battle_no} />
{lang_yes}
<input type="radio" name="image_battle" value="0" {image_battle_yes} />
{lang_no}</td>
</tr>
{endif user_battle}
13.)search in your template/thumbnail_bit.html and insert where ever you want:
{if image_battle}<sup class="imageBattle">{lang_image_battle}</sup>{endif image_battle}
14.) search in your templates/style.css "?>" and insert above:
.imageEditor{
border:0 outset;
background-color: #E5E5E5;
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
width: 200px;
}
.imageBattle {
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
font-size: 11px;
color: Green;
}
mfg Andi