Elgg  Version 1.9
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_get_plugins_path() . $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_get_plugins_path() . $this->getID();
59  } else {
60  $this->initializeAttributes();
61 
62  $mod_dir = elgg_get_plugins_path();
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 = get_config('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 = get_config('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_get_config('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 = get_config('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 
387  public function getUserSetting($name, $user_guid = 0) {
388  $user_guid = (int)$user_guid;
389 
390  if ($user_guid) {
392  } else {
394  }
395 
396  if (!($user instanceof ElggUser)) {
397  return false;
398  }
399 
400  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
401  return get_private_setting($user->guid, $name);
402  }
403 
412  public function getAllUserSettings($user_guid = 0) {
413  $user_guid = (int)$user_guid;
414 
415  if ($user_guid) {
417  } else {
419  }
420 
421  if (!($user instanceof ElggUser)) {
422  return false;
423  }
424 
425  $db_prefix = elgg_get_config('dbprefix');
426  // send an empty name so we just get the first part of the namespace
427  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
428  $ps_prefix_len = strlen($ps_prefix);
429 
430  // Get private settings for user
431  $q = "SELECT * FROM {$db_prefix}private_settings
432  WHERE entity_guid = {$user->guid}
433  AND name LIKE '$ps_prefix%'";
434 
435  $private_settings = $this->getDatabase()->getData($q);
436 
437  $return = array();
438 
439  if ($private_settings) {
440  foreach ($private_settings as $setting) {
441  $name = substr($setting->name, $ps_prefix_len);
442  $value = $setting->value;
443 
444  $return[$name] = $value;
445  }
446  }
447 
448  return $return;
449  }
450 
460  public function setUserSetting($name, $value, $user_guid = 0) {
461  $user_guid = (int)$user_guid;
462 
463  if ($user_guid) {
465  } else {
467  }
468 
469  if (!($user instanceof ElggUser)) {
470  return false;
471  }
472 
473  // Hook to validate setting
474  // note: this doesn't pass the namespaced name
475  $value = elgg_trigger_plugin_hook('usersetting', 'plugin', array(
476  'user' => $user,
477  'plugin' => $this,
478  'plugin_id' => $this->getID(),
479  'name' => $name,
480  'value' => $value
481  ), $value);
482 
483  // set the namespaced name.
484  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
485 
486  return set_private_setting($user->guid, $name, $value);
487  }
488 
496  public function unsetUserSetting($name, $user_guid = 0) {
497  $user_guid = (int)$user_guid;
498 
499  if ($user_guid) {
501  } else {
503  }
504 
505  if (!($user instanceof ElggUser)) {
506  return false;
507  }
508 
509  // set the namespaced name.
510  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
511 
512  return remove_private_setting($user->guid, $name);
513  }
514 
527  public function unsetAllUserSettings($user_guid) {
528  $db_prefix = get_config('dbprefix');
529  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
530 
531  $q = "DELETE FROM {$db_prefix}private_settings
532  WHERE entity_guid = $user_guid
533  AND name LIKE '$ps_prefix%'";
534 
535  return $this->getDatabase()->deleteData($q);
536  }
537 
546  public function unsetAllUsersSettings() {
547  $db_prefix = get_config('dbprefix');
548  $ps_prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $this->getID());
549 
550  $q = "DELETE FROM {$db_prefix}private_settings
551  WHERE name LIKE '$ps_prefix%'";
552 
553  return $this->getDatabase()->deleteData($q);
554  }
555 
556 
557  // validation
558 
567  public function isValid() {
568  if (!$this->getID()) {
569  $this->errorMsg = elgg_echo('ElggPlugin:MissingID', array($this->guid));
570  return false;
571  }
572 
573  if (!$this->getPackage() instanceof ElggPluginPackage) {
574  $this->errorMsg = elgg_echo('ElggPlugin:NoPluginPackagePackage', array($this->getID(), $this->guid));
575  return false;
576  }
577 
578  if (!$this->getPackage()->isValid()) {
579  $this->errorMsg = $this->getPackage()->getError();
580  return false;
581  }
582 
583  return true;
584  }
585 
592  public function isActive($site_guid = null) {
593  if (!$this->guid) {
594  return false;
595  }
596 
597  if ($site_guid) {
598  $site = get_entity($site_guid);
599  } else {
600  $site = get_config('site');
601  }
602 
603  if (!($site instanceof ElggSite)) {
604  return false;
605  }
606 
607  return check_entity_relationship($this->guid, 'active_plugin', $site->guid);
608  }
609 
619  public function canActivate($site_guid = null) {
620  if ($this->getPackage()) {
621  $result = $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
622  if (!$result) {
623  $this->errorMsg = $this->getPackage()->getError();
624  }
625 
626  return $result;
627  }
628 
629  return false;
630  }
631 
632 
633  // activating and deactivating
634 
641  public function activate($site_guid = null) {
642  if ($this->isActive($site_guid)) {
643  return false;
644  }
645 
646  if (!$this->canActivate()) {
647  return false;
648  }
649 
650  // set in the db, now perform tasks and emit events
651  if ($this->setStatus(true, $site_guid)) {
652  // emit an event. returning false will make this not be activated.
653  // we need to do this after it's been fully activated
654  // or the deactivate will be confused.
655  $params = array(
656  'plugin_id' => $this->getID(),
657  'plugin_entity' => $this,
658  );
659 
660  $return = elgg_trigger_event('activate', 'plugin', $params);
661 
662  // if there are any on_enable functions, start the plugin now and run them
663  // Note: this will not run re-run the init hooks!
664  if ($return) {
665  if ($this->canReadFile('activate.php')) {
668 
669  $this->start($flags);
670 
671  $return = $this->includeFile('activate.php');
672  }
673  }
674 
675  if ($return === false) {
676  $this->deactivate($site_guid);
677  }
678 
679  return $return;
680  }
681 
682  return false;
683  }
684 
691  public function deactivate($site_guid = null) {
692  if (!$this->isActive($site_guid)) {
693  return false;
694  }
695 
696  // emit an event. returning false will cause this to not be deactivated.
697  $params = array(
698  'plugin_id' => $this->getID(),
699  'plugin_entity' => $this,
700  );
701 
702  $return = elgg_trigger_event('deactivate', 'plugin', $params);
703 
704  // run any deactivate code
705  if ($return) {
706  if ($this->canReadFile('deactivate.php')) {
707  $return = $this->includeFile('deactivate.php');
708  }
709  }
710 
711  if ($return === false) {
712  return false;
713  } else {
714  return $this->setStatus(false, $site_guid);
715  }
716  }
717 
725  public function start($flags) {
726  //if (!$this->canActivate()) {
727  // return false;
728  //}
729 
730  // include classes
731  if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) {
732  $this->registerClasses();
733  }
734 
735  // include start file
736  if ($flags & ELGG_PLUGIN_INCLUDE_START) {
737  $this->includeFile('start.php');
738  }
739 
740  // include views
741  if ($flags & ELGG_PLUGIN_REGISTER_VIEWS) {
742  $this->registerViews();
743  }
744 
745  // include languages
746  if ($flags & ELGG_PLUGIN_REGISTER_LANGUAGES) {
747  $this->registerLanguages();
748  }
749 
750  return true;
751  }
752 
753 
754  // start helpers
755 
764  protected function includeFile($filename) {
765  // This needs to be here to be backwards compatible for 1.0-1.7.
766  // They expect the global config object to be available in start.php.
767  if ($filename == 'start.php') {
768  global $CONFIG;
769  }
770 
771  $filepath = "$this->path/$filename";
772 
773  if (!$this->canReadFile($filename)) {
774  $msg = elgg_echo('ElggPlugin:Exception:CannotIncludeFile',
775  array($filename, $this->getID(), $this->guid, $this->path));
776  throw new PluginException($msg);
777  }
778 
779  return include $filepath;
780  }
781 
788  protected function canReadFile($filename) {
789  return is_readable($this->path . '/' . $filename);
790  }
791 
798  protected function registerViews() {
799  $view_dir = "$this->path/views/";
800 
801  // plugins don't have to have views.
802  if (!is_dir($view_dir)) {
803  return true;
804  }
805 
806  // but if they do, they have to be readable
807  $handle = opendir($view_dir);
808  if (!$handle) {
809  $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterViews',
810  array($this->getID(), $this->guid, $view_dir));
811  throw new PluginException($msg);
812  }
813 
814  while (false !== ($view_type = readdir($handle))) {
815  $view_type_dir = $view_dir . $view_type;
816 
817  if ('.' !== substr($view_type, 0, 1) && is_dir($view_type_dir)) {
818  if (autoregister_views('', $view_type_dir, $view_dir, $view_type)) {
819  elgg_register_viewtype($view_type);
820  } else {
821  $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterViews',
822  array($this->getID(), $view_type_dir));
823  throw new PluginException($msg);
824  }
825  }
826  }
827 
828  return true;
829  }
830 
837  protected function registerLanguages() {
838  $languages_path = "$this->path/languages";
839 
840  // don't need to have classes
841  if (!is_dir($languages_path)) {
842  return true;
843  }
844 
845  // but need to have working ones.
846  if (!register_translations($languages_path)) {
847  $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterLanguages',
848  array($this->getID(), $this->guid, $languages_path));
849  throw new PluginException($msg);
850  }
851 
852  return true;
853  }
854 
861  protected function registerClasses() {
862  $classes_path = "$this->path/classes";
863 
864  if (is_dir($classes_path)) {
865  _elgg_services()->autoloadManager->addClasses($classes_path);
866  }
867 
868  return true;
869  }
870 
877  public function __get($name) {
878  // rewrite for old and inaccurate plugin:setting
879  if (strstr($name, 'plugin:setting:')) {
880  $msg = 'Direct access of user settings is deprecated. Use ElggPlugin->getUserSetting()';
881  elgg_deprecated_notice($msg, 1.8);
882  $name = str_replace('plugin:setting:', '', $name);
883  $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
884  }
885 
886  // See if its in our base attribute
887  if (array_key_exists($name, $this->attributes)) {
888  return $this->attributes[$name];
889  }
890 
891  // @todo clean below - getPrivateSetting() should return null now
892  // No, so see if its in the private data store.
893  // get_private_setting() returns false if it doesn't exist
894  $meta = $this->getPrivateSetting($name);
895 
896  if ($meta === false) {
897  // Can't find it, so return null
898  return null;
899  }
900 
901  return $meta;
902  }
903 
911  public function get($name) {
912  elgg_deprecated_notice("Use -> instead of get()", 1.9);
913  return $this->__get($name);
914  }
915 
925  public function __set($name, $value) {
926  if (array_key_exists($name, $this->attributes)) {
927  // Check that we're not trying to change the guid!
928  if ((array_key_exists('guid', $this->attributes)) && ($name == 'guid')) {
929  return;
930  }
931 
932  $this->attributes[$name] = $value;
933  } else {
934  // to make sure we trigger the correct hooks
935  $this->setSetting($name, $value);
936  }
937  }
938 
948  public function set($name, $value) {
949  elgg_deprecated_notice("Use -> instead of set()", 1.9);
950  $this->__set($name, $value);
951 
952  return true;
953  }
954 
963  private function setStatus($active, $site_guid = null) {
964  if (!$this->guid) {
965  return false;
966  }
967 
968  if ($site_guid) {
969  $site = get_entity($site_guid);
970 
971  if (!($site instanceof ElggSite)) {
972  return false;
973  }
974  } else {
975  $site = get_config('site');
976  }
977 
978  if ($active) {
979  $result = add_entity_relationship($this->guid, 'active_plugin', $site->guid);
980  } else {
981  $result = remove_entity_relationship($this->guid, 'active_plugin', $site->guid);
982  }
983 
985 
986  return $result;
987  }
988 
994  public function getError() {
995  return $this->errorMsg;
996  }
997 
1003  public function getManifest() {
1004  if ($this->manifest instanceof ElggPluginManifest) {
1005  return $this->manifest;
1006  }
1007 
1008  try {
1009  $this->manifest = $this->getPackage()->getManifest();
1010  } catch (Exception $e) {
1011  elgg_log("Failed to load manifest for plugin $this->guid. " . $e->getMessage(), 'WARNING');
1012  $this->errorMsg = $e->getmessage();
1013  }
1014 
1015  return $this->manifest;
1016  }
1017 
1023  public function getPackage() {
1024  if ($this->package instanceof ElggPluginPackage) {
1025  return $this->package;
1026  }
1027 
1028  try {
1029  $this->package = new ElggPluginPackage($this->path, false);
1030  } catch (Exception $e) {
1031  elgg_log("Failed to load package for $this->guid. " . $e->getMessage(), 'WARNING');
1032  $this->errorMsg = $e->getmessage();
1033  }
1034 
1035  return $this->package;
1036  }
1037 }
getSetting($name, $default=null)
Returns a plugin setting.
Definition: ElggPlugin.php:277
registerViews()
Registers the plugin&#39;s views.
Definition: ElggPlugin.php:798
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
getID()
Returns the ID (dir name) of this plugin.
Definition: ElggPlugin.php:120
ui datepicker title
Definition: admin.php:592
getDatabase()
Provides a pointer to the database object.
Definition: ElggData.php:67
start($flags)
Start the plugin.
Definition: ElggPlugin.php:725
getUserSetting($name, $user_guid=0)
Returns a user&#39;s setting for this plugin.
Definition: ElggPlugin.php:387
$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:861
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:669
activate($site_guid=null)
Actives the plugin for the current site.
Definition: ElggPlugin.php:641
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:685
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: elgglib.php:484
get_config($name, $site_guid=0)
Gets a configuration value.
$files
Definition: crop.php:36
load($guid)
Loads the full ElggObject when given a guid.
Definition: ElggObject.php:94
$value
Definition: longtext.php:29
unsetAllUsersSettings()
Removes this plugin&#39;s user settings for all users.
Definition: ElggPlugin.php:546
$return
Definition: opendd.php:15
$default
Definition: checkbox.php:36
canActivate($site_guid=null)
Checks if this plugin can be activated on the current Elgg installation.
Definition: ElggPlugin.php:619
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells ElggPlugin::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:496
autoregister_views($view_base, $folder, $base_location_path, $viewtype)
Auto-registers views from a location.
Definition: views.php:1455
includeFile($filename)
Includes one of the plugins files.
Definition: ElggPlugin.php:764
$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:512
canReadFile($filename)
Checks whether a plugin file with the given name exists.
Definition: ElggPlugin.php:788
unsetAllUserSettings($user_guid)
Removes all User Settings for this plugin for a particular user.
Definition: ElggPlugin.php:527
getPackage()
Returns this plugin&#39;s ElggPluginPackage object.
setUserSetting($name, $value, $user_guid=0)
Sets a user setting for a plugin.
Definition: ElggPlugin.php:460
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
registerLanguages()
Registers the plugin&#39;s languages.
Definition: ElggPlugin.php:837
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 ElggPlugin::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 ElggPlugin::start() to automatically register the plugin&#39;s views.
Definition: plugins.php:18
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
Definition: elgglib.php:925
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:255
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1171
elgg global
Pointer to the global context.
Definition: elgglib.js:12
elgg river item elgg form comment save
Definition: components.php:242
_elgg_cache_plugin_by_id(ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
Definition: plugins.php:191
isActive($site_guid=null)
Is this plugin active?
Definition: ElggPlugin.php:592
isValid()
Returns if the plugin is complete, meaning has all required files and Elgg can read them and they mak...
Definition: ElggPlugin.php:567
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:994
setSetting($name, $value)
Set a plugin setting for the plugin.
Definition: ElggPlugin.php:328
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1083
getManifest()
Returns this plugin&#39;s ElggPluginManifest object.
$comment access_id
Definition: save.php:52
const ACCESS_PUBLIC
Definition: elgglib.php:2123
__get($name)
Get an attribute or private setting value.
Definition: ElggPlugin.php:877
getAllUserSettings($user_guid=0)
Returns an array of all user settings saved for this plugin for the user.
Definition: ElggPlugin.php:412
deactivate($site_guid=null)
Deactivates the plugin.
Definition: ElggPlugin.php:691
getFriendlyName()
Returns the manifest&#39;s name if available, otherwise the ID.
Definition: ElggPlugin.php:130
register_translations($path, $load_all=false)
When given a full path, finds translation files and loads them.
Definition: languages.php:255
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:925
$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 ElggPlugin::start() to automatically register the plugin&#39;s classes.
Definition: plugins.php:28
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32
elgg_get_plugins_path()
Get the plugin path for this installation.
_elgg_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
Definition: plugins.php:610
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
$user_guid
Avatar remove action.
Definition: remove.php:6
elgg_trigger_event($event, $object_type, $object=null)
Trigger an Elgg Event and attempt to run all handler callbacks registered to that event...
Definition: elgglib.php:720
if(!$collection_name) $id
Definition: add.php:17
getPath()
Returns the plugin&#39;s full path with trailing slash.
Definition: ElggPlugin.php:144
A Site entity.
Definition: ElggSite.php:28
if(!$num_display) $db_prefix
Definition: content.php:12
Elgg Object.
Definition: ElggObject.php:22
$priority
elgg_get_plugin_from_id($plugin_id)
Returns an ElggPlugin object with the path $path.
Definition: plugins.php:204
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:604
elgg_register_viewtype($viewtype)
Register a viewtype.
Definition: views.php:116