public function __construct($page) { admin_gatekeeper(); global $CONFIG; $cshop = new stdClass(); $this->controller = GLOBAL_IZAP_CURRENT_CONTROLLER; $this->action = 'action' . ucfirst($page[0]); $this->_page = $page; $this->url_vars = $this->_page; $this->page_layout = $this->page_shell = 'admin'; $cshop->view = $this->_view = 'admin/' . implode('/', $page); $this->page_elements['title'] = elgg_echo("admin:{$page[0]}"); if (count($page) > 1) { $this->page_elements['title'] .= ' : ' . elgg_echo('admin:' . implode(':', $page)); } if (method_exists($this, $this->action)) { elgg_admin_add_plugin_settings_menu(); elgg_set_context('admin'); elgg_unregister_css('elgg'); $url = elgg_get_simplecache_url('js', 'admin'); elgg_register_js('elgg.admin', $url); elgg_load_js('elgg.admin'); elgg_register_js('jquery.jeditable', 'vendors/jquery/jquery.jeditable.mini.js'); elgg_load_js('jquery.jeditable'); } $CONFIG->cshop = $cshop; }
function get_entity_list_title($localtype, $relationship) { $title = ''; switch ($localtype) { case 'national': $title = elgg_echo('localgroups:regionalgroups'); break; case 'regional': if ($relationship == 'parent') { $title = elgg_echo('localgroups:nationalgroups'); } else { $title = elgg_echo('localgroups:departementalgroups'); } break; case 'departemental': if ($relationship == 'parent') { $title = elgg_echo('localgroups:regionalgroups'); } else { $title = elgg_echo('localgroups:towngroups'); } break; case 'town': $title = elgg_echo('localgroups:departementalgroups'); break; } return $title; }
/** * Change the default notification message for comments * * @param string $hook the name of the hook * @param stirng $type the type of the hook * @param Elgg_Notifications_Notification $return_value the current return value * @param array $params supplied values * * @return Elgg_Notifications_Notification */ function content_subscriptions_prepare_comment_notification($hook, $type, $return_value, $params) { if (empty($return_value) || !$return_value instanceof \Elgg\Notifications\Notification) { return $return_value; } if (empty($params) || !is_array($params)) { return $return_value; } $event = elgg_extract("event", $params); if (empty($event) || !$event instanceof \Elgg\Notifications\Event) { return $return_value; } // ignore access for now $ia = elgg_set_ignore_access(true); $comment = $event->getObject(); $actor = $event->getActor(); $object = $comment->getContainerEntity(); $language = elgg_extract("language", $params, get_current_language()); $recipient = elgg_extract("recipient", $params); $return_value->subject = elgg_echo("content_subscriptions:create:comment:subject", array($object->title), $language); $return_value->body = elgg_echo("content_subscriptions:create:comment:message", array($recipient->name, $actor->name, $object->title, $comment->description, $object->getURL()), $language); $return_value->summary = elgg_echo("content_subscriptions:create:comment:summary", array($object->title), $language); // restore access elgg_set_ignore_access($ia); return $return_value; }
/** * Initialize the plugin. */ function tour_init() { $js_lib = elgg_get_plugin_setting('js_library', 'tour'); if ($js_lib == 'joyride') { elgg_register_css('joyride', '/mod/tour/vendors/joyride/joyride-2.1.css'); elgg_load_css('joyride'); elgg_define_js('joyride', array('src' => '/mod/tour/vendors/joyride/jquery.joyride-2.1.js', 'exports' => 'joyride')); } else { elgg_register_css('hopscotch', '/mod/tour/vendors/hopscotch/css/hopscotch.min.css'); elgg_load_css('hopscotch'); elgg_define_js('hopscotch', array('src' => '/mod/tour/vendors/hopscotch/hopscotch.min.js', 'exports' => 'hopscotch')); } elgg_require_js('elgg/tour/display'); //elgg_require_js('elgg/tour/edit'); elgg_register_ajax_view('ajax/tour_stop/save'); elgg_extend_view('page/elements/footer', 'tour/outline'); elgg_extend_view('css/elgg', 'css/tour'); elgg_extend_view('css/admin', 'css/tour_admin'); elgg_register_action('tour_page/save', __DIR__ . '/actions/tour_page/save.php', 'admin'); elgg_register_action('tour_page/reorder', __DIR__ . '/actions/tour_page/reorder.php', 'admin'); elgg_register_action('tour_page/delete', __DIR__ . '/actions/tour_page/delete.php', 'admin'); elgg_register_action('tour_stop/save', __DIR__ . '/actions/tour_stop/save.php', 'admin'); elgg_register_action('tour_stop/delete', __DIR__ . '/actions/tour_stop/delete.php', 'admin'); elgg_register_page_handler('tour', 'tour_page_handler'); elgg_register_page_handler('tour_stop', 'tour_page_handler'); // For convenience elgg_register_admin_menu_item('administer', 'tour', 'administer_utilities'); elgg_register_menu_item('topbar', array('name' => 'tour', 'href' => '', 'text' => elgg_echo('tour:start'), 'id' => 'tour-start', 'section' => 'alt', 'data-library' => $js_lib)); elgg_register_plugin_hook_handler('register', 'menu:entity', array('Tour\\Page\\EntityMenu', 'setUp')); elgg_register_plugin_hook_handler('register', 'menu:entity', array('Tour\\Stop\\EntityMenu', 'setUp')); elgg_register_viewtype('json'); }
/** * Sanitizes and validates user input * @throws GraphException * @return Parameter */ public function prepare() { $this->value = get_input($this->name, $this->default); if ($this->value !== null) { if ($this->type == self::TYPE_ENUM) { if (!in_array($this->value, $this->enum_values)) { $msg = elgg_echo('Exception:UnsupportedEnumValue', array($this->value, $this->name, implode(', ', $this->enum_values))); throw new GraphException($msg); } } else { // Cast values to specified type if (!settype($this->value, $this->type)) { if (isset($this->default)) { $this->value = $this->default; } else { $msg = elgg_echo('Exception:UnrecognisedTypeCast', array($this->type, $this->name)); throw new GraphException($msg); } } } } // Validate required values if ($this->required) { if ($this->type == Parameter::TYPE_ARRAY && empty($this->value) || $this->value === '' || $this->value === null) { $msg = elgg_echo('Exception:MissingParameterInMethod', array($this->name)); throw new GraphException($msg); } } if ($this->name == 'limit' && $this->value > Graph::LIMIT_MAX) { $this->value = Graph::LIMIT_MAX; } return $this; }
/** * gvcontact page handler * * @param array $page URL segements * @param string $handler Handler identifier * @return bool */ function gvcontact_page_handler($page, $handler) { $title = elgg_echo('gvcontact:contacttitle'); $content = elgg_view_form('gvcontact/contact'); $body = elgg_view_layout('one_column', array('content' => $content)); echo elgg_view_page($title, $body); }
/** * @param ElggPlugin $plugin * @return string */ public function outputPluginSettingsForm($plugin) { $translationPrefix = elgg_extract('translationPrefix', $this->options); $result = '<div>'; foreach ($this->fields as $name => $field) { $result .= '<div class="mbm">'; $result .= '<label>' . elgg_echo($translationPrefix . $name) . '</label> '; $description = elgg_extract('description', $field); if ($description) { $result .= '<div class="mbs">' . $description . '</div> '; } $params = $field; $type = elgg_extract('type', $field); $params['name'] = "params[{$name}]"; if ($plugin) { $params['value'] = $plugin->{$name}; } if (!isset($params['value']) || $params['value'] === null) { $params['value'] = elgg_extract('default', $field); } $result .= elgg_view('input/' . $type, $params); $result .= '</div>'; } $result .= '</div>'; return $result; }
/** * Called during system init * * @return void */ function pages_tools_init() { // register DOM PDF as a library elgg_register_library("dompdf", dirname(__FILE__) . "/vendor/dompdf/dompdf/dompdf_config.inc.php"); // extend site css elgg_extend_view("css/elgg", "css/pages_tools/site"); // extend site js elgg_extend_view("js/elgg", "js/pages_tools/site"); // register JS library elgg_register_js("jquery.tree", elgg_get_site_url() . "mod/pages_tools/vendors/jstree/jquery.tree.min.js"); elgg_register_css("jquery.tree", elgg_get_site_url() . "mod/pages_tools/vendors/jstree/themes/classic/style.css"); // add widgets (overrule default pages widget, to add group support) elgg_register_widget_type("pages", elgg_echo("pages"), elgg_echo("pages:widget:description"), array("profile", "dashboard", "groups")); elgg_register_widget_type("index_pages", elgg_echo("pages"), elgg_echo("pages_tools:widgets:index_pages:description"), array("index"), true); // register plugin hooks elgg_register_plugin_hook_handler("route", "pages", "pages_tools_route_pages_hook"); elgg_register_plugin_hook_handler("register", "menu:entity", "pages_tools_entity_menu_hook"); elgg_register_plugin_hook_handler("permissions_check:comment", "object", "pages_tools_permissions_comment_hook"); elgg_register_plugin_hook_handler("widget_url", "widget_manager", "pages_tools_widget_url_hook"); elgg_register_plugin_hook_handler("cron", "daily", "pages_tools_daily_cron_hook"); // events elgg_register_event_handler('create', 'object', 'pages_tools_cache_handler'); elgg_register_event_handler('update', 'object', 'pages_tools_cache_handler'); elgg_register_event_handler('delete', 'object', 'pages_tools_cache_handler'); // register actions elgg_register_action("pages/export", dirname(__FILE__) . "/actions/export.php", "public"); elgg_register_action("pages/reorder", dirname(__FILE__) . "/actions/reorder.php"); elgg_register_action("pages_tools/update_edit_notice", dirname(__FILE__) . "/actions/update_edit_notice.php"); // overrule action elgg_register_action("pages/edit", dirname(__FILE__) . "/actions/pages/edit.php"); elgg_register_action("pages/delete", dirname(__FILE__) . "/actions/pages/delete.php"); }
/** * Listen to the login event to make sure the user is validated * * @param string $event the name of the event * @param string $type the type of the event * @param ElggUser $user supplied user * * @return bool */ function uservalidationbyadmin_login_event($event, $type, $user) { $result = false; // make sure we can see all users $hidden = access_get_show_hidden_status(); access_show_hidden_entities(true); // do we actualy have a user if (!empty($user) && elgg_instanceof($user, "user")) { // is the user enabled if ($user->isEnabled()) { if ($user->isAdmin()) { // admins are always allowed $result = true; } elseif (isset($user->admin_validated)) { // check if the user is validated if ($user->admin_validated) { // user is validated and can login $result = true; } } else { // user has register before this plugin was activated $result = true; } } } // check if the user can login if (empty($result)) { // register error register_error(elgg_echo("uservalidationbyadmin:login:error")); } // restore access setting access_show_hidden_entities($hidden); return $result; }
function widget_messages_init() { if (elgg_is_active_plugin("messages")) { elgg_register_widget_type("messages", elgg_echo("messages"), elgg_echo("widgets:messages:description"), "dashboard,index", false); elgg_register_plugin_hook_handler('widget_url', 'widget_manager', "widget_messages_url"); } }
/** * This functions performs actions when a wire post is created * * @param string $event 'create' * @param string $type 'object' * @param ElggObject $object the ElggObject created * * @return void */ function thewire_tools_create_object_event_handler($event, $type, ElggObject $object) { if (empty($object) || !elgg_instanceof($object, "object", "thewire")) { return; } //send out notification to users mentioned in a wire post $usernames = array(); preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames); if (empty($usernames)) { return; } $usernames = array_unique($usernames[0]); $params = array("object" => $object, "action" => "mention"); foreach ($usernames as $username) { $username = str_ireplace("@", "", $username); $user = get_user_by_username($username); if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) { continue; } $setting = thewire_tools_get_notification_settings($user->getGUID()); if (empty($setting)) { continue; } $subject = elgg_echo("thewire_tools:notify:mention:subject"); $message = elgg_echo("thewire_tools:notify:mention:message", array($user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@" . $user->username))); notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting); } }
/** * Set up menu items * */ function categories_pagesetup() { if (get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('categories:settings'), $CONFIG->wwwroot . 'mod/categories/settings.php'); } }
/** * Called on the login user event * Checks for spammers * * @param type $event * @param type $type * @param type $user * @return boolean */ function login_event($event, $type, $user) { $check_login = elgg_get_plugin_setting('event_login', PLUGIN_ID); $ip = get_ip(); $user->ip_address = $ip; if ($check_login != 'no' || !$user->last_login) { // do it by default if (!check_spammer($user->email, $ip, true) && !$user->isAdmin()) { register_error(elgg_echo('spam_login_filter:access_denied_mail_blacklist')); notify_admin($user->email, $ip, "Existing member identified as spammer has tried to login, check this account"); return false; } } // check user metadata for banned words/phrases $banned = get_banned_strings(); $metadata = get_metadata_names(); if ($banned && $metadata) { foreach ($metadata as $m) { foreach ($banned as $str) { if (strpos($user->{$m}, $str) !== false) { return false; } } } } }
/** * This functions performs actions when a wire post is created * * @param string $event 'create' * @param string $type 'object' * @param \ElggObject $object the ElggObject created * * @return void */ public static function triggerMentionNotificationEvent($event, $type, \ElggObject $object) { if (!elgg_instanceof($object, 'object', 'thewire')) { return; } // @todo replace with decent Elgg 2.0 notification event handling //send out notification to users mentioned in a wire post $usernames = []; preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames); if (empty($usernames)) { return; } $usernames = array_unique($usernames[0]); $params = ['object' => $object, 'action' => 'mention']; foreach ($usernames as $username) { $username = str_ireplace('@', '', $username); $user = get_user_by_username($username); if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) { continue; } $setting = thewire_tools_get_notification_settings($user->getGUID()); if (empty($setting)) { continue; } $subject = elgg_echo('thewire_tools:notify:mention:subject'); $message = elgg_echo('thewire_tools:notify:mention:message', [$user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@{$user->username}")]); notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting); } }
function friend_request_entity_menu_handler($hook, $type, $returnvalue, $params) { $result = $returnvalue; if (!empty($params) && is_array($params) && ($user = elgg_get_logged_in_user_entity())) { $entity = elgg_extract("entity", $params); if (elgg_instanceof($entity, "user") && $entity->getGUID() != $user->getGUID()) { if (!empty($result) && !is_array($result)) { $result = array($result); } elseif (empty($result)) { $result = array(); } // are we friends if (!$entity->isFriendOf($user->getGUID())) { // no, check if pending request if (check_entity_relationship($user->getGUID(), "friendrequest", $entity->getGUID())) { // pending request $result[] = ElggMenuItem::factory(array("name" => "friend_request", "text" => elgg_echo("friend_request:friend:add:pending"), "href" => "friend_request/" . $user->username . "#friend_request_sent_listing", "priority" => 500)); } else { // add as friend $result[] = ElggMenuItem::factory(array("name" => "add_friend", "text" => elgg_echo("friend:add"), "href" => "action/friends/add?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500)); } } else { // is friend, se remove friend link $result[] = ElggMenuItem::factory(array("name" => "remove_friend", "text" => elgg_echo("friend:remove"), "href" => "action/friends/remove?friend=" . $entity->getGUID(), "is_action" => true, "priority" => 500)); } } } return $result; }
/** * Adding the log browser to the admin menu * */ function logbrowser_pagesetup() { if (get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('logbrowser'), $CONFIG->wwwroot . 'pg/logbrowser/'); } }
/** * {@inheritdoc} */ public function validate(\ElggEntity $entity) { $validation = new ValidationStatus(); $metadata = get_input($this->getShortname(), array()); $keys = array_keys(elgg_extract('value', $metadata, array())); if (empty($keys)) { if ($this->isRequired()) { $validation->setFail(elgg_echo('prototyper:validate:error:required', array($this->getLabel()))); } } else { foreach ($keys as $i) { if ($metadata['name'][$i] == $this->getShortname()) { if (is_string($metadata['value'][$i])) { $value = strip_tags($metadata['value'][$i]); } else { $value = $metadata['value'][$i]; } if (is_null($value) || $value == '') { if ($this->isRequired()) { $validation->setFail(elgg_echo('prototyper:validate:error:required', array($this->getLabel()))); } } else { $validation = $this->applyValidationRules($value, $validation, $entity); } } } } return $validation; }
/** * Serves pages for twitter. * * @param array $page */ function twitter_api_pagehandler($page) { if (!isset($page[0])) { forward(); } switch ($page[0]) { case 'authorize': twitter_api_authorize(); break; case 'revoke': twitter_api_revoke(); break; case 'forward': twitter_api_forward(); break; case 'login': twitter_api_login(); break; case 'interstitial': gatekeeper(); // only let twitter users do this. $guid = elgg_get_logged_in_user_guid(); $twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api'); if (!$twitter_name) { register_error(elgg_echo('twitter_api:invalid_page')); forward(); } $pages = dirname(__FILE__) . '/pages/twitter_api'; include "{$pages}/interstitial.php"; break; default: forward(); break; } }
/** * Page setup. Adds admin controls to the admin panel. * */ function expages_pagesetup() { if (get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('expages'), $CONFIG->wwwroot . 'pg/expages/'); } }
/** * System init callback * @return void */ public function init() { hypeInbox()->config->registerLabels(); elgg_register_menu_item('page', array('name' => 'message_types', 'text' => elgg_echo('admin:inbox:message_types'), 'href' => 'admin/inbox/message_types', 'priority' => 500, 'contexts' => array('admin'), 'section' => 'configure')); elgg_register_css('inbox.base.css', elgg_get_simplecache_url('css', 'framework/inbox/stylesheet.css')); elgg_unregister_page_handler('messages', 'messages_page_handler'); elgg_register_page_handler($this->config->pagehandler_id, array($this->router, 'handlePages')); $action_path = $this->plugin->getPath() . '/actions/'; elgg_register_action("hypeInbox/settings/save", $action_path . 'settings/save.php', 'admin'); elgg_register_action('inbox/admin/import', $action_path . 'admin/import.php', 'admin'); elgg_register_action('messages/send', $action_path . 'messages/send.php'); elgg_register_action('messages/delete', $action_path . 'messages/delete.php'); elgg_register_action('messages/markread', $action_path . 'messages/markread.php'); elgg_register_action('messages/markunread', $action_path . 'messages/markunread.php'); // Third party integrations elgg_register_plugin_hook_handler('config:user_types', 'framework:inbox', array($this->hooks, 'filterUserTypes')); // Menu elgg_register_plugin_hook_handler('register', 'menu:page', array($this->hooks, 'setupPageMenu')); elgg_register_plugin_hook_handler('register', 'menu:inbox', array($this->hooks, 'setupInboxMenu')); elgg_register_plugin_hook_handler('register', 'menu:inbox:thread', array($this->hooks, 'setupInboxThreadMenu')); elgg_register_plugin_hook_handler('register', 'menu:entity', array($this->hooks, 'setupMessageMenu')); // Replace user hover menu items elgg_unregister_plugin_hook_handler('register', 'menu:user_hover', 'messages_user_hover_menu'); elgg_register_plugin_hook_handler('register', 'menu:user_hover', array($this->hooks, 'setupUserHoverMenu')); // URLs elgg_register_plugin_hook_handler('entity:url', 'object', array($this->hooks, 'handleMessageURL')); elgg_register_plugin_hook_handler('entity:icon:url', 'object', array($this->hooks, 'handleMessageIconURL')); }
function affiche_navbar($album, $deb, $i, $Max_pictures, $fichier) { //echo "album=".$album." i=".$i." deb=".$deb; // navigation bar v1.1 $content = "<h3>"; $tab = array('title' => elgg_echo('diapos:backlist'), 'href' => "diapos", 'is_action' => false, 'text' => elgg_echo('diapos:backlist')); $content .= "[ " . elgg_view('output/url', $tab); // liste des pages accessibles $Nb_pages = (int) (count($fichier) / ($Max_pictures + 1)) + 1; for ($j = 1; $j <= $Nb_pages; $j++) { if ($deb == ($j - 1) * $Max_pictures) { $content .= " | <u>" . $j . "</u>"; } else { $tab = array('title' => elgg_echo('diapos:goto') . " " . $j, 'href' => "diapos?album=" . $album . "&deb=" . (int) (($j - 1) * $Max_pictures), 'is_action' => false, 'text' => $j); $content .= " | " . elgg_view('output/url', $tab); } } /* $tab = array ('title' => elgg_echo('diapos:first'),'href' => "diapos?album=".$album."&deb=0",'is_action' => false,'text' => elgg_echo('diapos:first') ); $content .= elgg_view('output/url', $tab)." | " ; $tab = array ('title' => elgg_echo('diapos:end'),'href' => "diapos?album=".$album."&deb=".(int)(count($fichier)/$Max_pictures)*$Max_pictures,'is_action' => false,'text' => elgg_echo('diapos:end') ); $content .= elgg_view('output/url', $tab) ; */ if ($deb > 0) { // affiche le bouton previous $tab = array('title' => elgg_echo('diapos:previous'), 'href' => "diapos?album=" . $album . "&deb=" . (string) ($deb - $Max_pictures), 'is_action' => false, 'text' => elgg_echo('diapos:previous')); $content .= " | << " . elgg_view('output/url', $tab) . " "; } // next if ($i < count($fichier) && !empty($fichier)) { // affiche le bouton next $tab = array('title' => elgg_echo('diapos:next'), 'href' => "diapos?album=" . $album . "&deb=" . (string) ($deb + $Max_pictures), 'is_action' => false, 'text' => elgg_echo('diapos:next')); $content .= " | " . elgg_view('output/url', $tab) . " >>"; } $content .= " ]</h3>"; return $content; }
/** * Add some menu items during page setup */ function pagesetup() { elgg_register_menu_item('site', array('name' => 'categories', 'text' => elgg_echo('categories'), 'href' => PAGEHANDLER . '/all')); if (elgg_is_admin_logged_in()) { elgg_register_menu_item('page', array('name' => 'categories', 'text' => elgg_echo('categories:site'), 'href' => PAGEHANDLER . '/manage', 'priority' => 500, 'contexts' => array('admin'), 'section' => 'configure')); } }
function friend_request_pagesetup() { $context = elgg_get_context(); $page_owner = elgg_get_page_owner_entity(); // Remove link to friendsof elgg_unregister_menu_item("page", "friends:of"); if ($user = elgg_get_logged_in_user_entity()) { $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $user->getGUID(), "inverse_relationship" => true); if ($count = elgg_get_entities_from_relationship($options)) { $params = array("name" => "friend_request", "href" => "friend_request/" . $user->username, "text" => elgg_view_icon("user") . "<span class='friend-request-new'>" . $count . "</span>", "title" => elgg_echo("friend_request:menu"), "priority" => 301); elgg_register_menu_item("topbar", $params); } } // Show menu link in the correct context if (in_array($context, array("friends", "friendsof", "collections", "messages")) && !empty($page_owner) && $page_owner->canEdit()) { $options = array("type" => "user", "count" => true, "relationship" => "friendrequest", "relationship_guid" => $page_owner->getGUID(), "inverse_relationship" => true); if ($count = elgg_get_entities_from_relationship($options)) { $extra = " [" . $count . "]"; } else { $extra = ""; } // add menu item $menu_item = array("name" => "friend_request", "text" => elgg_echo("friend_request:menu") . $extra, "href" => "friend_request/" . $page_owner->username, "contexts" => array("friends", "friendsof", "collections", "messages"), "section" => "friend_request"); elgg_register_menu_item("page", $menu_item); } }
/** * Called on successful user login * If they are not in stormpath lets add them * * @param type $event * @param type $type * @param type $user */ function event_user_login($event, $type, $user) { $access_status = access_get_show_hidden_status(); access_show_hidden_entities(TRUE); if ($user instanceof ElggUser && !$user->isEnabled() && !$user->validated) { // send new validation email uservalidationbyemail_request_validation($user->getGUID()); // restore hidden entities settings access_show_hidden_entities($access_status); // throw error so we get a nice error message throw new LoginException(elgg_echo('uservalidationbyemail:login:fail')); } access_show_hidden_entities($access_status); if ($user->__stormpath_user) { return true; } // search stormpath for a matching account // may be in stormpath by manual addition, or from another application // with shared login $application = get_application(); if ($application) { $accts = $application->getAccounts(array('email' => $user->email)); foreach ($accts as $a) { $user->__stormpath_user = $a->href; return true; } $password = get_input('password'); if ($password) { add_to_stormpath($user, $password); } } return true; }
function questions_notify_message_handler($hook, $entity_type, $returnvalue, $params) { $entity = $params['entity']; $to_entity = $params['to_entity']; $method = $params['method']; if (elgg_instanceof($entity, 'object', 'question')) { $descr = $entity->description; $title = $entity->title; $url = $entity->getURL(); $owner = $entity->getOwnerEntity(); $via = elgg_echo("questions:via"); if ($method == 'sms') { //shortening the url for sms $url = elgg_get_site_url() . "view/{$entity->guid}"; return "{$owner->name} {$via}: {$url} ({$title})"; } if ($method == 'email') { return "{$owner->name} {$via}: {$title} \n\n {$descr} \n\n {$url}"; } if ($method == 'web') { return "{$owner->name} {$via}: {$title} \n\n {$descr} \n\n {$url}"; } } return null; }
/** * Clean up operations on calendar delete * * @param string $event "delete" * @param string $type "object" * @param ElggEntity $entity Entity being deleted */ function delete_event_handler($event, $type, $entity) { if ($entity instanceof Calendar) { // Do not allow users to delete publi calendars if ($entity->isPublicCalendar() && !elgg_is_admin_logged_in()) { register_error(elgg_echo('events:error:public_calendar_delete')); return false; } // Move all orphaned events to the public calendar $owner = $entity->getContainerEntity(); $public_calendar = Calendar::getPublicCalendar($owner); if (!$public_calendar) { register_error(elgg_echo('events:error:no_public_for_orphans')); return false; } $dbprefix = elgg_get_config('dbprefix'); $relationship_name = sanitize_string(Calendar::EVENT_CALENDAR_RELATIONSHIP); $calendar_subtype_id = (int) get_subtype_id('object', Calendar::SUBTYPE); // Get all events that do not appear on container's other calendars $events = new ElggBatch('elgg_get_entities_from_relationship', array('types' => 'object', 'subtypes' => Event::SUBTYPE, 'relationship' => Calendar::EVENT_CALENDAR_RELATIONSHIP, 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'limit' => 0, 'wheres' => array("NOT EXISTS(SELECT * FROM {$dbprefix}entity_relationships er2\n\t\t\t\t\tJOIN {$dbprefix}entities e2 ON er2.guid_two = e2.guid\n\t\t\t\t\tWHERE er2.relationship = '{$relationship_name}'\n\t\t\t\t\t\tAND er2.guid_one = e.guid\n\t\t\t\t\t\tAND er2.guid_two != {$entity->guid}\n\t\t\t\t\t\tAND e2.container_guid = {$entity->container_guid}\n\t\t\t\t\t\tAND e2.type = 'object' AND e2.subtype = {$calendar_subtype_id})"))); foreach ($events as $event) { /* @var Event $event */ $public_calendar->addEvent($event); } } return true; }
/** * Redirect the requestor to the new URL * Checks the plugin setting to determine the course of action: * a) Displays an error page with the new URL * b) Forwards to the new URL and displays an error message * c) Silently forwards to the new URL * * @param string $url Relative or absolute URL * @return mixed */ function legacy_urls_redirect($url) { $method = elgg_get_plugin_setting('redirect_method', 'legacy_urls'); // we only show landing page or queue warning if html generating page $viewtype = elgg_get_viewtype(); if ($viewtype != 'default' && !elgg_does_viewtype_fallback($viewtype)) { $method = 'immediate'; } switch ($method) { case 'landing': $content = elgg_view('legacy_urls/message', array('url' => $url)); $body = elgg_view_layout('error', array('content' => $content)); echo elgg_view_page('', $body, 'error'); return true; break; case 'immediate_error': // drop through after setting error message register_error(elgg_echo('changebookmark')); case 'immediate': default: $url = elgg_normalize_url($url); header("HTTP/1.1 301 Moved Permanently"); header("Location: {$url}"); exit; break; } }
/** * Set up menu items */ function theme_editable_pagesetup() { if (get_context() == 'admin' && isadminloggedin()) { global $CONFIG; add_submenu_item(elgg_echo('theme_editable:settings'), $CONFIG->wwwroot . 'mod/theme_editable/settings.php'); } }
function dietaryrequirements_fields($hook, $entity_type, $returnvalue, $params) { $options = array(elgg_echo("diet:omnivore") => "diet:omnivore", elgg_echo("diet:pescetarian") => "diet:pescetarian", elgg_echo("diet:veggie") => "diet:veggie", elgg_echo("diet:freegan") => "diet:freegan", elgg_echo("diet:vegan") => "diet:vegan", elgg_echo("diet:fruit") => "diet:fruit"); $returnvalue['diet'] = array("radio", $options); $returnvalue['dietextra'] = 'text'; return $returnvalue; }
function customstyle_page_handler($page) { gatekeeper(); elgg_set_context('customstyle'); elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); $title = elgg_echo('customstyle'); $base_dir = elgg_get_plugins_path() . 'customstyle/pages/customstyle'; switch ($page[0]) { case 'colors': $body = elgg_view('customstyle/colors'); break; case 'background': $body = elgg_view('customstyle/background'); break; case 'personalize': $body = elgg_view('customstyle/default'); break; default: $body = elgg_view('customstyle/default'); break; } $params = array('content' => $body, 'title' => $title); $body = elgg_view_layout('one_sidebar', $params); echo elgg_view_page($title, $body); return true; }