Version20150507152600.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V110;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. /**
  7. * Class Version20150507152600
  8. *
  9. * @package Application\Migrations\Schema\V110
  10. */
  11. class Version20150507152600 extends AbstractMigrationChamilo
  12. {
  13. /**
  14. * @param Schema $schema
  15. *
  16. * @throws \Doctrine\DBAL\Schema\SchemaException
  17. */
  18. public function up(Schema $schema)
  19. {
  20. // Move some settings from configuration.php to the database
  21. // Current settings categories are:
  22. // Platform, Course, Session, Languages, User, Tools, Editor, Security,
  23. // Tuning, Gradebook, Timezones, Tracking, Search, stylesheets (lowercase),
  24. // LDAP, CAS, Shibboleth, Facebook
  25. // Setting $_configuration['hide_home_top_when_connected'] = true;
  26. $value = $this->getConfigurationValue('hide_home_top_when_connected');
  27. $this->addSettingCurrent(
  28. 'hide_home_top_when_connected',
  29. '',
  30. 'radio',
  31. 'Platform',
  32. ($value ? 'true' : 'false'),
  33. 'HideHomeTopContentWhenLoggedInText',
  34. 'HideHomeTopContentWhenLoggedInComment',
  35. null,
  36. '',
  37. 1,
  38. true,
  39. false,
  40. [
  41. 0 => ['value' => 'true', 'text' => 'Yes'],
  42. 1 => ['value' => 'false', 'text' => 'No'],
  43. ]
  44. );
  45. // Hide the global announcements for non-connected users
  46. //$_configuration['hide_global_announcements_when_not_connected'] = true;
  47. $value = $this->getConfigurationValue('hide_global_announcements_when_not_connected');
  48. $this->addSettingCurrent(
  49. 'hide_global_announcements_when_not_connected',
  50. '',
  51. 'radio',
  52. 'Platform',
  53. ($value?'true':'false'),
  54. 'HideGlobalAnnouncementsWhenNotLoggedInText',
  55. 'HideGlobalAnnouncementsWhenNotLoggedInComment',
  56. null,
  57. '',
  58. 1,
  59. true,
  60. false,
  61. [
  62. 0 => ['value' => 'true', 'text' => 'Yes'],
  63. 1 => ['value' => 'false', 'text' => 'No'],
  64. ]
  65. );
  66. // Use this course as template for all new courses (define course real ID as value)
  67. //$_configuration['course_creation_use_template'] = 14;
  68. $value = $this->getConfigurationValue('course_creation_use_template');
  69. $this->addSettingCurrent(
  70. 'course_creation_use_template',
  71. '',
  72. 'textfield',
  73. 'Course',
  74. ($value?$value:''),
  75. 'CourseCreationUsesTemplateText',
  76. 'CourseCreationUsesTemplateComment',
  77. null,
  78. '',
  79. 1,
  80. true,
  81. false,
  82. [
  83. 0 => ['value' => 'true', 'text' => 'Yes'],
  84. 1 => ['value' => 'false', 'text' => 'No'],
  85. ]
  86. );
  87. // Add password strength checker
  88. //$_configuration['allow_strength_pass_checker'] = true;
  89. $value = $this->getConfigurationValue('allow_strength_pass_checker');
  90. $this->addSettingCurrent(
  91. 'allow_strength_pass_checker',
  92. '',
  93. 'radio',
  94. 'Security',
  95. ($value?'true':'false'),
  96. 'EnablePasswordStrengthCheckerText',
  97. 'EnablePasswordStrengthCheckerComment',
  98. null,
  99. '',
  100. 1,
  101. true,
  102. false,
  103. [
  104. 0 => ['value' => 'true', 'text' => 'Yes'],
  105. 1 => ['value' => 'false', 'text' => 'No'],
  106. ]
  107. );
  108. // Enable captcha
  109. // $_configuration['allow_captcha'] = true;
  110. $value = $this->getConfigurationValue('allow_captcha');
  111. $this->addSettingCurrent(
  112. 'allow_captcha',
  113. '',
  114. 'radio',
  115. 'Security',
  116. ($value?'true':'false'),
  117. 'EnableCaptchaText',
  118. 'EnableCaptchaComment',
  119. null,
  120. '',
  121. 1,
  122. true,
  123. false,
  124. [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
  125. );
  126. // Prevent account from logging in for a certain amount of time
  127. // if captcha is wrong for the specified number of times
  128. //$_configuration['captcha_number_mistakes_to_block_account'] = 5;
  129. $value = $this->getConfigurationValue('captcha_number_mistakes_to_block_account');
  130. $this->addSettingCurrent(
  131. 'captcha_number_mistakes_to_block_account',
  132. '',
  133. 'textfield',
  134. 'Security',
  135. ($value?$value:5),
  136. 'CaptchaNumberOfMistakesBeforeBlockingAccountText',
  137. 'CaptchaNumberOfMistakesBeforeBlockingAccountComment',
  138. null,
  139. '',
  140. 1,
  141. true,
  142. false
  143. );
  144. // Prevent account from logging in for the specified number of minutes
  145. //$_configuration['captcha_time_to_block'] = 5;//minutes
  146. $value = $this->getConfigurationValue('captcha_time_to_block');
  147. $this->addSettingCurrent(
  148. 'captcha_time_to_block',
  149. '',
  150. 'textfield',
  151. 'Security',
  152. ($value?$value:5),
  153. 'CaptchaTimeAccountIsLockedText',
  154. 'CaptchaTimeAccountIsLockedComment',
  155. null,
  156. '',
  157. 1,
  158. true,
  159. false
  160. );
  161. // Allow DRH role to access all content and users from the sessions he follows
  162. //$_configuration['drh_can_access_all_session_content'] = true;
  163. $value = $this->getConfigurationValue('drh_can_access_all_session_content');
  164. $this->addSettingCurrent(
  165. 'drh_can_access_all_session_content',
  166. '',
  167. 'radio',
  168. 'Session',
  169. ($value?'true':'false'),
  170. 'DRHAccessToAllSessionContentText',
  171. 'DRHAccessToAllSessionContentComment',
  172. null,
  173. '',
  174. 1,
  175. true,
  176. false,
  177. [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
  178. );
  179. // Display group's forum in general forum tool
  180. //$_configuration['display_groups_forum_in_general_tool'] = true;
  181. $value = $this->getConfigurationValue('display_groups_forum_in_general_tool');
  182. $this->addSettingCurrent(
  183. 'display_groups_forum_in_general_tool',
  184. '',
  185. 'radio',
  186. 'Tools',
  187. ($value?'true':'false'),
  188. 'ShowGroupForaInGeneralToolText',
  189. 'ShowGroupForaInGeneralToolComment',
  190. null,
  191. '',
  192. 1,
  193. true,
  194. false,
  195. [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
  196. );
  197. // Allow course tutors in sessions to add existing students to their session
  198. //$_configuration['allow_tutors_to_assign_students_to_session'] = 'false';
  199. $value = $this->getConfigurationValue('allow_tutors_to_assign_students_to_session');
  200. $this->addSettingCurrent(
  201. 'allow_tutors_to_assign_students_to_session',
  202. '',
  203. 'radio',
  204. 'Session',
  205. ($value?'true':'false'),
  206. 'TutorsCanAssignStudentsToSessionsText',
  207. 'TutorsCanAssignStudentsToSessionsComment',
  208. null,
  209. '',
  210. 1,
  211. true,
  212. false,
  213. [0 => ['value' => 'true', 'text' => 'Yes'], 1 => ['value' => 'false', 'text' => 'No']]
  214. );
  215. }
  216. /**
  217. * We don't allow downgrades yet
  218. * @param Schema $schema
  219. */
  220. public function down(Schema $schema)
  221. {
  222. $this->addSql("
  223. DELETE FROM settings_options WHERE variable IN ('hide_home_top_when_connected', 'hide_global_announcements_when_not_connected', 'course_creation_use_template', 'allow_strength_pass_checker', 'allow_captcha', 'captcha_number_mistakes_to_block_account', 'captcha_time_to_block', 'drh_can_access_all_session_content', 'display_groups_forum_in_general_tool', 'allow_tutors_to_assign_students_to_session')
  224. ");
  225. $this->addSql("
  226. DELETE FROM settings_current WHERE variable IN ('hide_home_top_when_connected', 'hide_global_announcements_when_not_connected', 'course_creation_use_template', 'allow_strength_pass_checker', 'allow_captcha', 'captcha_number_mistakes_to_block_account', 'captcha_time_to_block', 'drh_can_access_all_session_content', 'display_groups_forum_in_general_tool', 'allow_tutors_to_assign_students_to_session')
  227. ");
  228. }
  229. }