View Full Version : have to set allowposting on/off on delay
nexialys
10-14-2005, 02:19 PM
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
// ######################## 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'], 0, 2), substr($forum['timelimit'], 3, 2))-1;
$endtime = mktime(substr($forum['timelimit'], 6, 2), substr($forum['timelimit'], 9, 2))-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'], $delinfo, false, $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...
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
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.
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!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.