18 require_once SQ_SYSTEM_ROOT.
'/core/assets/system/tool/tool.inc';
19 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
46 parent::__construct($assetid);
62 $tool_info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code);
65 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
66 $preferencesBroken = array();
67 $squid_hostnames = trim(SQ_TOOL_SQUID_CACHE_HOSTNAMES);
68 if (empty($squid_hostnames) === TRUE) {
69 $preferencesBroken[] =
'squid_tool_no_hostnames';
72 $squidclient_path = trim(SQ_TOOL_SQUID_CACHE_PATH);
73 if (empty($squidclient_path) === TRUE) {
74 $preferencesBroken[] =
'squid_tool_path_empty';
76 if (is_file($squidclient_path) === FALSE) {
77 $preferencesBroken[] =
'squid_tool_path_invalid';
81 if (empty($preferencesBroken) === FALSE) {
82 $o->
openField(translate(
'squid_tool_not_configured'));
83 foreach ($preferencesBroken as $brokenItem) {
84 $o->
note(translate($brokenItem));
93 asset_finder($type_code.
'_assetid');
94 $o->
note(translate(
'squid_tool_asset_note'));
98 $o->
openField(translate(
'squid_tool_clear_now_field'));
99 check_box($type_code.
'_clear_now', TRUE);
103 $o->
openField(translate(
'squid_tool_populate_question'));
104 check_box($type_code.
'_populate_now', TRUE);
105 echo translate(
'squid_tool_populate_note');
109 $o->
openField(translate(
'cascade_question'));
111 'single' => translate(
'this_asset'),
112 'children' => translate(
'this_asset_and_children'),
114 check_box($type_code.
'_cascade', TRUE);
116 echo translate(
'squid_tool_cascade_note');
118 $o->
note(translate(
'squid_tool_note'));
124 $o->
openSection(translate(
'squid_tool_schedule_section'));
126 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
127 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'cron_job_squid_cache_purge');
131 if (!empty($purge_jobs)) {
132 $o->
openField(translate(
'squid_tool_scheduled_job_field'),
'new_line');
134 <table
class=
"sq-backend-table">
136 <td
class=
"sq-backend-table-header"><?php echo translate(
'asset'); ?></td>
137 <td
class=
"sq-backend-table-header"><?php echo translate(
'when'); ?></td>
138 <td align=
"center" class=
"sq-backend-table-header" style=
"text-align: center;"><?php echo translate(
'delete_question'); ?></td>
141 for ($i = 0; $i < count($purge_jobs); $i++) {
144 <td
class=
"sq-backend-table-cell">
145 <?php echo get_asset_tag_line($purge_jobs[$i]->
attr(
'ownerid')); ?>
148 <td
class=
"sq-backend-table-cell">
149 <?php echo $purge_jobs[$i]->readableWhen(); ?>
151 <td align=
"center" class=
"sq-backend-table-cell">
156 check_box($type_code.
'_remove_fs[]', $purge_jobs[$i]->id);
172 $cron_epoc = (int)$cron_mgr->attr(
'epoch');
173 $cron_refresh = (int)$cron_mgr->attr(
'refresh_time');
174 if ($cron_epoc > 0 && $cron_refresh > 0) {
177 $o->
openField(translate(
'squid_tool_one_off_field'),
'new_line');
178 require_once SQ_FUDGE_PATH.
'/general/datetime.inc';
180 $edit_fns = $new_job->getEditFns();
181 $edit_fns->paintInLineBackend($new_job, $o, $type_code.
'_one_off');
182 echo
' <br /><br />';
186 $o->
openField(translate(
'squid_tool_repeating_field'),
'new_line');
188 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
189 $new_job->setAttrValue(
'type',
'repeating');
190 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
191 $edit_fns = $new_job->getEditFns();
192 $edit_fns->paintInLineBackend($new_job, $o, $type_code.
'_repeating');
193 $o->
note(translate(
'cron_manager_next_run', $cron_mgr->readableRefreshTime(), readable_datetime($cron_mgr->timeOfNextRun())));
197 echo translate(
'cron_manager_not_configured');
200 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($cron_mgr);
221 if (isset($_POST[$type_code.
'_assetid']) === FALSE) {
225 $cron_mgr = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
226 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'cron_job_squid_cache_purge');
229 if (!empty($_POST[$type_code.
'_remove_fs'])) {
230 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'cron_job_squid_cache_purge');
232 if (!empty($purge_jobs)) {
233 if ($GLOBALS[
'SQ_SYSTEM']->am->acquireLock($cron_mgr->id,
'links')) {
234 for ($i = 0; $i < count($purge_jobs); $i++) {
235 if (in_array($purge_jobs[$i]->
id, $_POST[$type_code.
'_remove_fs'])) {
236 $cron_mgr->removeJob($purge_jobs[$i]);
240 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($cron_mgr->id,
'links');
242 trigger_localised_error(
'SYS0232', E_USER_NOTICE);
246 if (!$_REQUEST[$type_code.
'_assetid'][
'assetid']) {
252 if (!$_REQUEST[$type_code.
'_assetid'][
'assetid']) {
253 trigger_localised_error(
'SQUID0001', E_USER_NOTICE);
258 $assetid = $_REQUEST[$type_code.
'_assetid'][
'assetid'];
259 $cascade = (isset($_REQUEST[$type_code.
'_cascade'])) ? $_REQUEST[$type_code.
'_cascade'] : FALSE;
260 $populate_now = FALSE;
261 if (isset($_REQUEST[$type_code.
'_populate_now']) && $_REQUEST[$type_code.
'_populate_now']) {
262 $populate_now = TRUE;
265 'assetid' => $assetid,
266 'cascade' => $cascade,
267 'repopulate' => $populate_now,
271 $owner = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
273 $urls = $GLOBALS[
'SQ_SYSTEM']->am->getURLs($assetid);
278 if ($owner->adminAccess(
'')) {
282 $edit_fns = $new_job->getEditFns();
283 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
284 $new_job->setAttrValue(
'ownerid', $assetid);
285 $new_job->setAttrValue(
'cascade', $cascade);
286 $new_job->setAttrValue(
'repopulate', $populate_now);
287 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
288 if ($edit_fns->processInLineBackend($new_job, $o, $type_code.
'_one_off')) {
289 $cron_mgr->addJob($new_job, $GLOBALS[
'SQ_SYSTEM']->user);
294 $edit_fns = $new_job->getEditFns();
295 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
296 $new_job->setAttrValue(
'type',
'repeating');
297 $new_job->setAttrValue(
'ownerid',$assetid);
298 $new_job->setAttrValue(
'cascade', $cascade);
299 $new_job->setAttrValue(
'repopulate', $populate_now);
300 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
301 if ($edit_fns->processInLineBackend($new_job, $o, $type_code.
'_repeating')) {
302 $cron_mgr->addJob($new_job, $GLOBALS[
'SQ_SYSTEM']->user);
306 $run_now = isset($_REQUEST[$type_code.
'_clear_now']) && $_REQUEST[$type_code.
'_clear_now'];
307 if ($populate_now) $run_now = TRUE;
309 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
310 $hh->queueHipo(
'hipo_job_tool_clear_squid_cache', $vars,
'', SQ_PACKAGES_PATH.
'/squid/hipo_jobs');
311 $url = $hh->runQueuedJobs();
316 trigger_localised_error(
'SQUID0003', E_USER_NOTICE, translate(
'squid_cron_name', $owner->id));