77 *
88 * @package TestLink
99 * @author TestLink community
10- * @copyright 2007-2016 , TestLink community
10+ * @copyright 2007-2019 , TestLink community
1111 * @filesource projectView.php
1212 * @link http://www.testlink.org/
1313 *
14- * @internal revisions
15- * @since 1.9.9
1614 */
1715
1816
2119testlinkInitPage ($ db ,false ,false ,"checkRights " );
2220
2321$ templateCfg = templateConfiguration ();
24-
25- $ smarty = new TLSmarty ();
26- $ imgSet = $ smarty ->getImages ();
2722$ args = init_args ();
28- $ gui = initializeGui ($ db ,$ args );
23+ list ( $ gui, $ smarty ) = initializeGui ($ db ,$ args );
2924
3025$ 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 ) {
6728 $ template2launch = "projectEdit.tpl " ;
6829 $ gui ->doAction = "create " ;
69- }
30+ }
7031}
7132
7233$ smarty ->assign ('gui ' ,$ gui );
7738 *
7839 *
7940 */
80- function init_args ()
81- {
41+ function init_args () {
8242 $ _REQUEST = strings_stripSlashes ($ _REQUEST );
8343
8444 $ args = new stdClass ();
@@ -109,16 +69,17 @@ function init_args()
10969 *
11070 *
11171 */
112- function initializeGui (&$ dbHandler ,&$ argsObj )
113- {
72+ function initializeGui (&$ dbHandler ,&$ argsObj ) {
73+
74+ $ tplEngine = new TLSmarty ();
75+
11476 $ guiObj = new stdClass ();
11577 $ guiObj ->doAction = $ argsObj ->doAction ;
11678 $ guiObj ->canManage = $ argsObj ->user ->hasRight ($ dbHandler ,"mgt_modify_product " );
11779 $ guiObj ->name = is_null ($ argsObj ->name ) ? '' : $ argsObj ->name ;
11880 $ guiObj ->feedback = '' ;
11981
120- switch ($ argsObj ->doAction )
121- {
82+ switch ($ argsObj ->doAction ) {
12283 case 'list ' :
12384 $ filters = null ;
12485 break ;
@@ -131,7 +92,8 @@ function initializeGui(&$dbHandler,&$argsObj)
13192 }
13293
13394 $ 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 ,
13597 'add_codetracker ' => true , 'add_reqmgrsystem ' => true );
13698 $ guiObj ->tprojects = $ tproject_mgr ->get_accessible_for_user ($ argsObj ->userID ,$ opt ,$ filters );
13799 $ guiObj ->pageTitle = lang_get ('title_testproject_management ' );
@@ -141,16 +103,44 @@ function initializeGui(&$dbHandler,&$argsObj)
141103
142104 $ guiObj ->itemQty = count ($ guiObj ->tprojects );
143105
144- if ($ guiObj ->itemQty > 0 )
145- {
106+ if ($ guiObj ->itemQty > 0 ) {
146107 $ guiObj ->pageTitle .= ' ' . sprintf (lang_get ('available_test_projects ' ),$ guiObj ->itemQty );
108+
109+ initIntegrations ($ guiObj ->tprojects ,$ guiObj ->itemQty ,$ tplEngine );
147110 }
148111
149- return $ guiObj ;
112+ return array ( $ guiObj, $ tplEngine ) ;
150113}
151114
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+
152140
153- function checkRights (&$ db ,&$ user )
154- {
141+ /**
142+ *
143+ */
144+ function checkRights (&$ db ,&$ user ) {
155145 return $ user ->hasRight ($ db ,'mgt_modify_product ' );
156146}
0 commit comments