Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
ElggPlugin.php
Go to the documentation of this file.
1 <?php
11 class ElggPlugin extends \ElggObject {
12  private $package;
13  private $manifest;
14 
15  private $path;
16  private $errorMsg = '';
17 
23  protected function initializeAttributes() {
24  parent::initializeAttributes();
25 
26  $this->attributes['subtype'] = "plugin";
27 
28  // plugins must be public.
29  $this->access_id = ACCESS_PUBLIC;
30  }
31 
44  public function __construct($path) {
45  if (!$path) {
46  throw new \PluginException("ElggPlugin cannot be null instantiated. You must pass a full path.");
47  }
48 
49  if (is_object($path)) {
50  // database object
51  parent::__construct($path);
52  $this->path = _elgg_services()->config->getPluginsPath() . $this->getID();
53  } else if (is_numeric($path)) {
54  // guid
55  // @todo plugins with directory names of '12345'
56  elgg_deprecated_notice("Use elgg_get_plugin_from_id() to load a plugin.", 1.9);
57  parent::__construct($path);
58  $this->path = _elgg_services()->config->getPluginsPath() . $this->getID();
59  } else {
60  $this->initializeAttributes();
61 
62  $mod_dir = _elgg_services()->config->getPluginsPath();
63 
64  // not a full path, so assume a directory name and use the default path
65  if (strpos($path, $mod_dir) !== 0) {
66  elgg_deprecated_notice("You should pass a full path to ElggPlugin.", 1.9);
67  $path = $mod_dir . $path;
68  }
69 
70  // path checking is done in the package
71  $path = sanitise_filepath($path);
72  $this->path = $path;
73  $path_parts = explode('/', rtrim($path, '/'));
74  $plugin_id = array_pop($path_parts);
75  $this->title = $plugin_id;
76 
77  // check if we're loading an existing plugin
78  $existing_plugin = elgg_get_plugin_from_id($plugin_id);
79 
80  if ($existing_plugin) {
81  $this->load($existing_plugin->guid);
82  }
83  }
84 
86  }
87 
94  public function save() {
95  // own by the current site so users can be deleted without affecting plugins
96  $site = _elgg_services()->configTable->get('site');
97  $this->attributes['site_guid'] = $site->guid;
98  $this->attributes['owner_guid'] = $site->guid;
99  $this->attributes['container_guid'] = $site->guid;
100 
101  if (parent::save()) {
102  // make sure we have a priority
103  $priority = $this->getPriority();
104  if ($priority === false || $priority === null) {
105  return $this->setPriority('last');
106  }
107  } else {
108  return false;
109  }
110  }
111 
112 
113  // Plugin ID and path
114 
120  public function getID() {
121  return $this->title;
122  }
123 
130  public function getFriendlyName() {
131  $manifest = $this->getManifest();
132  if ($manifest) {
133  return $manifest->getName();
134  }
135 
136  return $this->getID();
137  }
138 
144  public function getPath() {
145  return sanitise_filepath($this->path);
146  }
147 
154  public function setID($id) {
155  return $this->attributes['title'] = $id;
156  }
157 
163  public function getAvailableTextFiles() {
164  $filenames = $this->getPackage()->getTextFilenames();
165 
166  $files = array();
167  foreach ($filenames as $filename) {
168  if ($this->canReadFile($filename)) {
169  $files[$filename] = "$this->path/$filename";
170  }
171  }
172 
173  return $files;
174  }
175 
176  // Load Priority
177 
183  public function getPriority() {
184  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
185  return $this->$name;
186  }
187 
197  public function setPriority($priority, $site_guid = null) {
198  if (!$this->guid) {
199  return false;
200  }
201 
202  $db_prefix = _elgg_services()->configTable->get('dbprefix');
203  $name = _elgg_namespace_plugin_private_setting('internal', 'priority');
204  // if no priority assume a priority of 1
205  $old_priority = (int) $this->getPriority();
206  $old_priority = (!$old_priority) ? 1 : $old_priority;
208 
209  // can't use switch here because it's not strict and
210  // php evaluates +1 == 1
211  if ($priority === '+1') {
212  $priority = $old_priority + 1;
213  } elseif ($priority === '-1') {
214  $priority = $old_priority - 1;
215  } elseif ($priority === 'first') {
216  $priority = 1;
217  } elseif ($priority === 'last') {
219  }
220 
221  // should be a number by now
222  if ($priority > 0) {
223  if (!is_numeric($priority)) {
224  return false;
225  }
226 
227  // there's nothing above the max.
228  if ($priority > $max_priority) {
230  }
231 
232  // there's nothing below 1.
233  if ($priority < 1) {
234  $priority = 1;
235  }
236 
237  if ($priority > $old_priority) {
238  $op = '-';
239  $where = "CAST(value as unsigned) BETWEEN $old_priority AND $priority";
240  } else {
241  $op = '+';
242  $where = "CAST(value as unsigned) BETWEEN $priority AND $old_priority";
243  }
244 
245  // displace the ones affected by this change
246  $q = "UPDATE {$db_prefix}private_settings
247  SET value = CAST(value as unsigned) $op 1
248  WHERE entity_guid != $this->guid
249  AND name = '$name'
250  AND $where";
251 
252  if (!$this->getDatabase()->updateData($q)) {
253  return false;
254  }
255 
256  // set this priority
257  if ($this->setPrivateSetting($name, $priority)) {
258  return true;
259  } else {
260  return false;
261  }
262  }
263 
264  return false;
265  }
266 
267 
268  // Plugin settings
269 
277  public function getSetting($name, $default = null) {
278  $values = _elgg_services()->pluginSettingsCache->getAll($this->guid);
279 
280  if ($values !== null) {
281  return isset($values[$name]) ? $values[$name] : $default;
282  }
283 
284  $val = $this->$name;
285  return $val !== null ? $val : $default;
286  }
287 
295  public function getAllSettings() {
296  $values = _elgg_services()->pluginSettingsCache->getAll($this->guid);
297  if ($values !== null) {
298  return $values;
299  }
300 
301  if (!$this->guid) {
302  return false;
303  }
304 
305  $db_prefix = _elgg_services()->config->get('dbprefix');
306  // need to remove all namespaced private settings.
307  $us_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
308  $is_prefix = _elgg_namespace_plugin_private_setting('internal', '', $this->getID());
309 
310  // Get private settings for user
311  $q = "SELECT * FROM {$db_prefix}private_settings
312  WHERE entity_guid = $this->guid
313  AND name NOT LIKE '$us_prefix%'
314  AND name NOT LIKE '$is_prefix%'";
315 
316  $private_settings = $this->getDatabase()->getData($q);
317 
318  $return = array();
319 
320  if ($private_settings) {
321  foreach ($private_settings as $setting) {
322  $return[$setting->name] = $setting->value;
323  }
324  }
325 
326  return $return;
327  }
328 
339  public function setSetting($name, $value) {
340  if (!$this->guid) {
341  return false;
342  }
343 
344  // Hook to validate setting
345  $value = elgg_trigger_plugin_hook('setting', 'plugin', array(
346  'plugin_id' => $this->getID(),
347  'plugin' => $this,
348  'name' => $name,
349  'value' => $value,
350  ), $value);
351 
352  return $this->setPrivateSetting($name, $value);
353  }
354 
362  public function unsetSetting($name) {
363  return remove_private_setting($this->guid, $name);
364  }
365 
374  public function unsetAllSettings() {
375  _elgg_services()->pluginSettingsCache->clear($this->guid);
376  _elgg_services()->boot->invalidateCache();
377 
378  $db_prefix = _elgg_services()->configTable->get('dbprefix');
379  $us_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
380  $is_prefix = _elgg_namespace_plugin_private_setting('internal', '', $this->getID());
381 
382  $q = "DELETE FROM {$db_prefix}private_settings
383  WHERE entity_guid = $this->guid
384  AND name NOT LIKE '$us_prefix%'
385  AND name NOT LIKE '$is_prefix%'";
386 
387  return $this->getDatabase()->deleteData($q);
388  }
389 
390 
391  // User settings
392 
402  public function getUserSetting($name, $user_guid = 0, $default = null) {
403  $user_guid = (int)$user_guid;
404 
405  if ($user_guid) {
407  } else {
408  $user = _elgg_services()->session->getLoggedInUser();
409  }
410 
411  if (!($user instanceof \ElggUser)) {
412  return false;
413  }
414 
415  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
416 
417  $val = get_private_setting($user->guid, $name);
418  return $val !== null ? $val : $default;
419  }
420 
429  public function getAllUserSettings($user_guid = 0) {
430  $user_guid = (int)$user_guid;
431 
432  if ($user_guid) {
434  } else {
435  $user = _elgg_services()->session->getLoggedInUser();
436  }
437 
438  if (!($user instanceof \ElggUser)) {
439  return false;
440  }
441 
442  $db_prefix = _elgg_services()->config->get('dbprefix');
443  // send an empty name so we just get the first part of the namespace
444  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
445  $ps_prefix_len = strlen($ps_prefix);
446 
447  // Get private settings for user
448  $q = "SELECT * FROM {$db_prefix}private_settings
449  WHERE entity_guid = {$user->guid}
450  AND name LIKE '$ps_prefix%'";
451 
452  $private_settings = $this->getDatabase()->getData($q);
453 
454  $return = array();
455 
456  if ($private_settings) {
457  foreach ($private_settings as $setting) {
458  $name = substr($setting->name, $ps_prefix_len);
459  $value = $setting->value;
460 
461  $return[$name] = $value;
462  }
463  }
464 
465  return $return;
466  }
467 
477  public function setUserSetting($name, $value, $user_guid = 0) {
478  $user_guid = (int)$user_guid;
479 
480  if ($user_guid) {
482  } else {
483  $user = _elgg_services()->session->getLoggedInUser();
484  }
485 
486  if (!($user instanceof \ElggUser)) {
487  return false;
488  }
489 
490  // Hook to validate setting
491  // note: this doesn't pass the namespaced name
492  $value = _elgg_services()->hooks->trigger('usersetting', 'plugin', array(
493  'user' => $user,
494  'plugin' => $this,
495  'plugin_id' => $this->getID(),
496  'name' => $name,
497  'value' => $value
498  ), $value);
499 
500  // set the namespaced name.
501  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
502 
503  return set_private_setting($user->guid, $name, $value);
504  }
505 
513  public function unsetUserSetting($name, $user_guid = 0) {
514  $user_guid = (int)$user_guid;
515 
516  if ($user_guid) {
518  } else {
519  $user = _elgg_services()->session->getLoggedInUser();
520  }
521 
522  if (!($user instanceof \ElggUser)) {
523  return false;
524  }
525 
526  // set the namespaced name.
527  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
528 
529  return remove_private_setting($user->guid, $name);
530  }
531 
544  public function unsetAllUserSettings($user_guid) {
545  $db_prefix = _elgg_services()->configTable->get('dbprefix');
546  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
547 
548  $q = "DELETE FROM {$db_prefix}private_settings
549  WHERE entity_guid = $user_guid
550  AND name LIKE '$ps_prefix%'";
551 
552  return $this->getDatabase()->deleteData($q);
553  }
554 
563  public function unsetAllUsersSettings() {
564  $db_prefix = _elgg_services()->configTable->get('dbprefix');
565  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
566 
567  $q = "DELETE FROM {$db_prefix}private_settings
568  WHERE name LIKE '$ps_prefix%'";
569 
570  return $this->getDatabase()->deleteData($q);
571  }
572 
573 
574  // validation
575 
584  public function isValid() {
585  if (!$this->getID()) {
586  $this->errorMsg = _elgg_services()->translator->translate('ElggPlugin:MissingID', array($this->guid));
587  return false;
588  }
589 
590  if (!$this->getPackage() instanceof \ElggPluginPackage) {
591  $this->errorMsg = _elgg_services()->translator->translate('ElggPlugin:NoPluginPackagePackage', array($this->getID(), $this->guid));
592  return false;
593  }
594 
595  if (!$this->getPackage()->isValid()) {
596  $this->errorMsg = $this->getPackage()->getError();
597  return false;
598  }
599 
600  return true;
601  }
602 
609  public function isActive($site_guid = null) {
610  if (!$this->guid) {
611  return false;
612  }
613 
614  if ($site_guid) {
615  $site = get_entity($site_guid);
616  } else {
617  $site = _elgg_services()->configTable->get('site');
618  }
619 
620  if (!($site instanceof \ElggSite)) {
621  return false;
622  }
623 
624  return check_entity_relationship($this->guid, 'active_plugin', $site->guid);
625  }
626 
636  public function canActivate($site_guid = null) {
637  if ($this->getPackage()) {
638  $result = $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
639  if (!$result) {
640  $this->errorMsg = $this->getPackage()->getError();
641  }
642 
643  return $result;
644  }
645 
646  return false;
647  }
648 
649 
650  // activating and deactivating
651 
658  public function activate($site_guid = null) {
659  if ($this->isActive($site_guid)) {
660  return false;
661  }
662 
663  if (!$this->canActivate()) {
664  return false;
665  }
666 
667  // set in the db, now perform tasks and emit events
668  if ($this->setStatus(true, $site_guid)) {
669  // emit an event. returning false will make this not be activated.
670  // we need to do this after it's been fully activated
671  // or the deactivate will be confused.
672  $params = array(
673  'plugin_id' => $this->getID(),
674  'plugin_entity' => $this,
675  );
676 
677  $return = _elgg_services()->events->trigger('activate', 'plugin', $params);
678 
679  // if there are any on_enable functions, start the plugin now and run them
680  // Note: this will not run re-run the init hooks!
681  if ($return) {
682  if ($this->canReadFile('activate.php')) {
685 
686  $this->start($flags);
687 
688  $return = $this->includeFile('activate.php');
689  }
690  }
691 
692  if ($return === false) {
693  $this->deactivate($site_guid);
694  }
695 
696  return $return;
697  }
698 
699  return false;
700  }
701 
708  public function deactivate($site_guid = null) {
709  if (!$this->isActive($site_guid)) {
710  return false;
711  }
712 
713  // emit an event. returning false will cause this to not be deactivated.
714  $params = array(
715  'plugin_id' => $this->getID(),
716  'plugin_entity' => $this,
717  );
718 
719  $return = _elgg_services()->events->trigger('deactivate', 'plugin', $params);
720 
721  // run any deactivate code
722  if ($return) {
723  if ($this->canReadFile('deactivate.php')) {
724  $return = $this->includeFile('deactivate.php');
725  }
726  }
727 
728  if ($return === false) {
729  return false;
730  } else {
731  return $this->setStatus(false, $site_guid);
732  }
733  }
734 
742  public function start($flags) {
743  //if (!$this->canActivate()) {
744  // return false;
745  //}
746 
747  // include classes
748  if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) {
749  $this->registerClasses();
750  }
751 
752  // include start file
753  if ($flags & ELGG_PLUGIN_INCLUDE_START) {
754  $this->includeFile('start.php');
755  }
756 
757  // include views
758  if ($flags & ELGG_PLUGIN_REGISTER_VIEWS) {
759  $this->registerViews();
760  }
761 
762  // include languages
763  if ($flags & ELGG_PLUGIN_REGISTER_LANGUAGES) {
764  $this->registerLanguages();
765  }
766 
767  return true;
768  }
769 
770 
771  // start helpers
772 
778  protected static function getConfigWrapper() {
779  static $wrapper;
780  if (null === $wrapper) {
781  global $CONFIG;
782  $warning = 'Do not rely on local $CONFIG being available in start.php';
783  $wrapper = new \Elgg\DeprecationWrapper($CONFIG, $warning, "1.10");
784  }
785  return $wrapper;
786  }
787 
796  protected function includeFile($filename) {
797  // This needs to be here to be backwards compatible for 1.0-1.7.
798  // They expect the global config object to be available in start.php.
799  if ($filename == 'start.php') {
800  $CONFIG = self::getConfigWrapper();
801  }
802 
803  $filepath = "$this->path/$filename";
804 
805  if (!$this->canReadFile($filename)) {
806  $msg = _elgg_services()->translator->translate('ElggPlugin:Exception:CannotIncludeFile',
807  array($filename, $this->getID(), $this->guid, $this->path));
808  throw new \PluginException($msg);
809  }
810 
811  return include $filepath;
812  }
813 
820  protected function canReadFile($filename) {
821  return is_readable($this->path . '/' . $filename);
822  }
823 
830  protected function registerViews() {
831  $views = _elgg_services()->views;
832 
833  // Declared views first
834  $file = "{$this->path}/views.php";
835  if (is_file($file)) {
836  $spec = (include $file);
837  if (is_array($spec)) {
838  $views->mergeViewsSpec($spec);
839  }
840  }
841 
842  // Allow /views directory files to override
843  if (!$views->registerPluginViews($this->path, $failed_dir)) {
844  $msg = _elgg_services()->translator->translate('ElggPlugin:Exception:CannotRegisterViews',
845  array($this->getID(), $this->guid, $failed_dir));
846  throw new \PluginException($msg);
847  }
848  }
849 
856  protected function registerLanguages() {
857  return _elgg_services()->translator->registerPluginTranslations($this->path);
858  }
859 
866  protected function registerClasses() {
867  $classes_path = "$this->path/classes";
868 
869  if (is_dir($classes_path)) {
870  _elgg_services()->autoloadManager->addClasses($classes_path);
871  }
872 
873  return true;
874  }
875 
882  public function __get($name) {
883  // See if its in our base attribute
884  if (array_key_exists($name, $this->attributes)) {
885  return $this->attributes[$name];
886  }
887 
888  // @todo clean below - getPrivateSetting() should return null now
889  // No, so see if its in the private data store.
890  // get_private_setting() returns false if it doesn't exist
891  $meta = $this->getPrivateSetting($name);
892 
893  if ($meta === false) {
894  // Can't find it, so return null
895  return null;
896  }
897 
898  return $meta;
899  }
900 
908  public function get($name) {
909  elgg_deprecated_notice("Use -> instead of get()", 1.9);
910  return $this->__get($name);
911  }
912 
922  public function __set($name, $value) {
923  if (array_key_exists($name, $this->attributes)) {
924  // Check that we're not trying to change the guid!
925  if ((array_key_exists('guid', $this->attributes)) && ($name == 'guid')) {
926  return;
927  }
928 
929  $this->attributes[$name] = $value;
930  } else {
931  // to make sure we trigger the correct hooks
932  $this->setSetting($name, $value);
933  }
934  }
935 
945  public function set($name, $value) {
946  elgg_deprecated_notice("Use -> instead of set()", 1.9);
947  $this->__set($name, $value);
948 
949  return true;
950  }
951 
960  private function setStatus($active, $site_guid = null) {
961  if (!$this->guid) {
962  return false;
963  }
964 
965  if ($site_guid) {
966  $site = get_entity($site_guid);
967 
968  if (!($site instanceof \ElggSite)) {
969  return false;
970  }
971  } else {
972  $site = _elgg_services()->configTable->get('site');
973  }
974 
975  if ($active) {
976  $result = add_entity_relationship($this->guid, 'active_plugin', $site->guid);
977  } else {
978  $result = remove_entity_relationship($this->guid, 'active_plugin', $site->guid);
979  }
980 
982  _elgg_services()->boot->invalidateCache();
983 
984  return $result;
985  }
986 
992  public function getError() {
993  return $this->errorMsg;
994  }
995 
1001  public function getManifest() {
1002  if ($this->manifest instanceof \ElggPluginManifest) {
1003  return $this->manifest;
1004  }
1005 
1006  try {
1007  $this->manifest = $this->getPackage()->getManifest();
1008  } catch (Exception $e) {
1009  _elgg_services()->logger->warn("Failed to load manifest for plugin $this->guid. " . $e->getMessage());
1010  $this->errorMsg = $e->getmessage();
1011  }
1012 
1013  return $this->manifest;
1014  }
1015 
1021  public function getPackage() {
1022  if ($this->package instanceof \ElggPluginPackage) {
1023  return $this->package;
1024  }
1025 
1026  try {
1027  $this->package = new \ElggPluginPackage($this->path, false);
1028  } catch (Exception $e) {
1029  _elgg_services()->logger->warn("Failed to load package for $this->guid. " . $e->getMessage());
1030  $this->errorMsg = $e->getmessage();
1031  }
1032 
1033  return $this->package;
1034  }
1035 }
getSetting($name, $default=null)
Returns a plugin setting.
Definition: ElggPlugin.php:277
registerViews()
Registers the plugin's views.
Definition: ElggPlugin.php:830
getID()
Returns the ID (dir name) of this plugin.
Definition: ElggPlugin.php:120
getDatabase()
Provides a pointer to the database object.
Definition: ElggData.php:46
start($flags)
Start the plugin.
Definition: ElggPlugin.php:742
if(!array_key_exists($filename, $text_files)) $file
$max_priority
Definition: full.php:23
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
registerClasses()
Registers the plugin's classes.
Definition: ElggPlugin.php:866
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
$e
Definition: metadata.php:12
setPrivateSetting($name, $value)
Adds a private setting to this entity.
Definition: ElggEntity.php:656
activate($site_guid=null)
Actives the plugin for the current site.
Definition: ElggPlugin.php:658
getAllSettings()
Returns an array of all settings saved for this plugin.
Definition: ElggPlugin.php:295
getPrivateSetting($name)
Returns a private setting value.
Definition: ElggEntity.php:672
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: elgglib.php:399
load($guid)
Loads the full when given a guid.
Definition: ElggObject.php:98
$value
Definition: longtext.php:26
unsetAllUsersSettings()
Removes this plugin's user settings for all users.
Definition: ElggPlugin.php:563
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:35
canActivate($site_guid=null)
Checks if this plugin can be activated on the current Elgg installation.
Definition: ElggPlugin.php:636
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ::start() to automatically register the plugin's languages.
Definition: plugins.php:23
$CONFIG path
The full path where Elgg is installed.
Definition: config.php:16
$title
Definition: save.php:22
unsetUserSetting($name, $user_guid=0)
Removes a user setting name and value.
Definition: ElggPlugin.php:513
getUserSetting($name, $user_guid=0, $default=null)
Returns a user's setting for this plugin.
Definition: ElggPlugin.php:402
includeFile($filename)
Includes one of the plugins files.
Definition: ElggPlugin.php:796
$params
Definition: login.php:72
setID($id)
Sets the location of this plugin.
Definition: ElggPlugin.php:154
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
Definition: plugins.php:151
if(!$plugin instanceof ElggPlugin) $active
Definition: details.php:14
canReadFile($filename)
Checks whether a plugin file with the given name exists.
Definition: ElggPlugin.php:820
_elgg_cache_plugin_by_id(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: plugins.php:71
unsetAllUserSettings($user_guid)
Removes all User Settings for this plugin for a particular user.
Definition: ElggPlugin.php:544
getPackage()
Returns this plugin's object.
setUserSetting($name, $value, $user_guid=0)
Sets a user setting for a plugin.
Definition: ElggPlugin.php:477
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
registerLanguages()
Registers the plugin's languages.
Definition: ElggPlugin.php:856
getAvailableTextFiles()
Returns an array of available markdown files for this plugin.
Definition: ElggPlugin.php:163
$plugin_id
Definition: save.php:16
global $CONFIG
initializeAttributes()
Set subtype to 'plugin'.
Definition: ElggPlugin.php:23
$user
Definition: ban.php:13
const ELGG_PLUGIN_INCLUDE_START
Tells ::start() to include the start.php file.
Definition: plugins.php:13
unsetAllSettings()
Removes all settings for this plugin.
Definition: ElggPlugin.php:374
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ::start() to automatically register the plugin's views.
Definition: plugins.php:18
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:801
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
Definition: plugins.php:108
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1070
isActive($site_guid=null)
Is this plugin active?
Definition: ElggPlugin.php:609
isValid()
Returns if the plugin is complete, meaning has all required files and Elgg can read them and they mak...
Definition: ElggPlugin.php:584
setPriority($priority, $site_guid=null)
Sets the priority of the plugin.
Definition: ElggPlugin.php:197
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
__construct($path)
Creates a new plugin from path.
Definition: ElggPlugin.php:44
getError()
Returns the last error message registered.
Definition: ElggPlugin.php:992
static getConfigWrapper()
Get the config object in a deprecation wrapper.
Definition: ElggPlugin.php:778
setSetting($name, $value)
Set a plugin setting for the plugin.
Definition: ElggPlugin.php:339
getManifest()
Returns this plugin's object.
$comment access_id
Definition: save.php:60
const ACCESS_PUBLIC
Definition: elgglib.php:1990
__get($name)
Get an attribute or private setting value.
Definition: ElggPlugin.php:882
getAllUserSettings($user_guid=0)
Returns an array of all user settings saved for this plugin for the user.
Definition: ElggPlugin.php:429
deactivate($site_guid=null)
Deactivates the plugin.
Definition: ElggPlugin.php:708
getFriendlyName()
Returns the manifest's name if available, otherwise the ID.
Definition: ElggPlugin.php:130
unsetSetting($name)
Removes a plugin setting name and value.
Definition: ElggPlugin.php:362
getPriority()
Gets the plugin's load priority.
Definition: ElggPlugin.php:183
__set($name, $value)
Set a value as private setting or attribute.
Definition: ElggPlugin.php:922
$filename
save()
Save the plugin object.
Definition: ElggPlugin.php:94
set_private_setting($entity_guid, $name, $value)
Sets a private setting for an entity.
const ELGG_PLUGIN_REGISTER_CLASSES
Tells ::start() to automatically register the plugin's classes.
Definition: plugins.php:28
_elgg_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
Definition: plugins.php:162
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
$user_guid
Avatar remove action.
Definition: remove.php:6
foreach($resources as $id=> $href) if(!empty($resources_html)) $files
Definition: details.php:141
if(!$collection_name) $id
Definition: add.php:17
set($name, $value)
Save a value as private setting or attribute.
Definition: ElggPlugin.php:945
getPath()
Returns the plugin's full path with trailing slash.
Definition: ElggPlugin.php:144
if(!$num_display) $db_prefix
Definition: content.php:12
$priority
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:82
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204