View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01343 seconds
  • Memory Usage 1,793KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_box_bit
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete