Rispondi 
Admin Edit
Autore Messaggio
Dvdxseo Assente
Vecchia guardia
*******

Messaggi: 1.222
Registrato: Aug 2008
Reputazione: 19
Versione: MyBB 1.6.5
Messaggio: #1
Admin Edit
Questo plugin permette agli admin di modificare l'username di un messaggio, la data, l'ip e dà altre funzioni quando si modifica un messaggio (Solo agli admin)
Versione Inglese (By Yumi http://mods.mybboard.net/download/admin-post-editing )

Italiano in allegato. (Hostare in /inc/plugins e attivare (se già attivo disattivare e poi attivare))

Ciao03


Allegati
.php  adminpedit.php (Dimensione: 6,25 KB / Download: 1)

Purtroppo non ho molto tempo da dedicare al forum, spero di poter tornare.. Scusatemi ragazzi. Non voglio abbandonare questo forum..
27-12-2009 11:36
Trova tutti i messaggi di questo utente Cita questo messaggio nella tua risposta
Tropic Offline
Novizio
*

Messaggi: 10
Registrato: Sep 2011
Reputazione: 0
Versione: MyBB 1.6.5
Messaggio: #2
RE: Admin Edit
Ho modificato il plugin per la versione MyBB 1.6 dato che quello non funzionava.
L'ho testato ed è funzionante.

Codice PHP:
<?php

if(!defined("IN_MYBB"))
    die(
"This file cannot be accessed directly.");

$plugins->add_hook('editpost_start''adminpedit_editpost');
$plugins->add_hook('editpost_do_editpost_start''adminpedit_do_editpost_start');

function 
adminpedit_info()
{
    return array(
        
'name'            => 'Admin Post Edit',
        
'description'    => 'Aggiunge pi&ugrave; opzioni di modifica quando si modifica un messaggio (solo admin).',
        
'website'        => 'http://mybbhacks.zingaburga.com/',
        
'author'        => 'ZiNgA BuRgA',
        
'authorsite'    => 'http://zingaburga.com/',
        
'version'        => '1.6',
        
'compatibility'    => '16*',
        
'guid'            => '4661af5161be4b6c4e43ec46edbcc959'
    
);
}


function 
adminpedit_activate()
{
    global 
$db;
    
    require 
MYBB_ROOT.'inc/adminfunctions_templates.php';
    
find_replace_templatesets('editpost''#'.preg_quote('<input type="hidden" name="action" value="do_editpost" />').'#''{$adminopt}<input type="hidden" name="action" value="do_editpost" />');
    
    
$db->insert_query('templates', array(
        
'title' => 'editpost_adminopt',
        
'template' => $db->escape_string(
'<br />
<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>Opzioni per l\'amministratore</strong></td>
</tr>
<tr>
<td width="50%" class="trow1">
<strong>Modifica il tempo</strong>
<br /><span class="smalltext">Questo segue il formato <a href="http://www.unixtimestamp.com/">Unix timestamp</a></span>
</td>
<td class="trow1"><input type="text" name="posttime" value="{$dateline}" class="textbox" /></td>
</tr>
<tr>
<td width="50%" class="trow2">
<strong>Utente Postatore</strong>
<br /><span class="smalltext">L\'utente che ha scritto questo messaggio</span>
</td>
<td class="trow2"><input type="text" name="postusername" value="{$postusername}" class="textbox" />
<br /><label><input type="checkbox" name="postreguser" value="yes" class="checkbox"{$regusercheck} /> Messaggio scritto da un utente registrato</label></td>
</tr>
<tr>
<td width="50%" class="trow1">
<strong>IP Messaggio</strong>
<br /><span class="smalltext">Questo è l\'ip con il quale l\'utente ha scritto questo messaggio.</span>
</td>
<td class="trow1"><input type="text" name="postip" value="{$ipaddress}" class="textbox" /></td>
</tr>
{$editopt}
</table>
'
        
),
        
'sid' => -1,
        
'version' => '1400'
    
));
}

function 
adminpedit_deactivate()
{
    global 
$db;
    require 
MYBB_ROOT.'inc/adminfunctions_templates.php';
    
find_replace_templatesets('editpost''#'.preg_quote('{$adminopt}').'#'''0);
    
$db->delete_query('templates''sid=-1 AND title = "editpost_adminopt"');
}

function 
adminpedit_editpost()
{
    global 
$mybb;
    if(
$mybb->usergroup['cancp'] != 1) return;
    
    global 
$templates$post$adminopt$theme;
        if(!
$post['pid']) {
        
$pid intval($mybb->input['pid']);
        if(
$pid$post get_post($pid);
        if(!
$post['pid']) return;
    }
    
// uid, username, dateline, ipaddress, edituid, edittime
    
if($post['uid'] || $mybb->input['postreguser'] == 'yes')
        
$regusercheck ' checked="checked"';
    else
        
$regusercheck '';
    if(
$mybb->input['postusername'])
        
$postusername htmlspecialchars_uni($mybb->input['postusername']);
    else
        
$postusername htmlspecialchars_uni($post['username']);
    
    if(
$mybb->input['posttime'])
        
$dateline intval($mybb->input['posttime']);
    else
        
$dateline $post['dateline'];
    
    if(
$mybb->input['postip'])
        
$ipaddress htmlspecialchars($mybb->input['postip']);
    else
        
$ipaddress $post['ipaddress'];
    
    
// silent/clear editing
    
$editopt '';
    if(
$mybb->settings['showeditedbyadmin'] == 1)
        
$editopt .= '<br /><label><input type="radio" name="editopt" value="silent"'.($mybb->input['editopt'] == 'silent' ' checked="checked"' '').' /> Fai una modifica &quot;Sileziosa&quot; (Non mostra la riga &quot;Ultima modifica di&quot;)</label>';
    if(
$post['edituid'])
        
$editopt .= '<br /><label><input type="radio" name="editopt" value="reset"'.($mybb->input['editopt'] == 'reset' ' checked="checked"' '').' /> Rimuovi la riga &quot;Ultima modifica di&quot; da questo messaggio.</label>';
    
    if(
$editopt)
        
$editopt '<tr><td class="trow2" width="50%"><strong>Edit Options</strong></td><td class="trow2"><label><input type="radio" name="editopt" value="normal"'.($mybb->input['editopt'] != 'silent' && $mybb->input['editopt'] != 'reset' ' checked="checked"' '').' /> Modifica Normalmente.</label>'.$editopt.'</td></tr>';
    eval(
'$adminopt = "'.$templates->get('editpost_adminopt').'";');
}

function 
adminpedit_do_editpost_start()
{
    global 
$mybb;
    if(
$mybb->usergroup['cancp'] != 1) return;
    if(
$mybb->input['editopt'] == 'silent')
        
$mybb->settings['showeditedbyadmin'] = 'no';
    
$GLOBALS['plugins']->add_hook('editpost_do_editpost_end''adminpedit_do_editpost');
}

function 
adminpedit_do_editpost()
{
    global 
$post$thread$db$mybb;
    
$update_array = array();
    if(
$mybb->input['posttime'])
        
$update_array['dateline'] = intval($mybb->input['posttime']);
    if(
$mybb->input['postusername'])
        
$update_array['username'] = $db->escape_string($mybb->input['postusername']);
    
    if(
$mybb->input['postreguser'] == 'yes')
    {
        
// saerch for the UID
        
$uid $db->fetch_field($db->simple_select('users''uid''LOWER(username)="'.strtolower($update_array['username']).'"'), 'uid');
        if(!
$uiderror('Il nome utente specificato non esiste!');
        
$update_array['uid'] = $uid;
    }
    else
    {
        
$update_array['uid'] = 0;
    }
    
    
$thread_updates $update_array;
    
    if(
$mybb->input['postip'])
    {
        if(!
preg_match('#^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#'$mybb->input['postip']))
            
error('Invalid IP specified');
        
$postip array_map('intval'explode('.'$mybb->input['postip']));
        if(
$postip[0] > 255 || $postip[1] > 255 || $postip[2] > 255 || $postip[3] > 255)
            
error('IP Specificato non valido');
        
        
$update_array['ipaddress'] = implode('.'$postip);
    }
    
    if(
$mybb->input['editopt'] == 'reset')
    {
        
$update_array['edituid'] = 0;
        
$update_array['edittime'] = 0;
    }
    
    
// if it's the first post, we should update the thread...
    
$firstcheck $db->fetch_array($db->simple_select("posts""pid""tid='{$thread['tid']}'", array("limit" => 1"order_by" => "dateline""order_dir" => "asc")));
    if(
$firstcheck['pid'] == $post['pid'])
    {
        
$db->update_query('threads'$thread_updates'tid='.$thread['tid']);
    }

     
$db->update_query('posts'$update_array'pid='.$post['pid']);  
 
// if it's the last  post, we should update the thread and forums...
    
$lastcheck $db->fetch_array($db->simple_select("posts""pid""tid='{$thread['tid']}'", array("limit" => 1"order_by" => "dateline""order_dir" => "desc")));
    if(
$lastcheck['pid'] == $post['pid'])
    {
        
$update_array1['lastposter'] = $update_array['username'] ;
        
$update_array1['lastposteruid'] = $update_array['uid'] ;
        
$db->update_query('threads'$update_array1'tid='.$thread['tid']);  
        
$db->update_query('forums'$update_array1'lastposttid='.$thread['tid']);
}
 
}
?>
ecco uno screenshot
[URL=http://imageshack.us/photo/my-images/846/adminedit.jpg/][Immagine: adminedit.jpg]

L'utente ha aggiunto in seguito...
ACP - Strumenti e Manutenzione - Ricalcola messaggi utente

Altrimenti il contatore dell'utente non si aggiorna dopo la modifica di cambio user del messaggio
(Questo messaggio è stato modificato l'ultima volta il: 19-09-2011 10:39 da Tropic.)
19-09-2011 02:15
Visita il sito web di questo utente Trova tutti i messaggi di questo utente Cita questo messaggio nella tua risposta
Rispondi 


Vai al forum:


Utente(i) che stanno guardando questa discussione: 1 Ospite(i)