admin_prefs.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <?php
  2. /*
  3. * e107 website system
  4. *
  5. * Copyright (C) 2008-2016 e107 Inc (e107.org)
  6. * Released under the terms and conditions of the
  7. * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
  8. *
  9. */
  10. require_once("../../class2.php");
  11. if (!getperms("P") || !e107::isInstalled('timekeeper')) {
  12. e107::redirect('admin');
  13. exit;
  14. }
  15. // Maybe later i'll setup languages
  16. //e107::includeLan(e_PLUGIN."timekeeper/languages/".e_LANGUAGE."_admin_timekeeper_menu.php");
  17. class timekeeper_admin extends e_admin_dispatcher {
  18. protected $modes = array(
  19. 'main' => array(
  20. 'controller' => 'plugin_tk_admin_ui',
  21. 'path' => null,
  22. 'ui' => 'plugin_tk_admin_form_ui',
  23. 'uipath' => null
  24. ),
  25. 'score' => array(
  26. 'controller' => 'tk_Score_ui',
  27. 'path' => null,
  28. 'ui' => 'tk_Score_form_ui',
  29. 'uipath' => null
  30. ),
  31. 'pending' => array(
  32. 'controller' => 'tk_Pending_ui',
  33. 'path' => null,
  34. 'ui' => 'tk_Pending_form_ui',
  35. 'uipath' => null
  36. ),
  37. 'report' => array(
  38. 'controller' => 'tk_Report_ui',
  39. 'path' => null,
  40. 'ui' => 'tk_Report_form_ui',
  41. 'uipath' => null
  42. ),
  43. 'reportold' => array(
  44. 'controller' => 'tk_Reportold_ui',
  45. 'path' => null,
  46. 'ui' => 'tk_Reportold_form_ui',
  47. 'uipath' => null
  48. ),
  49. 'wordlist' => array(
  50. 'controller' => 'tk_Wordlist_ui',
  51. 'path' => null,
  52. 'ui' => 'tk_Wordlist_form_ui',
  53. 'uipath' => null
  54. ),
  55. 'geography' => array(
  56. 'controller' => 'tk_geography_ui',
  57. 'path' => null,
  58. 'ui' => 'tk_geography_form_ui',
  59. 'uipath' => null
  60. ),
  61. );
  62. protected $adminMenu = array(
  63. 'main/list' => array('caption' => 'List Questions', 'perm' => '0'),
  64. 'main/create' => array('caption' => LAN_CREATE, 'perm' => '0'),
  65. 'other0' => array('divider' => true),
  66. //'subjects/list' => array('caption'=> 'List Subjects', 'perm' => '0'),
  67. //'subjects/create' => array('caption'=> 'Add Subjects', 'perm' => '0'),
  68. //'other1' => array('divider' => true),
  69. 'Score/list' => array('caption' => 'List Score', 'perm' => '0'),
  70. 'other2' => array('divider' => true),
  71. 'Pending/list' => array('caption' => 'List Pending', 'perm' => '0'),
  72. 'other3' => array('divider' => true),
  73. 'Report/list' => array('caption' => 'List Report', 'perm' => '0'),
  74. 'Reportold/list' => array('caption' => 'List Report (Old)', 'perm' => '0'),
  75. 'other4' => array('divider' => true),
  76. 'Wordlist/list' => array('caption' => 'Spelling Words', 'perm' => '0'),
  77. 'Wordlist/create' => array('caption' => 'Add Words', 'perm' => '0'),
  78. 'Wordlist/custom' => array('caption' => 'Spelling Score', 'perm' => '0'),
  79. 'other5' => array('divider' => true),
  80. 'Geography/list' => array('caption' => 'Geography', 'perm' => '0'),
  81. );
  82. protected $adminMenuAliases = array(
  83. 'main/edit' => 'main/list'
  84. );
  85. protected $menuTitle = 'TimeKeeper';
  86. }
  87. /*
  88. =========================================================================
  89. ===== Questions table interface
  90. =========================================================================
  91. */
  92. class plugin_tk_admin_ui extends e_admin_ui {
  93. protected $pluginTitle = 'TimeKeeper';
  94. protected $pluginName = 'TimeKeeper';
  95. protected $table = 'timekeeperQuestions';
  96. protected $pid = 'timekeeper_id';
  97. protected $perPage = 10;
  98. protected $fields = array(
  99. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  100. 'timekeeper_id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  101. 'timekeeper_questiondescription' => array('title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  102. 'timekeeper_question' => array('title' => "Question", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  103. 'timekeeper_answers' => array('title' => "Answers", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  104. 'timekeeper_subject' => array('title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  105. 'timekeeper_addeddatestamp' => array('title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly' => true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  106. 'timekeeper_yearlevel' => array('title' => "Year Level", 'type' => 'dropdown', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('optArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), 'class' => 'left', 'thclass' => 'left',),
  107. 'timekeeper_correctanswer' => array('title' => "Correct Answer", 'type' => 'number', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  108. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  109. );
  110. protected $fieldpref = array('checkboxes', 'timekeeper_questiondescription', 'timekeeper_question', 'timekeeper_answers', 'timekeeper_correctanswer', 'timekeeper_yearlevel', 'options');
  111. }
  112. class plugin_tk_admin_form_ui extends e_admin_form_ui {
  113. }
  114. /*
  115. =========================================================================
  116. ===== Score table interface
  117. =========================================================================
  118. */
  119. class tk_Score_ui extends e_admin_ui {
  120. protected $pluginTitle = 'TimeKeeper';
  121. protected $pluginName = 'TimeKeeper';
  122. protected $table = 'timekeeperScore';
  123. protected $pid = 'timekeeper_id';
  124. protected $perPage = 10;
  125. protected $fields = array(
  126. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  127. 'timekeeper_id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  128. 'timekeeper_username' => array('title' => "User Name", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  129. 'timekeeper_lifetimequestions' => array('title' => "life time Question", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  130. 'timekeeper_lifetimecorrect' => array('title' => "life time correct", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  131. 'timekeeper_minutes' => array('title' => "minutes", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  132. 'timekeeper_lastquestiondatestamp' => array('title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly' => true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  133. 'timekeeper_yearlevel' => array('title' => "Year Level", 'type' => 'dropdown', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('optArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), 'class' => 'left', 'thclass' => 'left',),
  134. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  135. );
  136. protected $fieldpref = array('checkboxes', 'timekeeper_username', 'timekeeper_lifetimequestions', 'timekeeper_lifetimecorrect', 'timekeeper_minutes', 'options');
  137. /*
  138. protected $prefs = array(
  139. 'rss_othernews' => array('title'=> RSS_LAN_ADMIN_13, 'type' => 'boolean', 'data' => 'int'),
  140. 'rss_summarydiz' => array('title'=> RSS_LAN_ADMIN_19, 'type' => 'boolean', 'data' => 'integer'),
  141. 'rss_shownewsimage' => array('title'=> RSS_LAN_ADMIN_33, 'type' => 'boolean', 'data' => 'int')
  142. );
  143. */
  144. }
  145. class tk_Score_form_ui extends e_admin_form_ui {
  146. // Custom Method/Function
  147. function rss_url3($curVal, $mode) {
  148. switch ($mode) {
  149. case 'read': // List Page
  150. $type = $this->getController()->getListModel()->get('rss_type');
  151. $topic = $this->getController()->getListModel()->get('rss_topicid');
  152. $link = e107::url('rss_menu', 'rss', array('rss_type' => $type, 'rss_url' => $curVal, 'rss_topicid' => $topic));
  153. return "<a href='" . $link . "'>" . $curVal . "</a>";
  154. case 'write': // Edit Page
  155. $link = SITEURL . "feed/"; // e107::url('rss_menu','index').'/';
  156. return "<div class='form-inline'>" . $link . e107::getForm()->text('rss_url', $curVal, 255, 'size=small') . "/rss/{Topic id}</div>";
  157. case 'filter':
  158. case 'batch':
  159. return null;
  160. }
  161. }
  162. }
  163. /*
  164. =========================================================================
  165. ===== Pending table interface
  166. =========================================================================
  167. */
  168. class tk_Pending_ui extends e_admin_ui {
  169. protected $pluginTitle = 'TimeKeeper';
  170. protected $pluginName = 'TimeKeeper';
  171. protected $table = 'Pending';
  172. protected $pid = 'timekeeper_id';
  173. protected $perPage = 10;
  174. protected $fields = array(
  175. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  176. 'timekeeper_id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  177. 'timekeeper_questiondescription' => array('title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  178. 'timekeeper_question' => array('title' => "Question", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  179. 'timekeeper_answers' => array('title' => "Answers", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  180. 'timekeeper_subject' => array('title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  181. 'timekeeper_addeddatestamp' => array('title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly' => true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  182. 'timekeeper_yearlevel' => array('title' => "Year Level", 'type' => 'dropdown', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('optArray' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), 'class' => 'left', 'thclass' => 'left',),
  183. 'timekeeper_correctanswer' => array('title' => "Correct Answer", 'type' => 'number', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  184. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  185. );
  186. protected $fieldpref = array('checkboxes', 'timekeeper_questiondescription', 'timekeeper_question', 'timekeeper_answers', 'timekeeper_correctanswer', 'timekeeper_yearlevel', 'options');
  187. /*
  188. protected $prefs = array(
  189. 'rss_othernews' => array('title'=> RSS_LAN_ADMIN_13, 'type' => 'boolean', 'data' => 'int'),
  190. 'rss_summarydiz' => array('title'=> RSS_LAN_ADMIN_19, 'type' => 'boolean', 'data' => 'integer'),
  191. 'rss_shownewsimage' => array('title'=> RSS_LAN_ADMIN_33, 'type' => 'boolean', 'data' => 'int')
  192. );
  193. */
  194. }
  195. class tk_Pending_form_ui extends e_admin_form_ui {
  196. // Custom Method/Function
  197. function rss_url4($curVal, $mode) {
  198. switch ($mode) {
  199. case 'read': // List Page
  200. $type = $this->getController()->getListModel()->get('rss_type');
  201. $topic = $this->getController()->getListModel()->get('rss_topicid');
  202. $link = e107::url('rss_menu', 'rss', array('rss_type' => $type, 'rss_url' => $curVal, 'rss_topicid' => $topic));
  203. return "<a href='" . $link . "'>" . $curVal . "</a>";
  204. case 'write': // Edit Page
  205. $link = SITEURL . "feed/"; // e107::url('rss_menu','index').'/';
  206. return "<div class='form-inline'>" . $link . e107::getForm()->text('rss_url', $curVal, 255, 'size=small') . "/rss/{Topic id}</div>";
  207. case 'filter':
  208. case 'batch':
  209. return null;
  210. }
  211. }
  212. }
  213. /*
  214. =========================================================================
  215. ===== Report table interface
  216. =========================================================================
  217. */
  218. class tk_Report_ui extends e_admin_ui {
  219. protected $pluginTitle = 'TimeKeeper';
  220. protected $pluginName = 'TimeKeeper';
  221. protected $table = 'tkReport';
  222. protected $pid = 'id';
  223. protected $perPage = 10;
  224. protected $fields = array(
  225. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  226. 'id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  227. 'username' => array('title' => "User Name", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  228. 'question' => array('title' => "Question", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  229. 'userAnswer' => array('title' => "User Answer", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  230. 'answer' => array('title' => "Correct Answer", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  231. 'subject' => array('title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  232. 'answereddatestamp' => array('title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly' => true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  233. 'correct' => array('title' => "Correct", 'type' => 'bool', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  234. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  235. );
  236. protected $fieldpref = array('checkboxes', 'username', 'question', 'userAnswer', 'answer', 'options');
  237. /*
  238. protected $prefs = array(
  239. 'rss_othernews' => array('title'=> RSS_LAN_ADMIN_13, 'type' => 'boolean', 'data' => 'int'),
  240. 'rss_summarydiz' => array('title'=> RSS_LAN_ADMIN_19, 'type' => 'boolean', 'data' => 'integer'),
  241. 'rss_shownewsimage' => array('title'=> RSS_LAN_ADMIN_33, 'type' => 'boolean', 'data' => 'int')
  242. );
  243. */
  244. }
  245. class tk_Report_form_ui extends e_admin_form_ui {
  246. // Custom Method/Function
  247. function rss_url5($curVal, $mode) {
  248. switch ($mode) {
  249. case 'read': // List Page
  250. $type = $this->getController()->getListModel()->get('rss_type');
  251. $topic = $this->getController()->getListModel()->get('rss_topicid');
  252. $link = e107::url('rss_menu', 'rss', array('rss_type' => $type, 'rss_url' => $curVal, 'rss_topicid' => $topic));
  253. return "<a href='" . $link . "'>" . $curVal . "</a>";
  254. case 'write': // Edit Page
  255. $link = SITEURL . "feed/"; // e107::url('rss_menu','index').'/';
  256. return "<div class='form-inline'>" . $link . e107::getForm()->text('rss_url', $curVal, 255, 'size=small') . "/rss/{Topic id}</div>";
  257. case 'filter':
  258. case 'batch':
  259. return null;
  260. }
  261. }
  262. }
  263. class tk_Reportold_ui extends e_admin_ui {
  264. protected $pluginTitle = 'TimeKeeper';
  265. protected $pluginName = 'TimeKeeper';
  266. protected $table = 'timekeeperReport';
  267. protected $pid = 'timekeeper_id';
  268. protected $perPage = 10;
  269. protected $fields = array(
  270. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  271. 'timekeeper_id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  272. 'timekeeper_username' => array('title' => "User Name", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  273. 'timekeeper_question' => array('title' => "Question", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  274. 'timekeeper_userAnswer' => array('title' => "User Answer", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  275. 'timekeeper_answer' => array('title' => "Correct Answer", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  276. 'timekeeper_subject' => array('title' => "Subject", 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  277. 'timekeeper_answereddatestamp' => array('title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly' => true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  278. 'timekeeper_yearLevel' => array('title' => "Year Level", 'type' => 'number', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  279. 'timekeeper_correct' => array('title' => "Correct", 'type' => 'bool', 'data' => 'int', 'inline' => true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  280. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  281. );
  282. protected $fieldpref = array('checkboxes', 'timekeeper_username', 'timekeeper_question', 'timekeeper_userAnswer', 'timekeeper_answer', 'timekeeper_yearLevel', 'options');
  283. /*
  284. protected $prefs = array(
  285. 'rss_othernews' => array('title'=> RSS_LAN_ADMIN_13, 'type' => 'boolean', 'data' => 'int'),
  286. 'rss_summarydiz' => array('title'=> RSS_LAN_ADMIN_19, 'type' => 'boolean', 'data' => 'integer'),
  287. 'rss_shownewsimage' => array('title'=> RSS_LAN_ADMIN_33, 'type' => 'boolean', 'data' => 'int')
  288. );
  289. */
  290. }
  291. class tk_Reportold_form_ui extends e_admin_form_ui {
  292. // Custom Method/Function
  293. function rss_url5($curVal, $mode) {
  294. switch ($mode) {
  295. case 'read': // List Page
  296. $type = $this->getController()->getListModel()->get('rss_type');
  297. $topic = $this->getController()->getListModel()->get('rss_topicid');
  298. $link = e107::url('rss_menu', 'rss', array('rss_type' => $type, 'rss_url' => $curVal, 'rss_topicid' => $topic));
  299. return "<a href='" . $link . "'>" . $curVal . "</a>";
  300. case 'write': // Edit Page
  301. $link = SITEURL . "feed/"; // e107::url('rss_menu','index').'/';
  302. return "<div class='form-inline'>" . $link . e107::getForm()->text('rss_url', $curVal, 255, 'size=small') . "/rss/{Topic id}</div>";
  303. case 'filter':
  304. case 'batch':
  305. return null;
  306. }
  307. }
  308. }
  309. /*
  310. =========================================================================
  311. ===== Wordlist table interface
  312. =========================================================================
  313. */
  314. class tk_Wordlist_ui extends e_admin_ui {
  315. protected $pluginTitle = 'TimeKeeper';
  316. protected $pluginName = 'TimeKeeper';
  317. protected $table = 'tk_wordList';
  318. protected $pid = 'indexNo';
  319. protected $perPage = 10;
  320. protected $fields = array(
  321. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  322. 'indexNo' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'readonly' => 1, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  323. 'word' => array('title' => "Word", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  324. 'usage' => array('title' => "Word Usage", 'type' => 'textarea', 'data' => 'str', 'width' => '65%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  325. 'year' => array('title' => "Year Level", 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => ['default' => 1, 'min' => 1, 'max' => 13], 'class' => 'left', 'thclass' => 'left',),
  326. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  327. );
  328. protected $fieldpref = array('checkboxes', 'indexNo', 'word', 'usage', 'year', 'options');
  329. public function customPage() {
  330. $sql = e107::getdb();
  331. $text = '<table style="width:600px;"><tr><td style="width:25%;">User</td><td style="width:25%;">Subject</td><td style="width:24%;">Percentage</td><td style="width:25%;">Questions last month</td></tr>';
  332. $Users = [];
  333. $getUsers = "SELECT DISTINCT username FROM e107.e107_tkReport WHERE `answereddatestamp` > UNIX_TIMESTAMP((NOW()) - INTERVAL 1 MONTH);";
  334. $getSubjects = "SELECT DISTINCT `subject` FROM e107_tkReport WHERE `answereddatestamp` > UNIX_TIMESTAMP((NOW()) - INTERVAL 1 MONTH) AND `username` = '<user>';";
  335. $getScore = "SELECT CAST((SUM(correct) / COUNT(id) * 100) AS DECIMAL (5 , 2 )) AS percent, COUNT(id) as `count`,'<subject>' AS `subject`
  336. FROM e107_tkReport WHERE `answereddatestamp` > UNIX_TIMESTAMP((NOW()) - INTERVAL 1 MONTH) AND `username` = '<user>' AND `subject` = '<subject>';";
  337. $sql->gen($getUsers);
  338. while ($row = $sql->fetch()) {
  339. $Users[] = $row['username'];
  340. }
  341. foreach ($Users as $user) {
  342. $Subjects = [];
  343. $sql->gen(str_replace('<user>', $user, $getSubjects));
  344. while ($row = $sql->fetch()) {
  345. $Subjects[] = $row['subject'];
  346. }
  347. foreach ($Subjects as $Subject) {
  348. $sql->gen(str_replace('<subject>', $Subject, str_replace('<user>', $user, $getScore)));
  349. while ($row = $sql->fetch()) {
  350. $text .= '<tr><td>'.$user.'</td><td>'.$row['subject'].'</td><td>'.$row['percent'].'</td><td>'.$row['count'].'</td></tr>';
  351. }
  352. }
  353. $returnArray['totalQuestionCount'] = e107::getDb()->count("tkReport", "(id)", "username = '" . $user . "'");
  354. e107::getDb()->gen("SELECT COUNT(id) as cntr, CAST((SUM(correct)/COUNT(id)*100) as DECIMAL(5,2)) as percent
  355. FROM e107.`e107_tkReport` WHERE username = '" . $user . "'
  356. AND answereddatestamp >= unix_timestamp(CURRENT_DATE() - INTERVAL 1 MONTH)
  357. AND answereddatestamp <= unix_timestamp(CURRENT_DATE() + INTERVAL 1 DAY)");
  358. while ($row = e107::getDb()->fetch()) {
  359. $returnArray = array_merge($returnArray,$row);
  360. }
  361. $diffi = $returnArray['totalQuestionCount']*$returnArray['percent'];
  362. $text .= '<tr><td colspan=2>Difficulty</td><td colspan=2>'.$diffi.'</td></tr>';
  363. }
  364. $text .= '</table><br/><br/>';
  365. $text .= $sql->retrieve('SELECT COUNT(`usage`) FROM `#tk_wordList` WHERE `usage`="";');
  366. $text .= ' words need a usage entered.<br/>';
  367. $nextWord = $sql->retrieve('SELECT `indexNo`,`word` FROM `#tk_wordList` WHERE `usage`="";');
  368. $text .= 'The next word to be entered is "'.$nextWord['word'].'" at position '.$nextWord['indexNo'].'.';
  369. $ns = e107::getRender();
  370. $ns->tablerender("Scores", $text);
  371. }
  372. }
  373. class tk_Wordlist_form_ui extends e_admin_form_ui {
  374. }
  375. class tk_geography_ui extends e_admin_ui {
  376. protected $pluginTitle = 'TimeKeeper';
  377. protected $pluginName = 'TimeKeeper';
  378. protected $table = 'tk_countries';
  379. protected $pid = 'id';
  380. protected $perPage = 10;
  381. protected $fields = array(
  382. 'checkboxes' => array('title' => '', 'type' => null, 'data' => false, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect',),
  383. 'id' => array('title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'readonly' => 1, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  384. 'country' => array('title' => "Country", 'type' => 'text', 'data' => 'str', 'readonly' => 1, 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  385. 'currency' => array('title' => "Currency", 'type' => 'text', 'data' => 'str', 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  386. 'capital' => array('title' => "Capital", 'type' => 'text', 'data' => 'str', 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  387. 'isoCode' => array('title' => "isoCode", 'type' => 'text', 'data' => 'str', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  388. 'difficulty' => array('title' => "Difficulty", 'type' => 'number', 'data' => 'int', 'inline' => true, 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => ['default' => 10, 'min' => 1, 'max' => 10], 'class' => 'left', 'thclass' => 'left',),
  389. 'culture' => array('title' => "Culture", 'type' => 'textarea', 'data' => 'str', 'width' => '20%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left',),
  390. 'continent' => array('title' => "Continent", 'type' => 'dropdown', 'data' => 'str', 'inline' => true, 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => ['optArray' => ['Africa'=>'Africa', 'Asia'=>'Asia', 'Europe'=>'Europe', 'North America'=>'North America', 'South America'=>'South America', 'Oceania'=>'Oceania']], 'class' => 'left', 'thclass' => 'left',),
  391. 'map_coords' => array('title' => "Map Coords", 'type' => 'text', 'data' => 'str', 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => ['default' => '{}'], 'class' => 'left', 'thclass' => 'left',),
  392. 'options' => array('title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1',),
  393. );
  394. protected $fieldpref = array('checkboxes', 'id', 'country', 'isoCode', 'difficulty', 'options');
  395. }
  396. class tk_geography_form_ui extends e_admin_form_ui {
  397. }
  398. new timekeeper_admin();
  399. require_once(e_ADMIN . "auth.php");
  400. e107::getAdminUI()->runPage();
  401. require_once(e_ADMIN . "footer.php");
  402. exit;