45 'friends_collections',
63 'uservalidationbyemail',
109 return $this->config->plugins_path;
121 $this->cache->clear();
122 if (!is_array($plugins)) {
123 unset($this->boot_plugins);
128 $this->boot_plugins = [];
130 if ($order_plugins) {
134 foreach ($plugins as
$plugin) {
144 $plugin->registerLanguages();
173 $handle = opendir($dir);
174 if ($handle ===
false) {
179 while (($plugin_dir = readdir($handle)) !==
false) {
181 if (!str_starts_with($plugin_dir,
'.') && is_dir($dir . $plugin_dir)) {
182 $plugin_dirs[] = $plugin_dir;
205 $known_plugins = $this->
find(
'all');
212 $latest_priority = 0;
213 foreach ($known_plugins as $i =>
$plugin) {
218 unset($known_plugins[$i]);
222 $id_map[
$plugin->getID()] = $i;
229 $current_priority =
$plugin->getPriority();
230 if (($current_priority - $latest_priority) > 1) {
234 $latest_priority = $current_priority;
238 if (empty($physical_plugins)) {
245 if (array_key_exists($plugin_id, $id_map)) {
261 unset($known_plugins[
$index]);
272 foreach ($known_plugins as
$plugin) {
273 if (!$plugin->isEnabled()) {
279 if ($plugin->isActive()) {
281 $plugin->deactivate();
320 'subtype' =>
'plugin',
321 'metadata_name_value_pairs' => [
329 if (empty($plugins)) {
347 $qb->select(
'MAX(CAST(md.value AS unsigned)) as max')
369 if (isset($this->boot_plugins) && is_array($this->boot_plugins)) {
370 return array_key_exists($plugin_id, $this->boot_plugins);
378 return $plugin->hasRelationship(1,
'active_plugin');
391 $plugins_path = $this->
getPath();
394 if (file_exists(
"{$plugins_path}/disabled")) {
395 if ($this->session_manager->isAdminLoggedIn() && $this->context->contains(
'admin')) {
396 $this->system_messages->addSuccessMessage($this->translator->translate(
'plugins:disabled'));
402 $this->events->registerHandler(
'plugins_load',
'system', [$this,
'register']);
403 $this->events->registerHandler(
'plugins_boot:before',
'system', [$this,
'boot']);
404 $this->events->registerHandler(
'init',
'system', [$this,
'init']);
405 $this->events->registerHandler(
'ready',
'system', [$this,
'ready']);
406 $this->events->registerHandler(
'upgrade',
'system', [$this,
'upgrade']);
407 $this->events->registerHandler(
'shutdown',
'system', [$this,
'shutdown']);
418 public function register():
void {
419 $plugins = $this->
find(
'active');
420 if (empty($plugins)) {
426 foreach ($plugins as
$plugin) {
429 }
catch (\Exception $ex) {
443 $plugins = $this->
find(
'active');
444 if (empty($plugins)) {
450 foreach ($plugins as
$plugin) {
453 }
catch (\Exception $ex) {
467 $plugins = $this->
find(
'active');
468 if (empty($plugins)) {
474 foreach ($plugins as
$plugin) {
477 }
catch (\Exception $ex) {
491 $plugins = $this->
find(
'active');
492 if (empty($plugins)) {
498 foreach ($plugins as
$plugin) {
500 $plugin->getBootstrap()->ready();
501 }
catch (\Exception $ex) {
515 $plugins = $this->
find(
'active');
516 if (empty($plugins)) {
522 foreach ($plugins as
$plugin) {
524 $plugin->getBootstrap()->upgrade();
525 }
catch (\Exception $ex) {
539 $plugins = $this->
find(
'active');
540 if (empty($plugins)) {
546 foreach ($plugins as
$plugin) {
548 $plugin->getBootstrap()->shutdown();
549 }
catch (\Exception $ex) {
566 $this->
getLogger()->log(LogLevel::ERROR, $previous, [
572 if (!$this->config->auto_disable_plugins) {
580 $msg = $this->translator->translate(
581 'PluginException:CannotStart',
582 [
$id, $plugin->guid, $previous->getMessage()]
587 $this->
getLogger()->log(LogLevel::ERROR, $ex, [
602 public function find(
string $status =
'active'): array {
603 if (!$this->db || !$this->config->installed) {
607 if ($status ===
'active' && isset($this->boot_plugins)) {
609 return array_values($this->boot_plugins);
612 $volatile_data_name = null;
618 'subtype' =>
'plugin',
625 $options[
'relationship'] =
'active_plugin';
626 $options[
'relationship_guid'] = $site_guid;
627 $options[
'inverse_relationship'] =
true;
630 $volatile_data_name =
'select:value';
639 $subquery = $qb->
subquery(
'entity_relationships',
'active_er');
640 $subquery->select(
'active_er.guid_one')
644 return $qb->
compare(
"{$main_alias}.guid",
'NOT IN', $subquery->getSQL());
659 if ($status ===
'active' && !isset($this->boot_plugins)) {
664 foreach ($plugins as
$plugin) {
666 $this->cache->save($plugin->getID(),
$plugin);
682 $sorted_plugins = [];
684 foreach ($plugins as
$plugin) {
686 if (!empty($volatile_data_name)) {
687 $priority = $plugin->getVolatileData($volatile_data_name);
694 $priorities[$plugin->guid] = (int)
$priority;
695 $sorted_plugins[$plugin->guid] =
$plugin;
700 return array_values(array_replace($priorities, $sorted_plugins));
718 $plugins = $this->
find(
'all');
719 if (empty($plugins)) {
725 $order = array_values($order);
728 $missing_plugins = [];
731 foreach ($plugins as
$plugin) {
732 if (!$plugin->isEnabled()) {
734 if ($plugin->getPriority() !== null) {
736 unset($plugin->$name);
757 if (empty($missing_plugins)) {
761 foreach ($missing_plugins as $plugin) {
793 if (!$plugin->setMetadata(
$name, $priority)) {
797 if (!$plugin->guid) {
805 if ($priority > $old_priority) {
806 $qb->set(
'value',
'CAST(value AS UNSIGNED) - 1');
809 $qb->set(
'value',
'CAST(value AS UNSIGNED) + 1');
813 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 table(string $table)
Returns a QueryBuilder for updating data in a given table.
getID()
Returns the ID (dir name) of this plugin.
reindexPriorities()
Reindexes all plugin priorities starting at 1.
getMaxPriority()
Returns the highest priority of the plugins.
Plugin class containing helper functions for plugin activation/deactivation, dependency checking capa...
if(!$user||!$user->canDelete()) $name
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.
disable(\ElggPlugin $plugin,\Exception $previous)
Disable a plugin upon exception.
$plugin_id
Remove all user and plugin settings from the give plugin ID.
$config
Advanced site settings, debugging section.
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.
const ELGG_IGNORE_ACCESS
elgg_call() flags
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.
const ELGG_SHOW_DISABLED_ENTITIES
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
ready()
Run plugin ready handlers.
init()
Initialize plugins.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
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.
upgrade()
Run plugin upgrade handlers.
const PRIORITY_SETTING_NAME
__construct(protected PluginsCache $cache, protected Database $db, protected SessionManagerService $session_manager, protected EventsService $events, protected Translator $translator, protected ViewsService $views, protected Config $config, protected SystemMessagesService $system_messages, protected Invoker $invoker, Request $request)
Constructor.
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.
static fromTable(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
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.
find(string $status= 'active')
Returns an ordered list of plugins.
$id
Generic annotation delete action.
Manages a global stack of strings for sharing information about the current execution context...
endTimer(array $keys)
Ends the timer (when enabled)