vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   have to set allowposting on/off on delay (https://vborg.vbsupport.ru/showthread.php?t=98399)

nexialys 10-14-2005 02:19 PM

have to set allowposting on/off on delay
 
allowposting is a permission, so set in the bitfields...
( $fmanager->set_bitfield('options', 'allowposting', 1); )

i need to set all forum tagged X to be closed at X hour... i just need to know how to set the permission per forum, and i can't find it...

i have my cron jobs for both situation (open/close) but i need to know the best way to deal with these two settings:

1- select each forum that have the proper tag
2- for each of these forums, set the proper permission and save

can someone help on that stupid task ?!

... btw, this gadget would be released to let admins set a forum they want to be open/closed on certain hours per day.. (like a nightlife forum...)

Andreas 10-14-2005 02:21 PM

PHP Code:

<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!
is_object($vbulletin->db))
{
    exit;
}

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
require_once(DIR '/includes/functions.php');
require_once(
DIR '/includes/adminfunctions.php');
require_once(
DIR '/includes/functions_databuild.php');


$delinfo = array(
    
'userid' => '0',
    
'username' => 'Time Limited Forum-Hack',
    
'reason' => ''
);

$forums $vbulletin->db->query_read("SELECT physicallydelete, options, timelimit, forumid, title_clean FROM " TABLE_PREFIX "forum WHERE timelimited=1");
while (
$forum $vbulletin->db->fetch_array($forums))
{
    
$starttime mktime(substr($forum['timelimit'], 02), substr($forum['timelimit'], 32))-1;
    
$endtime mktime(substr($forum['timelimit'], 62), substr($forum['timelimit'], 92))-1;
    
$now time();
    
// Overlapping day?
    
if ($endtime $starttime)
    {
            
$endtime += 86400;
    }
      if ((
$now $starttime) OR ($now $endtime))
    {
        
// Hide Forum
        
$forum['options'] &= ~$vbulletin->bf_misc_forumoptions['active'];
        
// Disallow posting
        
$forum['options'] &= ~$vbulletin->bf_misc_forumoptions['allowposting'];
            
// Remove the threads
        
$threads $vbulletin->db->query_read("SELECT * FROM " TABLE_PREFIX "thread
            WHERE forumid=
$forum[forumid]
                AND visible IN (0,1)
        "
);
        while (
$thread $vbulletin->db->fetch_array($threads))
        {
            
delete_thread($thread['threadid'], false$forum['physicallydelete'], $delinfofalse$thread);
        }
        
log_cron_action("Time Limited Forum deactivated: $forum[title_clean]"$nextitem);
    }
    else
    {
        
// Show Forum
        
$forum['options'] |= $vbulletin->bf_misc_forumoptions['active'];
        
// Allow posting
        
$forum['options'] |= $vbulletin->bf_misc_forumoptions['allowposting'];
        
log_cron_action("Time Limited Forum activated: $forum[title_clean]"$nextitem);
    }
      
$vbulletin->db->query_write("UPDATE " TABLE_PREFIX "forum SET options=$forum[options] WHERE forumid=$forum[forumid]");
    
build_forum_counters($forum[forumid]);
}
build_forum_permissions();
?>

Am I fast? Written in just 2 minutes ... :D
Hmm ... but could be optimized. It uses one query/forum = bad.

nexialys 10-14-2005 02:22 PM

ya, surely you have this hack in your pocket hey... release it my friend!!!

Andreas 10-14-2005 02:24 PM

I don't think IO am going to release it. Not coded thaaat good, as I just did that for my site last year or so.

nexialys 10-14-2005 02:30 PM

ya, anyway, this is not exactly the thing i created the task for...

let's see if we can build something solid:

1- in the Edit Forum, admin can set the forum to be opened at X hour and closed at X hour. (if set to 0, the forum is not touched by the cron job)
... that's it for the forum...
2- the cron job #1 verify what forum is to be re-opened (at X hour) and open it.
3- the cron job #2 will do the opposite, close the forum that exceed the hour limit...

these two crons have to be run once an hour, and can be contained in the same cronjob...

when the forum is closed for that feature, a message to invite people to come between the two hours limits is displayed... etc etc etc...

Quote:

Originally Posted by KirbyDE
I don't think IO am going to release it. Not coded thaaat good, as I just did that for my site last year or so.

oh, and i can suggest you to release EVERYTHING you have in hands, even if it is badly coded... look at the other releases, and compare.. lol

hu, btw, you have so much great ideas, when we play with your hacks we can find more features to add...

just like me... my craps are used in some other hacks... funny.. lol

Andreas 10-14-2005 02:44 PM

Quote:

Originally Posted by nexialys
1- in the Edit Forum, admin can set the forum to be opened at X hour and closed at X hour. (if set to 0, the forum is not touched by the cron job)
... that's it for the forum...
2- the cron job #1 verify what forum is to be re-opened (at X hour) and open it.
3- the cron job #2 will do the opposite, close the forum that exceed the hour limit...

I'ts moreless the same like I got running:
In forummanager, one can define a time interval when the forum shoul be open, as well as an option to decide if threads should be physically deleted or not.
The cronjob runs at opening/closing times and does the job.

Quote:

when the forum is closed for that feature, a message to invite people to come between the two hours limits is displayed... etc etc etc...
This is currently not a feature, but might be worth looking into, although I don't think it is that necessary as the forum is hidden anyway in off-times.

nexialys 10-14-2005 02:50 PM

ya, it's hidden for your own feature, but not for mine... hum,. i may even add a setting for hidding or not the closed forum.. lol

will see!


All times are GMT. The time now is 09:01 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01532 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete