Skip to content

Commit

Permalink
se agregan tareas que permiten publicar/despublicar articulos de mane…
Browse files Browse the repository at this point in the history
…ra automatica en función de la configuración de los mismos
  • Loading branch information
jpablop committed Jun 3, 2014
1 parent b83b16b commit 021f112
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
10 changes: 10 additions & 0 deletions apps/backend/modules/article/config/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ generator:
open_reference_new_window:
name: Abrir en nueva ventana
help: Utilice está opción si desea que los enlaces al articulo se abran en nuevas ventanas
auto_publish_at:
name: Publicar articulo automáticamente el
params: date_format="dd/MM/yyyy H:mm"
help: Si desea que el articulo se publique automáticamente seleccione la fecha y la hora
auto_unpublish_at:
name: Despublicar articulo automáticamente el
params: date_format="dd/MM/yyyy H:mm"
help: Si desea que el articulo se despublique automáticamente seleccione la fecha y la hora

filters:
fields:
Expand Down Expand Up @@ -205,6 +213,8 @@ generator:
Secciones relacionadas: [_section_id, _article_section]
# @ncuesta: De 'Contenido' eliminé 'link_id', porque no encontré para qué se usaba.
Contenido: [upper_description, title, heading, _editor, contact, _multimedia_id, zoomable_multimedia, main_gallery_id, _reference_type, _reference, open_reference_new_window]
Tareas Automáticas: [auto_publish_at, auto_unpublish_at]

fields:
heading:
type: textarea_tag
Expand Down
8 changes: 8 additions & 0 deletions config/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ propel:
open_as_popup:
type: boolean
default: false
auto_publish_at:
type: timestamp
required: false
auto_unpublish_at:
type: timestamp
required: false


_indexes:
name_publmished_at_index: [name, published_at]

Expand Down
18 changes: 17 additions & 1 deletion lib/slotlet/slotlets/ContextualMenuSlotlet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public function render($options = array())
{
sfLoader::loadHelpers(array('Javascript', 'I18N'));

$section = SectionPeer::retrieveByName($options['section_name']);
$section_name = $options['section_name'];

$section = SectionPeer::retrieveByName($section_name);



if (null === $section || !$section->getIsPublished() || ($section->getDepth() < $options['start_depth']))
{
Expand Down Expand Up @@ -226,6 +230,18 @@ public function getConfigurationForm($values = array())
'%field%' => select_tag('start_depth', options_for_select($depths, $values['start_depth']), array('class' => 'slotlet_option'))
));

$form .= strtr($row, array(
'%id%' => 'use_home_for_contact',
'%label%' => __('Utilizar contexto de Home para Contacto'),
'%field%' => checkbox_tag('use_home_for_contact', true, $values['use_home_for_contact'] != false, array('class' => 'slotlet_option'))
));

$form .= strtr($row, array(
'%id%' => 'use_home_for_event',
'%label%' => __('Utilizar contexto de Home para Eventos'),
'%field%' => checkbox_tag('use_home_for_event', true, $values['use_home_for_event'] != false, array('class' => 'slotlet_option'))
));

return $form;
}

Expand Down
75 changes: 74 additions & 1 deletion plugins/sfChoiqueTasksPlugin/data/tasks/sfPakeChoiqueTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,77 @@ function run_choique_user_enable($task, $args)
}
}



pake_desc('Publish unpublished Articles with auto_publish date prior to now');
pake_task('choique-autopublish-articles');

/**
* Select flavor
*
*
* @param object $task
* @param array $args
*/
function run_choique_autopublish_articles($task, $args)
{
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', 'backend');
define('SF_ENVIRONMENT', 'prod');
define('SF_DEBUG', true);
// get configuration
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();

$c = new Criteria();
$c->add(ArticlePeer::IS_PUBLISHED, false);
$c->add(ArticlePeer::AUTO_PUBLISH_AT, time(), Criteria::LESS_EQUAL);
$c->add(ArticlePeer::AUTO_PUBLISH_AT,null,Criteria::ISNOTNULL);
$c->setLimit(10);
$cont = 0;
foreach (ArticlePeer::doSelect($c) as $article)
{
$article->setIsPublished(true);
$article->save();
$cont ++;
}
echo "\n".pakeColor::colorize("$cont published articles\n", array('fg'=>'green', 'bold'=>true));

}

pake_desc('Unpublish published Articles with auto_unpublish date prior to now');
pake_task('choique-autounpublish-articles');

/**
* Select flavor
*
*
* @param object $task
* @param array $args
*/
function run_choique_autounpublish_articles($task, $args)
{
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
define('SF_APP', 'backend');
define('SF_ENVIRONMENT', 'prod');
define('SF_DEBUG', true);
// get configuration
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();

$c = new Criteria();
$c->add(ArticlePeer::IS_PUBLISHED, true);
$c->add(ArticlePeer::AUTO_UNPUBLISH_AT, time(), Criteria::LESS_EQUAL);
$c->add(ArticlePeer::AUTO_UNPUBLISH_AT,null,Criteria::ISNOTNULL);
$c->setLimit(10);
$cont = 0;
foreach (ArticlePeer::doSelect($c) as $article)
{
$article->setIsPublished(false);
$article->save();
$cont ++;
}
echo "\n".pakeColor::colorize("$cont unpublished articles\n", array('fg'=>'green', 'bold'=>true));

}

0 comments on commit 021f112

Please sign in to comment.