禁止查看其他人的个人资料-Datalife Engine

禁止查看用户个人资料。
规则profile.php。个人资料页面只能查看某些群组。

安装
打开engine / modules / profile.php文件并查找:

<span class="variable">$tpl</span>->compile(<span class="string">'content'</span>);

上面我们插入:

<span class="keyword">if</span> (<span class="variable">$is_logged</span> AND <span class="variable">$member_id</span>[<span class="string">'name'</span>] == <span class="variable">$row</span>[<span class="string">'name'</span>] OR <span class="variable">$member_id</span>[<span class="string">'user_group'</span>] == <span class="number">1</span>) {
        <span class="variable">$tpl</span>->set(<span class="string">'[member_name]'</span>, <span class="string">""</span>);
        <span class="variable">$tpl</span>->set(<span class="string">'[/member_name]'</span>, <span class="string">""</span>);
    } <span class="keyword">else</span> {
        <span class="keyword">if</span> (<span class="variable">$is_logged</span>) {
            <span class="variable">$tpl</span>->set_block(<span class="string">"'\\[member_name\\](.<span class="variable">*?</span>)\\[/member_name\\]'si"</span>, <span class="string">""</span>);
            msgbox(<span class="variable">$lang</span>[<span class="string">'all_info'</span>], <span class="string">"Вы можете просматривать только свой профиль!"</span>);
        }
        <span class="keyword">if</span> (!<span class="variable">$is_logged</span>) {            
            <span class="variable">$tpl</span>->set_block(<span class="string">"'\\[member_name\\](.<span class="variable">*?</span>)\\[/member_name\\]'si"</span>, <span class="string">""</span>);
            msgbox(<span class="variable">$lang</span>[<span class="string">'all_info'</span>], <span class="string">"У вас нет прав просматривать профиль!"</span>);
        }
    }

打开userinfo.tpl模板文件并包装整个内容:

<span class="attr_selector">[member_name]</span> 
  содержимое <span class="tag">userinfo</span><span class="class">.tpl</span>
<span class="attr_selector">[/member_name]</span>

如果我们想要指定特定的ID而不是组,我们会更改:

<span class="variable">$member_id</span>[<span class="string">'user_group'</span>] == <span class="number">1</span>

<span class="variable">$member_id</span>[<span class="string">'user_id'</span>] == <span class="number">1</span>

对于几个群体:

in_array(<span class="variable">$member_id</span>[<span class="string">'user_group'</span>], <span class="keyword">array</span>(<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>,<span class="number">5</span>))

完成!

订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x