Skip to content

Commit 021f112

Browse files
committed
se agregan tareas que permiten publicar/despublicar articulos de manera automatica en función de la configuración de los mismos
1 parent b83b16b commit 021f112

File tree

4 files changed

+109
-2
lines changed

4 files changed

+109
-2
lines changed

apps/backend/modules/article/config/generator.yml

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ generator:
109109
open_reference_new_window:
110110
name: Abrir en nueva ventana
111111
help: Utilice está opción si desea que los enlaces al articulo se abran en nuevas ventanas
112+
auto_publish_at:
113+
name: Publicar articulo automáticamente el
114+
params: date_format="dd/MM/yyyy H:mm"
115+
help: Si desea que el articulo se publique automáticamente seleccione la fecha y la hora
116+
auto_unpublish_at:
117+
name: Despublicar articulo automáticamente el
118+
params: date_format="dd/MM/yyyy H:mm"
119+
help: Si desea que el articulo se despublique automáticamente seleccione la fecha y la hora
112120

113121
filters:
114122
fields:
@@ -205,6 +213,8 @@ generator:
205213
Secciones relacionadas: [_section_id, _article_section]
206214
# @ncuesta: De 'Contenido' eliminé 'link_id', porque no encontré para qué se usaba.
207215
Contenido: [upper_description, title, heading, _editor, contact, _multimedia_id, zoomable_multimedia, main_gallery_id, _reference_type, _reference, open_reference_new_window]
216+
Tareas Automáticas: [auto_publish_at, auto_unpublish_at]
217+
208218
fields:
209219
heading:
210220
type: textarea_tag

config/schema.yml

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ propel:
8888
open_as_popup:
8989
type: boolean
9090
default: false
91+
auto_publish_at:
92+
type: timestamp
93+
required: false
94+
auto_unpublish_at:
95+
type: timestamp
96+
required: false
97+
98+
9199
_indexes:
92100
name_publmished_at_index: [name, published_at]
93101

lib/slotlet/slotlets/ContextualMenuSlotlet.class.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public function render($options = array())
5757
{
5858
sfLoader::loadHelpers(array('Javascript', 'I18N'));
5959

60-
$section = SectionPeer::retrieveByName($options['section_name']);
60+
$section_name = $options['section_name'];
61+
62+
$section = SectionPeer::retrieveByName($section_name);
63+
64+
6165

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

233+
$form .= strtr($row, array(
234+
'%id%' => 'use_home_for_contact',
235+
'%label%' => __('Utilizar contexto de Home para Contacto'),
236+
'%field%' => checkbox_tag('use_home_for_contact', true, $values['use_home_for_contact'] != false, array('class' => 'slotlet_option'))
237+
));
238+
239+
$form .= strtr($row, array(
240+
'%id%' => 'use_home_for_event',
241+
'%label%' => __('Utilizar contexto de Home para Eventos'),
242+
'%field%' => checkbox_tag('use_home_for_event', true, $values['use_home_for_event'] != false, array('class' => 'slotlet_option'))
243+
));
244+
229245
return $form;
230246
}
231247

plugins/sfChoiqueTasksPlugin/data/tasks/sfPakeChoiqueTasks.php

+74-1
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,77 @@ function run_choique_user_enable($task, $args)
402402
}
403403
}
404404

405-
405+
406+
pake_desc('Publish unpublished Articles with auto_publish date prior to now');
407+
pake_task('choique-autopublish-articles');
408+
409+
/**
410+
* Select flavor
411+
*
412+
*
413+
* @param object $task
414+
* @param array $args
415+
*/
416+
function run_choique_autopublish_articles($task, $args)
417+
{
418+
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
419+
define('SF_APP', 'backend');
420+
define('SF_ENVIRONMENT', 'prod');
421+
define('SF_DEBUG', true);
422+
// get configuration
423+
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
424+
$databaseManager = new sfDatabaseManager();
425+
$databaseManager->initialize();
426+
427+
$c = new Criteria();
428+
$c->add(ArticlePeer::IS_PUBLISHED, false);
429+
$c->add(ArticlePeer::AUTO_PUBLISH_AT, time(), Criteria::LESS_EQUAL);
430+
$c->add(ArticlePeer::AUTO_PUBLISH_AT,null,Criteria::ISNOTNULL);
431+
$c->setLimit(10);
432+
$cont = 0;
433+
foreach (ArticlePeer::doSelect($c) as $article)
434+
{
435+
$article->setIsPublished(true);
436+
$article->save();
437+
$cont ++;
438+
}
439+
echo "\n".pakeColor::colorize("$cont published articles\n", array('fg'=>'green', 'bold'=>true));
440+
441+
}
442+
443+
pake_desc('Unpublish published Articles with auto_unpublish date prior to now');
444+
pake_task('choique-autounpublish-articles');
445+
446+
/**
447+
* Select flavor
448+
*
449+
*
450+
* @param object $task
451+
* @param array $args
452+
*/
453+
function run_choique_autounpublish_articles($task, $args)
454+
{
455+
define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
456+
define('SF_APP', 'backend');
457+
define('SF_ENVIRONMENT', 'prod');
458+
define('SF_DEBUG', true);
459+
// get configuration
460+
require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php';
461+
$databaseManager = new sfDatabaseManager();
462+
$databaseManager->initialize();
463+
464+
$c = new Criteria();
465+
$c->add(ArticlePeer::IS_PUBLISHED, true);
466+
$c->add(ArticlePeer::AUTO_UNPUBLISH_AT, time(), Criteria::LESS_EQUAL);
467+
$c->add(ArticlePeer::AUTO_UNPUBLISH_AT,null,Criteria::ISNOTNULL);
468+
$c->setLimit(10);
469+
$cont = 0;
470+
foreach (ArticlePeer::doSelect($c) as $article)
471+
{
472+
$article->setIsPublished(false);
473+
$article->save();
474+
$cont ++;
475+
}
476+
echo "\n".pakeColor::colorize("$cont unpublished articles\n", array('fg'=>'green', 'bold'=>true));
477+
478+
}

0 commit comments

Comments
 (0)