70c139fed11cd09060fbfbc1d5287117.resolve.dbchanges.resolver 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Gallery
  4. *
  5. * Copyright 2010-2012 by Shaun McCormick <shaun@modx.com>
  6. *
  7. * Gallery is free software; you can redistribute it and/or modify it under the
  8. * terms of the GNU General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
  13. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. * Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * @package gallery
  21. */
  22. /**
  23. * Resolve changes to db model
  24. *
  25. * @var xPDOObject $object
  26. * @var array $options
  27. *
  28. * @package gallery
  29. * @subpackage build
  30. */
  31. if ($object->xpdo) {
  32. switch ($options[xPDOTransport::PACKAGE_ACTION]) {
  33. case xPDOTransport::ACTION_INSTALL:
  34. case xPDOTransport::ACTION_UPGRADE:
  35. $modx =& $object->xpdo;
  36. $modelPath = $modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/';
  37. $modx->addPackage('gallery',$modelPath);
  38. $manager = $modx->getManager();
  39. $oldLogLevel = $modx->getLogLevel();
  40. $modx->setLogLevel(0);
  41. $manager->addField('galAlbum','parent',array('after' => 'id'));
  42. $manager->addIndex('galAlbum','parent');
  43. $manager->addField('galItem','url',array('after' => 'mediatype'));
  44. /* 1.6.0+ */
  45. $manager->addField('galItem','slug',array('after' => 'mediatype'));
  46. $manager->addIndex('galItem','slug');
  47. $manager->addIndex('galItem','name');
  48. $manager->addIndex('galItem','active');
  49. $manager->addIndex('galItem','mediatype');
  50. $manager->addIndex('galAlbum','rank');
  51. $manager->addIndex('galAlbum','active');
  52. $manager->addIndex('galAlbum','prominent');
  53. $manager->addIndex('galAlbumItem','rank');
  54. $manager->addField('galAlbum', 'year');
  55. /* 1.5.3+ */
  56. $manager->addField('galAlbum','cover_filename');
  57. $modx->setLogLevel($oldLogLevel);
  58. break;
  59. }
  60. }
  61. return true;