function subsite_manager_remove_superadmin($user_guid = 0) { $result = false; if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } if (!empty($user_guid) && subsite_manager_is_superadmin_logged_in()) { if (remove_private_setting($user_guid, "superadmin")) { $result = true; } } return $result; }
function translation_editor_actions_hook($hook, $type, $return, $params) { $allowed_actions = array("admin/plugins/activate", "admin/plugins/deactivate", "admin/plugins/activate_all", "admin/plugins/deactivate_all", "admin/plugins/set_priority", "upgrading"); if (!empty($type) && in_array($type, $allowed_actions)) { // make sure we have all translations translation_editor_reload_all_translations(); if ($languages = get_installed_translations()) { foreach ($languages as $key => $desc) { remove_private_setting(elgg_get_site_entity()->getGUID(), "te_last_update_" . $key); } } } }
/** * Validate and execute a password reset for a user. * * @param int $user_guid The user id * @param string $conf_code Confirmation code as sent in the request email. */ function execute_new_password_request($user_guid, $conf_code) { global $CONFIG; $user_guid = (int) $user_guid; $user = get_entity($user_guid); if ($user && get_private_setting($user_guid, 'passwd_conf_code') == $conf_code) { $password = generate_random_cleartext_password(); if (force_user_password_reset($user_guid, $password)) { //remove_metadata($user_guid, 'conf_code'); remove_private_setting($user_guid, 'passwd_conf_code'); $email = sprintf(elgg_echo('email:resetpassword:body'), $user->name, $password); return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), $email, NULL, 'email'); } } return false; }
/** * Discovers plugins in the plugins_path setting and creates ElggPlugin * entities for them if they don't exist. If there are plugins with entities * but not actual files, will disable the ElggPlugin entities and mark as inactive. * The ElggPlugin object holds config data, so don't delete. * * @todo Crappy name? * @return bool * @since 1.8.0 * @access private */ function elgg_generate_plugin_entities() { // @todo $site unused, can remove? $site = get_config('site'); $dir = elgg_get_plugins_path(); $db_prefix = elgg_get_config('dbprefix'); $options = array('type' => 'object', 'subtype' => 'plugin', 'selects' => array('plugin_oe.*'), 'joins' => array("JOIN {$db_prefix}objects_entity plugin_oe on plugin_oe.guid = e.guid"), 'limit' => ELGG_ENTITIES_NO_VALUE); $old_ia = elgg_set_ignore_access(true); $old_access = access_get_show_hidden_status(); access_show_hidden_entities(true); $known_plugins = elgg_get_entities_from_relationship($options); /* @var ElggPlugin[] $known_plugins */ if (!$known_plugins) { $known_plugins = array(); } // map paths to indexes $id_map = array(); foreach ($known_plugins as $i => $plugin) { // if the ID is wrong, delete the plugin because we can never load it. $id = $plugin->getID(); if (!$id) { $plugin->delete(); unset($known_plugins[$i]); continue; } $id_map[$plugin->getID()] = $i; } $physical_plugins = elgg_get_plugin_ids_in_dir($dir); if (!$physical_plugins) { return false; } // check real plugins against known ones foreach ($physical_plugins as $plugin_id) { // is this already in the db? if (array_key_exists($plugin_id, $id_map)) { $index = $id_map[$plugin_id]; $plugin = $known_plugins[$index]; // was this plugin deleted and its entity disabled? if (!$plugin->isEnabled()) { $plugin->enable(); $plugin->deactivate(); $plugin->setPriority('last'); } // remove from the list of plugins to disable unset($known_plugins[$index]); } else { // add new plugins // priority is force to last in save() if not set. $plugin = new ElggPlugin($plugin_id); $plugin->save(); } } // everything remaining in $known_plugins needs to be disabled // because they are entities, but their dirs were removed. // don't delete the entities because they hold settings. foreach ($known_plugins as $plugin) { if ($plugin->isActive()) { $plugin->deactivate(); } // remove the priority. $name = elgg_namespace_plugin_private_setting('internal', 'priority'); remove_private_setting($plugin->guid, $name); $plugin->disable(); } access_show_hidden_entities($old_access); elgg_set_ignore_access($old_ia); elgg_reindex_plugin_priorities(); return true; }
/** * Removes a user setting name and value. * * @param string $name The user setting name * @param int $user_guid The user GUID * @return bool */ public function unsetUserSetting($name, $user_guid = null) { $user_guid = (int) $user_guid; if ($user_guid) { $user = get_entity($user_guid); } else { $user = elgg_get_logged_in_user_entity(); } if (!$user instanceof ElggUser) { return false; } // set the namespaced name. $name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID()); return remove_private_setting($user->guid, $name); }
// add new plugins // priority is force to last in save() if not set. $plugin = new ElggPlugin($plugin_id); $plugin->save(); } } // everything remaining in $known_plugins needs to be disabled // because they are entities, but their dirs were removed. // don't delete the entities because they hold settings. foreach ($known_plugins as $plugin) { if ($plugin->isActive()) { $plugin->deactivate(); } // remove the priority. $name = elgg_namespace_plugin_private_setting('internal', 'priority'); remove_private_setting($plugin->guid, $name); $plugin->disable(); } // get old enabled plugins $enabled_plugin_options["guids"] = array($subsite->getGUID()); $old_enabled_plugins = elgg_get_metadata($enabled_plugin_options); if (!empty($old_enabled_plugins)) { $old_enabled_plugins = metadata_array_to_values($old_enabled_plugins); $old_enabled_plugins = array_unique($old_enabled_plugins); foreach ($old_enabled_plugins as $plugin_id) { if ($plugin = elgg_get_plugin_from_id($plugin_id)) { if (!check_entity_relationship($plugin->getGUID(), 'active_plugin', $subsite->getGUID())) { add_entity_relationship($plugin->getGUID(), 'active_plugin', $subsite->getGUID()); } } }
$entity_guid = (int) get_input('entity_guid'); $icons = get_input('icons'); $texts = get_input('texts'); $hrefs = get_input('hrefs'); $targets = get_input('targets'); $entity = get_entity($entity_guid); if (empty($entity) || !$entity->canEdit()) { register_error(elgg_echo('InvalidParameterException:NoEntityFound')); forward(REFERER); } $new_values = array(); foreach ($hrefs as $index => $href) { // check if value matches placeholder text if ($texts[$index] == elgg_echo('theme_haarlem_intranet:quick_nav:text')) { $texts[$index] = ''; } if ($href == elgg_echo('theme_haarlem_intranet:quick_nav:href')) { continue; } if (empty($href)) { continue; } $new_values[] = array('icon' => $icons[$index], 'text' => $texts[$index], 'href' => $href, 'target' => $targets[$index]); } if (empty($new_values)) { remove_private_setting($entity_guid, 'quick_nav'); } else { set_private_setting($entity_guid, 'quick_nav', json_encode($new_values)); } system_message(elgg_echo('theme_haarlem_intranet:action:quick_nav:success')); forward(REFERER);
function pleio_api_push_gcm_messages($gcmMessages = array()) { if (!sizeof($gcmMessages)) { return; } $apiKey = elgg_get_plugin_setting("gcm_api_key", "pleio_api"); $url = 'https://android.googleapis.com/gcm/send'; $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); foreach ($gcmMessages as $m) { //$m ["dry_run"] = true; //TEST SERVER $user_guids = $m["user_guids"]; unset($m["user_guids"]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($m)); $result = curl_exec($ch); $results = json_decode($result); for ($i = 0; $i < sizeof($results->results); $i++) { $result = $results->results[$i]; if (isset($result->error)) { switch ($result->error) { case "InvalidRegistration": case "NotRegistered": remove_private_setting($user_guids[$i], "device_token"); break; } } elseif (isset($result->registration_id)) { set_private_setting($user_guids[$i], "device_token", $result->registration_id); } } } curl_close($ch); return true; }
/** * Reset the site timestamp that tracks the merged translation status. * * This will recreate the translation editor cache * * @param int $site_guid which site to invalidate (defaults to current site) * * @return void */ function translation_editor_invalidate_site_cache($site_guid = 0) { $site_guid = sanitize_int($site_guid, false); // make sure we have all translations translation_editor_reload_all_translations(); $languages = get_installed_translations(); if (empty($languages) || !is_array($languages)) { return; } $site = elgg_get_site_entity($site_guid); if (empty($site)) { return; } foreach ($languages as $key => $desc) { remove_private_setting($site->getGUID(), "te_last_update_{$key}"); } }
/** * Validate and execute a password reset for a user. * * @param int $user_guid The user id * @param string $conf_code Confirmation code as sent in the request email. * * @return mixed */ function execute_new_password_request($user_guid, $conf_code) { global $CONFIG; $user_guid = (int) $user_guid; $user = get_entity($user_guid); if ($user instanceof ElggUser) { $saved_code = $user->getPrivateSetting('passwd_conf_code'); if ($saved_code && $saved_code == $conf_code) { $password = generate_random_cleartext_password(); if (force_user_password_reset($user_guid, $password)) { remove_private_setting($user_guid, 'passwd_conf_code'); // clean the logins failures reset_login_failure_count($user_guid); $email = '<div style="color:#333;font-size:16px;">' . elgg_echo('email:resetpassword:body', array($user->name, $password)) . '</div>'; //return notify_user($user->guid, $CONFIG->site->guid, // elgg_echo('email:resetpassword:subject'), $email, array(), 'email'); $site_name = elgg_get_site_entity()->name; return zhgroups_send_email($site_name, $user->email, elgg_echo('email:resetpassword:subject', array($site_name)), $email); } } } return FALSE; }
/** * Validate and change password for a user. * * @param int $user_guid The user id * @param string $conf_code Confirmation code as sent in the request email. * @param string $password Optional new password, if not randomly generated. * * @return bool True on success */ function executeNewPasswordReset($user_guid, $conf_code, $password = null) { $user_guid = (int) $user_guid; $user = get_entity($user_guid); if ($password === null) { $password = generate_random_cleartext_password(); $reset = true; } else { $reset = false; } if (!$user instanceof \ElggUser) { return false; } $saved_code = $user->getPrivateSetting('passwd_conf_code'); $code_time = (int) $user->getPrivateSetting('passwd_conf_time'); $codes_match = _elgg_services()->crypto->areEqual($saved_code, $conf_code); if (!$saved_code || !$codes_match) { return false; } // Discard for security if it is 24h old if (!$code_time || $code_time < time() - 24 * 60 * 60) { return false; } if (!$this->forcePasswordReset($user, $password)) { return false; } remove_private_setting($user_guid, 'passwd_conf_code'); remove_private_setting($user_guid, 'passwd_conf_time'); // clean the logins failures reset_login_failure_count($user_guid); $ns = $reset ? 'resetpassword' : 'changepassword'; $message = _elgg_services()->translator->translate("email:{$ns}:body", array($user->username, $password), $user->language); $subject = _elgg_services()->translator->translate("email:{$ns}:subject", array(), $user->language); notify_user($user->guid, elgg_get_site_entity()->guid, $subject, $message, array(), 'email'); return true; }
/** * Removes a user setting name and value. * * @param string $name The user setting name * @param int $user_guid The user GUID * @return bool */ public function unsetUserSetting($name, $user_guid = null) { $user_guid = (int) $user_guid; if ($user_guid) { $user = get_entity($user_guid); } else { $user = elgg_get_logged_in_user_entity(); } if (!$user instanceof ElggUser) { return false; } // set the namespaced name. $name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID()); // Subsite adjustment $site = elgg_get_site_entity(); $alt_name = str_replace(ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":", ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":" . $site->getGUID() . ":", $name); $main_res = remove_private_setting($user->getGUID(), $name); $alt_res = remove_private_setting($user->getGUID(), $alt_name); return $main_res || $alt_res; }
/** * Validate and change password for a user. * * @param int $user_guid The user id * @param string $conf_code Confirmation code as sent in the request email. * @param string $password Optional new password, if not randomly generated. * * @return bool True on success */ function execute_new_password_request($user_guid, $conf_code, $password = null) { $user_guid = (int) $user_guid; $user = get_entity($user_guid); if ($password === null) { $password = generate_random_cleartext_password(); $reset = true; } if (!elgg_instanceof($user, 'user')) { return false; } $saved_code = $user->getPrivateSetting('passwd_conf_code'); $code_time = (int) $user->getPrivateSetting('passwd_conf_time'); if (!$saved_code || $saved_code != $conf_code) { return false; } // Discard for security if it is 24h old if (!$code_time || $code_time < time() - 24 * 60 * 60) { return false; } if (force_user_password_reset($user_guid, $password)) { remove_private_setting($user_guid, 'passwd_conf_code'); remove_private_setting($user_guid, 'passwd_conf_time'); // clean the logins failures reset_login_failure_count($user_guid); $ns = $reset ? 'resetpassword' : 'changepassword'; notify_user($user->guid, elgg_get_site_entity()->guid, elgg_echo("email:{$ns}:subject", array(), $user->language), elgg_echo("email:{$ns}:body", array($user->username, $password), $user->language), array(), 'email'); return true; } return false; }
/** * Removes a user setting name and value. * * @param string $name The user setting name * @param int $user_guid The user GUID * @return bool */ public function unsetUserSetting($name, $user_guid = 0) { $user_guid = (int) $user_guid; if ($user_guid) { $user = get_entity($user_guid); } else { $user = _elgg_services()->session->getLoggedInUser(); } if (!$user instanceof \ElggUser) { return false; } // set the namespaced name. $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID()); return remove_private_setting($user->guid, $name); }
/** * Validate and execute a password reset for a user. * * @param int $user_guid The user id * @param string $conf_code Confirmation code as sent in the request email. * * @return mixed */ function execute_new_password_request($user_guid, $conf_code) { global $CONFIG; $user_guid = (int) $user_guid; $user = get_entity($user_guid); if ($user) { $saved_code = $user->getPrivateSetting('passwd_conf_code'); if ($saved_code && $saved_code == $conf_code) { $password = generate_random_cleartext_password(); if (force_user_password_reset($user_guid, $password)) { remove_private_setting($user_guid, 'passwd_conf_code'); // clean the logins failures reset_login_failure_count($user_guid); $email = elgg_echo('email:resetpassword:body', array($user->name, $password)); return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), $email, NULL, 'email'); } } } return FALSE; }
/** * Removes private setting * * @param string $name Name of the private setting * * @return bool */ public function removePrivateSetting($name) { return remove_private_setting($this->getGUID(), $name); }
/** * Clear a plugin setting. * * @param string $name The name. * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from. */ function clear_plugin_setting($name, $plugin_name = "") { $plugin = find_plugin_settings($plugin_name); if ($plugin) { return remove_private_setting($plugin->guid, $name); } return FALSE; }