Skip to content

Commit

Permalink
if we're running on a nonpersistent root topic, skip subnodes loading…
Browse files Browse the repository at this point in the history
… & node toolbar
  • Loading branch information
flack committed Jul 20, 2018
1 parent b5391bc commit b415b94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
28 changes: 16 additions & 12 deletions lib/midcom/helper/nav/node.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,22 @@ public function is_readable_by($user_id)
public function get_subnodes()
{
if (!isset($this->subnodes)) {
// Use midgard_collector to get the subnodes
$mc = midcom_db_topic::new_collector('up', (int) $this->topic_id);
$mc->add_constraint('name', '<>', '');
$mc->add_order('metadata.score', 'DESC');
$mc->add_order('metadata.created');

//we always write all the subnodes to cache and filter for ACLs after the fact
midcom::get()->auth->request_sudo('midcom.helper.nav');
$subnodes = $mc->get_values('id');
midcom::get()->auth->drop_sudo();

$this->subnodes = $subnodes;
if ((int) $this->topic_id == 0) {
$this->subnodes = [];
} else {
// Use midgard_collector to get the subnodes
$mc = midcom_db_topic::new_collector('up', (int) $this->topic_id);
$mc->add_constraint('name', '<>', '');
$mc->add_order('metadata.score', 'DESC');
$mc->add_order('metadata.created');

//we always write all the subnodes to cache and filter for ACLs after the fact
midcom::get()->auth->request_sudo('midcom.helper.nav');
$subnodes = $mc->get_values('id');
midcom::get()->auth->drop_sudo();

$this->subnodes = $subnodes;
}
$this->get_cache()->put_node($this->topic_id, $this->get_data());
}

Expand Down
4 changes: 3 additions & 1 deletion lib/midcom/helper/toolbar/node.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function __construct(midcom_db_topic $topic)
$config = midcom::get()->config;
parent::__construct($config->get('toolbars_node_style_class'), $config->get('toolbars_node_style_id'));
$this->label = midcom::get()->i18n->get_string('folder', 'midcom');
$this->add_commands();
if (!empty($topic->id)) {
$this->add_commands();
}
}

private function add_commands()
Expand Down

0 comments on commit b415b94

Please sign in to comment.