مرجع پارسی MyBB

نسخه‌ی کامل: درخواست کمک در مورد ساخت پلاگین محدودیت تعداد دانلود برای کاربر
شما درحال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب‌بندی مناسب.
سلام خواهش میکنم اگه میتونید کمک کنید

این کدهای پلاگین محدودیت تعداد پیام خصوصی هست:

کد php:
<?php
/**
 * Limit number of PMs
 * Copyright 2010 Starpaul20
 */

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Tell MyBB when to run the hooks
$plugins->add_hook('private_send_do_send''limitpm_run');
$plugins->add_hook('private_send_start''limitpm_run');
$plugins->add_hook('admin_formcontainer_output_row''limitpm_usergroup_permission');
$plugins->add_hook('admin_user_groups_edit_commit''limitpm_usergroup_permission_commit');

// The information that shows up on the plugin manager
function limitpm_info()
{
    return array(
        
"name"            => "Limit number of PMs",
        
"description"    => "Allows you to limit the number of Private Messages that a user in a usergroup can send in a day.",
        
"website"        => "http://galaxiesrealm.com/index.php",
        
"author"        => "Starpaul20",
        
"authorsite"    => "http://galaxiesrealm.com/index.php",
        
"version"        => "2.0.2",
        
"guid"            => "c13b1bac7595d16c854a60918453499a",
        
"compatibility" => "14*,16*"
    
);
}

// This function runs when the plugin is activated.
function limitpm_activate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxpmsday INT(3) NOT NULL DEFAULT '10'");

    
$cache->update_usergroups();
}

// This function runs when the plugin is deactivated.
function limitpm_deactivate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxpmsday");

    
$cache->update_usergroups();
}

function 
limitpm_run()
{
    global 
$mybb$db$lang;
    
$lang->load("limitpm");

    
// Check group limits
    
if($mybb->usergroup['maxpmsday'] > 0)
    {
        
$query $db->simple_select("privatemessages""COUNT(*) AS sent_count""fromid='{$mybb->user['uid']}' AND folder != 2 AND dateline >= '".(TIME_NOW - (60*60*24))."'");
        
$sent_count $db->fetch_field($query"sent_count");
        if(
$sent_count >= $mybb->usergroup['maxpmsday'])
        {
            
$lang->error_max_pms_day $lang->sprintf($lang->error_max_pms_day$mybb->usergroup['maxpmsday']);
            
error($lang->error_max_pms_day);
        }
    }
}

// Admin CP permission control
function limitpm_usergroup_permission($above)
{
    global 
$mybb$lang$form;
    
$lang->load("limitpm");

    if(
$above['title'] == $lang->private_messaging && $lang->private_messaging)
    {
        
$above['content'] .= "<div class=\"group_settings_bit\">{$lang->maxpmday}:<br /><small>{$lang->maxpmday_desc}</small><br /></div>".$form->generate_text_box('maxpmsday'$mybb->input['maxpmsday'], array('id' => 'maxpmsday''class' => 'field50'));
    }
}

function 
limitpm_usergroup_permission_commit()
{
    global 
$mybb$updated_group;
    
$updated_group['maxpmsday'] = intval($mybb->input['maxpmsday']);
}

?>
و این کدهای پلاگین محدودیت ارسال موضوع:

کد php:
<?php
/**
 * Limit number of Threads
 * Copyright 2010 Starpaul20
 */

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Tell MyBB when to run the hooks
$plugins->add_hook('newthread_start''limitthreads_run');
$plugins->add_hook('newthread_do_newthread_start''limitthreads_run');
$plugins->add_hook('admin_formcontainer_output_row''limitthreads_usergroup_permission');
$plugins->add_hook('admin_user_groups_edit_commit''limitthreads_usergroup_permission_commit');

// The information that shows up on the plugin manager
function limitthreads_info()
{
    return array(
        
"name"            => "Limit number of Threads",
        
"description"    => "Allows you to limit the number of threads that a user in a usergroup can post in a day.",
        
"website"        => "http://galaxiesrealm.com/index.php",
        
"author"        => "Starpaul20",
        
"authorsite"    => "http://galaxiesrealm.com/index.php",
        
"version"        => "2.0.1",
        
"guid"            => "5691f550ad5ec10de6fd86ab2f6590c4",
        
"compatibility" => "14*,16*"
    
);
}

// This function runs when the plugin is activated.
function limitthreads_activate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups ADD maxthreadsday INT(3) NOT NULL DEFAULT '10'");

    
$cache->update_usergroups();
}

// This function runs when the plugin is deactivated.
function limitthreads_deactivate()
{
    global 
$db$cache;
    
$db->query("ALTER TABLE ".TABLE_PREFIX."usergroups DROP maxthreadsday");

    
$cache->update_usergroups();
}

function 
limitthreads_run()
{
    global 
$mybb$db$lang;
    
$lang->load("limitthreads");

    
// Check group limits
    
if($mybb->usergroup['maxthreadsday'] > 0)
    {
        
$query $db->simple_select("threads""COUNT(*) AS thread_count""uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'");
        
$thread_count $db->fetch_field($query"thread_count");
        if(
$thread_count >= $mybb->usergroup['maxthreadsday'])
        {
            
$lang->error_max_threads_day $lang->sprintf($lang->error_max_threads_day$mybb->usergroup['maxthreadsday']);
            
error($lang->error_max_threads_day);
        }
    }
}

// Admin CP permission control
function limitthreads_usergroup_permission($above)
{
    global 
$mybb$lang$form;
    
$lang->load("limitthreads");

    if(
$above['title'] == $lang->posting_rating_options && $lang->posting_rating_options)
    {
        
$above['content'] .= "<div class=\"group_settings_bit\">{$lang->maxthreadsday}:<br /><small>{$lang->maxthreadsday_desc}</small><br /></div>".$form->generate_text_box('maxthreadsday'$mybb->input['maxthreadsday'], array('id' => 'maxthreadsday''class' => 'field50'));
    }
}

function 
limitthreads_usergroup_permission_commit()
{
    global 
$mybb$updated_group;
    
$updated_group['maxthreadsday'] = intval($mybb->input['maxthreadsday']);
}

?>

اگر دقت کنید میبینید هردو دقیقا یکی هستند فقط جای limitpm و limitthreads در این دو تغییر کرده .

حالا سوال اینجاست چطور میشه این محدودیت را برای فایلهای پیوست هم تعریفش کرد Cool

هر دو پلاگین هم ضمیمه شد:

(۱۳۹۰/۴/۱۵، ۲۰:۴۴:۰۴ عصر)M48D1 نوشته است: [ -> ]فایل های پیوست که برای هر پست در خود مای بی بی به طور پیش فرض هست اما به صورت محدودیت دار در روز نیست.

ولی تو به جای کد LImitPm میتونی بزنی

limitattachments

فکر کنم اونم حل بشه

ممنون. این کار را کردم ولی وقتی وارد صفحه پلاگینها شدم ارور Parse error و syntax erro داد
(۱۳۹۰/۴/۱۵، ۲۰:۴۴:۰۴ عصر)M48D1 نوشته است: [ -> ]فایل های پیوست که برای هر پست در خود مای بی بی به طور پیش فرض هست اما به صورت محدودیت دار در روز نیست.

ولی تو به جای کد LImitPm میتونی بزنی

limitattachments

فکر کنم اونم حل بشه

دوست گرامی اینی که شما دادی فقط نام پلاگین را در کد عوض می کند!
با جایگزینیlimitattachments میشه راش انداخت من نصبش هم کردم ولی موقع دانلود هیچ فایلی دانلود نمیشه و ارور زیر میاد:

SQL Error:
1054 - Unknown column 'dateline' in 'where clause'
Query:
SELECT COUNT(*) AS attachments_count FROM mybb_attachments WHERE uid='9' AND dateline >='1309936079'

که مربوط میشه به این خط (خط 60) از پلاگین

کد php:
$query $db->simple_select("attachments""COUNT(*) AS attachments_count""uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'"); 

این خط رو نمیدونم چطور باید تعریف کرد Huh
(۱۳۹۰/۴/۱۶، ۱۱:۴۴:۰۸ صبح)Farhoodi نوشته است: [ -> ]با جایگزینیlimitattachments میشه راش انداخت من نصبش هم کردم ولی موقع دانلود هیچ فایلی دانلود نمیشه و ارور زیر میاد:

SQL Error:
1054 - Unknown column 'dateline' in 'where clause'
Query:
SELECT COUNT(*) AS attachments_count FROM mybb_attachments WHERE uid='9' AND dateline >='1309936079'

که مربوط میشه به این خط (خط 60) از پلاگین

کد php:
$query $db->simple_select("attachments""COUNT(*) AS attachments_count""uid='{$mybb->user['uid']}' AND dateline >='".(TIME_NOW - (60*60*24))."'"); 

این خط رو نمیدونم چطور باید تعریف کرد Huh

در جدول attachments ستونی به نام dateline وجود ندراد.
به همین دلیل ساختن این پلاگین به سادگی دو پلاگین قبلی نیست.
پلاگین مورد نظر ساخته شد.
لینک : http://community.mybbiran.com/thread-6069.html