Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2005, 02:19 PM
nexialys
Guest
 
Posts: n/a
Default 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...)
Reply With Quote
  #2  
Old 10-14-2005, 02:21 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 ...
Hmm ... but could be optimized. It uses one query/forum = bad.
Reply With Quote
  #3  
Old 10-14-2005, 02:22 PM
nexialys
Guest
 
Posts: n/a
Default

ya, surely you have this hack in your pocket hey... release it my friend!!!
Reply With Quote
  #4  
Old 10-14-2005, 02:24 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 10-14-2005, 02:30 PM
nexialys
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #6  
Old 10-14-2005, 02:44 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 10-14-2005, 02:50 PM
nexialys
Guest
 
Posts: n/a
Default

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!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:31 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03923 seconds
  • Memory Usage 2,242KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (3)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_imicons
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete