kannelsms_plugin.class.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /vendor/license.txt */
  3. /**
  4. * Class KannelsmsPlugin
  5. * This script contains SMS type constants and basic plugin functions
  6. *
  7. * @package chamilo.plugin.kannelsms.lib
  8. * @author Imanol Losada <imanol.losada@beeznest.com>
  9. * @author Julio Montoya Refactor code
  10. */
  11. class KannelsmsPlugin extends SmsPlugin
  12. {
  13. /**
  14. * create (a singleton function that ensures KannelsmsPlugin instance is
  15. * created only once. If it is already created, it returns the instance)
  16. * @return object KannelsmsPlugin instance
  17. */
  18. public static function create()
  19. {
  20. static $result = null;
  21. return $result ? $result : $result = new self();
  22. }
  23. /**
  24. * Constructor
  25. * @return void
  26. */
  27. protected function __construct()
  28. {
  29. $fields = array(
  30. 'tool_enable' => 'boolean',
  31. 'hostAddress' => 'text',
  32. 'username' => 'text',
  33. 'password' => 'text',
  34. 'from' => 'text'
  35. );
  36. $smsTypeOptions = $this->getSmsTypeOptions();
  37. foreach ($smsTypeOptions as $smsTypeOption) {
  38. $fields[$smsTypeOption] = 'checkbox';
  39. }
  40. parent::__construct('0.1', 'Imanol Losada', $fields);
  41. }
  42. /**
  43. * install (uninstalls the plugin and removes all plugin's tables and/or rows)
  44. * @return void
  45. */
  46. public function uninstall()
  47. {
  48. $tSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  49. $sql = "DELETE FROM $tSettings WHERE subkey = 'kannelsms'";
  50. Database::query($sql);
  51. }
  52. }