PDA

View Full Version : Notice Flush/add to Cache


CoffeeLovesYou
10-24-2014, 03:30 PM
Hello,
I made a notice creator form that will easily create notices for my staff (with no HTML involved for them).
Basically, it's a HTML form that they enter the info, and it makes it into HTML for them (e.g. if they put Color #FF0000, when I pass it through the query to add the notice's phrase, it'll do <font color="#FF0000">).
I'm not comfortable sharing my code publicly, however, it works. It adds the notice to the notice table correctly, the noticecriteria table correctly, and the phrase table correctly.
Here's the problem. Notices are cached. The cache isn't flushed unless you add a notice from the ACP or modify one.

How can I flush the cache when adding a notice from my form? Or how can I add the notice they just made with my form to the cache? (whichever one is the right one).

Thanks for any help. If someone wants to help privately, I don't mind sending my code.

kh99
10-24-2014, 03:38 PM
The admincp code does this when it's finished:

// update the datastore notice cache
require_once(DIR . '/includes/adminfunctions_notice.php');
build_notice_datastore();

// rebuild languages
require_once(DIR . '/includes/adminfunctions_language.php');
build_language();

CoffeeLovesYou
10-24-2014, 03:42 PM
The admincp code does this when it's finished:

// update the datastore notice cache
require_once(DIR . '/includes/adminfunctions_notice.php');
build_notice_datastore();

// rebuild languages
require_once(DIR . '/includes/adminfunctions_language.php');
build_language();

Thanks kh99.
However, I don't use the same variables used in adminfunctions_notice.php
If I remade that file with different names and changed the variables to match my own, do you think it'd work?
Would you mind if I PM'd you my code?

kh99
10-24-2014, 03:56 PM
Well, the lines I posted rebuild the notice cache and the languages (because a phrase was added), so I don't think it matters what variables your code uses. Unless I'm not understanding the issue.

CoffeeLovesYou
10-24-2014, 03:58 PM
That is my issue, you're right.
I tried adding that piece of code where my queries are executed, but upon submission, I received a blank, white page. I can't give you an error because error reports are off. :(
Perhaps I need to do what this person did? https://vborg.vbsupport.ru/showthread.php?t=231389
He said he needed to include fetch_js_safe_string.. how could I do that? Is that needed?

kh99
10-24-2014, 06:15 PM
That is my issue, you're right.
I tried adding that piece of code where my queries are executed, but upon submission, I received a blank, white page. I can't give you an error because error reports are off. :(
Perhaps I need to do what this person did? https://vborg.vbsupport.ru/showthread.php?t=231389
He said he needed to include fetch_js_safe_string.. how could I do that? Is that needed?

Yeah, that's probably it. So what you'd do is add this:
require_once(DIR . '/includes/adminfunctions.php');

before the code I posted above.