@@ -36,38 +36,98 @@ class tabs {
3636 /**
3737 * Generates a Moodle tabrow i.e. an array of tabs
3838 *
39- * @return array
39+ * @param bool $activelink display active workflows tab as link
40+ * @param bool $deactivatelink display deactivated workflows tab as link
41+ * @param bool $draftlink display draft workflows tab as link
42+ * @return array of tabobjects
4043 * @throws \coding_exception
44+ * @throws \dml_exception
4145 * @throws moodle_exception
4246 */
43- public static function get_tabrow () {
47+ public static function get_tabrow ($ activelink = false , $ deactivatelink = false , $ draftlink = false ) {
48+ global $ DB ;
4449
45- $ targeturl = new \moodle_url ('/admin/settings.php ' , ['section ' => 'lifecycle ' ]);
50+ $ classnotnull = 'badge badge-primary badge-pill ml-1 ' ;
51+ $ classnull = 'badge badge-secondary badge-pill ml-1 ' ;
52+
53+ // Get number of drafts.
54+ $ sql = "select count(id)
55+ from {tool_lifecycle_workflow}
56+ where timeactive IS NULL AND timedeactive IS NULL " ;
57+ $ i = $ DB ->count_records_sql ($ sql );
58+ $ drafts = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
59+
60+ // Get number of active workflows.
61+ $ sql = "select count(id)
62+ from {tool_lifecycle_workflow}
63+ where timeactive IS NOT NULL " ;
64+ $ i = $ DB ->count_records_sql ($ sql );
65+ $ activewf = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
66+
67+ // Get number of deactivated workflows.
68+ $ sql = "select count(id)
69+ from {tool_lifecycle_workflow}
70+ where timeactive IS NULL AND timedeactive IS NOT NULL " ;
71+ $ i = $ DB ->count_records_sql ($ sql );
72+ $ deactivatedewf = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
73+
74+ // Get number of delayed courses.
75+ $ sql = "select count(id)
76+ from {tool_lifecycle_delayed} " ;
77+ $ i = $ DB ->count_records_sql ($ sql );
78+ $ delayedcourses = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
79+
80+ // Get number of lifecycle course backups.
81+ $ sql = "select count(id)
82+ from {tool_lifecycle_backups} " ;
83+ $ i = $ DB ->count_records_sql ($ sql );
84+ $ coursebackups = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
85+
86+ // Get number of stores lifecycle errors.
87+ $ sql = "select count(id)
88+ from {tool_lifecycle_proc_error} " ;
89+ $ i = $ DB ->count_records_sql ($ sql );
90+ $ lcerrors = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
91+
92+ // General Settings and Subplugins.
93+ $ targeturl = new \moodle_url ('/admin/category.php ' , ['category ' => 'lifecycle ' ]);
4694 $ tabrow [] = new \tabobject ('settings ' , $ targeturl ,
4795 get_string ('general_config_header ' , 'tool_lifecycle ' ));
4896
97+ // Tab to the draft workflows page.
4998 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/workflowdrafts.php ' , ['id ' => 'workflowdrafts ' ]);
5099 $ tabrow [] = new \tabobject ('workflowdrafts ' , $ targeturl ,
51- get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ));
100+ get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ).$ drafts ,
101+ get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ), $ draftlink );
52102
103+ // Tab to the active workflows page.
53104 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/activeworkflows.php ' , ['id ' => 'activeworkflows ' ]);
54105 $ tabrow [] = new \tabobject ('activeworkflows ' , $ targeturl ,
55- get_string ('active_workflows_header ' , 'tool_lifecycle ' ));
106+ get_string ('active_workflows_header ' , 'tool_lifecycle ' ).$ activewf ,
107+ get_string ('active_workflows_header ' , 'tool_lifecycle ' ), $ activelink );
56108
109+ // Tab to the deactivated workflows page.
57110 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/deactivatedworkflows.php ' , ['id ' => 'deactivatedworkflows ' ]);
58111 $ tabrow [] = new \tabobject ('deactivatedworkflows ' , $ targeturl ,
59- get_string ('deactivated_workflows_header ' , 'tool_lifecycle ' ));
60-
61- $ targeturl = new \moodle_url ('/admin/tool/lifecycle/coursebackups.php ' , ['id ' => 'coursebackups ' ]);
62- $ tabrow [] = new \tabobject ('coursebackups ' , $ targeturl ,
63- get_string ('course_backups_list_header ' , 'tool_lifecycle ' ));
112+ get_string ('deactivated_workflows_header ' , 'tool_lifecycle ' ).$ deactivatedewf ,
113+ get_string ('deactivated_workflows_header ' , 'tool_lifecycle ' ), $ deactivatelink );
64114
115+ // Tab to the delayed courses list page.
65116 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/delayedcourses.php ' , ['id ' => 'delayedcourses ' ]);
66117 $ tabrow [] = new \tabobject ('delayedcourses ' , $ targeturl ,
118+ get_string ('delayed_courses_header ' , 'tool_lifecycle ' ).$ delayedcourses ,
67119 get_string ('delayed_courses_header ' , 'tool_lifecycle ' ));
68120
121+ // Tab to the course backups list page.
122+ $ targeturl = new \moodle_url ('/admin/tool/lifecycle/coursebackups.php ' , ['id ' => 'coursebackups ' ]);
123+ $ tabrow [] = new \tabobject ('coursebackups ' , $ targeturl ,
124+ get_string ('course_backups_list_header ' , 'tool_lifecycle ' ).$ coursebackups ,
125+ get_string ('course_backups_list_header ' , 'tool_lifecycle ' ));
126+
127+ // Tab to the lifecycle errors page.
69128 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/errors.php ' , ['id ' => 'errors ' ]);
70129 $ tabrow [] = new \tabobject ('errors ' , $ targeturl ,
130+ get_string ('process_errors_header ' , 'tool_lifecycle ' ).$ lcerrors ,
71131 get_string ('process_errors_header ' , 'tool_lifecycle ' ));
72132
73133 return $ tabrow ;
0 commit comments