7
7
*
8
8
* @package TestLink
9
9
* @author TestLink community
10
- * @copyright 2007-2016 , TestLink community
10
+ * @copyright 2007-2019 , TestLink community
11
11
* @filesource projectView.php
12
12
* @link http://www.testlink.org/
13
13
*
14
- * @internal revisions
15
- * @since 1.9.9
16
14
*/
17
15
18
16
21
19
testlinkInitPage ($ db ,false ,false ,"checkRights " );
22
20
23
21
$ templateCfg = templateConfiguration ();
24
-
25
- $ smarty = new TLSmarty ();
26
- $ imgSet = $ smarty ->getImages ();
27
22
$ args = init_args ();
28
- $ gui = initializeGui ($ db ,$ args );
23
+ list ( $ gui, $ smarty ) = initializeGui ($ db ,$ args );
29
24
30
25
$ template2launch = $ templateCfg ->default_template ;
31
- if (!is_null ($ gui ->tprojects ) || $ args ->doAction =='list ' )
32
- {
33
- $ labels = init_labels (array ('active_integration ' => null , 'inactive_integration ' => null ));
34
- for ($ idx =0 ; $ idx < $ gui ->itemQty ; $ idx ++)
35
- {
36
- $ gui ->tprojects [$ idx ]['itstatusImg ' ] = '' ;
37
- if ($ gui ->tprojects [$ idx ]['itname ' ] != '' )
38
- {
39
- $ ak = ($ gui ->tprojects [$ idx ]['issue_tracker_enabled ' ]) ? 'active ' : 'inactive ' ;
40
- $ gui ->tprojects [$ idx ]['itstatusImg ' ] = ' <img title=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
41
- ' alt=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
42
- ' src=" ' . $ imgSet [$ ak ] . '"/> ' ;
43
- }
44
-
45
- $ gui ->tprojects [$ idx ]['ctstatusImg ' ] = '' ;
46
- if ($ gui ->tprojects [$ idx ]['ctname ' ] != '' )
47
- {
48
- $ ak = ($ gui ->tprojects [$ idx ]['code_tracker_enabled ' ]) ? 'active ' : 'inactive ' ;
49
- $ gui ->tprojects [$ idx ]['ctstatusImg ' ] = ' <img title=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
50
- ' alt=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
51
- ' src=" ' . $ imgSet [$ ak ] . '"/> ' ;
52
- }
53
-
54
-
55
- $ gui ->tprojects [$ idx ]['rmsstatusImg ' ] = '' ;
56
- if ($ gui ->tprojects [$ idx ]['rmsname ' ] != '' )
57
- {
58
- $ ak = ($ gui ->tprojects [$ idx ]['reqmgr_integration_enabled ' ]) ? 'active ' : 'inactive ' ;
59
- $ gui ->tprojects [$ idx ]['rmsstatusImg ' ] = ' <img title=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
60
- ' alt=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
61
- ' src=" ' . $ imgSet [$ ak ] . '"/> ' ;
62
- }
63
- }
64
-
65
- if (count ($ gui ->tprojects ) == 0 )
66
- {
26
+ if (!is_null ($ gui ->tprojects ) || $ args ->doAction =='list ' ) {
27
+ if ( $ gui ->itemQty == 0 ) {
67
28
$ template2launch = "projectEdit.tpl " ;
68
29
$ gui ->doAction = "create " ;
69
- }
30
+ }
70
31
}
71
32
72
33
$ smarty ->assign ('gui ' ,$ gui );
77
38
*
78
39
*
79
40
*/
80
- function init_args ()
81
- {
41
+ function init_args () {
82
42
$ _REQUEST = strings_stripSlashes ($ _REQUEST );
83
43
84
44
$ args = new stdClass ();
@@ -109,16 +69,17 @@ function init_args()
109
69
*
110
70
*
111
71
*/
112
- function initializeGui (&$ dbHandler ,&$ argsObj )
113
- {
72
+ function initializeGui (&$ dbHandler ,&$ argsObj ) {
73
+
74
+ $ tplEngine = new TLSmarty ();
75
+
114
76
$ guiObj = new stdClass ();
115
77
$ guiObj ->doAction = $ argsObj ->doAction ;
116
78
$ guiObj ->canManage = $ argsObj ->user ->hasRight ($ dbHandler ,"mgt_modify_product " );
117
79
$ guiObj ->name = is_null ($ argsObj ->name ) ? '' : $ argsObj ->name ;
118
80
$ guiObj ->feedback = '' ;
119
81
120
- switch ($ argsObj ->doAction )
121
- {
82
+ switch ($ argsObj ->doAction ) {
122
83
case 'list ' :
123
84
$ filters = null ;
124
85
break ;
@@ -131,7 +92,8 @@ function initializeGui(&$dbHandler,&$argsObj)
131
92
}
132
93
133
94
$ tproject_mgr = new testproject ($ dbHandler );
134
- $ opt = array ('output ' => 'array_of_map ' , 'order_by ' => " ORDER BY name " , 'add_issuetracker ' => true ,
95
+ $ opt = array ('output ' => 'array_of_map ' , 'order_by ' => " ORDER BY name " ,
96
+ 'add_issuetracker ' => true ,
135
97
'add_codetracker ' => true , 'add_reqmgrsystem ' => true );
136
98
$ guiObj ->tprojects = $ tproject_mgr ->get_accessible_for_user ($ argsObj ->userID ,$ opt ,$ filters );
137
99
$ guiObj ->pageTitle = lang_get ('title_testproject_management ' );
@@ -141,16 +103,44 @@ function initializeGui(&$dbHandler,&$argsObj)
141
103
142
104
$ guiObj ->itemQty = count ($ guiObj ->tprojects );
143
105
144
- if ($ guiObj ->itemQty > 0 )
145
- {
106
+ if ($ guiObj ->itemQty > 0 ) {
146
107
$ guiObj ->pageTitle .= ' ' . sprintf (lang_get ('available_test_projects ' ),$ guiObj ->itemQty );
108
+
109
+ initIntegrations ($ guiObj ->tprojects ,$ guiObj ->itemQty ,$ tplEngine );
147
110
}
148
111
149
- return $ guiObj ;
112
+ return array ( $ guiObj, $ tplEngine ) ;
150
113
}
151
114
115
+ /**
116
+ *
117
+ */
118
+ function initIntegrations (&$ tprojSet ,$ tprojQty ,&$ tplEngine ) {
119
+ $ labels = init_labels (array ('active_integration ' => null ,
120
+ 'inactive_integration ' => null ));
121
+
122
+ $ imgSet = $ tplEngine ->getImages ();
123
+
124
+ $ intk = array ('it ' => 'issue ' , 'ct ' => 'code ' );
125
+ for ($ idx =0 ; $ idx < $ tprojQty ; $ idx ++) {
126
+ foreach ( $ intk as $ short => $ item ) {
127
+ $ tprojSet [$ idx ][$ short . 'statusImg ' ] = '' ;
128
+ if ($ tprojSet [$ idx ][$ short . 'name ' ] != '' ) {
129
+ $ ak = ($ tprojSet [$ idx ][$ item . '_tracker_enabled ' ]) ?
130
+ 'active ' : 'inactive ' ;
131
+ $ tprojSet [$ idx ][$ short . 'statusImg ' ] =
132
+ ' <img title=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
133
+ ' alt=" ' . $ labels [$ ak . '_integration ' ] . '" ' .
134
+ ' src=" ' . $ imgSet [$ ak ] . '"/> ' ;
135
+ }
136
+ }
137
+ }
138
+ }
139
+
152
140
153
- function checkRights (&$ db ,&$ user )
154
- {
141
+ /**
142
+ *
143
+ */
144
+ function checkRights (&$ db ,&$ user ) {
155
145
return $ user ->hasRight ($ db ,'mgt_modify_product ' );
156
146
}
0 commit comments