private function fetch_posts($params = array()) { foreach ($this->locals as $varname => $default) { ${$varname} = isset($params[$varname]) ? $params[$varname] : $default; } // if we're updating posts, let's do so: if ($do_update && isset($post_ids)) { $okay = true; if (empty($nonce) || empty($timestamp) || empty($password_digest)) { $okay = false; } $wsse = Utils::WSSE($nonce, $timestamp); if ($password_digest != $wsse['digest']) { $okay = false; } if ($okay) { foreach ($post_ids as $id) { $ids[] = array('id' => $id); } $to_update = Posts::get(array('where' => $ids, 'nolimit' => 1)); foreach ($to_update as $post) { switch ($change) { case 'delete': if (ACL::access_check($post->get_access(), 'delete')) { $post->delete(); } break; case 'publish': if (ACL::access_check($post->get_access(), 'edit')) { $post->publish(); } break; case 'unpublish': if (ACL::access_check($post->get_access(), 'edit')) { $post->status = Post::status('draft'); $post->update(); } break; } } unset($this->handler_vars['change']); } } // we load the WSSE tokens // for use in the delete button $this->theme->wsse = Utils::WSSE(); // Only pass set values to Posts::get(), otherwise they will override the defaults in the preset $user_filters = array(); if (isset($type)) { $user_filters['content_type'] = $type; } if (isset($status)) { $user_filters['status'] = $status; } if (isset($limit)) { $user_filters['limit'] = $limit; } if (isset($author)) { $user_filters['user_id'] = User::get($author)->id; } if (isset($before)) { $user_filters['before'] = $before; } if (isset($after)) { $user_filters['after'] = $after; } if (isset($text)) { $user_filters['criteria'] = $text; } if (isset($tag)) { if (!is_array($tag)) { $tag = explode(',', $tag); // also makes $tag an array in every case } $user_filters['vocabulary'][Tags::vocabulary()->name . ':term_display'] = $tag; } if (isset($page)) { $user_filters['page'] = $page; $this->theme->pagenr = $page; } else { $this->theme->pagenr = 1; } $this->theme->posts = Posts::get(array_merge(array('preset' => 'admin'), $user_filters)); }