@@ -40,34 +40,90 @@ class tabs {
4040 * @throws \coding_exception
4141 * @throws moodle_exception
4242 */
43- public static function get_tabrow () {
43+ public static function get_tabrow ($ activelink = false , $ deactivatelink = false , $ draftlink = false ) {
44+ global $ DB ;
4445
45- $ targeturl = new \moodle_url ('/admin/settings.php ' , ['section ' => 'lifecycle ' ]);
46+ $ classnotnull = 'badge badge-primary badge-pill ml-1 ' ;
47+ $ classnull = 'badge badge-secondary badge-pill ml-1 ' ;
48+
49+ // Get number of drafts.
50+ $ sql = "select count(id)
51+ from {tool_lifecycle_workflow}
52+ where timeactive IS NULL AND timedeactive IS NULL " ;
53+ $ i = $ DB ->count_records_sql ($ sql );
54+ $ drafts = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
55+
56+ // Get number of active workflows.
57+ $ sql = "select count(id)
58+ from {tool_lifecycle_workflow}
59+ where timeactive IS NOT NULL " ;
60+ $ i = $ DB ->count_records_sql ($ sql );
61+ $ activewf = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
62+
63+ // Get number of deactivated workflows.
64+ $ sql = "select count(id)
65+ from {tool_lifecycle_workflow}
66+ where timeactive IS NULL AND timedeactive IS NOT NULL " ;
67+ $ i = $ DB ->count_records_sql ($ sql );
68+ $ deactivatedewf = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
69+
70+ // Get number of delayed courses.
71+ $ sql = "select count(id)
72+ from {tool_lifecycle_delayed} " ;
73+ $ i = $ DB ->count_records_sql ($ sql );
74+ $ delayedcourses = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
75+
76+ // Get number of lifecycle course backups.
77+ $ sql = "select count(id)
78+ from {tool_lifecycle_backups} " ;
79+ $ i = $ DB ->count_records_sql ($ sql );
80+ $ coursebackups = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
81+
82+ // Get number of stores lifecycle errors.
83+ $ sql = "select count(id)
84+ from {tool_lifecycle_proc_error} " ;
85+ $ i = $ DB ->count_records_sql ($ sql );
86+ $ lcerrors = \html_writer::span ($ i , $ i > 0 ? $ classnotnull : $ classnull );
87+
88+ // General Settings and Subplugins.
89+ $ targeturl = new \moodle_url ('/admin/category.php ' , ['category ' => 'lifecycle ' ]);
4690 $ tabrow [] = new \tabobject ('settings ' , $ targeturl ,
4791 get_string ('general_config_header ' , 'tool_lifecycle ' ));
4892
93+ // Tab to the draft workflows page.
4994 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/workflowdrafts.php ' , ['id ' => 'workflowdrafts ' ]);
5095 $ tabrow [] = new \tabobject ('workflowdrafts ' , $ targeturl ,
51- get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ));
96+ get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ).$ drafts ,
97+ get_string ('workflow_drafts_header ' , 'tool_lifecycle ' ), $ draftlink );
5298
99+ // Tab to the active workflows page.
53100 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/activeworkflows.php ' , ['id ' => 'activeworkflows ' ]);
54101 $ tabrow [] = new \tabobject ('activeworkflows ' , $ targeturl ,
55- get_string ('active_workflows_header ' , 'tool_lifecycle ' ));
102+ get_string ('active_workflows_header ' , 'tool_lifecycle ' ).$ activewf ,
103+ get_string ('active_workflows_header ' , 'tool_lifecycle ' ), $ activelink );
56104
105+ // Tab to the deactivated workflows page.
57106 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/deactivatedworkflows.php ' , ['id ' => 'deactivatedworkflows ' ]);
58107 $ 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 ' ));
108+ get_string ('deactivated_workflows_header ' , 'tool_lifecycle ' ).$ deactivatedewf ,
109+ get_string ('deactivated_workflows_header ' , 'tool_lifecycle ' ), $ deactivatelink );
64110
111+ // Tab to the delayed courses list page.
65112 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/delayedcourses.php ' , ['id ' => 'delayedcourses ' ]);
66113 $ tabrow [] = new \tabobject ('delayedcourses ' , $ targeturl ,
114+ get_string ('delayed_courses_header ' , 'tool_lifecycle ' ).$ delayedcourses ,
67115 get_string ('delayed_courses_header ' , 'tool_lifecycle ' ));
68116
117+ // Tab to the course backups list page.
118+ $ targeturl = new \moodle_url ('/admin/tool/lifecycle/coursebackups.php ' , ['id ' => 'coursebackups ' ]);
119+ $ tabrow [] = new \tabobject ('coursebackups ' , $ targeturl ,
120+ get_string ('course_backups_list_header ' , 'tool_lifecycle ' ).$ coursebackups ,
121+ get_string ('course_backups_list_header ' , 'tool_lifecycle ' ));
122+
123+ // Tab to the lifecycle errors page.
69124 $ targeturl = new \moodle_url ('/admin/tool/lifecycle/errors.php ' , ['id ' => 'errors ' ]);
70125 $ tabrow [] = new \tabobject ('errors ' , $ targeturl ,
126+ get_string ('process_errors_header ' , 'tool_lifecycle ' ).$ lcerrors ,
71127 get_string ('process_errors_header ' , 'tool_lifecycle ' ));
72128
73129 return $ tabrow ;
0 commit comments