/** * Function to save or update object data back into the database */ public function save() { $class = get_class($this); $portal = new MyPortal($GLOBALS['identifier']); // // check the database to ensure this user owns the tab in question // // TODO: do we have to instantiate the whole MyPortal object? // if (self::dbstr($class, 'type') == 'channel') { if ($portal->tabs($this->usertab_id, false)->wp_id != $GLOBALS['identifier']) { if (!$portal->is_admin()) { return false; } } } elseif (self::dbstr($class, 'type') == 'tab') { if ($this->wp_id != $GLOBALS['identifier']) { return false; } } //end elseif // if we've passed all the validation checks, save the data $this->_save(); }
/** * 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'; }
/** * Ensure that a portal object is custom. Modifies the * incoming portal object. */ public static function force_clone(MyPortal $portal) { $identifier = $portal->wp_id; // do not force a clone if the wp_id is 0 (manipulating the default layout) // or if the user ALREADY has a cloned layout if (0 === $identifier || !$portal->is_default_layout()) { return; } $portal->cloneLayout(); }
$GLOBALS['TEMPLATES'] = $GLOBALS['BASE_DIR'] . '/templates'; /*******************[End Site Constants]*****************/ /*******************[Common Includes]**********************/ require_once PSU_BASE_DIR . '/webapp/my/includes/MyPortal.class.php'; /*******************[End Common Includes]**********************/ /*******************[Authentication Stuff]*****************/ IDMObject::authN(); /*******************[End Authentication Stuff]*****************/ /*******************[Database Connections]*****************/ $GLOBALS['MY'] = PSU::db('myplymouth'); /*******************[End Database Connections]*****************/ $theme = new PSUTheme($GLOBALS['MY']); function isAdmin() { return IDMObject::authZ('permission', 'theme_admin'); } //end isAdmin $theme_level = array('basic', 'holiday', 'event'); if (isAdmin()) { $theme_level[] = 'admin'; } //end if if ($_SESSION['username'] == 'nrporter') { $theme_level[] = 'extreme'; $theme_level[] = 'dev'; } //end if $valid_themes = $theme->getThemes($theme_level); $portal = new MyPortal($_SESSION['wp_id']); $GLOBALS['fluid'] = $portal->is_fluid(); $GLOBALS['disabled_chat'] = $portal->is_chat_disabled();