isDir() && !$file->isDot()) {
$infoPlugin = $file->getPathname() . "/plugin.info.txt";
if (file_exists($infoPlugin)) {
touch($infoPlugin);
}
}
}
}
/**
* @return bool true if the user can touch the file or the reason why it can't
*
* Because a non-empty string is also true
* Use it like this:
* $stale->canTouch()!==true
*
*/
public function canTouch()
{
$canTouch = true;
if ($this->getConf(self::CONF_ADMIN_ONLY)) {
global $USERINFO;
if (!auth_isadmin($_SERVER['REMOTE_USER'] ?? null, $USERINFO['grps'] ?? null)) {
return "Only admin can touch";
}
}
return $canTouch;
}
public function getIcon()
{
return __DIR__ . '/images/hand-index-fill.svg';
}
public function deleteSitemap()
{
global $conf;
$cacheDirectory = $conf['cachedir'];
$file = $cacheDirectory . "/sitemap.xml.gz";
if (file_exists($file)) {
unlink($file);
return true;
} else {
return false;
}
}
public function stale()
{
$this->touchConfFiles();
$message = "The configurations files were touched.";
$deleted = $this->deleteSitemap();
if ($deleted) {
$message .= "
The sitemap file was deleted.";
} else {
$message .= "
No sitemap was present.";
}
$message .= "
The cache is now stale.";
return $message;
}
}