diff --git a/action/cache.php b/action/cache.php
index 105853f..3620b69 100644
--- a/action/cache.php
+++ b/action/cache.php
@@ -3,6 +3,7 @@
/**
* Double caching of pages containing struct aggregations:
* one for regular users, one for publishers/approvers
+ *
* @see action_plugin_struct_cache
*/
class action_plugin_structpublish_cache extends DokuWiki_Action_Plugin
diff --git a/action/migration.php b/action/migration.php
index 93cf925..99c4ed1 100644
--- a/action/migration.php
+++ b/action/migration.php
@@ -42,7 +42,9 @@ public function handleMigrations(Doku_Event $event)
// check if struct has required version
if ($dbVersionStruct < self::MIN_DB_STRUCT) {
- throw new Exception('Plugin struct is outdated. Minimum required database version is ' . self::MIN_DB_STRUCT);
+ throw new Exception(
+ 'Plugin struct is outdated. Minimum required database version is ' . self::MIN_DB_STRUCT
+ );
}
// check whether we are already up-to-date
diff --git a/action/revisions.php b/action/revisions.php
index 652ad55..108bb7c 100644
--- a/action/revisions.php
+++ b/action/revisions.php
@@ -1,11 +1,10 @@
register_hook('FORM_REVISIONS_OUTPUT', 'BEFORE', $this, 'handleRevisions');
@@ -27,7 +26,9 @@ public function handleRevisions(Doku_Event $event)
/** @var helper_plugin_structpublish_db $helper */
$helper = plugin_load('helper', 'structpublish_db');
- if (!$helper->isPublishable()) return;
+ if (!$helper->isPublishable()) {
+ return;
+ }
$elCount = $form->elementCount();
$checkName = 'rev2[]';
@@ -52,9 +53,14 @@ public function handleRevisions(Doku_Event $event)
$version = $revision->getVersion();
// insert status for published revisions
- if (is_a($el, \dokuwiki\Form\HTMLElement::class) && !empty(trim($el->val())) && $status === Constants::STATUS_PUBLISHED) {
+ if (
+ is_a($el, \dokuwiki\Form\HTMLElement::class) &&
+ !empty(trim($el->val())) &&
+ $status === Constants::STATUS_PUBLISHED
+ ) {
$val = $el->val();
- $label = '' . $status . ' (' . $this->getLang('version') . ' ' . $version . ')';
+ $label = '' .
+ $status . ' (' . $this->getLang('version') . ' ' . $version . ')';
$el->val("$val $label");
}
}
diff --git a/action/save.php b/action/save.php
index e110f66..8ebee3b 100644
--- a/action/save.php
+++ b/action/save.php
@@ -41,7 +41,7 @@ public function handleSave(Doku_Event $event)
try {
$revision->save();
- } catch(StructException $e) {
+ } catch (StructException $e) {
msg($e->getMessage(), -1);
}
}
diff --git a/action/show.php b/action/show.php
index e2b79c9..e1c7144 100644
--- a/action/show.php
+++ b/action/show.php
@@ -6,7 +6,7 @@
class action_plugin_structpublish_show extends DokuWiki_Action_Plugin
{
/** @var int */
- static protected $latestPublishedRev;
+ protected static $latestPublishedRev;
/** @inheritDoc */
public function register(Doku_Event_Handler $controller)
diff --git a/admin.php b/admin.php
index 9d6ad56..231df0e 100644
--- a/admin.php
+++ b/admin.php
@@ -37,7 +37,7 @@ public function handle()
try {
$assignments = Assignments::getInstance();
- } catch(Exception $e) {
+ } catch (Exception $e) {
msg($e->getMessage(), -1);
return;
}
@@ -46,8 +46,11 @@ public function handle()
$assignment = $INPUT->arr('assignment');
if (!blank($assignment['pattern']) && !blank($assignment['status'])) {
if ($INPUT->str('action') === 'delete') {
- $ok = $assignments->removePattern($assignment['pattern'], $assignment['user'],
- $assignment['status']);
+ $ok = $assignments->removePattern(
+ $assignment['pattern'],
+ $assignment['user'],
+ $assignment['status']
+ );
if (!$ok) {
msg('failed to remove pattern', -1);
}
@@ -56,15 +59,21 @@ public function handle()
if (@preg_match($assignment['pattern'], null) === false) {
msg('Invalid regular expression. Pattern not saved', -1);
} else {
- $ok = $assignments->addPattern($assignment['pattern'], $assignment['user'],
- $assignment['status']);
+ $ok = $assignments->addPattern(
+ $assignment['pattern'],
+ $assignment['user'],
+ $assignment['status']
+ );
if (!$ok) {
msg('failed to add pattern', -1);
}
}
} else {
- $ok = $assignments->addPattern($assignment['pattern'], $assignment['user'],
- $assignment['status']);
+ $ok = $assignments->addPattern(
+ $assignment['pattern'],
+ $assignment['user'],
+ $assignment['status']
+ );
if (!$ok) {
msg('failed to add pattern', -1);
}
@@ -87,7 +96,7 @@ public function html()
try {
$assignments = Assignments::getInstance();
- } catch(Exception $e) {
+ } catch (Exception $e) {
msg($e->getMessage(), -1);
return;
}
@@ -152,4 +161,3 @@ public function html()
echo '';
}
}
-
diff --git a/conf/default.php b/conf/default.php
index 3d3b051..8188ee3 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -1,4 +1,5 @@
getDB(false);
- if(!$sqlite) return null;
+ if (!$sqlite) {
+ return null;
+ }
// on init
- if(!$this->initialized) {
+ if (!$this->initialized) {
$sqlite->getPdo()->sqliteCreateFunction('IS_PUBLISHER', [$this, 'isPublisher'], -1);
$this->initialized = true;
}
@@ -35,12 +37,15 @@ public function getDB()
/**
* Get list of all pages known to the plugin
+ *
* @return array
*/
public function getPages()
{
$sqlite = $this->getDB();
- if(!$sqlite) return [];
+ if (!$sqlite) {
+ return [];
+ }
$sql = 'SELECT pid FROM titles';
$list = $sqlite->queryAll($sql);
@@ -57,9 +62,13 @@ public function isPublishable($pid = null)
{
global $ID;
$sqlite = $this->getDB();
- if(!$sqlite) return false;
+ if (!$sqlite) {
+ return false;
+ }
- if (!$pid) $pid = $ID;
+ if (!$pid) {
+ $pid = $ID;
+ }
$sql = 'SELECT pid FROM structpublish_assignments WHERE pid = ? AND assigned = 1';
return (bool) $sqlite->queryAll($sql, $pid);
@@ -94,9 +103,7 @@ public function isPublisher()
$args = func_get_args();
$pid = $args[0];
- if (!$pid) return 1;
-
- if (!$this->isPublishable($pid)) {
+ if (!$pid || !$this->isPublishable($pid)) {
return 1;
}
@@ -152,5 +159,4 @@ public static function userHasRole($pid, $userId = '', $grps = [], $roles = [])
return false;
}
-
}
diff --git a/helper/notify.php b/helper/notify.php
index 6945afb..b08f967 100644
--- a/helper/notify.php
+++ b/helper/notify.php
@@ -29,7 +29,9 @@ public function __construct()
public function sendEmails($action, $newRevision)
{
- if (!$this->triggerNotification($action)) return;
+ if (!$this->triggerNotification($action)) {
+ return;
+ }
// get assignees from DB
$assignments = Assignments::getInstance();
@@ -37,7 +39,9 @@ public function sendEmails($action, $newRevision)
// get recipients for the next workflow step
$nextAction = Constants::workflowSteps($action)['nextAction'];
- if (is_null($nextAction)) return;
+ if (is_null($nextAction)) {
+ return;
+ }
if (empty($assignees[$nextAction])) {
msg($this->getLang('email_error_norecipients'), -1);
@@ -133,7 +137,9 @@ protected function resolveUser(&$resolved, $recipient)
/** @var AuthPlugin $auth */
global $auth;
$user = $auth->getUserData($recipient);
- if ($user) $resolved[] = $user['mail'];
+ if ($user) {
+ $resolved[] = $user['mail'];
+ }
}
/**
@@ -143,7 +149,9 @@ protected function resolveUser(&$resolved, $recipient)
*/
private function triggerNotification($action)
{
- if (!$this->getConf('email_enable')) return false;
+ if (!$this->getConf('email_enable')) {
+ return false;
+ }
$actions = array_map('trim', explode(',', $this->getConf('email_status')));
return in_array($action, $actions);
diff --git a/helper/publish.php b/helper/publish.php
index 7812960..fd0773f 100644
--- a/helper/publish.php
+++ b/helper/publish.php
@@ -12,7 +12,6 @@
*/
class helper_plugin_structpublish_publish extends DokuWiki_Plugin
{
-
/** @var helper_plugin_structpublish_db */
protected $dbHelper;
@@ -33,9 +32,7 @@ public function saveRevision($action, $newversion = '')
global $ID;
global $INFO;
- if (
- !$this->dbHelper->checkAccess($ID, [$action])
- ) {
+ if (!$this->dbHelper->checkAccess($ID, [$action])) {
throw new \Exception('User may not ' . $action);
}
@@ -81,10 +78,14 @@ protected function updateSchemaData()
$sqlite->query("UPDATE multi_$table SET published = 0 WHERE pid = ?", [$ID]);
// publish the current revision
- $sqlite->query("UPDATE data_$table SET published = 1 WHERE pid = ? AND rev = ?",
- [$ID, $INFO['currentrev']]);
- $sqlite->query("UPDATE multi_$table SET published = 1 WHERE pid = ? AND rev = ?",
- [$ID, $INFO['currentrev']]);
+ $sqlite->query(
+ "UPDATE data_$table SET published = 1 WHERE pid = ? AND rev = ?",
+ [$ID, $INFO['currentrev']]
+ );
+ $sqlite->query(
+ "UPDATE multi_$table SET published = 1 WHERE pid = ? AND rev = ?",
+ [$ID, $INFO['currentrev']]
+ );
}
}
}
diff --git a/meta/Assignments.php b/meta/Assignments.php
index d2828ff..9658acd 100644
--- a/meta/Assignments.php
+++ b/meta/Assignments.php
@@ -26,7 +26,7 @@ class Assignments
/**
* Get the singleton instance of the Assignments
*
- * @param bool $forcereload create a new instace to reload the assignment data
+ * @param bool $forcereload create a new instance to reload the assignment data
* @return Assignments
*/
public static function getInstance($forcereload = false)
diff --git a/meta/Constants.php b/meta/Constants.php
index 7e35088..30ca7a5 100644
--- a/meta/Constants.php
+++ b/meta/Constants.php
@@ -18,7 +18,6 @@ class Constants
const ACTION_APPROVE = 'approve';
const ACTION_PUBLISH = 'publish';
-
/**
* Convenience function mapping transition actions to resulting status
*
diff --git a/meta/Revision.php b/meta/Revision.php
index b06dca1..3f1e3a7 100644
--- a/meta/Revision.php
+++ b/meta/Revision.php
@@ -65,6 +65,7 @@ public function __construct($id, $rev)
/**
* Store the currently set structpublish meta data in the database
+ *
* @return void
*/
public function save()
@@ -197,6 +198,7 @@ public function setTimestamp($timestamp)
/**
* The page ID this revision is for
+ *
* @return string
*/
public function getId()
@@ -229,6 +231,7 @@ protected function updateCoreData($pid, $rid = 0)
* Fetches data from the structpublish schema for the current page.
* Returns an array of struct Value objects, not literal values.
* $andFilters can be used to limit the search, e.g. by status or revision
+ *
* @see https://www.dokuwiki.org/plugin:struct:filters
*
* @param array $andFilters
@@ -244,8 +247,9 @@ public function getCoreData($andFilters = [])
];
if (!empty($andFilters)) {
- foreach ($andFilters as $filter)
- $lines[] = 'filter: ' . $filter;
+ foreach ($andFilters as $filter) {
+ $lines[] = 'filter: ' . $filter;
+ }
}
$parser = new ConfigParser($lines);
@@ -279,8 +283,10 @@ public function getLatestPublishedRevision($rev = null)
return null;
}
- $published = new Revision($this->id,
- $latestPublished[$this->revisionCol->getColref() - 1]->getRawValue());
+ $published = new Revision(
+ $this->id,
+ $latestPublished[$this->revisionCol->getColref() - 1]->getRawValue()
+ );
$published->setStatus($latestPublished[$this->statusCol->getColref() - 1]->getRawValue());
$published->setUser($latestPublished[$this->userCol->getColref() - 1]->getRawValue());