Elgg  Version 1.11
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  $val = $this->$name;
279  return $val !== null ? $val : $default;
280  }
281 
289  public function getAllSettings() {
290  if (!$this->guid) {
291  return false;
292  }
293 
294  $db_prefix = _elgg_services()->config->get('dbprefix');
295  // need to remove all namespaced private settings.
296  $us_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
297  $is_prefix = _elgg_namespace_plugin_private_setting('internal', '', $this->getID());
298 
299  // Get private settings for user
300  $q = "SELECT * FROM {$db_prefix}private_settings
301  WHERE entity_guid = $this->guid
302  AND name NOT LIKE '$us_prefix%'
303  AND name NOT LIKE '$is_prefix%'";
304 
305  $private_settings = $this->getDatabase()->getData($q);
306 
307  $return = array();
308 
309  if ($private_settings) {
310  foreach ($private_settings as $setting) {
311  $return[$setting->name] = $setting->value;
312  }
313  }
314 
315  return $return;
316  }
317 
328  public function setSetting($name, $value) {
329  if (!$this->guid) {
330  return false;
331  }
332 
333  // Hook to validate setting
334  $value = elgg_trigger_plugin_hook('setting', 'plugin', array(
335  'plugin_id' => $this->getID(),
336  'plugin' => $this,
337  'name' => $name,
338  'value' => $value,
339  ), $value);
340 
341  return $this->setPrivateSetting($name, $value);
342  }
343 
351  public function unsetSetting($name) {
352  return remove_private_setting($this->guid, $name);
353  }
354 
363  public function unsetAllSettings() {
364  $db_prefix = _elgg_services()->configTable->get('dbprefix');
365  $us_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
366  $is_prefix = _elgg_namespace_plugin_private_setting('internal', '', $this->getID());
367 
368  $q = "DELETE FROM {$db_prefix}private_settings
369  WHERE entity_guid = $this->guid
370  AND name NOT LIKE '$us_prefix%'
371  AND name NOT LIKE '$is_prefix%'";
372 
373  return $this->getDatabase()->deleteData($q);
374  }
375 
376 
377  // User settings
378 
388  public function getUserSetting($name, $user_guid = 0, $default = null) {
389  $user_guid = (int)$user_guid;
390 
391  if ($user_guid) {
393  } else {
394  $user = _elgg_services()->session->getLoggedInUser();
395  }
396 
397  if (!($user instanceof \ElggUser)) {
398  return false;
399  }
400 
401  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
402 
403  $val = get_private_setting($user->guid, $name);
404  return $val !== null ? $val : $default;
405  }
406 
415  public function getAllUserSettings($user_guid = 0) {
416  $user_guid = (int)$user_guid;
417 
418  if ($user_guid) {
420  } else {
421  $user = _elgg_services()->session->getLoggedInUser();
422  }
423 
424  if (!($user instanceof \ElggUser)) {
425  return false;
426  }
427 
428  $db_prefix = _elgg_services()->config->get('dbprefix');
429  // send an empty name so we just get the first part of the namespace
430  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
431  $ps_prefix_len = strlen($ps_prefix);
432 
433  // Get private settings for user
434  $q = "SELECT * FROM {$db_prefix}private_settings
435  WHERE entity_guid = {$user->guid}
436  AND name LIKE '$ps_prefix%'";
437 
438  $private_settings = $this->getDatabase()->getData($q);
439 
440  $return = array();
441 
442  if ($private_settings) {
443  foreach ($private_settings as $setting) {
444  $name = substr($setting->name, $ps_prefix_len);
445  $value = $setting->value;
446 
447  $return[$name] = $value;
448  }
449  }
450 
451  return $return;
452  }
453 
463  public function setUserSetting($name, $value, $user_guid = 0) {
464  $user_guid = (int)$user_guid;
465 
466  if ($user_guid) {
468  } else {
469  $user = _elgg_services()->session->getLoggedInUser();
470  }
471 
472  if (!($user instanceof \ElggUser)) {
473  return false;
474  }
475 
476  // Hook to validate setting
477  // note: this doesn't pass the namespaced name
478  $value = _elgg_services()->hooks->trigger('usersetting', 'plugin', array(
479  'user' => $user,
480  'plugin' => $this,
481  'plugin_id' => $this->getID(),
482  'name' => $name,
483  'value' => $value
484  ), $value);
485 
486  // set the namespaced name.
487  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
488 
489  return set_private_setting($user->guid, $name, $value);
490  }
491 
499  public function unsetUserSetting($name, $user_guid = 0) {
500  $user_guid = (int)$user_guid;
501 
502  if ($user_guid) {
504  } else {
505  $user = _elgg_services()->session->getLoggedInUser();
506  }
507 
508  if (!($user instanceof \ElggUser)) {
509  return false;
510  }
511 
512  // set the namespaced name.
513  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
514 
515  return remove_private_setting($user->guid, $name);
516  }
517 
530  public function unsetAllUserSettings($user_guid) {
531  $db_prefix = _elgg_services()->configTable->get('dbprefix');
532  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
533 
534  $q = "DELETE FROM {$db_prefix}private_settings
535  WHERE entity_guid = $user_guid
536  AND name LIKE '$ps_prefix%'";
537 
538  return $this->getDatabase()->deleteData($q);
539  }
540 
549  public function unsetAllUsersSettings() {
550  $db_prefix = _elgg_services()->configTable->get('dbprefix');
551  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
552 
553  $q = "DELETE FROM {$db_prefix}private_settings
554  WHERE name LIKE '$ps_prefix%'";
555 
556  return $this->getDatabase()->deleteData($q);
557  }
558 
559 
560  // validation
561 
570  public function isValid() {
571  if (!$this->getID()) {
572  $this->errorMsg = _elgg_services()->translator->translate('ElggPlugin:MissingID', array($this->guid));
573  return false;
574  }
575 
576  if (!$this->getPackage() instanceof \ElggPluginPackage) {
577  $this->errorMsg = _elgg_services()->translator->translate('ElggPlugin:NoPluginPackagePackage', array($this->getID(), $this->guid));
578  return false;
579  }
580 
581  if (!$this->getPackage()->isValid()) {
582  $this->errorMsg = $this->getPackage()->getError();
583  return false;
584  }
585 
586  return true;
587  }
588 
595  public function isActive($site_guid = null) {
596  if (!$this->guid) {
597  return false;
598  }
599 
600  if ($site_guid) {
601  $site = get_entity($site_guid);
602  } else {
603  $site = _elgg_services()->configTable->get('site');
604  }
605 
606  if (!($site instanceof \ElggSite)) {
607  return false;
608  }
609 
610  return check_entity_relationship($this->guid, 'active_plugin', $site->guid);
611  }
612 
622  public function canActivate($site_guid = null) {
623  if ($this->getPackage()) {
624  $result = $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
625  if (!$result) {
626  $this->errorMsg = $this->getPackage()->getError();
627  }
628 
629  return $result;
630  }
631 
632  return false;
633  }
634 
635 
636  // activating and deactivating
637 
644  public function activate($site_guid = null) {
645  if ($this->isActive($site_guid)) {
646  return false;
647  }
648 
649  if (!$this->canActivate()) {
650  return false;
651  }
652 
653  // set in the db, now perform tasks and emit events
654  if ($this->setStatus(true, $site_guid)) {
655  // emit an event. returning false will make this not be activated.
656  // we need to do this after it's been fully activated
657  // or the deactivate will be confused.
658  $params = array(
659  'plugin_id' => $this->getID(),
660  'plugin_entity' => $this,
661  );
662 
663  $return = _elgg_services()->events->trigger('activate', 'plugin', $params);
664 
665  // if there are any on_enable functions, start the plugin now and run them
666  // Note: this will not run re-run the init hooks!
667  if ($return) {
668  if ($this->canReadFile('activate.php')) {
671 
672  $this->start($flags);
673 
674  $return = $this->includeFile('activate.php');
675  }
676  }
677 
678  if ($return === false) {
679  $this->deactivate($site_guid);
680  }
681 
682  return $return;
683  }
684 
685  return false;
686  }
687 
694  public function deactivate($site_guid = null) {
695  if (!$this->isActive($site_guid)) {
696  return false;
697  }
698 
699  // emit an event. returning false will cause this to not be deactivated.
700  $params = array(
701  'plugin_id' => $this->getID(),
702  'plugin_entity' => $this,
703  );
704 
705  $return = _elgg_services()->events->trigger('deactivate', 'plugin', $params);
706 
707  // run any deactivate code
708  if ($return) {
709  if ($this->canReadFile('deactivate.php')) {
710  $return = $this->includeFile('deactivate.php');
711  }
712  }
713 
714  if ($return === false) {
715  return false;
716  } else {
717  return $this->setStatus(false, $site_guid);
718  }
719  }
720 
728  public function start($flags) {
729  //if (!$this->canActivate()) {
730  // return false;
731  //}
732 
733  // include classes
734  if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) {
735  $this->registerClasses();
736  }
737 
738  // include start file
739  if ($flags & ELGG_PLUGIN_INCLUDE_START) {
740  $this->includeFile('start.php');
741  }
742 
743  // include views
744  if ($flags & ELGG_PLUGIN_REGISTER_VIEWS) {
745  $this->registerViews();
746  }
747 
748  // include languages
749  if ($flags & ELGG_PLUGIN_REGISTER_LANGUAGES) {
750  $this->registerLanguages();
751  }
752 
753  return true;
754  }
755 
756 
757  // start helpers
758 
764  protected static function getConfigWrapper() {
765  static $wrapper;
766  if (null === $wrapper) {
767  global $CONFIG;
768  $warning = 'Do not rely on local $CONFIG being available in start.php';
769  $wrapper = new \Elgg\DeprecationWrapper($CONFIG, $warning, "1.10");
770  }
771  return $wrapper;
772  }
773 
782  protected function includeFile($filename) {
783  // This needs to be here to be backwards compatible for 1.0-1.7.
784  // They expect the global config object to be available in start.php.
785  if ($filename == 'start.php') {
786  $CONFIG = self::getConfigWrapper();
787  }
788 
789  $filepath = "$this->path/$filename";
790 
791  if (!$this->canReadFile($filename)) {
792  $msg = _elgg_services()->translator->translate('ElggPlugin:Exception:CannotIncludeFile',
793  array($filename, $this->getID(), $this->guid, $this->path));
794  throw new \PluginException($msg);
795  }
796 
797  return include $filepath;
798  }
799 
806  protected function canReadFile($filename) {
807  return is_readable($this->path . '/' . $filename);
808  }
809 
816  protected function registerViews() {
817  if (!_elgg_services()->views->registerPluginViews($this->path, $failed_dir)) {
818  $msg = _elgg_services()->translator->translate('ElggPlugin:Exception:CannotRegisterViews',
819  array($this->getID(), $this->guid, $failed_dir));
820  throw new \PluginException($msg);
821  }
822  }
823 
830  protected function registerLanguages() {
831  $languages_path = "$this->path/languages";
832 
833  // don't need to have classes
834  if (!is_dir($languages_path)) {
835  return true;
836  }
837 
838  // but need to have working ones.
839  if (!_elgg_services()->translator->registerTranslations($languages_path)) {
840  $msg = _elgg_services()->translator->translate('ElggPlugin:Exception:CannotRegisterLanguages',
841  array($this->getID(), $this->guid, $languages_path));
842  throw new \PluginException($msg);
843  }
844 
845  return true;
846  }
847 
854  protected function registerClasses() {
855  $classes_path = "$this->path/classes";
856 
857  if (is_dir($classes_path)) {
858  _elgg_services()->autoloadManager->addClasses($classes_path);
859  }
860 
861  return true;
862  }
863 
870  public function __get($name) {
871  // rewrite for old and inaccurate plugin:setting
872  if (strstr($name, 'plugin:setting:')) {
873  $msg = 'Direct access of user settings is deprecated. Use ElggPlugin->getUserSetting()';
874  elgg_deprecated_notice($msg, 1.8);
875  $name = str_replace('plugin:setting:', '', $name);
876  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
877  }
878 
879  // See if its in our base attribute
880  if (array_key_exists($name, $this->attributes)) {
881  return $this->attributes[$name];
882  }
883 
884  // @todo clean below - getPrivateSetting() should return null now
885  // No, so see if its in the private data store.
886  // get_private_setting() returns false if it doesn't exist
887  $meta = $this->getPrivateSetting($name);
888 
889  if ($meta === false) {
890  // Can't find it, so return null
891  return null;
892  }
893 
894  return $meta;
895  }
896 
904  public function get($name) {
905  elgg_deprecated_notice("Use -> instead of get()", 1.9);
906  return $this->__get($name);
907  }
908 
918  public function __set($name, $value) {
919  if (array_key_exists($name, $this->attributes)) {
920  // Check that we're not trying to change the guid!
921  if ((array_key_exists('guid', $this->attributes)) && ($name == 'guid')) {
922  return;
923  }
924 
925  $this->attributes[$name] = $value;
926  } else {
927  // to make sure we trigger the correct hooks
928  $this->setSetting($name, $value);
929  }
930  }
931 
941  public function set($name, $value) {
942  elgg_deprecated_notice("Use -> instead of set()", 1.9);
943  $this->__set($name, $value);
944 
945  return true;
946  }
947 
956  private function setStatus($active, $site_guid = null) {
957  if (!$this->guid) {
958  return false;
959  }
960 
961  if ($site_guid) {
962  $site = get_entity($site_guid);
963 
964  if (!($site instanceof \ElggSite)) {
965  return false;
966  }
967  } else {
968  $site = _elgg_services()->configTable->get('site');
969  }
970 
971  if ($active) {
972  $result = add_entity_relationship($this->guid, 'active_plugin', $site->guid);
973  } else {
974  $result = remove_entity_relationship($this->guid, 'active_plugin', $site->guid);
975  }
976 
978 
979  return $result;
980  }
981 
987  public function getError() {
988  return $this->errorMsg;
989  }
990 
996  public function getManifest() {
997  if ($this->manifest instanceof \ElggPluginManifest) {
998  return $this->manifest;
999  }
1000 
1001  try {
1002  $this->manifest = $this->getPackage()->getManifest();
1003  } catch (Exception $e) {
1004  _elgg_services()->logger->warn("Failed to load manifest for plugin $this->guid. " . $e->getMessage());
1005  $this->errorMsg = $e->getmessage();
1006  }
1007 
1008  return $this->manifest;
1009  }
1010 
1016  public function getPackage() {
1017  if ($this->package instanceof \ElggPluginPackage) {
1018  return $this->package;
1019  }
1020 
1021  try {
1022  $this->package = new \ElggPluginPackage($this->path, false);
1023  } catch (Exception $e) {
1024  _elgg_services()->logger->warn("Failed to load package for $this->guid. " . $e->getMessage());
1025  $this->errorMsg = $e->getmessage();
1026  }
1027 
1028  return $this->package;
1029  }
1030 }
getSetting($name, $default=null)
Returns a plugin setting.
Definition: ElggPlugin.php:277
registerViews()
Registers the plugin&#39;s views.
Definition: ElggPlugin.php:816
getID()
Returns the ID (dir name) of this plugin.
Definition: ElggPlugin.php:120
ui datepicker title
Definition: admin.php:616
getDatabase()
Provides a pointer to the database object.
Definition: ElggData.php:67
start($flags)
Start the plugin.
Definition: ElggPlugin.php:728
$max_priority
Definition: full.php:23
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
registerClasses()
Registers the plugin&#39;s classes.
Definition: ElggPlugin.php:854
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:668
activate($site_guid=null)
Actives the plugin for the current site.
Definition: ElggPlugin.php:644
getAllSettings()
Returns an array of all settings saved for this plugin.
Definition: ElggPlugin.php:289
getPrivateSetting($name)
Returns a private setting value.
Definition: ElggEntity.php:684
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: elgglib.php:368
$files
Definition: crop.php:36
load($guid)
Loads the full when given a guid.
Definition: ElggObject.php:108
$value
Definition: longtext.php:26
unsetAllUsersSettings()
Removes this plugin&#39;s user settings for all users.
Definition: ElggPlugin.php:549
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:34
canActivate($site_guid=null)
Checks if this plugin can be activated on the current Elgg installation.
Definition: ElggPlugin.php:622
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ::start() to automatically register the plugin&#39;s languages.
Definition: plugins.php:23
$CONFIG path
The full path where Elgg is installed.
Definition: config.php:66
$title
Definition: save.php:24
unsetUserSetting($name, $user_guid=0)
Removes a user setting name and value.
Definition: ElggPlugin.php:499
getUserSetting($name, $user_guid=0, $default=null)
Returns a user&#39;s setting for this plugin.
Definition: ElggPlugin.php:388
includeFile($filename)
Includes one of the plugins files.
Definition: ElggPlugin.php:782
$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:210
canReadFile($filename)
Checks whether a plugin file with the given name exists.
Definition: ElggPlugin.php:806
_elgg_cache_plugin_by_id(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: plugins.php:86
unsetAllUserSettings($user_guid)
Removes all User Settings for this plugin for a particular user.
Definition: ElggPlugin.php:530
getPackage()
Returns this plugin&#39;s object.
setUserSetting($name, $value, $user_guid=0)
Sets a user setting for a plugin.
Definition: ElggPlugin.php:463
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
$CONFIG views
Holds information about views.
Definition: config.php:243
registerLanguages()
Registers the plugin&#39;s languages.
Definition: ElggPlugin.php:830
getAvailableTextFiles()
Returns an array of available markdown files for this plugin.
Definition: ElggPlugin.php:163
_elgg_services()
Definition: autoloader.php:14
$plugin_id
Definition: save.php:16
$active
Definition: full.php:20
global $CONFIG
initializeAttributes()
Set subtype to &#39;plugin&#39;.
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:363
const ELGG_PLUGIN_REGISTER_VIEWS
Tells ::start() to automatically register the plugin&#39;s views.
Definition: plugins.php:18
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:775
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:123
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1006
elgg global
Pointer to the global context.
Definition: elgglib.js:12
elgg river item elgg form comment save
Definition: components.php:242
isActive($site_guid=null)
Is this plugin active?
Definition: ElggPlugin.php:595
isValid()
Returns if the plugin is complete, meaning has all required files and Elgg can read them and they mak...
Definition: ElggPlugin.php:570
setPriority($priority, $site_guid=null)
Sets the priority of the plugin.
Definition: ElggPlugin.php:197
__construct($path)
Creates a new plugin from path.
Definition: ElggPlugin.php:44
getError()
Returns the last error message registered.
Definition: ElggPlugin.php:987
static getConfigWrapper()
Get the config object in a deprecation wrapper.
Definition: ElggPlugin.php:764
setSetting($name, $value)
Set a plugin setting for the plugin.
Definition: ElggPlugin.php:328
getManifest()
Returns this plugin&#39;s object.
Definition: ElggPlugin.php:996
$comment access_id
Definition: save.php:61
const ACCESS_PUBLIC
Definition: elgglib.php:1956
__get($name)
Get an attribute or private setting value.
Definition: ElggPlugin.php:870
getAllUserSettings($user_guid=0)
Returns an array of all user settings saved for this plugin for the user.
Definition: ElggPlugin.php:415
deactivate($site_guid=null)
Deactivates the plugin.
Definition: ElggPlugin.php:694
getFriendlyName()
Returns the manifest&#39;s name if available, otherwise the ID.
Definition: ElggPlugin.php:130
unsetSetting($name)
Removes a plugin setting name and value.
Definition: ElggPlugin.php:351
getPriority()
Gets the plugin&#39;s load priority.
Definition: ElggPlugin.php:183
__set($name, $value)
Set a value as private setting or attribute.
Definition: ElggPlugin.php:918
$filename
Definition: crop.php:23
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&#39;s classes.
Definition: plugins.php:28
_elgg_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
Definition: plugins.php:244
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
$user_guid
Avatar remove action.
Definition: remove.php:6
if(!$collection_name) $id
Definition: add.php:17
getPath()
Returns the plugin&#39;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:97
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:382