Quote:
Originally Posted by nhawk
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\');';