47 'friends_collections',
64 'uservalidationbyemail',
113 $this->
cache = $cache;
131 $path = $this->config->plugins_path;
149 unset($this->boot_plugins);
154 $this->boot_plugins = [];
156 if ($order_plugins) {
170 $plugin->registerLanguages();
183 $this->
cache->clear();
192 $this->
cache->invalidate();
212 $handle = opendir($dir);
213 if ($handle ===
false) {
218 while (($plugin_dir = readdir($handle)) !==
false) {
220 if (!str_starts_with($plugin_dir,
'.') && is_dir($dir . $plugin_dir)) {
221 $plugin_dirs[] = $plugin_dir;
242 $old_ia = $this->session_manager->setIgnoreAccess(
true);
245 $old_access = $this->session_manager->setDisabledEntityVisibility(
true);
247 $known_plugins = $this->
find(
'all');
248 if (empty($known_plugins)) {
257 $latest_priority = -1;
258 foreach ($known_plugins as $i =>
$plugin) {
263 unset($known_plugins[$i]);
267 $id_map[
$plugin->getID()] = $i;
275 $current_priority =
$plugin->getPriority();
276 if (($current_priority - $latest_priority) > 1) {
280 $latest_priority = $current_priority;
284 if (empty($physical_plugins)) {
285 $this->session_manager->setIgnoreAccess($old_ia);
286 $this->session_manager->setDisabledEntityVisibility($old_access);
294 if (array_key_exists($plugin_id, $id_map)) {
310 unset($known_plugins[
$index]);
322 foreach ($known_plugins as
$plugin) {
323 if (!$plugin->isEnabled()) {
329 if ($plugin->isActive()) {
331 $plugin->deactivate();
347 $this->session_manager->setIgnoreAccess($old_ia);
348 $this->session_manager->setDisabledEntityVisibility($old_access);
361 if (!$plugin->
getID()) {
404 'subtype' =>
'plugin',
405 'metadata_name_value_pairs' => [
444 $qb->select(
'MAX(CAST(md.value AS unsigned)) as max')
445 ->join(
'e',
'metadata',
'md',
'e.guid = md.entity_guid')
466 if (isset($this->boot_plugins) && is_array($this->boot_plugins)) {
467 return array_key_exists($plugin_id, $this->boot_plugins);
475 return $plugin->hasRelationship(1,
'active_plugin');
488 $plugins_path = $this->
getPath();
491 if (file_exists(
"{$plugins_path}/disabled")) {
492 if ($this->session_manager->isAdminLoggedIn() && $this->context->contains(
'admin')) {
493 $this->system_messages->addSuccessMessage($this->translator->translate(
'plugins:disabled'));
499 $this->events->registerHandler(
'plugins_load',
'system', [$this,
'register']);
500 $this->events->registerHandler(
'plugins_boot:before',
'system', [$this,
'boot']);
501 $this->events->registerHandler(
'init',
'system', [$this,
'init']);
502 $this->events->registerHandler(
'ready',
'system', [$this,
'ready']);
503 $this->events->registerHandler(
'upgrade',
'system', [$this,
'upgrade']);
504 $this->events->registerHandler(
'shutdown',
'system', [$this,
'shutdown']);
515 public function register():
void {
597 $plugin->getBootstrap()->ready();
621 $plugin->getBootstrap()->upgrade();
645 $plugin->getBootstrap()->shutdown();
663 $this->
getLogger()->log(LogLevel::ERROR, $previous, [
669 if (!$this->config->auto_disable_plugins) {
677 $msg = $this->translator->translate(
678 'PluginException:CannotStart',
679 [
$id, $plugin->guid, $previous->getMessage()]
684 $this->
getLogger()->log(LogLevel::ERROR, $ex, [
699 public function find(
string $status =
'active'): array {
700 if (!$this->db || !$this->config->installed) {
704 if ($status ===
'active' && isset($this->boot_plugins)) {
706 return array_values($this->boot_plugins);
709 $volatile_data_name = null;
715 'subtype' =>
'plugin',
722 $options[
'relationship'] =
'active_plugin';
723 $options[
'relationship_guid'] = $site_guid;
724 $options[
'inverse_relationship'] =
true;
727 $volatile_data_name =
'select:value';
728 $options[
'select'] = [
'n_table.value'];
736 $subquery = $qb->
subquery(
'entity_relationships',
'active_er');
737 $subquery->select(
'active_er.guid_one')
741 return $qb->
compare(
"{$main_alias}.guid",
'NOT IN', $subquery->getSQL());
750 $old_ia = $this->session_manager->setIgnoreAccess(
true);
752 $this->session_manager->setIgnoreAccess($old_ia);
756 if ($status ===
'active' && !isset($this->boot_plugins)) {
774 $sorted_plugins = [];
778 if (!empty($volatile_data_name)) {
779 $priority = $plugin->getVolatileData($volatile_data_name);
786 $priorities[$plugin->guid] = (int)
$priority;
787 $sorted_plugins[$plugin->guid] =
$plugin;
792 return array_values(array_replace($priorities, $sorted_plugins));
817 $order = array_values($order);
820 $missing_plugins = [];
824 if (!$plugin->isEnabled()) {
826 if ($plugin->getPriority() !== null) {
828 unset($plugin->$name);
849 if (empty($missing_plugins)) {
853 foreach ($missing_plugins as $plugin) {
889 if (!$plugin->guid) {
897 if ($priority > $old_priority) {
898 $qb->set(
'value',
'CAST(value AS UNSIGNED) - 1');
901 $qb->set(
'value',
'CAST(value AS UNSIGNED) + 1');
905 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)
{}
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(!$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($x, $comparison, $y=null, $type=null, $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
subquery($table, $alias=null)
Creates a new SelectQueryBuilder for join/where subqueries using the DB connection of the primary Que...
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)