47 'friends_collections',
65 'uservalidationbyemail',
114 $this->
cache = $cache;
132 $path = $this->config->plugins_path;
149 if (!is_array($plugins)) {
150 unset($this->boot_plugins);
155 $this->boot_plugins = [];
157 if ($order_plugins) {
161 foreach ($plugins as
$plugin) {
171 $plugin->registerLanguages();
184 $this->
cache->clear();
193 $this->
cache->invalidate();
213 $handle = opendir($dir);
214 if ($handle ===
false) {
219 while (($plugin_dir = readdir($handle)) !==
false) {
221 if (!str_starts_with($plugin_dir,
'.') && is_dir($dir . $plugin_dir)) {
222 $plugin_dirs[] = $plugin_dir;
243 $old_ia = $this->session_manager->setIgnoreAccess(
true);
246 $old_access = $this->session_manager->setDisabledEntityVisibility(
true);
248 $known_plugins = $this->
find(
'all');
249 if (empty($known_plugins)) {
258 $latest_priority = -1;
259 foreach ($known_plugins as $i =>
$plugin) {
264 unset($known_plugins[$i]);
268 $id_map[
$plugin->getID()] = $i;
276 $current_priority =
$plugin->getPriority();
277 if (($current_priority - $latest_priority) > 1) {
281 $latest_priority = $current_priority;
285 if (empty($physical_plugins)) {
286 $this->session_manager->setIgnoreAccess($old_ia);
287 $this->session_manager->setDisabledEntityVisibility($old_access);
295 if (array_key_exists($plugin_id, $id_map)) {
311 unset($known_plugins[
$index]);
323 foreach ($known_plugins as
$plugin) {
324 if (!$plugin->isEnabled()) {
330 if ($plugin->isActive()) {
332 $plugin->deactivate();
348 $this->session_manager->setIgnoreAccess($old_ia);
349 $this->session_manager->setDisabledEntityVisibility($old_access);
362 if (!$plugin->
getID()) {
405 'subtype' =>
'plugin',
406 'metadata_name_value_pairs' => [
414 if (empty($plugins)) {
418 $plugins[0]->cache();
445 $qb->select(
'MAX(CAST(md.value AS unsigned)) as max')
467 if (isset($this->boot_plugins) && is_array($this->boot_plugins)) {
468 return array_key_exists($plugin_id, $this->boot_plugins);
476 return $plugin->hasRelationship(1,
'active_plugin');
489 $plugins_path = $this->
getPath();
492 if (file_exists(
"{$plugins_path}/disabled")) {
493 if ($this->session_manager->isAdminLoggedIn() && $this->context->contains(
'admin')) {
494 $this->system_messages->addSuccessMessage($this->translator->translate(
'plugins:disabled'));
500 $this->events->registerHandler(
'plugins_load',
'system', [$this,
'register']);
501 $this->events->registerHandler(
'plugins_boot:before',
'system', [$this,
'boot']);
502 $this->events->registerHandler(
'init',
'system', [$this,
'init']);
503 $this->events->registerHandler(
'ready',
'system', [$this,
'ready']);
504 $this->events->registerHandler(
'upgrade',
'system', [$this,
'upgrade']);
505 $this->events->registerHandler(
'shutdown',
'system', [$this,
'shutdown']);
516 public function register():
void {
517 $plugins = $this->
find(
'active');
518 if (empty($plugins)) {
524 foreach ($plugins as
$plugin) {
541 $plugins = $this->
find(
'active');
542 if (empty($plugins)) {
548 foreach ($plugins as
$plugin) {
565 $plugins = $this->
find(
'active');
566 if (empty($plugins)) {
572 foreach ($plugins as
$plugin) {
589 $plugins = $this->
find(
'active');
590 if (empty($plugins)) {
596 foreach ($plugins as
$plugin) {
598 $plugin->getBootstrap()->ready();
613 $plugins = $this->
find(
'active');
614 if (empty($plugins)) {
620 foreach ($plugins as
$plugin) {
622 $plugin->getBootstrap()->upgrade();
637 $plugins = $this->
find(
'active');
638 if (empty($plugins)) {
644 foreach ($plugins as
$plugin) {
646 $plugin->getBootstrap()->shutdown();
664 $this->
getLogger()->log(LogLevel::ERROR, $previous, [
670 if (!$this->config->auto_disable_plugins) {
678 $msg = $this->translator->translate(
679 'PluginException:CannotStart',
680 [
$id, $plugin->guid, $previous->getMessage()]
685 $this->
getLogger()->log(LogLevel::ERROR, $ex, [
700 public function find(
string $status =
'active'): array {
701 if (!$this->db || !$this->config->installed) {
705 if ($status ===
'active' && isset($this->boot_plugins)) {
707 return array_values($this->boot_plugins);
710 $volatile_data_name = null;
716 'subtype' =>
'plugin',
723 $options[
'relationship'] =
'active_plugin';
724 $options[
'relationship_guid'] = $site_guid;
725 $options[
'inverse_relationship'] =
true;
728 $volatile_data_name =
'select:value';
737 $subquery = $qb->
subquery(
'entity_relationships',
'active_er');
738 $subquery->select(
'active_er.guid_one')
742 return $qb->
compare(
"{$main_alias}.guid",
'NOT IN', $subquery->getSQL());
751 $old_ia = $this->session_manager->setIgnoreAccess(
true);
753 $this->session_manager->setIgnoreAccess($old_ia);
757 if ($status ===
'active' && !isset($this->boot_plugins)) {
775 $sorted_plugins = [];
777 foreach ($plugins as
$plugin) {
779 if (!empty($volatile_data_name)) {
780 $priority = $plugin->getVolatileData($volatile_data_name);
787 $priorities[$plugin->guid] = (int)
$priority;
788 $sorted_plugins[$plugin->guid] =
$plugin;
793 return array_values(array_replace($priorities, $sorted_plugins));
811 $plugins = $this->
find(
'any');
812 if (empty($plugins)) {
818 $order = array_values($order);
821 $missing_plugins = [];
824 foreach ($plugins as
$plugin) {
825 if (!$plugin->isEnabled()) {
827 if ($plugin->getPriority() !== null) {
829 unset($plugin->$name);
850 if (empty($missing_plugins)) {
854 foreach ($missing_plugins as $plugin) {
890 if (!$plugin->guid) {
898 if ($priority > $old_priority) {
899 $qb->set(
'value',
'CAST(value AS UNSIGNED) - 1');
902 $qb->set(
'value',
'CAST(value AS UNSIGNED) + 1');
906 if (!$this->db->updateData(
$qb)) {
isActive(string $plugin_id)
Returns if a plugin is active for a current site.
trait Profilable
Make an object accept a timer.
static project()
Get the project root (where composer is installed) path with "/".
getID()
Returns the ID (dir name) of this plugin.
setMetadata(string $name, $value, string $value_type= '', bool $multiple=false)
Set metadata on this entity.
reindexPriorities()
Reindexes all plugin priorities starting at 1.
Exception thrown if an argument is not of the expected type.
getMaxPriority()
Returns the highest priority of the plugins.
if(!$user||!$user->canDelete()) $name
static table($table, $alias=null)
{}
subquery(string $table, string $alias=null)
Creates a new SelectQueryBuilder for join/where sub queries using the DB connection of the primary Qu...
build()
Registers lifecycle events for all active plugins sorted by their priority.
const ELGG_VALUE_INTEGER
Value types.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Database abstraction query builder.
getDirsInDir(string $dir=null)
Returns a list of plugin directory names from a base directory.
__construct(BaseCache $cache, Database $db, SessionManagerService $session_manager, EventsService $events, Translator $translator, ViewsService $views, Config $config, SystemMessagesService $system_messages, Request $request)
Constructor.
invalidate()
Invalidate plugin cache.
disable(\ElggPlugin $plugin,\Exception $previous)
Disable a plugin upon exception.
$plugin_id
Remove all user and plugin settings from the give plugin ID.
elgg_invalidate_caches()
Invalidate all the registered caches.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
if(!$entity instanceof\ElggUser) $data
trait Loggable
Enables adding a logger.
exists(string $id)
Returns if a plugin exists in the system.
setBootPlugins(array $plugins=null, bool $order_plugins=true)
Set the list of active plugins according to the boot data cache.
orderPluginsByPriority(array $plugins=[], string $volatile_data_name=null)
Sorts plugins by priority.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
ready()
Run plugin ready handlers.
init()
Initialize plugins.
generateEntities()
Discovers plugins in the plugins_path setting and creates entities for them if they don't exist...
compare(string $x, string $comparison, $y=null, string $type=null, bool $case_sensitive=null)
Build value comparison clause.
SystemMessagesService $system_messages
upgrade()
Run plugin upgrade handlers.
The Elgg cache base class.
clear()
Clear plugin caches.
invalidateCache($plugin_id)
Remove plugin from cache.
const PRIORITY_SETTING_NAME
static fromTable($table, $alias=null)
{}
getLogger()
Returns logger.
deactivate()
Deactivates the plugin.
getContextStack()
Returns context stack.
setPriority(\ElggPlugin $plugin, int $priority)
Set plugin priority and adjust the priorities of other plugins.
beginTimer(array $keys)
Start the timer (when enabled)
getPath()
Get the plugin path for this installation, ending with slash.
getPriority()
Gets the plugin's load priority.
setPriorities(array $order)
Reorder plugins to an order specified by the array.
elgg_add_admin_notice(string $id, string $message)
Write a persistent message to the admin view.
shutdown()
Run plugin shutdown handlers.
Persistent, installation-wide key-value storage.
static fromId(string $plugin_id, string $path=null)
Load a plugin object from its ID Create a new plugin entity if doesn't exist.
cache(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
find(string $status= 'active')
Returns an ordered list of plugins.
$id
Generic annotation delete action.
trait Cacheable
Utility trait for injecting cache.
Manages a global stack of strings for sharing information about the current execution context...
SessionManagerService $session_manager
endTimer(array $keys)
Ends the timer (when enabled)