Решил сам. Может кому пригодится для версии 3.1.0
Отображаем ссылку на странице Продление объявления "Мои объявления". Для этого в файле /components/com_adsmanager/views/myads/tmpl/default.php меняем
if ($this->conf->expiration == 1) {
if ($content->expiration_date != null) {
$expiration_time = strtotime($content->expiration_date);
$current_time = time();
if ($expiration_time - $current_time <= ($conf->recall_time * 3600 *24)) {
if(function_exists('countRenewDurations') && countRenewDurations() > 1){
$target = TRoute::_("index.php?option=com_adsmanager&view=expiration&id=$content->id");
} else {
$target = TRoute::_("index.php?option=com_adsmanager&task=renew&id=$content->id");
}
echo "<br/><a href='".$target."'>".JText::_('ADSMANAGER_RENEW_CONTENT')."</a>";
}
}
}
на
$target = TRoute::_("index.php?option=com_adsmanager&view=expiration&id=$content->id");
echo "<a href='".$target."'>".JText::_('ADSMANAGER_RENEW_CONTENT')."</a>";
Ссылка Продление объявления появилась. Затем в файле /components/com_adsmanager/controller.php
function renew() {
$app = JFactory::getApplication();
$contentid = JRequest::getInt('id', 0);
$this->addModelPath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_adsmanager'.DS.'models');
$contentmodel =$this->getModel( "content" );
$confmodel =$this->getModel( "configuration" );
$conf = $confmodel->getConfiguration();
$c = $contentmodel->getContent($contentid,false);
if ($c == null)
exit();
if ($c->expiration_date == null) {
exit();
}
$expiration_time = strtotime($c->expiration_date);
$current_time = time();
if (function_exists("renewPaidAd")) {
renewPaidAd($contentid);
}
else
{
if ($current_time < $expiration_time - ($conf->recall_time * 3600 *24)) {
$app->redirect(TRoute::_("index.php?option=com_adsmanager"),JText::_('ADSMANAGER_CONTENT_CANNOT_RESUBMIT'),'message');
}
$contentmodel->renewContent($contentid,$conf->ad_duration);
}
$cache = JFactory::getCache( 'com_adsmanager');
$cache->clean();
$app->redirect(TLink::getMyAdsLink(), JText::_('ADSMANAGER_CONTENT_RESUBMIT'),'message');
}
поменял на
function renew() {
$app = JFactory::getApplication();
$contentid = JRequest::getInt('id', 0);
$this->addModelPath(JPATH_ADMINISTRATOR.'/components/com_adsmanager/models');
$contentmodel =$this->getModel( "content" );
$confmodel =$this->getModel( "configuration" );
$conf = $confmodel->getConfiguration();
$c = $contentmodel->getContent($contentid,false);
if ($c == null)
exit();
if ($c->expiration_date == null) {
exit();
}
$expiration_time = strtotime($c->expiration_date);
$current_time = time();
if (function_exists("renewPaidAd")) {
renewPaidAd($contentid);
}
else
{
$contentmodel->renewContent($contentid,$conf->ad_duration);
}
$cache = JFactory::getCache( 'com_adsmanager');
$cache->clean();
$app->redirect(TLink::getMyAdsLink(), JText::_('ADSMANAGER_CONTENT_RESUBMIT'),'message');
}
Теперь дата подачи объявления изменяется на текущую и объявление перемещается на верхнюю позицию. Если нужно чтобы кроме даты обновлялось и время, в файле administrator/components/com_adsmanager/models/content.php
function renewContent($contentid,$ad_duration)
{
$this->_db->setQuery( "SELECT expiration_date FROM #__adsmanager_ads WHERE id = ".(int)$contentid);
$expiration_date = $this->_db->loadResult();
$time = strtotime($expiration_date);
if ($time < time())
{
$time = time();
}
$time = $time + ( $ad_duration * 3600 *24);
$newdate = date("Y-m-d",$time);
$this->_db->setQuery( "UPDATE #__adsmanager_ads SET expiration_date = '$newdate', date_created = CURDATE(),recall_mail_sent=0,published=1 WHERE id=".(int)$contentid."");//TODO and recall_mail_sent = 1
$this->_db->query();
}
поменял на
function renewContent($contentid,$ad_duration)
{
$this->_db->setQuery( "SELECT expiration_date FROM #__adsmanager_ads WHERE id = ".(int)$contentid);
$expiration_date = $this->_db->loadResult();
$time = strtotime($date_created);
if ($time < time())
{
$time = time();
}
$time = $time + ( $ad_duration * 3600 *24);
$newdate = date("Y-m-d",$time);
$this->_db->setQuery( "UPDATE #__adsmanager_ads SET expiration_date = '$newdate', date_created = NOW(),recall_mail_sent=0,published=1 WHERE id=".(int)$contentid."");//TODO and recall_mail_sent = 1
$this->_db->query();
}