Author: david
Date: Fri Dec 23 15:14:58 2011
New Revision: 10453
Log:
Allow updating pub status of all descriptions in a repository
Modified:
trunk/lib/task/updatePublicationStatusTask.class.php
Modified: trunk/lib/task/updatePublicationStatusTask.class.php
==============================================================================
--- trunk/lib/task/updatePublicationStatusTask.class.php Fri Dec 23
00:03:11 2011 (r10452)
+++ trunk/lib/task/updatePublicationStatusTask.class.php Fri Dec 23
15:14:58 2011 (r10453)
@@ -32,7 +32,8 @@
new sfCommandOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
new sfCommandOption('force', 'f', sfCommandOption::PARAMETER_NONE,
'Force update of descendants', null),
new sfCommandOption('ignore-descendants', 'i',
sfCommandOption::PARAMETER_NONE, 'Don\'t update descendants', null),
- new sfCommandOption('no-confirm', null, sfCommandOption::PARAMETER_NONE,
'No confirmation message', null)
+ new sfCommandOption('no-confirm', null, sfCommandOption::PARAMETER_NONE,
'No confirmation message', null),
+ new sfCommandOption('repo', null, sfCommandOption::PARAMETER_NONE,
'Update all description in given repository', null)
));
$this->namespace = 'tools';
@@ -51,7 +52,15 @@
$criteria = new Criteria;
$criteria->add(QubitSlug::SLUG, $arguments['slug']);
$criteria->addJoin(QubitSlug::OBJECT_ID, QubitObject::ID);
- $resource = QubitInformationObject::get($criteria)->__get(0);
+
+ if (!$options['repo'])
+ {
+ $resource = QubitInformationObject::get($criteria)->__get(0);
+ }
+ else
+ {
+ $resource = QubitRepository::get($criteria)->__get(0);
+ }
$publicationStatus = QubitTerm::getById($arguments['publicationStatusId']);
@@ -77,7 +86,7 @@
{
if (!$this->askConfirmation(array(
'Please, confirm that you want to change',
- 'the publication status of "' . $resource . '"',
+ 'the publication status of "' . $resource->__toString() . '"',
'to "' . $publicationStatus . '" (y/N)'), 'QUESTION_LARGE', false))
{
$this->logSection('tools', 'Bye!');
@@ -86,6 +95,27 @@
}
}
+ // Do work
+ if (!$options['repo'])
+ {
+ self::updatePublicationStatus($resource, $publicationStatus, $options);
+ }
+ else
+ {
+ $criteria = new Criteria;
+ $criteria->add(QubitInformationObject::REPOSITORY_ID, $resource->id);
+
+ foreach(QubitInformationObject::get($criteria) as $item)
+ {
+ self::updatePublicationStatus($item, $publicationStatus, $options);
+ }
+ }
+
+ echo "\n";
+ }
+
+ protected static function updatePublicationStatus($resource,
$publicationStatus, $options)
+ {
// Start work
$resource->setPublicationStatus($publicationStatus->id);
$resource->save();
@@ -111,7 +141,5 @@
}
}
}
-
- echo "\n";
}
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.