Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-17-2011, 02:16 AM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Where are calendars created?

Hello everyone, I was wondering if anyone knew by any chance where i could find how calendars are created (after saving through admin panel), I ask because I have successfully created a new calendar with a SQL query to add the record in the "calendar" table ; I even see the new calendar in the admin panel and I can edit it's settings but I can't view it nor it appears on the "Calender Picker" drop down menu from the forums. If I try and view it from the admin panel I get a invalid permissions page so I'm guessing it's not as direct as a simple SQL query, I image there's some permissions that need to be updated somewhere?? I checked my own permissions and I am able to view all other calendars except that one. Any9one have any ideas what I could be missing?

The idea I have is the following...

I want to have a calendar on the home page of my mod that updates weekly according to what the moderator of the mod inserts (events). I was able to embed the calendar successfully in my page and had the permissions changed so that everyone can view this calendar with the events that the "chosen" moderator places. At the same time the calendar will be updated every time the cron file runs at whatever time the moderator places the event. I am half way there...

The calendar appears successfully and permissions are correct to view. I have also been able to have the back-end for the moderator created for him/her to add events and no one else (another option is added for the admin to provide the user id of the contest moderator(s)) and this is used within the calendar code; meaning everyone who views this page the calendar assumes it's user_id x and views only the events we control. Next step would be creating the code for the creation of the calendar (initially when the mod installs; this is my initial question for this thread ). After that it's a matter of syncing the cron and the events and voil?... Got a bit of track there so about that everyone. Needed to vent my thoughts a bit.

Any way if anyone has any ideas or thoughts about how to create a new calendar with proper permisisons please don't be shy. Sharing is caring everyone, specially knowledge. Thanks for your time everyone. Please let me know your thoughts. Have a good night everyone.

Best Regards.
Reply With Quote
  #2  
Old 08-17-2011, 11:34 AM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Calendars are created in admincalendar.php. The saving portion is just an sql that parses the data from the routine in admincalendar.php.

By default, calendar permissions are empty (as in no permissions exist for a calendar) which allows all members all access and that information is held in the calendarpermission table as a bitfield total. So I don't think that's the problem unless you wrote something to that table for that calendar.

You may not have set all of the fields in the calendar and that might be a problem. Also, you need to be careful because at least one of the fields is a bitfield total. And another is an array definition for emails (not just an array of emails).
Reply With Quote
  #3  
Old 08-17-2011, 11:49 AM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
Calendars are created in admincalendar.php. The saving portion is just an sql that parses the data from the routine in admincalendar.php.

By default, calendar permissions are empty (as in no permissions exist for a calendar) which allows all members all access and that information is held in the calendarpermission table as a bitfield total. So I don't think that's the problem unless you wrote something to that table for that calendar.

You may not have set all of the fields in the calendar and that might be a problem. Also, you need to be careful because at least one of the fields is a bitfield total. And another is an array definition for emails (not just an array of emails).
Thanks for your reply nhawk. That's exactly where I was looking at yesterday but at 1 am your mind can't grasp things as best as it can. I was looking particualrly at this bit of code:

PHP Code:
    if ($_REQUEST['do'] == 'add')
    {
        
// need to set default yes permissions!
        
$calendar = array(
            
'active'        => 1,
            
'allowbbcode'   => 1,
            
'allowimgcode'  => 1,
            
'allowsmilies'  => 1,
            
'startofweek'   => 1,
            
'showholidays'  => 1,
            
'showbirthdays' => 1,
            
'showweekends'  => 1,
            
'cutoff'        => 40,
            
'eventcount'    => 4,
            
'birthdaycount' => 4,
            
'daterange'     => $exampledaterange,
            
'usetimes'      => 1,
            
'usetranstime'  => 1,
            
'showupcoming'  => 1,
        );

        
$maxdisplayorder $db->query_first("
            SELECT MAX(displayorder) AS displayorder
            FROM " 
TABLE_PREFIX "calendar
        "
);
        
$calendar['displayorder'] = $maxdisplayorder['displayorder'] + 1;

        
print_table_header($vbphrase['add_new_calendar']);
    } 
That's the only place I can think see that has to do with add a calendar. What I don't see is that query to insert into database. I don't quite understand how it inserts these new values . There is an else condition right after the code above but I believe it's for editing existing calendars. Basically I would need to add this code into some sort of function and have it run when the install script for the mod runs. What I would need specify is the title of the calendar basically. About what I tried before is duplicate with an SQL query another calendar with the same values that it had in the database table except change the id to the next one, same permissions same everything else, maybe that was the problem in itself, it would be definitely better to code it this way using what vb uses to create calendars.
Reply With Quote
  #4  
Old 08-17-2011, 12:05 PM
nhawk nhawk is offline
 
Join Date: Jan 2011
Posts: 1,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, something to keep in mind, you NEVER assign a value to the first field in any table (in this case, calendarid). You don't even specify it in your save SQL. That field auto-increments and should never be assigned a value in any query that adds a record to the table.

The save routine IS this..
Code:
$db->query_write(fetch_query_sql($vbulletin->GPC['calendar'], 'calendar'));
I said to just ignore it because all it does is parse the calendar data into the calendar table. Other than the parse, there's nothing special about it. The fetch_query_sql is in includes/functions.php if you want to look at it.

If you just duplicated an existing calendar that you can view (with a different name I hope), there's no reason why it shouldn't work.

So far as that code, it's not really needed if you write directly to the table with known values.

--------------- Added [DATE]1313587108[/DATE] at [TIME]1313587108[/TIME] ---------------

Just to be sure I'm not talking out of my hind end, I just added a calendar with all of the same settings as the default calendar on my dev server by a direct SQL add and it does work.

The only settings I changed were the calendar name, and the display order.
Reply With Quote
  #5  
Old 08-17-2011, 12:45 PM
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Location: Naples
Posts: 354
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nhawk View Post
Ok, something to keep in mind, you NEVER assign a value to the first field in any table (in this case, calendarid). You don't even specify it in your save SQL. That field auto-increments and should never be assigned a value in any query that adds a record to the table.

The save routine IS this..
Code:
$db->query_write(fetch_query_sql($vbulletin->GPC['calendar'], 'calendar'));
I said to just ignore it because all it does is parse the calendar data into the calendar table. Other than the parse, there's nothing special about it. The fetch_query_sql is in includes/functions.php if you want to look at it.

If you just duplicated an existing calendar that you can view (with a different name I hope), there's no reason why it shouldn't work.

So far as that code, it's not really needed if you write directly to the table with known values.

--------------- Added [DATE]1313587108[/DATE] at [TIME]1313587108[/TIME] ---------------

Just to be sure I'm not talking out of my hind end, I just added a calendar with all of the same settings as the default calendar on my dev server by a direct SQL add and it does work.

The only settings I changed were the calendar name, and the display order.
Thanks for your reply, understood sensei . I knew that I couldn't assign an id because that field is auto-increment but I wasn't sure about the permissions. I tried what you said and duplicated the calendar via SQL but with a different name and display order and it works too. I can see it fine now, what I was doing yesterday I was duplicating a nmew calendar I had created and not the default one, maybe that was causing some sort of issue. I took note of the php SQL code used ot create the calendar and saved it for the install script.

PHP Code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
$sql 'INSERT INTO `calendar` (`calendarid`, `title`, `description`, `displayorder`, `neweventemail`, `moderatenew`, `startofweek`, `options`, `cutoff`, `eventcount`, `birthdaycount`, `startyear`, `endyear`, `holidays`) VALUES (NULL, \'Default Calendar Bz\', \'\', \'4\', \'a:0:{}\', \'0\', \'1\', \'631\', \'40\', \'4\', \'4\', \'2008\', \'2014\', \'0\');'
I can just use this with certain variables assigned of course at my install script and I don't have to deal with anything else creating the calendar.

What comes to mind creating the calendar, setting a custom name for it "Contest Of The Week" then use that name to get the calendar id to display it in my page with the code I have now which all I have to specify is which calendar id it is.

Thank you so much for your help nhawk. Can't wait for you to see what all this works been about I think people are really going to enjoy this. There's nothing out there right now like it, as far as I know anyway.


UPDATE:

The SQL works perfect. I just used the id of the calendar in my page to show the new calendar I created with the SQL query and it shows fine, for me and everyone else! Thanks again.

--------------- Added [DATE]1313591950[/DATE] at [TIME]1313591950[/TIME] ---------------

Using this to add events:

PHP Code:
$sql 'INSERT INTO `event` (`eventid`, `userid`, `event`, `title`, `allowsmilies`, `recurring`, `recuroption`, `calendarid`, `customfields`, `visible`, `dateline`, `utc`, `dst`, `dateline_from`, `dateline_to`) VALUES (NULL, \'1\', \'\', \'Signature Of The Week #2\', \'1\', \'0\', \'\', \'2\', \'a:0:{}\', \'1\', \'1313591803\', \'0.00\', \'0\', \'1314144000\', \'0\');'
Using this to add cron job:

PHP Code:
$sql 'INSERT INTO `cron` (`cronid`, `nextrun`, `weekday`, `day`, `hour`, `minute`, `filename`, `loglevel`, `active`, `varname`, `volatile`, `product`) VALUES (NULL, \'1313942400\', \'0\', \'-1\', \'12\', \'a:1:{i:0;i:-1;}\', \'./includes/cron/cotw_func_sotw_recycle.php\', \'0\', \'1\', \'cotw_recycle2\', \'1\', \'cotw\');'
Reply With Quote
Благодарность от:
nhawk
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:25 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.04273 seconds
  • Memory Usage 2,245KB
  • 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
  • (2)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (1)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete