/** * Returns the name of the content author * * @return string */ public function getUsername() { if ($this->use_item) { $this->loadContent(); return $this->content->getUsername(); } return false; }
protected function load_content_info() { $type_instance = vB_Types::instance(); $class = $type_instance->getContentTypeClass($this->contenttypeid); $package = $type_instance->getContentTypePackage($this->contenttypeid); //this forces some of the fields we access to be loaded. $contentinfo = vBCms_Content::create($package, $class); //we have a contenttype and content id, but we need the nodeid. if ($record = vB::$vbulletin->db->query_first("SELECT nodeid FROM " . TABLE_PREFIX . "cms_node WHERE contenttypeid = " . $this->contenttypeid . " AND contentid = " . $this->contentid)) { $item = vB_Item_Content::create($package, $class, $this->nodeid = $record['nodeid']); $item->requireInfo($contentinfo->getViewInfoFlags(vB_Content::VIEW_PREVIEW)); $contentinfo->setContentItem($item); return $contentinfo; } return false; }
/** * Sets preloaded info from an existing item to the current content. * * @param vBCms_Item_Content $node */ public function castFrom(vB_Item_Content $source) { $this->content = $source; $this->contentid = $source->getNodeId(); }
/** * Creates a content item to add to the collection. * * @param array mixed $iteminfo - The known properties of the new item * @return vB_Item - The created item */ protected function createItem($iteminfo, $load_flags = false) { $class = vBCms_Types::instance()->getContentTypeClass($iteminfo['contenttypeid']); $package = vBCms_Types::instance()->getContentTypePackage($iteminfo['contenttypeid']); $item = vB_Item_Content::create($package, $class, $iteminfo[$this->primary_key]); $item->setInfo($iteminfo, $load_flags); return $item; }
protected function postSave($result, $deferred, $replace, $ignore) { if (! $this->save_children) { return true; } vB::$vbulletin->input->clean_array_gpc('p', array( 'ids' => vB_Input::TYPE_ARRAY)); //The parent classes insist on setting new=1, but we want new=0; vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET new = 0 WHERE nodeid = " . (isset($this->set_fields['nodeid']) ? $this->set_fields['nodeid'] : $this->primary_id)); //We have a minor issue here. The edit screen does not have a time and date //So- if the item is currently published and is still published, we should do nothing. //To make that decision we need to know what's currently published. $existing = array(); if (count(vB::$vbulletin->GPC['ids'])) { $rst = $record = vB::$vbulletin->db->query_read($sql = "SELECT nodeid, publishdate, setpublish, publicpreview FROM " . TABLE_PREFIX . "cms_node AS node WHERE nodeid in (" . implode(', ', vB::$vbulletin->GPC['ids']) . ")"); if ($rst) { while($record = vB::$vbulletin->db->fetch_array($rst)) { $existing[$record['nodeid']] = $record; } } } $orders = array(); foreach (vB::$vbulletin->GPC['ids'] as $nodeid) { vB::$vbulletin->input->clean_array_gpc('p', array( "cb_preview_$nodeid" => vB_Input::TYPE_INT, "cb_delete_$nodeid" => vB_Input::TYPE_INT, "order_$nodeid" => vB_Input::TYPE_INT, "published_$nodeid" => vB_Input::TYPE_INT )); //If we're deleting we need to instantiate the appropriate data manager // and use that to delete. Otherwise we know where the variables are and // can just update them directly. if (vB::$vbulletin->GPC_exists["cb_delete_$nodeid"]) { if ($record = vB::$vbulletin->db->query_first("SELECT contenttype.class, package.class AS package FROM " . TABLE_PREFIX . "cms_node node INNER JOIN " . TABLE_PREFIX . "contenttype AS contenttype ON contenttype.contenttypeid = node.contenttypeid INNER JOIN " . TABLE_PREFIX . "package AS package ON package.packageid = contenttype.packageid WHERE nodeid = " . $nodeid)) { $item = vB_Item_Content::create($record['package'], $record['class'], $nodeid); $dm = $item->getDM(); $dm->delete(); } } else { //Check the order. This is fairly tricky. If we do the order updates // out of sequence, things get scrambled and we are sure to wind up incorrect. So we // need to index them and do them in order. if (intval( vB::$vbulletin->GPC["order_$nodeid"])) { $orders[$nodeid] = vB::$vbulletin->GPC["order_$nodeid"]; } else { $orders[$nodeid] = 0; } $updates = array(); //Check the preview status $newpreview = vB::$vbulletin->GPC_exists["cb_preview_$nodeid"] ? 1 : 0; if (($newpreview == 1) AND (array_key_exists($nodeid, $existing)) AND (intval($existing[$nodeid]['publicpreview']) != 1)) { $updates[] = " publicpreview = 1"; } else if (($newpreview == 0) AND (array_key_exists($nodeid, $existing)) AND (intval($existing[$nodeid]['publicpreview']) != 0)) { $updates[] = " publicpreview = 0"; } //Check the published status. Remember we set published = 2; if (array_key_exists($nodeid, $existing) AND vB::$vbulletin->GPC_exists["published_$nodeid"] AND (vB::$vbulletin->GPC["published_$nodeid"] == 2) AND ($existing[$nodeid]['setpublish'] != 1)) { $updates[] = " setpublish = 1, publishdate = " . (TIMENOW - vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo, false) ); } else if (array_key_exists($nodeid, $existing) AND vB::$vbulletin->GPC_exists["published_$nodeid"] AND (vB::$vbulletin->GPC["published_$nodeid"] == 1) AND ($existing[$nodeid]['setpublish'] != 0)) { $updates[] = " setpublish = 0 " ; } if (count($updates)) { $sql = "UPDATE " . TABLE_PREFIX . "cms_node set " . implode(', ' , $updates) . " WHERE nodeid = $nodeid"; vB::$vbulletin->db->query_write($sql); } } } asort($orders); $min_sequence = 1; foreach ($orders as $nodeid => $order) { if ($order == 0) { vBCms_ContentManager::setDisplayOrder($this->set_fields['nodeid'], $nodeid, 0); } else { $order = max($min_sequence, intval($order)); $min_sequence++; vBCms_ContentManager::setDisplayOrder($this->set_fields['nodeid'], $nodeid, $order); } } return parent::postSave($result, $deferred, $replace, $ignore); }
/** * Loads non item properties from a cache hit. * * @param mixed $info - The info loaded from the cache */ protected function loadCacheInfo($info) { parent::loadCacheInfo($info); if (isset($info['pending_parent'])) { $this->pending_parent = $info['pending_parent']; } if (isset($info['node_layout'])) { $this->node_layout = $info['node_layout']; } if (isset($info['node_styleid'])) { $this->node_styleid = $info['node_styleid']; } if (isset($info['parents'])) { $this->parents = unserialize($info['parents']); } if (isset($info['config'])) { $this->config = unserialize($info['config']); } return true; }