public function __construct($id = null, $getlists = TRUE) { //if row is null then get an empty post object if ($id != null) { $select_sql = "SELECT * from pbpost where id = {$id}"; if ($result = $GLOBALS['mysqli']->query($select_sql)) { $row = $result->fetch_assoc(); $this->ID = $row['id']; $this->Title = $row['title']; $this->SubTitle = $row['subtitle']; $this->PageName = $row['pagename']; $this->Blog = $row['blog']; $this->ReadyForPublish = isset($row['readyforpublish']) ? TRUE : FALSE; $this->CreateDate = $row['createdate']; $this->ModifiedDate = $row['modifieddate']; $this->PublishDate = $row['publishdate']; $this->UnpublishDate = $row['unpublishdate']; $this->Categories = CategoryFactory::GetCategoriesByPost($this->ID); $this->Types = TypeFactory::GetTypesByPost($this->ID); if ((!empty($this->Title) || !isset($this->Title)) && (!empty($this->Blog) || !isset($this->Blog))) { $this->CanDelete = TRUE; } //we're going to republish all every single time //but why //the related post column for previously published will then have refs to newer links //but first check if readyforpublish is true //first check that a blog has a title and subtitle and or post if (!empty($this->Title) && (!empty($this->SubTitle) || !empty($this->Blog))) { //we're not going to use the ready flag to check if it can be published //the ready flag is only used in a batch publish - IMPORTANT $this->CanPublish = TRUE; } //can delete if it is not published //or if the unpublish date is greater than publish date if (!isset($this->PublishDate) || $this->UnpublishDate > $this->PublishDate || sizeof($this->Categories) == 0) { $this->CanDelete = TRUE; } //can unpublish if its been published - that's all nothing about being outdated if (isset($this->PublishDate)) { $this->CanUnpublish = TRUE; } } else { //TODO: error in sql execute } } else { $this->Categories = array(); //TODO: I dont think this is required } require_once 'pbglobal.php'; $globalData = GlobalFactory::GetGlobalData(); $this->TemplateFolder = $globalData->TemplateFolder; $this->TemplateName = $globalData->PostTemplateName; $this->PostFolder = $globalData->PostFolder; $this->PostUrl = $globalData->PostUrl; }