Elgg  Version 3.0
tools.php
Go to the documentation of this file.
1 <?php
10 
11 $username = elgg_extract('username', $vars);
12 if (!$username) {
14 }
15 
17 if (!$user || !$user->canEdit()) {
18  throw new \Elgg\EntityPermissionsException();
19 }
20 
22 
23 $plugin_id = elgg_extract("plugin_id", $vars);
24 
25 if (empty($plugin_id)) {
26  throw new \Elgg\PageNotFoundException(elgg_echo('ElggPlugin:MissingID'));
27 }
28 
30 
31 if (!$plugin) {
32  throw new \Elgg\PageNotFoundException(elgg_echo('PluginException:InvalidID', [$plugin_id]));
33 }
34 
35 if (elgg_language_key_exists($plugin_id . ':usersettings:title')) {
36  $title = elgg_echo($plugin_id . ':usersettings:title');
37 } else {
38  $title = $plugin->getDisplayName();
39 }
40 
41 $username = elgg_extract('username', $vars);
42 
43 elgg_push_breadcrumb(elgg_echo('settings'), "settings/user/$username");
44 elgg_push_breadcrumb(elgg_echo('usersettings:plugins:opt:linktext'));
45 
47 
48 if (elgg_action_exists("{$plugin->getID()}/usersettings/save")) {
49  $form_vars['action'] = "action/{$plugin->getID()}/usersettings/save";
50 }
51 
52 $content = elgg_view_form('plugins/usersettings/save', $form_vars, ['entity' => $plugin]);
53 
55  'content' => $content,
56  'title' => $title,
57  'show_owner_block_menu' => false,
58 ];
59 $body = elgg_view_layout('one_sidebar', $params);
60 
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
$username
Definition: tools.php:11
$params
Definition: tools.php:54
$body
Definition: tools.php:59
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_set_page_owner_guid($guid)
Set the guid of the entity that owns this page.
Definition: pageowner.php:81
elgg_push_breadcrumb($text, $href=false)
Adds a breadcrumb to the breadcrumbs stack.
Definition: navigation.php:298
elgg_view_page($title, $body, $page_shell= 'default', $vars=[])
Assembles and outputs a full page.
Definition: views.php:360
if(empty($plugin_id)) $plugin
Definition: tools.php:29
get_user_by_username($username)
Get user by username.
Definition: users.php:61
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
$form_vars
Definition: tools.php:46
$title
Definition: user.php:20
if(!$username) $user
Definition: tools.php:16
elgg_view_form($action, $form_vars=[], $body_vars=[])
Definition: views.php:1318
$plugin_id
Definition: tools.php:23
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
elgg_view_layout($layout_name, $vars=[])
Displays a layout with optional parameters.
Definition: views.php:593
$vars['type']
Definition: save.php:11
if(elgg_action_exists("{$plugin->getID()}/usersettings/save")) $content
Definition: tools.php:52
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
elgg_action_exists($action)
Check if an action is registered and its script exists.
Definition: actions.php:117
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:28