Jump to content

Site News not updating


TennShadow

Recommended Posts

I've recently noticed that my VA news hasn't updated on VACentral since March of 2013. In my admin panel, under NEWS, I have recent news there. Can someone give me a hint at where to start troubleshooting? As far as I can tell, I've made all the required updates and so far everything seems to be working fine except for the news.

Thanks,

Keith

Link to comment
Share on other sites

  • Administrators

I do not know what version you are using but on my version there is a function behind the scenes when loading the admin dashboard.

https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/Dashboard/Dashboard.php#L36

And there is a function in the vastats update here -> https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/common/CentralData.class.php#L258

Some older versions do not have this built in, and it also seems to have disappeared somewhere between the 934 and 935 release and returned later.

Link to comment
Share on other sites

Thanks David,

I'm running 935 and I'm definitly missing those lines. I went back on Github and found a earlier version of code that had it but so far nothing has updated. I added the below to the CentralData.class.php

I added

$all_news = SiteData::getAllNews();
    if(count($all_news) > 0) {

	    $news_parent = self::addElement(null, 'newsitems');
	    foreach($all_news as $news) {

		    $body = str_ireplace('<br>', "\n", $news->body);
		    $body = str_ireplace('<br />', "\n", $body);
		    $body = htmlentities(strip_tags($body));

		    $news_xml = self::addElement($news_parent, 'news', null, array(
				    'id' => $news->id,
				    'subject' => $news->subject,
				    'body' => $body,
				    'postdate' => $news->postdate,
				    'postedby' => $news->postedby,
			    )
		    );
	    }
    }

right after

self::set_xml('update_vainfo');
 self::$xml->addChild('pilotcount', StatsData::PilotCount());
 self::$xml->addChild('totalhours', StatsData::TotalHours());
 self::$xml->addChild('totalflights', StatsData::TotalFlights());
 self::$xml->addChild('totalschedules', StatsData::TotalSchedules());

then added

/**
 * CentralData::send_news()
 *
 * @return
 */
   public static function send_news() {

    if (!self::central_enabled()) return false;

    $all_news = SiteData::getAllNews();
    if(!is_array($all_news) && count($all_news) == 0) {
	    return false;
    }

    self::startBody('vanews');
    self::addElement(null, 'total', count($all));
    $news_parent = self::addElement('newsitems');
    foreach($all_news as $news) {
	    $news_xml = self::addElement($news_parent, 'news', null, array(
		    'id' => $news->id,
		    'subject' => $news->subject,
		    'body' => '<![CDATA['.$news->body.']]>',
		    'postdate' => $news->postdate,
		    'postedby' => $news->postedby,
	    ));
    }

    CronData::set_lastupdate('vanews');
    $res = self::sendToCentral();

    return $res;
   }

after

# Package and send
 CronData::set_lastupdate('update_vainfo'); 
 return self::send_xml();
}

Is there anything that you can thing of that I've missed?

Link to comment
Share on other sites

  • 3 weeks later...

In short of upgrading my .935 site to the new 5.5 is there a way to get this working? I've added the above into my files but that didn't work. I'd like to get this working with my current version. I will eventually update to 5.5 but I've got a lot of work to do to make that happen and right now I just don't have the time to invest to that project.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...