database.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* For license terms, see /license.txt */
  3. use Doctrine\DBAL\Types\Type;
  4. /**
  5. * Plugin database installation script. Can only be executed if included
  6. * inside another script loading global.inc.php.
  7. *
  8. * @package chamilo.plugin.customcertificate
  9. */
  10. /**
  11. * Check if script can be called.
  12. */
  13. if (!function_exists('api_get_path')) {
  14. die('This script must be loaded through the Chamilo plugin installer sequence');
  15. }
  16. $entityManager = Database::getManager();
  17. $pluginSchema = new \Doctrine\DBAL\Schema\Schema();
  18. $connection = $entityManager->getConnection();
  19. $platform = $connection->getDatabasePlatform();
  20. if ($pluginSchema->hasTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE)) {
  21. return;
  22. }
  23. //Create tables
  24. $certificateTable = $pluginSchema->createTable(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE);
  25. $certificateTable->addColumn('id', Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]);
  26. $certificateTable->addColumn('access_url_id', Type::INTEGER, ['unsigned' => true]);
  27. $certificateTable->addColumn('c_id', Type::INTEGER, ['unsigned' => true]);
  28. $certificateTable->addColumn('session_id', Type::INTEGER, ['unsigned' => true]);
  29. $certificateTable->addColumn('content_course', Type::TEXT);
  30. $certificateTable->addColumn('contents_type', Type::INTEGER, ['unsigned' => true]);
  31. $certificateTable->addColumn('contents', Type::TEXT);
  32. $certificateTable->addColumn('date_change', Type::INTEGER, ['unsigned' => true]);
  33. $certificateTable->addColumn('date_start', Type::DATETIME);
  34. $certificateTable->addColumn('date_end', Type::DATETIME);
  35. $certificateTable->addColumn('type_date_expediction', Type::INTEGER, ['unsigned' => true]);
  36. $certificateTable->addColumn('place', Type::STRING);
  37. $certificateTable->addColumn('day', Type::STRING, ['notnull' => false]);
  38. $certificateTable->addColumn('month', Type::STRING, ['notnull' => false]);
  39. $certificateTable->addColumn('year', Type::STRING, ['notnull' => false]);
  40. $certificateTable->addColumn('logo_left', Type::STRING);
  41. $certificateTable->addColumn('logo_center', Type::STRING);
  42. $certificateTable->addColumn('logo_right', Type::STRING);
  43. $certificateTable->addColumn('seal', Type::STRING);
  44. $certificateTable->addColumn('signature1', Type::STRING);
  45. $certificateTable->addColumn('signature2', Type::STRING);
  46. $certificateTable->addColumn('signature3', Type::STRING);
  47. $certificateTable->addColumn('signature4', Type::STRING);
  48. $certificateTable->addColumn('signature_text1', Type::STRING);
  49. $certificateTable->addColumn('signature_text2', Type::STRING);
  50. $certificateTable->addColumn('signature_text3', Type::STRING);
  51. $certificateTable->addColumn('signature_text4', Type::STRING);
  52. $certificateTable->addColumn('background', Type::STRING);
  53. $certificateTable->addColumn('margin_left', Type::INTEGER, ['unsigned' => true]);
  54. $certificateTable->addColumn('margin_right', Type::INTEGER, ['unsigned' => true]);
  55. $certificateTable->addColumn('certificate_default', Type::INTEGER, ['unsigned' => true]);
  56. $certificateTable->addIndex(['c_id', 'session_id']);
  57. $certificateTable->setPrimaryKey(['id']);
  58. $queries = $pluginSchema->toSql($platform);
  59. foreach ($queries as $query) {
  60. Database::query($query);
  61. }