/**
 * Get the quick nav menu for an entity
 *
 * @param int $entity_guid the guid of the entity to get the quick nav for
 *
 * @return array
 */
function theme_haarlem_intranet_get_quick_nav($entity_guid)
{
    $settings = get_private_setting($entity_guid, 'quick_nav');
    if (empty($settings)) {
        return array();
    }
    return @json_decode($settings, true);
}
示例#2
0
/**
 * Returns a single object that holds information about
 * customizations for the $section site page.  The object guid
 * is stored as private data on the site entity.  This allows the pages
 * to still be searchable as standard entities.
 *
 * @param $type
 * @return mixed ElggSitePage on success, FALSE on fail
 */
function sitepages_get_sitepage_object($page_type)
{
    global $CONFIG;
    $page_guid = get_private_setting($CONFIG->site->getGUID(), "sitepages:{$page_type}");
    $sitepage = get_entity($page_guid);
    if ($sitepage instanceof ElggSitePage || $sitepage->page_type == $page_type) {
        return $sitepage;
    }
    return FALSE;
}
 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();
         }
     }
 }
示例#4
0
文件: plugins.php 项目: eokyere/elgg
 /**
  * Override entity get and sets in order to save data to private data store.
  */
 public function get($name)
 {
     // See if its in our base attribute
     if (isset($this->attributes[$name])) {
         return $this->attributes[$name];
     }
     // No, so see if its in the private data store.
     $meta = get_private_setting($this->guid, $name);
     if ($meta) {
         return $meta;
     }
     // Can't find it, so return null
     return null;
 }
示例#5
0
文件: Upgrades.php 项目: n8b/VMN
 /**
  * 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());
         }
     }
 }
 /**
  * Override entity get and sets in order to save data to private data store.
  */
 public function get($name)
 {
     // See if its in our base attribute
     if (isset($this->attributes[$name])) {
         return $this->attributes[$name];
     }
     // No, so see if its in the private data store.
     // get_private_setting() returns false if it doesn't exist
     $meta = get_private_setting($this->guid, $name);
     if ($meta === false) {
         // Can't find it, so return null
         return NULL;
     }
     return $meta;
 }
示例#7
0
 /**
  * Returns a user's setting for this plugin
  *
  * @param string $name      The setting name
  * @param int    $user_guid The user GUID
  * @param mixed  $default   The default value to return if none is set
  *
  * @return mixed The setting string value, the default value or false if there is no user
  */
 public function getUserSetting($name, $user_guid = 0, $default = null)
 {
     $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;
     }
     $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
     $val = get_private_setting($user->guid, $name);
     return $val !== null ? $val : $default;
 }
示例#8
0
文件: ElggEntity.php 项目: elgg/elgg
 /**
  * Returns a private setting value
  *
  * @param string $name Name of the private setting
  *
  * @return mixed Null if the setting does not exist
  */
 public function getPrivateSetting($name)
 {
     if ((int) $this->guid > 0) {
         return get_private_setting($this->getGUID(), $name);
     } else {
         if (isset($this->temp_private_settings[$name])) {
             return $this->temp_private_settings[$name];
         }
     }
     return null;
 }
示例#9
0
function translation_editor_load_translations($current_language = "")
{
    global $CONFIG;
    if (empty($current_language)) {
        $current_language = get_current_language();
    }
    // check if update is needed
    $main_ts = datalist_get("te_last_update_" . $current_language);
    $site_ts = get_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language);
    if (!empty($main_ts)) {
        if (empty($site_ts) || $main_ts > $site_ts) {
            if (translation_editor_merge_translations($current_language)) {
                set_private_setting($CONFIG->site_guid, "te_last_update_" . $current_language, time());
            }
        }
    } else {
        translation_editor_merge_translations($current_language, true);
    }
    // load translations
    if ($translations = translation_editor_read_translation($current_language, "translation_editor_merged_" . $CONFIG->site_guid)) {
        add_translation($current_language, $translations);
    }
}
/**
 * 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;
}
示例#11
0
function pleio_api_queue_push_message($to_guid, $from_guid, $message, $object_type, $object_guid = 0, $site_guid = 0, $container_guid = 0)
{
    $to = get_user($to_guid);
    if ($to) {
        $device_token = get_private_setting($to->guid, "device_token");
        if ($device_token) {
            if ($from_guid) {
                $from = get_user($from_guid);
                if ($from) {
                    $push = elgg_echo($message, array($from->name), 'nl');
                }
            }
            $message = new ElggObject();
            $message->subtype = 'push_message_queue';
            // $message -> access_id = ACCESS_PUBLIC;
            $message->description = $push;
            $message->to_guid = $to->guid;
            $message->object_guid = $object_guid;
            $message->message_type = $object_type;
            $message->site_guid = $site_guid;
            $message->container_guid = $container_guid;
            $message->save();
        }
    }
}
示例#12
0
文件: ElggPlugin.php 项目: rasul/Elgg
 /**
  * Returns a user's setting for this plugin
  *
  * @param string $name      The setting name
  * @param int    $user_guid The user GUID
  *
  * @return mixed The setting string value or false
  */
 public function getUserSetting($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;
     }
     $name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
     return get_private_setting($user->guid, $name);
 }
示例#13
0
文件: entities.php 项目: jricher/Elgg
 function getPrivateSetting($name)
 {
     return get_private_setting($this->getGUID(), $name);
 }
<style>

	#c_accepted_general_terms_status_bar {
		background-color: green;
		text-align: center;
		color: white;
	}

	#c_notaccepted_general_terms_status_bar {
		background-color: red;
		text-align: center;
		color: white;
	}

</style>

<?php 
// only admins can see this status
if (get_loggedin_user()->isAdmin()) {
    if (get_private_setting(elgg_get_page_owner_entity()->guid, 'general_terms_accepted')) {
        echo '<div id="c_accepted_general_terms_status_bar">';
        echo elgg_echo('acgt:accepted');
    } else {
        echo '<div id="c_notaccepted_general_terms_status_bar">';
        echo elgg_echo('acgt:not_accepted');
    }
    echo '</div>';
}
示例#15
0
function pleio_api_get_all_subsites($search = null, $subsite_id = 0, $locked_filter = 0, $order_by = 0, $offset = 0, $wheres = array(), $joins = array())
{
    $list = array();
    $total = 0;
    $joins[] = sprintf(" INNER JOIN %ssites_entity s USING (guid) ", get_config("dbprefix"));
    $offset = intval($offset);
    if ($search) {
        $search = sanitise_string($search);
        $wheres[] = " (s.name LIKE '%{$search}%' OR s.url LIKE '%{$search}%' OR s.description LIKE '%{$search}%') ";
    }
    if ($locked_filter == 1) {
        $joins[] = sprintf(" INNER JOIN %sprivate_settings ps ON ps.entity_guid = guid ", get_config("dbprefix"));
        $wheres[] = " ps.name = 'membership' AND ps.value = 'open' ";
    } elseif ($locked_filter == 2) {
        $joins[] = sprintf(" INNER JOIN %sprivate_settings ps ON ps.entity_guid = guid ", get_config("dbprefix"));
        $wheres[] = " ps.name = 'membership' AND ps.value != 'open' ";
    }
    $options = array('type' => 'site', 'limit' => 20, 'offset' => $offset, 'count' => true, "wheres" => $wheres, "joins" => $joins, 'site_guid' => ELGG_ENTITIES_ANY_VALUE);
    if ($subsite_id) {
        $options["guids"] = $subsite_id;
    }
    $total = elgg_get_entities($options);
    if ($total > 0) {
        $options['count'] = false;
        if ($order_by == 1) {
            $options['order_by'] = ' s.name ';
        } elseif ($order_by == 2) {
            $options['order_by'] = ' s.name DESC ';
        }
        $sites = elgg_get_entities($options);
        /* @var $site Subsite */
        foreach ($sites as $site) {
            $e = pleio_api_export($site, explode(",", "guid,name,url"));
            $membership = get_private_setting($site->guid, "membership");
            $e["o"] = !$membership || $membership == "open" ? 1 : 0;
            $is_member = $site instanceof Subsite && $site->isUser() || !$site instanceof Subsite && $site instanceof ElggSite ? 1 : 0;
            $e["m"] = $is_member;
            $e["i"] = !$is_member && $site instanceof Subsite && $site->hasInvitation() ? 1 : 0;
            $e["p"] = !$is_member && $site instanceof Subsite && $site->pendingMembershipRequest() ? 1 : 0;
            $e["l"] = pleio_api_get_mobile_logo($e['guid'], $e["url"]);
            $colors = pleio_api_get_site_colors($e['guid']);
            $e["c"] = $colors[0];
            $e["fc"] = $colors[1];
            $count_result = get_data_row(sprintf("select count(*) as c from %sentity_relationships where guid_two = %d and relationship = 'member_of_site' ", get_config("dbprefix"), $e['guid']));
            $e["mt"] = $count_result->c;
            $e["e"] = $site->email;
            $list[] = $e;
        }
    }
    return array("total" => $total, "list" => $list, "offset" => $offset);
}
<?php 
echo get_loggedin_user()->username;
echo get_private_setting(get_loggedin_user()->guid, 'general_terms_accepted');
echo '<br/>';
echo get_private_setting(881, 'general_terms_accepted');
示例#17
0
/**
 * Load all the custom translations into the running translations
 *
 * @param string $current_language the language to load (defaults to the language of the current user)
 *
 * @return void
 */
function translation_editor_load_translations($current_language = "")
{
    $site = elgg_get_site_entity();
    if (empty($current_language)) {
        $current_language = get_current_language();
    }
    // check if update is needed
    $main_ts = (int) datalist_get("te_last_update_{$current_language}");
    $site_ts = (int) get_private_setting($site->getGUID(), "te_last_update_{$current_language}");
    if (!empty($main_ts)) {
        if (empty($site_ts) || $main_ts > $site_ts) {
            if (translation_editor_merge_translations($current_language)) {
                set_private_setting($site->getGUID(), "te_last_update_{$current_language}", time());
            }
        }
    } else {
        translation_editor_merge_translations($current_language, true);
    }
    // load translations
    $translations = translation_editor_read_translation($current_language, "translation_editor_merged_{$site->getGUID()}");
    if (!empty($translations)) {
        add_translation($current_language, $translations);
    }
}
示例#18
0
    register_error('subsite_manager:users:bulk_remove:no_file');
    forward(REFERER);
}
$removed = 0;
// number of removed users
$not_found = 0;
// number of users not found
$already_activated = 0;
// number of users not removed because they where already activated
while ($data = fgetcsv($fh, 0, ";")) {
    if (!$data[0]) {
        continue;
    }
    if (strpos($data[0], '@') !== false) {
        $users = get_user_by_email($data[0]);
        $user = $users[0];
    } else {
        $user = get_user_by_username($data[0]);
    }
    if (!$user) {
        $not_found += 1;
        continue;
    }
    if (get_private_setting($user->guid, 'general_terms_accepted')) {
        $already_activated += 1;
    } else {
        $user->delete();
        $removed += 1;
    }
}
system_message(elgg_echo("subsite_manager:users:bulk_remove:success", array($removed, $not_found, $already_activated)));
示例#19
0
 /**
  * Returns a user's setting for this plugin
  *
  * @param string $name      The setting name
  * @param int    $user_guid The user GUID
  *
  * @return mixed The setting string value or false
  */
 public function getUserSetting($name, $user_guid = null)
 {
     $result = false;
     $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;
     }
     $name = elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID());
     // Subsite adjustment
     $site = elgg_get_site_entity();
     $org_name = $name;
     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);
     }
     $tmp_result = get_private_setting($user->getGUID(), $name);
     if ($tmp_result === false) {
         // fallback
         if ($name == $org_name) {
             $name = str_replace(ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":", ELGG_PLUGIN_USER_SETTING_PREFIX . $this->getID() . ":" . $site->getGUID() . ":", $name);
         } else {
             $name = $org_name;
         }
         $result = get_private_setting($user->getGUID(), $name);
     } else {
         $result = $tmp_result;
     }
     return $result;
 }