16 private $errorMsg =
'';
24 parent::initializeAttributes();
26 $this->attributes[
'subtype'] =
"plugin";
46 throw new \PluginException(
"\ElggPlugin cannot be null instantiated. You must pass a full path.");
49 if (is_object($path)) {
51 parent::__construct($path);
53 }
else if (is_numeric($path)) {
57 parent::__construct($path);
65 if (strpos($path, $mod_dir) !== 0) {
67 $path = $mod_dir . $path;
73 $path_parts = explode(
'/', rtrim($path,
'/'));
80 if ($existing_plugin) {
81 $this->
load($existing_plugin->guid);
97 $this->attributes[
'site_guid'] =
$site->guid;
98 $this->attributes[
'owner_guid'] =
$site->guid;
99 $this->attributes[
'container_guid'] =
$site->guid;
133 return $manifest->getName();
136 return $this->
getID();
155 return $this->attributes[
'title'] =
$id;
164 $filenames = $this->
getPackage()->getTextFilenames();
206 $old_priority = (!$old_priority) ? 1 : $old_priority;
239 $where =
"CAST(value as unsigned) BETWEEN $old_priority AND $priority";
242 $where =
"CAST(value as unsigned) BETWEEN $priority AND $old_priority";
246 $q =
"UPDATE {$db_prefix}private_settings
247 SET value = CAST(value as unsigned) $op 1
248 WHERE entity_guid != $this->guid
279 return $val !==
null ? $val :
$default;
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%'";
305 $private_settings = $this->
getDatabase()->getData($q);
309 if ($private_settings) {
310 foreach ($private_settings as $setting) {
311 $return[$setting->name] = $setting->value;
335 'plugin_id' => $this->
getID(),
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%'";
404 return $val !==
null ? $val :
$default;
431 $ps_prefix_len = strlen($ps_prefix);
434 $q =
"SELECT * FROM {$db_prefix}private_settings
435 WHERE entity_guid = {$user->guid}
436 AND name LIKE '$ps_prefix%'";
438 $private_settings = $this->
getDatabase()->getData($q);
442 if ($private_settings) {
443 foreach ($private_settings as $setting) {
444 $name = substr($setting->name, $ps_prefix_len);
481 'plugin_id' => $this->
getID(),
534 $q =
"DELETE FROM {$db_prefix}private_settings
535 WHERE entity_guid = $user_guid
536 AND name LIKE '$ps_prefix%'";
553 $q =
"DELETE FROM {$db_prefix}private_settings
554 WHERE name LIKE '$ps_prefix%'";
571 if (!$this->
getID()) {
572 $this->errorMsg =
_elgg_services()->translator->translate(
'ElggPlugin:MissingID', array($this->guid));
577 $this->errorMsg =
_elgg_services()->translator->translate(
'ElggPlugin:NoPluginPackagePackage', array($this->
getID(), $this->guid));
582 $this->errorMsg = $this->
getPackage()->getError();
626 $this->errorMsg = $this->
getPackage()->getError();
654 if ($this->setStatus(
true, $site_guid)) {
659 'plugin_id' => $this->
getID(),
660 'plugin_entity' => $this,
672 $this->
start($flags);
701 'plugin_id' => $this->
getID(),
702 'plugin_entity' => $this,
717 return $this->setStatus(
false, $site_guid);
766 if (
null === $wrapper) {
768 $warning =
'Do not rely on local $CONFIG being available in start.php';
769 $wrapper = new \Elgg\DeprecationWrapper(
$CONFIG, $warning,
"1.10");
789 $filepath =
"$this->path/$filename";
792 $msg =
_elgg_services()->translator->translate(
'ElggPlugin:Exception:CannotIncludeFile',
794 throw new \PluginException($msg);
797 return include $filepath;
817 $view_dir =
"$this->path/views/";
820 if (!is_dir($view_dir)) {
825 $handle = opendir($view_dir);
827 $msg =
_elgg_services()->translator->translate(
'ElggPlugin:Exception:CannotRegisterViews',
828 array($this->
getID(), $this->guid, $view_dir));
829 throw new \PluginException($msg);
832 while (
false !== ($view_type = readdir($handle))) {
833 $view_type_dir = $view_dir . $view_type;
835 if (
'.' !== substr($view_type, 0, 1) && is_dir($view_type_dir)) {
839 $msg =
_elgg_services()->translator->translate(
'ElggPlugin:Exception:CannotRegisterViews',
840 array($this->
getID(), $view_type_dir));
841 throw new \PluginException($msg);
856 $languages_path =
"$this->path/languages";
859 if (!is_dir($languages_path)) {
864 if (!
_elgg_services()->translator->registerTranslations($languages_path)) {
865 $msg =
_elgg_services()->translator->translate(
'ElggPlugin:Exception:CannotRegisterLanguages',
866 array($this->
getID(), $this->guid, $languages_path));
867 throw new \PluginException($msg);
880 $classes_path =
"$this->path/classes";
882 if (is_dir($classes_path)) {
897 if (strstr(
$name,
'plugin:setting:')) {
898 $msg =
'Direct access of user settings is deprecated. Use \ElggPlugin->getUserSetting()';
900 $name = str_replace(
'plugin:setting:',
'',
$name);
905 if (array_key_exists(
$name, $this->attributes)) {
906 return $this->attributes[
$name];
914 if ($meta ===
false) {
944 if (array_key_exists(
$name, $this->attributes)) {
946 if ((array_key_exists(
'guid', $this->attributes)) && (
$name ==
'guid')) {
981 private function setStatus(
$active, $site_guid =
null) {
1013 return $this->errorMsg;
1023 return $this->manifest;
1027 $this->manifest = $this->
getPackage()->getManifest();
1028 }
catch (Exception
$e) {
1029 _elgg_services()->logger->warn(
"Failed to load manifest for plugin $this->guid. " .
$e->getMessage());
1030 $this->errorMsg =
$e->getmessage();
1033 return $this->manifest;
1043 return $this->package;
1047 $this->
package = new \ElggPluginPackage($this->path, false);
1048 }
catch (Exception
$e) {
1049 _elgg_services()->logger->warn(
"Failed to load package for $this->guid. " .
$e->getMessage());
1050 $this->errorMsg =
$e->getmessage();
1053 return $this->package;
if(! $collection_name) $id
if($guid==elgg_get_logged_in_user_guid()) $name
if(! $autoload_available) _elgg_services()
$user_guid
Avatar remove action.
getDatabase()
Provides a pointer to the database object.
setPrivateSetting($name, $value)
Adds a private setting to this entity.
getPrivateSetting($name)
Returns a private setting value.
load($guid)
Loads the full \ElggObject when given a guid.
includeFile($filename)
Includes one of the plugins files.
getUserSetting($name, $user_guid=0, $default=null)
Returns a user's setting for this plugin.
start($flags)
Start the plugin.
getPath()
Returns the plugin's full path with trailing slash.
__set($name, $value)
Set a value as private setting or attribute.
__get($name)
Get an attribute or private setting value.
getAllUserSettings($user_guid=0)
Returns an array of all user settings saved for this plugin for the user.
getSetting($name, $default=null)
Returns a plugin setting.
unsetAllSettings()
Removes all settings for this plugin.
setSetting($name, $value)
Set a plugin setting for the plugin.
setID($id)
Sets the location of this plugin.
registerLanguages()
Registers the plugin's languages.
registerViews()
Registers the plugin's views.
canReadFile($filename)
Checks whether a plugin file with the given name exists.
getPackage()
Returns this plugin's \ElggPluginPackage object.
initializeAttributes()
Set subtype to 'plugin'.
getManifest()
Returns this plugin's \ElggPluginManifest object.
__construct($path)
Creates a new plugin from path.
registerClasses()
Registers the plugin's classes.
activate($site_guid=null)
Actives the plugin for the current site.
getID()
Returns the ID (dir name) of this plugin.
unsetSetting($name)
Removes a plugin setting name and value.
getError()
Returns the last error message registered.
isValid()
Returns if the plugin is complete, meaning has all required files and Elgg can read them and they mak...
getAvailableTextFiles()
Returns an array of available markdown files for this plugin.
static getConfigWrapper()
Get the config object in a deprecation wrapper.
isActive($site_guid=null)
Is this plugin active?
setUserSetting($name, $value, $user_guid=0)
Sets a user setting for a plugin.
deactivate($site_guid=null)
Deactivates the plugin.
getPriority()
Gets the plugin's load priority.
unsetAllUserSettings($user_guid)
Removes all User Settings for this plugin for a particular user.
getAllSettings()
Returns an array of all settings saved for this plugin.
canActivate($site_guid=null)
Checks if this plugin can be activated on the current Elgg installation.
save()
Save the plugin object.
setPriority($priority, $site_guid=null)
Sets the priority of the plugin.
unsetAllUsersSettings()
Removes this plugin's user settings for all users.
unsetUserSetting($name, $user_guid=0)
Removes a user setting name and value.
getFriendlyName()
Returns the manifest's name if available, otherwise the ID.
elgg river item elgg form comment save
$CONFIG path
The full path where Elgg is installed.
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg_get_plugin_from_id($plugin_id)
Returns an \ElggPlugin object with the path $path.
const ELGG_PLUGIN_REGISTER_LANGUAGES
Tells \ElggPlugin::start() to automatically register the plugin's languages.
_elgg_cache_plugin_by_id(\ElggPlugin $plugin)
Cache a reference to this plugin by its ID.
const ELGG_PLUGIN_REGISTER_VIEWS
Tells \ElggPlugin::start() to automatically register the plugin's views.
const ELGG_PLUGIN_REGISTER_CLASSES
Tells \ElggPlugin::start() to automatically register the plugin's classes.
const ELGG_PLUGIN_INCLUDE_START
Tells \ElggPlugin::start() to include the start.php file.
_elgg_namespace_plugin_private_setting($type, $name, $id=null)
Namespaces a string to be used as a private setting name for a plugin.
_elgg_invalidate_plugins_provides_cache()
Deletes all cached data on plugins being provided.
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
get_entity($guid)
Loads and returns an entity object from a guid.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
set_private_setting($entity_guid, $name, $value)
Sets a private setting for an entity.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg_register_viewtype($viewtype)
Register a viewtype.
autoregister_views($view_base, $folder, $base_location_path, $viewtype)
Auto-registers views from a location.
if(! $num_display) $db_prefix