45 'friends_collections',
63 'uservalidationbyemail',
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)) {
362 $qb->select(
'MAX(CAST(md.value AS unsigned)) as max')
384 if (isset($this->boot_plugins) && is_array($this->boot_plugins)) {
385 return array_key_exists($plugin_id, $this->boot_plugins);
393 return $plugin->hasRelationship(1,
'active_plugin');
406 $plugins_path = $this->
getPath();
409 if (file_exists(
"{$plugins_path}/disabled")) {
410 if ($this->session_manager->isAdminLoggedIn() && $this->context->contains(
'admin')) {
411 $this->system_messages->addSuccessMessage($this->translator->translate(
'plugins:disabled'));
417 $this->events->registerHandler(
'plugins_load',
'system', [$this,
'register']);
418 $this->events->registerHandler(
'plugins_boot:before',
'system', [$this,
'boot']);
419 $this->events->registerHandler(
'init',
'system', [$this,
'init']);
420 $this->events->registerHandler(
'ready',
'system', [$this,
'ready']);
421 $this->events->registerHandler(
'upgrade',
'system', [$this,
'upgrade']);
422 $this->events->registerHandler(
'shutdown',
'system', [$this,
'shutdown']);
433 public function register():
void {
434 $plugins = $this->
find(
'active');
435 if (empty($plugins)) {
441 foreach ($plugins as
$plugin) {
444 }
catch (\Exception $ex) {
458 $plugins = $this->
find(
'active');
459 if (empty($plugins)) {
465 foreach ($plugins as
$plugin) {
468 }
catch (\Exception $ex) {
482 $plugins = $this->
find(
'active');
483 if (empty($plugins)) {
489 foreach ($plugins as
$plugin) {
492 }
catch (\Exception $ex) {
506 $plugins = $this->
find(
'active');
507 if (empty($plugins)) {
513 foreach ($plugins as
$plugin) {
515 $plugin->getBootstrap()->ready();
516 }
catch (\Exception $ex) {
530 $plugins = $this->
find(
'active');
531 if (empty($plugins)) {
537 foreach ($plugins as
$plugin) {
539 $plugin->getBootstrap()->upgrade();
540 }
catch (\Exception $ex) {
554 $plugins = $this->
find(
'active');
555 if (empty($plugins)) {
561 foreach ($plugins as
$plugin) {
563 $plugin->getBootstrap()->shutdown();
564 }
catch (\Exception $ex) {
581 $this->
getLogger()->log(LogLevel::ERROR, $previous, [
587 if (!$this->config->auto_disable_plugins) {
595 $msg = $this->translator->translate(
596 'PluginException:CannotStart',
597 [
$id, $plugin->guid, $previous->getMessage()]
602 $this->
getLogger()->log(LogLevel::ERROR, $ex, [
617 public function find(
string $status =
'active'): array {
618 if (!$this->db || !$this->config->installed) {
622 if ($status ===
'active' && isset($this->boot_plugins)) {
624 return array_values($this->boot_plugins);
627 $volatile_data_name = null;
633 'subtype' =>
'plugin',
640 $options[
'relationship'] =
'active_plugin';
641 $options[
'relationship_guid'] = $site_guid;
642 $options[
'inverse_relationship'] =
true;
645 $volatile_data_name =
'select:value';
654 $subquery = $qb->
subquery(
'entity_relationships',
'active_er');
655 $subquery->select(
'active_er.guid_one')
659 return $qb->
compare(
"{$main_alias}.guid",
'NOT IN', $subquery->getSQL());
674 if ($status ===
'active' && !isset($this->boot_plugins)) {
679 foreach ($plugins as
$plugin) {
681 $this->cache->save($plugin->getID(),
$plugin);
697 $sorted_plugins = [];
699 foreach ($plugins as
$plugin) {
701 if (!empty($volatile_data_name)) {
702 $priority = $plugin->getVolatileData($volatile_data_name);
709 $priorities[$plugin->guid] = (int)
$priority;
710 $sorted_plugins[$plugin->guid] =
$plugin;
715 return array_values(array_replace($priorities, $sorted_plugins));
733 $plugins = $this->
find(
'all');
734 if (empty($plugins)) {
740 $order = array_values($order);
743 $missing_plugins = [];
746 foreach ($plugins as
$plugin) {
747 if (!$plugin->isEnabled()) {
749 if ($plugin->getPriority() !== null) {
751 unset($plugin->$name);
772 if (empty($missing_plugins)) {
776 foreach ($missing_plugins as $plugin) {
812 if (!$plugin->guid) {
820 if ($priority > $old_priority) {
821 $qb->set(
'value',
'CAST(value AS UNSIGNED) - 1');
824 $qb->set(
'value',
'CAST(value AS UNSIGNED) + 1');
828 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 "/".
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
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.
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
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.
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.
The Elgg cache base class.
const PRIORITY_SETTING_NAME
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)
__construct(protected BaseCache $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.