diff --git a/src/Action.php b/src/Action.php index 7bd28c6..f1ac80d 100644 --- a/src/Action.php +++ b/src/Action.php @@ -18,10 +18,10 @@ class Action /** * Constructor sets action description. * - * @param string $id The action ID - * @param string $title The action title - * @param string $message The action message - * @param string $behavior The behavior name + * @param string $id The action ID + * @param string $title The action title + * @param string $message The action message + * @param string $behavior The behavior name * @param null|callable $function The callback function */ public function __construct( diff --git a/src/ActivityReport.php b/src/ActivityReport.php index d4fa778..48dab77 100644 --- a/src/ActivityReport.php +++ b/src/ActivityReport.php @@ -6,6 +6,7 @@ namespace Dotclear\Plugin\activityReport; use ArrayObject; use Dotclear\App; +use Dotclear\Core\Process; use Dotclear\Database\MetaRecord; use Dotclear\Database\Statement\{ DeleteStatement, @@ -22,6 +23,7 @@ use Dotclear\Helper\File\{ use Dotclear\Helper\Network\Mail\Mail; use Dotclear\Helper\Text; use Exception; +use Throwable; /** * @brief activityReport main class. @@ -32,6 +34,13 @@ use Exception; */ class ActivityReport { + /** + * Third party plugins ActivityReport class name. + * + * @var string ACTIVITYREPORT_CLASS_NAME + */ + public const ACTIVITYREPORT_CLASS_NAME = 'ActivityReportAction'; + /** @var int activity marked as pending mail report */ public const STATUS_PENDING = 0; @@ -72,6 +81,23 @@ class ActivityReport $this->obsoleteLogs(); } + public static function init(): void + { + foreach (App::plugins()->getDefines() as $module) { + $class = $module->get('namespace') . '\\' . self::ACTIVITYREPORT_CLASS_NAME; + + try { + if (is_a($class, Process::class, true)) { + // check class prerequiretics + if ($class::init()) { + $class::process(); + } + } + } catch (Throwable $e) { + } + } + } + /** * Get singleton instance. * @@ -193,8 +219,8 @@ class ActivityReport if (!empty($params['requests'])) { $or = []; foreach ($this->settings->requests as $group => $actions) { - foreach ($actions as $action) { - $or[] = $sql->andGroup(['activity_group = ' . $sql->quote($group), 'activity_action = ' . $sql->quote($action)]); + foreach (array_keys($actions) as $action) { + $or[] = $sql->andGroup(['activity_group = ' . $sql->quote((string) $group), 'activity_action = ' . $sql->quote((string) $action)]); } } if (!empty($or)) { diff --git a/src/ActivityBehaviors.php b/src/ActivityReportAction.php similarity index 95% rename from src/ActivityBehaviors.php rename to src/ActivityReportAction.php index 762edff..8d9c3d5 100644 --- a/src/ActivityBehaviors.php +++ b/src/ActivityReportAction.php @@ -6,15 +6,14 @@ namespace Dotclear\Plugin\activityReport; use ArrayObject; use Dotclear\App; -use Dotclear\Interface\Core\BlogInterace; +use Dotclear\Core\Process; +use Dotclear\Interface\Core\BlogInterface; use Dotclear\Database\{ Cursor, MetaRecord }; use Dotclear\Helper\Network\Http; -/** - */ /** * @brief activityReport register class. * @ingroup activityReport @@ -24,10 +23,19 @@ use Dotclear\Helper\Network\Http; * @author Jean-Christian Denis (author) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html */ -class ActivityBehaviors +class ActivityReportAction extends Process { - public static function register(): void + public static function init(): bool { + return self::status(true); + } + + public static function process(): bool + { + if (!self::status()) { + return false; + } + $my = new Group(My::id(), __('ActivityReport messages')); $blog = new Group('blog', __('Actions on blog')); $post = new Group('post', __('Actions on posts')); @@ -261,6 +269,8 @@ class ActivityBehaviors '
Powered by activityReport