function saveBlogDraft($fData)
 {
     require_once PATH_CORE . '/classes/userBlogs.class.php';
     $ubTable = new UserBlogsTable($this->db);
     $ub = $ubTable->getRowObject();
     $ub->blogid = $fData->blogid;
     $ub->siteContentId = $fData->siteContentId;
     $ub->title = $fData->title;
     $ub->entry = $fData->entry;
     $ub->url = $fData->url;
     $ub->imageUrl = $fData->imageUrl;
     $ub->videoEmbed = $fData->videoEmbed;
     $ub->userid = $this->session->userid;
     $ub->status = $fData->status;
     // check if it exists already
     if ($fData->blogid == 0) {
         // insert blog into drafts
         $fData->blogid = $ub->insert();
     } else {
         // update blog draft
         $ub->update();
     }
     return $fData->blogid;
 }
 function fetchReadStory($cid = 0, $nolongerused = '')
 {
     $this->initObjs();
     $cacheName = 'read_' . $cid . '_top';
     if ($this->templateObj->checkCache($cacheName, 30)) {
         // still current, get from cache
         $code = $this->templateObj->fetchCache($cacheName);
     } else {
         $code = '';
         if (!is_numeric($cid)) {
             exit('error3');
         }
         $q = $this->db->query("SELECT isBlogEntry,url,videoid,widgetid FROM Content WHERE siteContentId={$cid}");
         $data = $this->db->readQ($q);
         $isBlogEntry = $data->isBlogEntry;
         $videoid = $data->videoid;
         $widgetid = $data->widgetid;
         $url = $data->url;
         $this->templateObj->db->setTemplateCallback('submitBy', array($this->templateObj, 'submitBy'), 'postedByName');
         $this->templateObj->db->setTemplateCallback('caption', array($this->templateObj, 'cleanString'), array('caption', LENGTH_LONG_CAPTION));
         $this->templateObj->db->setTemplateCallback('cmdVote', array($this->templateObj, 'commandVote'), 'siteContentId');
         $this->templateObj->db->setTemplateCallback('cmdComment', array($this->templateObj, 'commandComment'), 'siteContentId');
         $this->templateObj->db->setTemplateCallback('mbrLink', array($this->templateObj, 'memberLink'), 'userid');
         $this->templateObj->db->setTemplateCallback('mbrImage', array($this->templateObj, 'memberImage'), 'postedById');
         $this->templateObj->db->setTemplateCallback('timeSince', array($this->utilObj, 'time_since'), 'date');
         $this->templateObj->db->setTemplateCallback('cmdRead', array($this->templateObj, 'commandRead'), 'permalink');
         $this->templateObj->db->setTemplateCallback('videoIntro', array($this, 'getVideoIntro'), 'videoIntroId');
         $this->templateObj->db->result = $this->templateObj->db->query("SELECT Content.*,ContentImages.url as imageUrl,UserInfo.fbId FROM Content LEFT JOIN UserInfo ON (Content.userid = UserInfo.userid OR Content.postedById = UserInfo.userid) LEFT JOIN ContentImages ON (ContentImages.siteContentId=Content.siteContentId) WHERE Content.siteContentId={$cid}");
         if ($isBlogEntry == 0) {
             $this->templateObj->db->setTemplateCallback('storyImage', array($this->templateObj, 'getLargeStoryImageFromUrl'), 'imageUrl');
             $code .= $this->templateObj->mergeTemplate($this->templateObj->templates['readStoryList'], $this->templateObj->templates['readStoryItem']);
         } else {
             // blog entry
             if ($url == '') {
                 // no url, leave out the more and read full story buttons
                 $item = $this->templateObj->templates['blogStoryItem'];
             } else {
                 // relabel the read full story button
                 $item = str_replace('Read the full story', 'Read the related story', $this->templateObj->templates['readStoryItem']);
             }
             $temp = $this->templateObj->mergeTemplate($this->templateObj->templates['readStoryList'], $item);
             require_once PATH_CORE . '/classes/userBlogs.class.php';
             $ubTable = new UserBlogsTable($this->db);
             $ub = $ubTable->getRowObject();
             $ub->loadWhere("siteContentId=" . $cid);
             if ($ub->imageUrl == '') {
                 $temp = str_replace('{storyImage}', '', $temp);
             } else {
                 $temp = str_replace('{storyImage}', '<img  src="' . $ub->imageUrl . '" alt="blog image" />', $temp);
                 // style="width:180px; height:auto;"
             }
             $code .= $temp;
             $code .= '<div id="readBlog">';
             $code .= $ub->entry;
             $code .= '<!-- end readBlog --></div>';
         }
         if ($videoid > 0) {
             // display embedded video
             require_once PATH_CORE . '/classes/video.class.php';
             $videoTable = new VideoTable($this->db);
             $video = $videoTable->getRowObject();
             $video->load($videoid);
             $code .= '<div id="readVideo">' . videos::buildPlayerFromLink($video->embedCode, 320, 240) . '<!-- end of storyVideo --></div>';
         }
         if ($widgetid > 0) {
             require_once PATH_CORE . '/classes/widgets.class.php';
             $wt = new WidgetsTable($this->db);
             $code .= $wt->fetchWidgets($widgetid);
         }
         $this->templateObj->cacheContent($cacheName, $code);
     }
     if (defined('ADS_ANY_SMALL_BANNER')) {
         $code .= str_replace("{ad}", '<fb:iframe src="' . URL_CALLBACK . '?p=cache&m=ad&locale=anySmallBanner" frameborder="0" scrolling="no" style="width:478px;height:70px;margin:-5px 0px 5px 0px;padding:0px;"/>', $this->pageObj->common['adWrapSmallBanner']);
     }
     $cacheName = 'read_' . $cid . '_com_' . ($this->session->isMember ? 'm' : 'n');
     if ($this->templateObj->checkCache($cacheName, 30)) {
         // still current, get from cache
         $temp = $this->templateObj->fetchCache($cacheName);
     } else {
         $temp = '<div id="commentList">';
         $temp .= $this->fetchComments($cid);
         $temp .= '</div><!-- end commentList -->';
         $this->templateObj->cacheContent($cacheName, $temp);
     }
     $code .= $temp;
     $code .= $this->fetchLinkBox($cid);
     if (defined('ADS_ANY_LARGE_RECT')) {
         $code .= str_replace("{ad}", '<fb:iframe src="' . URL_CALLBACK . '?p=cache&m=ad&locale=anyLargeRect" frameborder="0" scrolling="no" style="width:346px;height:290px;margin:0px;padding:0px;"/>', $this->pageObj->common['adWrapLargeRect']);
     }
     return $code;
 }
    // create Notifications and NotificationMessages Tables
    require_once PATH_CORE . '/classes/notifications.class.php';
    NotificationsTable::createTable($manageObj);
    NotificationMessagesTable::createTable($manageObj);
}
// Set up some default SystemStatus variables
require_once PATH_CORE . '/classes/systemStatus.class.php';
$ssObj = new systemStatus($manageObj->db);
$ssObj->setState('cloudid', SITE_CLOUDID);
//$ssObj->name=$this->getState('name');
//$ssObj->permalink=$this->getState('permalink');
$ssObj->setState('max_sessions', MAX_SESSIONS_ACTIVE);
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'userBlogs.class.php')) {
    // create UserBlogs
    require_once PATH_CORE . '/classes/userBlogs.class.php';
    UserBlogsTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'widgets.class.php')) {
    // create Widgets
    require_once PATH_CORE . '/classes/widgets.class.php';
    WidgetsTable::createTable($manageObj);
    FeaturedWidgetsTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'adCode.class.php')) {
    // create AdCode Table
    require_once PATH_CORE . '/classes/adCode.class.php';
    AdCodeTable::createTable($manageObj);
}
if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'subscriptions.class.php')) {
    require_once PATH_CORE . '/classes/subscriptions.class.php';
    SubscriptionsTable::createTable($manageObj);