/**
  * Set to the cache
  *
  * @param string $id
  * @param mixed $data
  * @param string $group
  * @param integer $expire
  * @return boolean
  */
 function set($id, $data, $group = 'default', $expire = 0)
 {
     $key = $this->_get_cache_key($id, $group);
     if (is_object($data)) {
         $data = nxt_clone($data);
     }
     $this->cache[$key] = $data;
     if ($this->_caching && !in_array($group, $this->nonpersistent_groups)) {
         $cache =& $this->_get_cache();
         return $cache->set($key, $data, $expire ? $expire : $this->_lifetime);
     }
     return true;
 }
 /**
  * Sets the data contents into the cache
  *
  * The cache contents is grouped by the $group parameter followed by the
  * $id. This allows for duplicate ids in unique groups. Therefore, naming of
  * the group should be used with care and should follow normal function
  * naming guidelines outside of core NXTClass usage.
  *
  * The $expire parameter is not used, because the cache will automatically
  * expire for each time a page is accessed and PHP finishes. The method is
  * more for cache plugins which use files.
  *
  * @since 2.0.0
  *
  * @param int|string $id What to call the contents in the cache
  * @param mixed $data The contents to store in the cache
  * @param string $group Where to group the cache contents
  * @param int $expire Not Used
  * @return bool Always returns true
  */
 function set($id, $data, $group = 'default', $expire = '')
 {
     if (empty($group)) {
         $group = 'default';
     }
     if (NULL === $data) {
         $data = '';
     }
     if (is_object($data)) {
         $data = nxt_clone($data);
     }
     $this->cache[$group][$id] = $data;
     if (isset($this->non_existant_objects[$group][$id])) {
         unset($this->non_existant_objects[$group][$id]);
     }
     return true;
 }
/**
 * Loads an Achievement's edit page. Also implements controller logic.
 *
 * @global nxt_Error $achievements_errors Achievement creation error object
 * @global object $bp BuddyPress global settings
 * @since 2.0
 * @uses DPA_Achievement
 */
function dpa_screen_achievement_edit()
{
    global $achievements_errors, $bp;
    if (empty($_POST['achievement-edit'])) {
        $bp->achievements->current_achievement = new DPA_Achievement(array('slug' => apply_filters('dpa_get_achievement_slug', $bp->current_item), 'populate_extras' => false));
        do_action('dpa_screen_achievement_edit');
        bp_core_load_template(apply_filters('dpa_screen_achievement_edit_template', 'achievements/single/home'));
        return;
    }
    // Edit
    if (!nxt_verify_nonce($_POST['_nxtnonce'], 'achievement-edit-' . $bp->current_item)) {
        nxt_nonce_ays('');
        die;
    }
    $bp->achievements->current_achievement = new DPA_Achievement(array('slug' => apply_filters('dpa_get_achievement_slug', $bp->current_item), 'populate_extras' => false));
    $old_achievement = nxt_clone($bp->achievements->current_achievement);
    $achievement =& $bp->achievements->current_achievement;
    /* We can't use template tags because if the new details fail validation and do not save, the template loop will fetch the old version. */
    if ('badge' == stripslashes($_POST['achievement_type'])) {
        $achievement->action_count = 1;
        $achievement->action_id = -1;
    } else {
        $achievement->action_count = (int) $_POST['action_count'];
        $achievement->action_id = (int) $_POST['action_id'];
    }
    if (is_multisite() && bp_is_active('blogs')) {
        $achievement->site_id = (int) $_POST['site_id'];
    } else {
        $achievement->site_id = BP_ROOT_BLOG;
    }
    if (bp_is_active('groups')) {
        $achievement->group_id = (int) $_POST['group_id'];
    } else {
        $achievement->group_id = -1;
    }
    if (!empty($_POST['is_hidden'])) {
        $achievement->is_active = 2;
    } elseif (!empty($_POST['is_active'])) {
        $achievement->is_active = 1;
    } else {
        $achievement->is_active = 0;
    }
    $achievement->id = (int) $achievement->id;
    $achievement->name = stripslashes($_POST['name']);
    $achievement->description = stripslashes($_POST['description']);
    $achievement->points = (int) $_POST['points'];
    $achievement->slug = stripslashes($_POST['slug']);
    $achievements_errors = $achievement->save($old_achievement);
    if (!is_nxt_error($achievements_errors)) {
        do_action('dpa_screen_achievement_edit_success', $achievement, $old_achievement);
        bp_core_add_message(__("The Achievement's details have been updated.", 'dpa'));
        bp_core_redirect(dpa_get_achievements_permalink() . '/' . $achievement->slug . '/');
    } else {
        if (!$achievement->points) {
            $achievement->points = '';
        }
        if (!$achievement->action_count) {
            $achievement->action_count = '';
        }
        do_action('dpa_screen_achievement_edit_fail', $achievement, $achievements_errors);
        bp_core_add_message(__("An error has occurred and the Achievement's details have not been updated. See below for details.", 'dpa'), 'error');
        bp_core_load_template(apply_filters('dpa_screen_achievement_edit_template', 'achievements/single/home'));
    }
}