本文整理汇总了PHP中set_private_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP set_private_setting函数的具体用法?PHP set_private_setting怎么用?PHP set_private_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_private_setting函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sitepages_create_sitepage_object
/**
* Creates a site page object.
*
* @param str $page_type
* @return mixed ElggSitePage on success, FALSE on fail.
*/
function sitepages_create_sitepage_object($page_type)
{
global $CONFIG;
$sitepage = new ElggSitePage();
$sitepage->page_type = $page_type;
$sitepage->access_id = ACCESS_PUBLIC;
$sitepage->save();
if ($sitepage->save() && set_private_setting($CONFIG->site->getGUID(), "sitepages:{$page_type}", $sitepage->getGUID())) {
return $sitepage;
}
return FALSE;
}
开发者ID:adamboardman,项目名称:Elgg,代码行数:18,代码来源:sitepages_functions.php
示例2: testElggApiGettersEntitiesFromPrivateSettings
public function testElggApiGettersEntitiesFromPrivateSettings()
{
// create some test private settings
$setting_name = 'test_setting_name_' . rand();
$setting_value = rand(1000, 9999);
$setting_name2 = 'test_setting_name_' . rand();
$setting_value2 = rand(1000, 9999);
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$guids = array();
// our targets
$valid = new ElggObject();
$valid->subtype = $subtype;
$valid->save();
$guids[] = $valid->getGUID();
set_private_setting($valid->getGUID(), $setting_name, $setting_value);
set_private_setting($valid->getGUID(), $setting_name2, $setting_value2);
$valid2 = new ElggObject();
$valid2->subtype = $subtype;
$valid2->save();
$guids[] = $valid2->getGUID();
set_private_setting($valid2->getGUID(), $setting_name, $setting_value);
set_private_setting($valid2->getGUID(), $setting_name2, $setting_value2);
// simple test with name
$options = array('private_setting_name' => $setting_name);
$entities = elgg_get_entities_from_private_settings($options);
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
$value = get_private_setting($entity->getGUID(), $setting_name);
$this->assertEqual($value, $setting_value);
}
// simple test with value
$options = array('private_setting_value' => $setting_value);
$entities = elgg_get_entities_from_private_settings($options);
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
$value = get_private_setting($entity->getGUID(), $setting_name);
$this->assertEqual($value, $setting_value);
}
// test pairs
$options = array('type' => 'object', 'subtype' => $subtype, 'private_setting_name_value_pairs' => array(array('name' => $setting_name, 'value' => $setting_value), array('name' => $setting_name2, 'value' => $setting_value2)));
$entities = elgg_get_entities_from_private_settings($options);
$this->assertEqual(2, count($entities));
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
}
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
$e->delete();
}
}
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:52,代码来源:ElggCoreGetEntitiesFromPrivateSettingsTest.php
示例3: set
/**
* Override entity get and sets in order to save data to private data store.
*/
public function set($name, $value)
{
if (array_key_exists($name, $this->attributes)) {
// Check that we're not trying to change the guid!
if (array_key_exists('guid', $this->attributes) && $name == 'guid') {
return false;
}
$this->attributes[$name] = $value;
} else {
return set_private_setting($this->guid, $name, $value);
}
return true;
}
开发者ID:eokyere,项目名称:elgg,代码行数:16,代码来源:plugins.php
示例4: subsite_manager_make_superadmin
function subsite_manager_make_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 (set_private_setting($user_guid, "superadmin", true)) {
$result = true;
}
}
return $result;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:13,代码来源:functions.php
示例5: runUpgrades
/**
* Runs pending upgrades
* @return void
*/
public function runUpgrades()
{
$site = elgg_get_site_entity();
$upgrades = $this->getUpgrades();
foreach ($upgrades as $upgrade) {
$upgradename = "hypeScraper_{$upgrade}";
if (get_private_setting($site->guid, $upgradename)) {
continue;
}
if (is_callable(array($this, $upgrade))) {
call_user_func(array($this, $upgrade));
set_private_setting($site->guid, $upgradename, time());
}
}
}
开发者ID:n8b,项目名称:VMN,代码行数:19,代码来源:Upgrades.php
示例6: translation_editor_merge_translations
function translation_editor_merge_translations($language = "", $update = false)
{
global $CONFIG;
$result = false;
if (empty($language)) {
$language = get_current_language();
}
if (!empty($language)) {
$translations = array();
if ($core = translation_editor_read_translation($language, "core")) {
$translations = $core;
}
if ($custom_keys = translation_editor_read_translation($language, "custom_keys")) {
$translations += $custom_keys;
}
if ($plugins = elgg_get_plugins()) {
foreach ($plugins as $plugin) {
if ($plugin_translation = translation_editor_read_translation($language, $plugin->title)) {
$translations += $plugin_translation;
}
}
}
if (!empty($translations)) {
if (translation_editor_write_translation($language, "translation_editor_merged_" . $CONFIG->site_guid, $translations)) {
$result = true;
}
} else {
if (translation_editor_delete_translation($language, "translation_editor_merged_" . $CONFIG->site_guid)) {
$result = true;
}
}
}
if ($result) {
elgg_trigger_event("language:merge", "translation_editor", $language);
}
// reset language cache on all sites
if ($update) {
$ts = time();
datalist_set("te_last_update_" . $language, $ts);
set_private_setting($CONFIG->site_guid, "te_last_update_" . $language, $ts);
}
return $result;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:43,代码来源:functions.php
示例7: setUserSetting
/**
* Sets a user setting for a plugin
*
* @param string $name The setting name
* @param string $value The setting value
* @param int $user_guid The user GUID
*
* @return mixed The new setting ID or false
*/
public function setUserSetting($name, $value, $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;
}
// Hook to validate setting
// note this doesn't pass the namespaced name!
$value = elgg_trigger_plugin_hook('plugin:usersetting', 'user', array('user' => $user, 'plugin' => $this->getID(), 'name' => $name, 'value' => $value), $value);
// set the namespaced name.
$name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
return set_private_setting($user->guid, $name, $value);
}
开发者ID:rasul,项目名称:Elgg,代码行数:27,代码来源:ElggPlugin.php
示例8: unserialize
$old_plugin_order = unserialize($site->pluginorder);
$old_enabled_plugins = $site->enabled_plugins;
$db_prefix = get_config('dbprefix');
$plugin_subtype_id = get_subtype_id('object', 'plugin');
// easy one first: make sure the the site owns all plugin entities.
$q = "UPDATE {$db_prefix}entities e\n\tSET owner_guid = site_guid, container_guid = site_guid\n\tWHERE e.type = 'object' AND e.subtype = {$plugin_subtype_id}";
$r = update_data($q);
// rewrite all plugin:setting:* to ELGG_PLUGIN_USER_SETTING_PREFIX . *
$q = "UPDATE {$db_prefix}private_settings\n\tSET name = replace(name, 'plugin:settings:', '" . ELGG_PLUGIN_USER_SETTING_PREFIX . "')\n\tWHERE name LIKE 'plugin:settings:%'";
$r = update_data($q);
// grab current plugin GUIDs to add a temp priority
$q = "SELECT * FROM {$db_prefix}entities e\n\tJOIN {$db_prefix}objects_entity oe ON e.guid = oe.guid\n\tWHERE e.type = 'object' AND e.subtype = {$plugin_subtype_id}";
$plugins = get_data($q);
foreach ($plugins as $plugin) {
$priority = elgg_namespace_plugin_private_setting('internal', 'priority');
set_private_setting($plugin->guid, $priority, 0);
}
// force regenerating plugin entities
elgg_generate_plugin_entities();
// set the priorities for all plugins
// this function rewrites it to a normal index so use the current one.
elgg_set_plugin_priorities($old_plugin_order);
// add relationships for enabled plugins
if ($old_enabled_plugins) {
// they might only have one plugin enabled.
if (!is_array($old_enabled_plugins)) {
$old_enabled_plugins = array($old_enabled_plugins);
}
// sometimes there were problems and you'd get 1000s of enabled plugins.
$old_enabled_plugins = array_unique($old_enabled_plugins);
foreach ($old_enabled_plugins as $plugin_id) {
开发者ID:pleio,项目名称:subsite_manager,代码行数:31,代码来源:2011010101.php
示例9: pleio_api_push_gcm_messages
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;
}
开发者ID:appstaat,项目名称:pleio_api,代码行数:37,代码来源:helpers.php
示例10: setUserSetting
/**
* Sets a user setting for a plugin
*
* @param string $name The setting name
* @param string $value The setting value
* @param int $user_guid The user GUID
*
* @return mixed The new setting ID or false
*/
public function setUserSetting($name, $value, $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;
}
// Hook to validate setting
// note: this doesn't pass the namespaced name
$value = _elgg_services()->hooks->trigger('usersetting', 'plugin', array('user' => $user, 'plugin' => $this, 'plugin_id' => $this->getID(), 'name' => $name, 'value' => $value), $value);
// set the namespaced name.
$name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
return set_private_setting($user->guid, $name, $value);
}
开发者ID:bhargavgarlapati,项目名称:Elgg,代码行数:27,代码来源:ElggPlugin.php
示例11: get_input
$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);
开发者ID:Twizanex,项目名称:theme_haarlem_intranet,代码行数:31,代码来源:quick_nav.php
示例12: pleio_api_swordfish_site_connect
function pleio_api_swordfish_site_connect($subsite_id = 0, $swordfish_api_url = "")
{
$subsite_id = intval($subsite_id);
$swordfish_api_url = sanitise_string($swordfish_api_url);
$user = elgg_get_logged_in_user_entity();
$subsite = get_entity($subsite_id);
$parsed = parse_url($swordfish_api_url);
if (!$subsite) {
return new ErrorResult(elgg_echo('pleio_api:swordfish_api_url:subsite_not_found'));
}
if (!$parsed["scheme"] || !$parsed["host"] || !$parsed["path"]) {
return new ErrorResult(elgg_echo('pleio_api:swordfish_api_url:invalid_url'));
}
if (set_private_setting($subsite_id, "swordfish_api_url", $swordfish_api_url)) {
return new SuccessResult(elgg_echo('pleio_api:swordfish_api_url:success'));
}
return new ErrorResult(elgg_echo('pleio_api:swordfish_api_url:fail'));
}
开发者ID:appstaat,项目名称:pleio_api,代码行数:18,代码来源:methods.php
示例13: translation_editor_merge_translations
/**
* Merge all custom translations into a single file for performance
*
* @param string $language the language to merge
* @param bool $update force and update to other sites
*
* @return bool
*/
function translation_editor_merge_translations($language = "", $update = false)
{
$result = false;
$site = elgg_get_site_entity();
if (empty($language)) {
$language = get_current_language();
}
if (!empty($language)) {
$translations = array();
// get core translations
$core = translation_editor_read_translation($language, 'core');
if (!empty($core)) {
$translations = $core;
}
// get the customo keys
$custom_keys = translation_editor_read_translation($language, 'custom_keys');
if (!empty($custom_keys)) {
$translations += $custom_keys;
}
// proccess all plugins
$plugins = elgg_get_plugins();
if (!empty($plugins)) {
foreach ($plugins as $plugin) {
// add plugin translations
$plugin_translation = translation_editor_read_translation($language, $plugin->title);
if (!empty($plugin_translation)) {
$translations += $plugin_translation;
}
}
}
if (!empty($translations)) {
// write all to disk
if (translation_editor_write_translation($language, "translation_editor_merged_{$site->getGUID()}", $translations)) {
$result = true;
}
} else {
// no custom translations, so remove the cache file
if (translation_editor_delete_translation($language, "translation_editor_merged_{$site->getGUID()}")) {
$result = true;
}
}
}
if ($result) {
// clear system cache
$cache = elgg_get_system_cache();
$cache->delete("{$language}.lang");
// let others know this happend
elgg_trigger_event("language:merge", "translation_editor", $language);
}
// reset language cache on all sites
if ($update) {
$ts = time();
datalist_set("te_last_update_{$language}", $ts);
set_private_setting($site->getGUID(), "te_last_update_{$language}", $ts);
}
return $result;
}
开发者ID:coldtrick,项目名称:translation_editor,代码行数:65,代码来源:functions.php
示例14: setUserSetting
/**
* Sets a user setting for a plugin
*
* @param string $name The setting name
* @param string $value The setting value
* @param int $user_guid The user GUID
*
* @return mixed The new setting ID or false
*/
public function setUserSetting($name, $value, $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;
}
// Hook to validate setting
// note: this doesn't pass the namespaced name
$value = elgg_trigger_plugin_hook('usersetting', 'plugin', array('user' => $user, 'plugin' => $this, 'plugin_id' => $this->getID(), 'name' => $name, 'value' => $value), $value);
// set the namespaced name.
$name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
// Subsite adjustment
$site = elgg_get_site_entity();
if (!subsite_manager_check_global_plugin_setting($this->getID(), "use_global_usersettings")) {
$name = str_replace(ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":", ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":" . $site->getGUID() . ":", $name);
}
return set_private_setting($user->getGUID(), $name, $value);
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:32,代码来源:SubsitePlugin.php
示例15: get_input
<?php
$container_guid = (int) get_input('container_guid', elgg_get_logged_in_user_guid());
$ordered_guids = get_input('guids', '');
if (get_entity($container_guid)) {
set_private_setting($container_guid, 'quicklinks_order', json_encode($ordered_guids));
}
开发者ID:coldtrick,项目名称:quicklinks,代码行数:7,代码来源:reorder.php
示例16: RegistrationException
}
if (strcmp($password, $password2) != 0) {
throw new RegistrationException(elgg_echo('RegistrationException:PasswordMismatch'));
}
$guid = register_user($username, $password, $name, $email, false, $friend_guid, $invitecode);
if ($guid) {
$new_user = get_entity($guid);
// allow plugins to respond to self registration
// note: To catch all new users, even those created by an admin,
// register for the create, user event instead.
// only passing vars that aren't in ElggUser.
$params = array('user' => $new_user, 'password' => $password, 'friend_guid' => $friend_guid, 'invitecode' => $invitecode);
// accept general terms
if (get_input("accept_terms") == "yes") {
$ia = elgg_set_ignore_access(true);
set_private_setting($guid, "general_terms_accepted", time());
elgg_set_ignore_access($ia);
}
// @todo should registration be allowed no matter what the plugins return?
if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
$ia = elgg_set_ignore_access(true);
$new_user->delete();
elgg_set_ignore_access($ia);
// @todo this is a generic messages. We could have plugins
// throw a RegistrationException, but that is very odd
// for the plugin hooks system.
throw new RegistrationException(elgg_echo('registerbad'));
}
elgg_clear_sticky_form('register');
system_message(elgg_echo("registerok", array(elgg_get_site_entity()->name)));
// if exception thrown, this probably means there is a validation
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:31,代码来源:register.php
示例17: send_new_password_request
/**
* Generate and send a password request email to a given user's registered email address.
*
* @param int $user_guid
*/
function send_new_password_request($user_guid)
{
global $CONFIG;
$user_guid = (int) $user_guid;
$user = get_entity($user_guid);
if ($user) {
// generate code
$code = generate_random_cleartext_password();
//create_metadata($user_guid, 'conf_code', $code,'', 0, ACCESS_PRIVATE);
set_private_setting($user_guid, 'passwd_conf_code', $code);
// generate link
$link = $CONFIG->site->url . "action/user/passwordreset?u={$user_guid}&c={$code}";
// generate email
$email = sprintf(elgg_echo('email:resetreq:body'), $user->name, $_SERVER['REMOTE_ADDR'], $link);
return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetreq:subject'), $email, NULL, 'email');
}
return false;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:23,代码来源:users.php
示例18: setPrivateSetting
function setPrivateSetting($name, $value)
{
return set_private_setting($this->getGUID(), $name, $value);
}
开发者ID:jricher,项目名称:Elgg,代码行数:4,代码来源:entities.php
示例19: setPrivateSetting
/**
* Adds a private setting to this entity.
*
* Private settings are similar to metadata but will not
* be searched and there are fewer helper functions for them.
*
* @param string $name Name of private setting
* @param mixed $value Value of private setting
*
* @return bool
*/
public function setPrivateSetting($name, $value)
{
if ((int) $this->guid > 0) {
return set_private_setting($this->getGUID(), $name, $value);
} else {
$this->temp_private_settings[$name] = $value;
return true;
}
}
开发者ID:elgg,项目名称:elgg,代码行数:20,代码来源:ElggEntity.php
示例20: batchSync
/**
* Batch sync data to ElasticSearch
*
* This function is timed at a max runtime of 30sec
*
* @param array $options the options for elgg_get_entities()
* @param int $crontime the starttime of the cron in order to limit max runtime
* @param string $getter the getter function to use for \ElggBatch
*
* @return bool|void
*/
protected static function batchSync($options, $crontime, $getter = '')
{
if (empty($options) || !is_array($options)) {
return;
}
if (empty($getter)) {
$getter = 'elgg_get_entities_from_private_settings';
}
if (!is_callable($getter)) {
return false;
}
$client = elasticsearch_get_client();
if (empty($client)) {
return;
}
$crontime = sanitise_int($crontime, false);
if (empty($crontime)) {
$crontime = time();
}
if (time() - $crontime >= 30) {
return false;
}
set_time_limit(40);
$ia = elgg_set_ignore_access(true);
$time_left = true;
$batch_size = 100;
$options['callback'] = false;
$options['limit'] = $batch_size;
while ($time_left && ($rows = call_user_func($getter, $options))) {
$guids = array();
foreach ($rows as $row) {
$guids[] = (int) $row->guid;
}
$result = $client->bulkIndexDocuments($guids);
if (empty($result)) {
break;
}
$items = elgg_extract('items', $result);
foreach ($items as $item) {
$guid = (int) elgg_extract('_id', elgg_extract('index', $item));
$status = elgg_extract('status', elgg_extract('index', $item));
if ($status !== 200) {
continue;
}
if (empty($guid)) {
continue;
}
set_private_setting($guid, ELASTICSEARCH_INDEXED_NAME, time());
}
if (time() - $crontime >= 30) {
$time_left = false;
break;
}
}
// restore access
elgg_set_ignore_access($ia);
return $time_left;
}
开发者ID:coldtrick,项目名称:elasticsearch,代码行数:69,代码来源:Cron.php
注:本文中的set_private_setting函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论