public function test() { $this->_force_admin(); PSU::db('portal')->debug = true; var_dump(MyUserTab::get_child_id($this->portal->person, 1)); var_dump(MyUserChannel::get_child_id($this->portal->person, 1)); }
/** * Load tabs for the logged-in user. * * @param $id \b id of tab * @param $load_all \b true loads all user tabs, false only loads requested tab */ public function tabs($id = null, $load_all = true) { if ($this->tabs === null) { //use the default tabset if user is PortaLord /* if( $_SESSION['generic_user_type'] == 'portalord' ) { // @todo this shouldn't overwrite $this->tabs every time, it should add to the array if we're not loading all $this->tabs = !$load_all && $id ? array(MyUserTab::fetch($id)) : MyUserTab::getUserTabs( 0 ); }else { */ // @todo this shouldn't overwrite $this->tabs every time, it should add to the array if we're not loading all $this->tabs = !$load_all && $id ? array(MyUserTab::fetch($id)) : MyUserTab::getUserTabs($this->person); // } foreach ($this->tabs as $tab) { $tab->parent($this); } } if ($id !== null) { foreach ($this->tabs as $tab) { if ($tab->id == $id || $tab->slug == $id) { return $tab; } } return false; } return $this->tabs; }
/** * handles the moving of a channel * @param $channel \b int the channel id * @param $location \b string destination: tab, before, after, col * @param $target \b id of the target element */ public function move($channel, $location, $target = null) { ignore_user_abort(); MyPortal::force_clone($this->portal); $channel_id = str_replace('channel-', '', $channel); $target = str_replace('channel-', '', $target); // // if portal was just cloned, the incoming tab and channel ids must be updated. // they referred to the default layout in the ui, but we will actually update // the custom user layout. // // @todo account for admins updating the default layout (GET param?) // if ($this->portal->cloned) { $channel_id = MyUserChannel::get_child_id($this->portal->person, $channel_id); if ($location == 'tab') { $target = MyUserTab::get_child_id($this->portal->person, $target); } elseif ($location == 'before' || $location == 'after') { $target = MyUserChannel::get_child_id($this->portal->person, $target); } } // // perform the channel moving // $channel = MyUserChannel::fetch($channel_id); if ($location == 'before') { $target = MyUserChannel::fetch($target); $direction = $target->sort_order <= $channel->sort_order ? 'up' : 'down'; $channel->setLocation($target->col_num, $target->sort_order, null, $direction); } elseif ($location == 'after') { $target = MyUserChannel::fetch($target); $channel->setLocation($target->col_num, $target->sort_order + 1, null, 'down'); } elseif ($location == 'col') { $channel->setLocation($target, 1); } elseif ($location == 'tab') { $channel->setLocation(1, 1, $target); } //end if echo $is_default_layout ? 'default' : 'user'; }