MyBB.de Forum

Normale Version: Für jedes Miglied eigene Info
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo,

ist es duch Codeveränderung oder ein Plugin möglich auf der Index Seite des Forums für jedes einzelne Mitglied eine Message zu hinterlegen. Natürlich dürfen die anderen diese Message nicht lesen! Schaut euch das Beispiel auf dem Screen bitte an!

Vielen Dank!!

MFG
Ich benutze ein Plugin, das solche Nachrichten für einzelne Mitglieder-GRUPPEN ermöglicht. Würde Dir das ausreichen?
Ja das wär auch erstaml super, vielleicht kann ja jemand das Plugin dann umformen? Aber ein solches Plugin kann ich leider nicht finden!
Super vielen Dank! Könnte mir jemand den Code so umformen, dass jeweils nur festgelegte Mitglieder die Information sehen können. Zudem soll es möglich sein, dass mehrere Infotexte an verschiedene Mitglieder sichtbar gemacht werden!
Z.B:
Typ A kann nur Text B lesen!
Typ B kann nur Text A lesen!

Hier die verschiedenen Codes. Wäre für Hilfe sehe dankbar!!!!!!!

importantmsg.php
PHP-Code:
<?php
/**
 * Copyright © 2006 CraKteR.
 */
if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}

$plugins->add_hook('admin_index_navigation_end''importantmsgs_add_links'1000000);
$plugins->add_hook('admin_adminoptions_do_updateperms''importantmsgs_add_adminpermission'100000);
$plugins->add_hook('admin_adminoptions_adminpermissions_yesnocodes''importantmsgs_add_yesnocode'100000);
$plugins->add_hook('global_end''importantmsgs_add_msgs'1000000);

function 
importantmsgs_info() {
    return array(
        
"name"            =>    "Important messages on index.",
        
"description"    =>    "Show Important messages on index.",
        
"website"        =>    "http://mcdcpp.net/",
        
"author"        =>    "CraKteR",
        
"authorsite"    =>    "mailto:crakter@gmail.com",
        
"version"        =>    "1.3.7"
    
);
}

function 
importantmsgs_activate() {
    global 
$db;
    
$template = array(
        
"title"        => "important_msgs",
        
"template"    => "<p {\$class}{\$id}{\$style}>{\$img}<strong>{\$title}</strong><br />{\$message}</p>",
        
"sid"        => -1
    
);
    
$db->insert_query(TABLE_PREFIX."templates"$template);
    
    
$wm_template = array(
        
"title"        => "important_msgs_alt",
        
"template"    => "<table border=\"0\" cellspacing=\"{\$theme[\'borderwidth\']}\" cellpadding=\"{\$theme[\'tablespace\']}\" class=\"tborder\">
<thead>
    <tr>
        <td class=\"thead\">
            <div class=\"expcolimage\"><img src=\"{\$theme[\'imgdir\']}/collapse{\$collapsedimg[\$cid]}.gif\" id=\"important_{\$id}_img\" class=\"expander\" alt=\"[-]\" /></div><div>{\$img}<strong>{\$title}</strong></div>
        </td>
    </tr>
</thead>
<tbody style=\"{\$collapsed[\$cid2]}\" id=\"important_{\$id}_e\">
    <tr>
        <td class=\"trow1\"><span{\$style}>{\$message}</span></td>
    </tr>
</tbody>
</table>
<br/>"
,
        
"sid"        => -1
    
);

    
$db->insert_query(TABLE_PREFIX."templates"$wm_template);
    
    
$db->query("CREATE TABLE ".TABLE_PREFIX."importantmsgs (
      `mid` int unsigned NOT NULL auto_increment,
      `title` varchar(255) NOT NULL default '',
      `message` text NOT NULL default '',
      `usergroups` varchar(40) NOT NULL default '-1',
      `bgcolor` varchar(20) NOT NULL default '',
      `color` varchar(20) NOT NULL default '',
      `class` varchar(20) NOT NULL default '',
      `id` varchar(20) NOT NULL default '',
      `image` varchar(50) NOT NULL default '',
      `ord` int(4) NOT NULL default '0',
      `style` int(1) NOT NULL default '0',
      `global` int(1) NOT NULL default '0',
      PRIMARY KEY  (mid)
    ) TYPE=MyISAM;"
);
    
    
$db->query("ALTER TABLE ".TABLE_PREFIX."adminoptions ADD `canaddimportantmessage` char(3) NOT NULL default '' AFTER `canrundbtools`");
    
$db->query("UPDATE ".TABLE_PREFIX."adminoptions SET canaddimportantmessage='yes' WHERE uid='1'");
    
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";

    
find_replace_templatesets("index"'#{\$header}#'"{\$header}{\$importantmsgs}");
    
find_replace_templatesets("header"'#<div id=\"content\">#'"<!--IMPORTANT-->\n\t\t<div id=\"content\">");
}

function 
importantmsgs_deactivate() {
    global 
$db;
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='important_msgs'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='important_msgs_alt'");
    
    
$db->query("DROP TABLE ".TABLE_PREFIX."importantmsgs");

    
$db->query("ALTER TABLE ".TABLE_PREFIX."adminoptions DROP `canaddimportantmessage`");
    
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";

    
find_replace_templatesets("index"'#(\r?)(\n?)(\t?)(\t?){\$importantmsgs}#'""0);
    
find_replace_templatesets("header"'#(\r?)(\n?)(\t?)(\t?)<!--IMPORTANT-->#'""0);
}

function 
importantmsgs_add_links() {
    global 
$menu$lang;
    
$lang->load("importantmsgs");
    
$menu[260] = array(
        
"title" => $lang->important,
        
"items" => array(
            
10 => array("title" => $lang->add_msg"url" => "importantmsgs.php?".SID."&amp;action=add"),
            
20 => array("title" => $lang->edit_msg"url" => "importantmsgs.php?".SID),
            
30 => array("title" => $lang->reset"url" => "importantmsgs.php?".SID."&amp;action=reset")
        )
    );
}

function 
importantmsgs_add_msgs() {
    global 
$mybb$db$importantmsgs$templates$collapsed$collapsedimg$theme$headerinclude$header;
    
$importantmsgs $impmsgsglobal "";
    
$options = array(
        
"order_by" => "ord",
        
"order_dir" => "ASC"
    
);
    
$query $db->simple_select(TABLE_PREFIX."importantmsgs""*"""$options);
    require_once 
MYBB_ROOT."inc/class_parser.php";
    
$parser = new postParser;
    
$var "importantmsgs";
    if(
$db->num_rows($query) > 0) {
        
$headerinclude .= "\n<style type=\"text/css\">
p.important {
    background-color: #efefef;
    color: #000000;
    border-top: 2px solid #d4d4d4;
    border-bottom: 2px solid #d4d4d4;
    text-align: center;
    margin: 10px auto;
    padding: 5px 20px;
}
</style>"
;
    }
    while(
$msg $db->fetch_array($query)) {
        if(
$msg['global'] == 1) {
            
$var "impmsgsglobal";
        } else {
            
$var "importantmsgs";
        }
        
$groups explode(','$msg['usergroups']);
        if(!
is_array($groups)) {
            
$groups[0] = $msg['usergroups'];
        }
        if(!
in_array(-1$groups)) {
            if(
in_array(-2$groups) || !in_array($mybb->user['usergroup'], $groups)) {
                continue;
            }
            
$additionalgroups explode(','$mybb->user['additionalgroups']);
            if(!
is_array($additionalgroups)) {
                
$additionalgroups[0] = $mybb->user['additionalgroups'];
            }
            foreach(
$additionalgroups as $additionalgroup) {
                if(!
in_array($additionalgroup$groups)) {
                    continue;
                }
            }
        }
        if(
$msg['class'] == "") {
            
$class "class=\"important\"";
        } else {
            
$class "class=\"".stripslashes($msg['class'])."\"";
        }
        if(
$msg['id'] != "") {
            
$id " id=\"".stripslashes($msg['id'])."\"";
        }
        if(
$msg['image'] != "") {
            
$img "<img src=\"".$msg['image']."\" alt=\"Important\" />";
        }
        if(
$msg['bgcolor'] != "" || $msg['color'] != "") {
            
$bgcolor = ($msg['bgcolor'] != "") ? "background-color: ".stripslashes($msg['bgcolor'])."; " " ";
            
$color = ($msg['color'] != "") ? "color: ".stripslashes($msg['color']).";" "";
            
$style " style=\"".$bgcolor.$color."\"";
        }
        
$parser_options = array(
            
"allow_html" => "yes",
            
"allow_mycode" => "yes",
            
"allow_smilies" => "yes",
            
"allow_imgcode" => "yes"
        
);

        
$message $parser->parse_message($msg['message'], $parser_options);
        
$title $parser->parse_message($msg['title'], $parser_options);
        
$username htmlspecialchars_uni($mybb->user['username']);
        
$message str_replace('{username}'$username$message);
        
$title str_replace('{username}'$username$title);
        
$uid htmlspecialchars_uni($mybb->user['uid']);
        
$message str_replace('{uid}'$uid$message);
        
$title str_replace('{uid}'$uid$title);
        if(
$msg['style'] == 1) {
            
$id $msg['mid'];
            
$cid "important_".$id;
            
$cid2 $cid."_e";
            eval(
"\$$var .= \"".$templates->get("important_msgs_alt")."\";");
        } else {
            eval(
"\$$var .= \"".$templates->get("important_msgs")."\";");
        }
    }
    if(isset(
$impmsgsglobal) && $impmsgsglobal != "") {
        
$header str_replace('<!--IMPORTANT-->'$impmsgsglobal$header);
    }
}

function 
importantmsgs_add_adminpermission() {
    global 
$sqlarray$db$newperms;
    
$sqlarray['canaddimportantmessage'] = $db->escape_string($newperms['canaddimportantmessage']);
}

function 
importantmsgs_add_yesnocode() {
    global 
$permissions;
    
makeyesnocode("Can add important message""newperms[canaddimportantmessage]"$permissions['canaddimportantmessage']);
}
?>

////////////////////////////////////////////////////////////////////

importantmsgs.lang.php

PHP-Code:
<?php
/**
 * Copyright © 2006 CraKteR.
 */
$l['add_important'] = "Add important message";
$l['important'] = "Important messages";
$l['edit_important'] = "Edit important message";

$l['add_msg'] = "Add message";
$l['edit_msg'] = "Edit message";
$l['reset'] = "Reset messages";
$l['top_title'] = "Title";

$l['title'] = "Title:<br /><small>You may use {uid} and {username} in your message.</small>";
$l['message'] = "Message:<br /><small>You may use {uid} and {username} in your message.</small>";
$l['showusersgroups'] = "Show to usergroups:";
$l['bgcolor'] = "Background color:";
$l['txtcolor'] = "Text color:";
$l['css_class'] = "CSS class:";
$l['css_id'] = "CSS id:";
$l['image'] = "Image:";
$l['order'] = "Order:";
$l['style'] = "Style:";
$l['submit'] = "Insert important message";
$l['submit_update'] = "Update important message";

$l['imgdesc'] = "Want an image to show? input here.";
$l['iddesc'] = "Have an CSS class already? input here. Does not work on alternative style";
$l['classdesc'] = "Have an CSS id already? input here. Does not work on alternative style";
$l['usersdesc'] = "None selected will show for all.";
$l['orderdesc'] = "Which message should display first";

$l['important_added'] = "Important messages added";
$l['important_edited'] = "Important messages edited";
$l['important_deleted'] = "Important message deleted";
$l['important_reseted'] = "Important message reseted";
$l['no_important'] = "No important message at this time.";
$l['edit'] = "Edit";
$l['delete'] = "Delete";
$l['options'] = "Options";

$l['default'] = "Default style";
$l['alt'] = "Alternative style";

$l['globally'] = "Show message globally:";
$l['show_none'] = "Shows for none";
$l['usergroups'] = "Shows for usersgroups:";
$l['show_all'] = "Shows for all";
?>

////////////////////////////////////////////////////////////////

und Admin/importantmsgs.php

PHP-Code:
<?php
/**
 * Copyright © 2006 CraKteR.
 */
define("IN_MYBB"1);

require_once 
"./global.php";

checkadminpermissions("canaddimportantmessage");
logadmin();

$lang->load("importantmsgs");

addacpnav($lang->important"importantmsgs.php?".SID);
$mid intval($mybb->input['mid']);
switch(
$mybb->input['action']) {
    case 
"add":
        
addacpnav($lang->add_important);
        
$plugins->run_hooks("admin_importantmsgs_add");
        
cpheader();
        
startform("importantmsgs.php""""do_add");
        
starttable();
        
tableheader($lang->add_important);
        
makeinputcode($lang->title"title""""40");
        
maketextareacode($lang->message"message""""20""80");
        
$bgcolor getaltbg();
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->showusersgroups</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">";
        echo 
"<input type=\"checkbox\" name=\"usersgroups[]\" value=\"-2\" /> ".$lang->show_none."<br />";
        echo 
make_usergroup_checkbox_code('usersgroups');
        echo 
"\n</td>\n</tr>\n";
        
makeinputcode($lang->bgcolor"bgcolor");
        
makeinputcode($lang->txtcolor"color");
        
makeinputcode($lang->css_class"class""""25"$lang->classdesc);
        
makeinputcode($lang->css_id"css_id""""25"$lang->iddesc);
        
makeinputcode($lang->image"image""""25"$lang->imgdesc);
        
makeinputcode($lang->order"order""""25"$lang->orderdesc);
        
$bgcolor getaltbg();
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->style</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">
        <select name=\"style\">
            <option value=\"0\" selected=\"selected\">
$lang->default</option>
            <option value=\"1\">
$lang->alt</option>
        </select>\n</td>\n</tr>\n"
;
        
$bgcolor getaltbg();
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->globally</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">";
        echo 
"<input type=\"checkbox\" name=\"global\" value=\"1\" />";
        echo 
"\n</td>\n</tr>\n";
        
endtable();
        
endform($lang->submit$lang->reset_button);
        
cpfooter();
        break;
    case 
"edit":
        
addacpnav($lang->edit_important);
        
$query $db->simple_select(TABLE_PREFIX."importantmsgs""*""mid='$mid'");
        
$msg $db->fetch_array($query);
        
$plugins->run_hooks("admin_importantmsgs_edit");
        
cpheader();
        
startform("importantmsgs.php""""do_edit");
        
makehiddencode("mid"$mid);
        
starttable();
        
tableheader($lang->edit_important);
        
makeinputcode($lang->title"title"$msg['title'], "40");
        
maketextareacode($lang->message"message"$msg['message'], "20""80");
        
$bgcolor getaltbg();
        
$groups explode(','$msg['usergroups']);
        if(
in_array('-2'$groups)) {
            
$checked " checked=\"checked\"";
        }
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->showusersgroups</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">";
        echo 
"<input type=\"checkbox\" name=\"usersgroups[]\" value=\"-2\"$checked /> ".$lang->show_none."<br />";
        echo 
make_usergroup_checkbox_code('usersgroups'$groups);
        echo 
"\n</td>\n</tr>\n";
        
makeinputcode($lang->bgcolor"bgcolor"$msg['bgcolor']);
        
makeinputcode($lang->txtcolor"color"$msg['color']);
        
makeinputcode($lang->css_class"class"$msg['class'], "25"$lang->classdesc);
        
makeinputcode($lang->css_id"css_id"$msg['id'], "25"$lang->iddesc);
        
makeinputcode($lang->image"image"$msg['image'], "25"$lang->imgdesc);
        
makeinputcode($lang->order"order"$msg['order'], "25"$lang->orderdesc);
        
$as $df "";
        if(
$msg['style'] == 1) {
            
$as " selected=\"selected\"";
        } else {
            
$df " selected=\"selected\"";
        }
        
$bgcolor getaltbg();
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->style</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">
        <select name=\"style\">
            <option value=\"0\"
$df>$lang->default</option>
            <option value=\"1\"
$as>$lang->alt</option>
        </select>\n</td>\n</tr>\n"
;
        
$bgcolor getaltbg();
        if(
$msg['global'] == 1) {
            
$check " checked=\"checked\"";
        }
        echo 
"<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$lang->globally</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">";
        echo 
"<input type=\"checkbox\" name=\"global\" value=\"1\"$check />";
        echo 
"\n</td>\n</tr>\n";
        
endtable();
        
endform($lang->submit_update$lang->reset_button);
        
cpfooter();
        break;
    case 
"do_add":
        if(
is_array($mybb->input['usersgroups'])) {
            
$usergroups implode(','$mybb->input['usersgroups']);
        } else {
            
$usergroups "-1";
        }
        
$sqlarray = array(
            
"title" => $db->escape_string($mybb->input['title']),
            
"message" => $db->escape_string($mybb->input['message']),
            
"usergroups" => $db->escape_string($usergroups),
            
"bgcolor" => $db->escape_string($mybb->input['bgcolor']),
            
"color" => $db->escape_string($mybb->input['color']),
            
"class" => $db->escape_string($mybb->input['class']),
            
"id" => $db->escape_string($mybb->input['css_id']),
            
"image" => $db->escape_string($mybb->input['image']),
            
"ord" => $db->escape_string($mybb->input['order']),
            
"style" => intval($db->escape_string($mybb->input['style'])),
            
"global" => intval($db->escape_string($mybb->input['global']))
        );
        
$plugins->run_hooks("admin_importantmsgs_do_add");
        
$db->insert_query(TABLE_PREFIX."importantmsgs"$sqlarray);
        
cpredirect("importantmsgs.php?".SID$lang->important_added);
        break;
    case 
"do_edit":
        if(
is_array($mybb->input['usersgroups'])) {
            
$usergroups implode(','$mybb->input['usersgroups']);
        } else {
            
$usergroups = -1;
        }
        
$sqlarray = array(
            
"mid" => $mid,
            
"title" => $db->escape_string($mybb->input['title']),
            
"message" => $db->escape_string($mybb->input['message']),
            
"usergroups" => $db->escape_string($usergroups),
            
"bgcolor" => $db->escape_string($mybb->input['bgcolor']),
            
"color" => $db->escape_string($mybb->input['color']),
            
"class" => $db->escape_string($mybb->input['class']),
            
"id" => $db->escape_string($mybb->input['css_id']),
            
"image" => $db->escape_string($mybb->input['image']),
            
"ord" => $db->escape_string($mybb->input['order']),
            
"style" => intval($db->escape_string($mybb->input['style'])),
            
"global" => intval($db->escape_string($mybb->input['global']))
        );
        
$plugins->run_hooks("admin_importantmsgs_do_edit");
        
$db->update_query(TABLE_PREFIX."importantmsgs"$sqlarray"mid='".$sqlarray['mid']."'");
        
cpredirect("importantmsgs.php?".SID$lang->important_edited);
        break;
    case 
"delete":
        if(
$mid) {
            
$plugins->run_hooks("admin_importantmsgs_delete");
            
$db->delete_query(TABLE_PREFIX."importantmsgs""mid='".$mid."'");
            
cpredirect("importantmsgs.php?".SID$lang->important_deleted);
            exit;
        }
        break;
    default:
        
$plugins->run_hooks("admin_importantmsgs_modify");
        
cpheader();
        
$hopto[] = "<input type=\"button\" value=\"$lang->add_important\" onclick=\"hopto('importantmsgs.php?".SID."&amp;action=add');\" class=\"hoptobutton\" />";
        
makehoptolinks($hopto);
        
starttable();
        
tableheader($lang->add_important""4);
        echo 
"<tr>\n";
        echo 
"\t<td class=\"subheader\">{$lang->top_title}</td>\n";
        echo 
"\t<td class=\"subheader\">{$lang->usergroups}</td>\n";
        echo 
"\t<td class=\"subheader\" colspan=\"2\" align=\"center\">$lang->options</td>\n";
        echo 
"</tr>\n";
        
$options = array(
            
"order_by" => "ord",
            
"order_dir" => "ASC"
        
);
        
$query $db->simple_select(TABLE_PREFIX."importantmsgs""*"""$options);
        
$options = array(
            
'order_by' => 'title',
            
'order_dir' => 'ASC'
        
);
        while(
$msg $db->fetch_array($query))
        {
            
$bgcolor getaltbg();
            if(
$msg['usergroups'] == -1)
            {
                
$usergroups $lang->show_all;
            }
            else if(
$msg['usergroups'] == 0)
            {
                
$usergroups $lang->show_none;
            }
            else
            {
                
$query2 $db->simple_select(TABLE_PREFIX."usergroups""title""gid IN({$msg['usergroups']})"$options);
                
$usergroups = array();
                while(
$usergroup $db->fetch_array($query2))
                {
                    
$usergroups[] = $usergroup['title'];
                }
                
$usergroups implode('<br />'$usergroups);
            }
            echo 
"<tr>\n";
            echo 
"<td class=\"$bgcolor\" width=\"42%\">".$msg['title']."</td>\n";
            echo 
"<td class=\"$bgcolor\">";
            echo 
$usergroups;
            echo 
"</td>\n";
            echo 
"<td class=\"$bgcolor\" align=\"center\">";
            
startform("importantmsgs.php""""edit");
            
makehiddencode("mid"$msg['mid']);
            echo 
"<input type=\"submit\" name=\"edit\" value=\"$lang->edit\" class=\"submitbutton\" />";
            
endform();
            echo 
"</td>\n";
            echo 
"<td class=\"$bgcolor\" align=\"center\">";
            
startform("importantmsgs.php""""delete");
            
makehiddencode("mid"$msg['mid']);
            echo 
"<input type=\"submit\" name=\"delete\" value=\"$lang->delete\" class=\"submitbutton\" />";
            
endform();
            echo 
"</td>\n";
            echo 
"</tr>\n";
            
$done 1;
        }
        if(!
$done) {
            
makelabelcode("<div align=\"center\">$lang->no_important</div>"""4);
        }
        
endtable();
        
cpfooter();
        break;
}
?>


VIELEN DANK DÜR JEDEN DER HELFEN KANN!!!!!!
Anscheinend kann mir keiner helfen oder gibt es doch jemanden. Kann mir jemand vielleicht ein neues erstellen. Muss nicht so aufwenig sein!
Nur so eine Idee ... weiß nicht ob das möglich ist, da ich mich mit der Gruppenverwaltung noch nie ernsthaft beschäftigt habe.

Du könntest doch neue Gruppen erstellen und den Mitgliedern, die Nachrichten erhalten sollen, diese neuen Gruppen als sekundäre Benutzergruppe zuweisen; dann noch im Plugin diese Gruppen für die Anzeige der Nachrichten markieren.
Achso. Leider kann ich das nicht. Könnte das jemand vielleicht machen? Habe null Ahnung voll umschreiben etc.