@@ -36,119 +36,30 @@ function prepareDataRow($rec)
3636 $ tmp_date = date ('Y-m ' );
3737 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ? AND month = ? " , $ rec ['mailuser_id ' ], $ tmp_date );
3838 $ rec ['this_month_sort ' ] = $ tmp_rec ['t ' ];
39- // $rec['this_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
4039 $ rec ['this_month ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['t ' ]);
41- if ($ rec ['this_month ' ] == 'NAN ' ) $ rec ['this_month ' ] = '0 KB ' ;
4240
4341 //** Traffic of the current year
4442 $ tmp_date = date ('Y ' );
4543 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ? AND month like ? " , $ rec ['mailuser_id ' ], $ tmp_date . '% ' );
4644 $ rec ['this_year_sort ' ] = $ tmp_rec ['t ' ];
47- // $rec['this_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
4845 $ rec ['this_year ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['t ' ]);
49- if ($ rec ['this_year ' ] == 'NAN ' ) $ rec ['this_year ' ] = '0 KB ' ;
5046
5147 //** Traffic of the last month
5248 $ tmp_date = date ('Y-m ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
5349 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ? AND month = ? " , $ rec ['mailuser_id ' ], $ tmp_date );
5450 $ rec ['last_month_sort ' ] = $ tmp_rec ['t ' ];
55- // $rec['last_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
5651 $ rec ['last_month ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['t ' ]);
57- if ($ rec ['last_month ' ] == 'NAN ' ) $ rec ['last_month ' ] = '0 KB ' ;
5852
5953 //** Traffic of the last year
6054 $ tmp_date = date ('Y ' , mktime (0 , 0 , 0 , date ("m " ), date ("d " ), date ("Y " )-1 ));
6155 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ? AND month like ? " , $ rec ['mailuser_id ' ], $ tmp_date . '% ' );
6256 $ rec ['last_year_sort ' ] = $ tmp_rec ['t ' ];
63- // $rec['last_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
6457 $ rec ['last_year ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['t ' ]);
65- if ($ rec ['last_year ' ] == 'NAN ' ) $ rec ['last_year ' ] = '0 KB ' ;
6658
6759 //* The variable "id" contains always the index variable
6860 $ rec ['id ' ] = $ rec [$ this ->idx_key ];
6961 return $ rec ;
7062 }
71-
72- function getQueryString ($ no_limit = false ) {
73- global $ app ;
74- $ sql_where = '' ;
75-
76- //* Generate the search sql
77- if ($ app ->listform ->listDef ['auth ' ] != 'no ' ) {
78- if ($ _SESSION ['s ' ]['user ' ]['typ ' ] == "admin " ) {
79- $ sql_where = '' ;
80- } else {
81- $ sql_where = $ app ->tform ->getAuthSQL ('r ' , $ app ->listform ->listDef ['table ' ]).' and ' ;
82- //$sql_where = $app->tform->getAuthSQL('r').' and';
83- }
84- }
85- if ($ this ->SQLExtWhere != '' ) {
86- $ sql_where .= ' ' .$ this ->SQLExtWhere .' and ' ;
87- }
88-
89- $ sql_where = $ app ->listform ->getSearchSQL ($ sql_where );
90- if ($ app ->listform ->listDef ['join_sql ' ]) $ sql_where .= ' AND ' .$ app ->listform ->listDef ['join_sql ' ];
91- $ app ->tpl ->setVar ($ app ->listform ->searchValues );
92-
93- $ order_by_sql = $ this ->SQLOrderBy ;
94-
95- //* Generate SQL for paging
96- $ limit_sql = $ app ->listform ->getPagingSQL ($ sql_where );
97- $ app ->tpl ->setVar ('paging ' , $ app ->listform ->pagingHTML );
98-
99- $ extselect = '' ;
100- $ join = '' ;
101-
102- if (!empty ($ _SESSION ['search ' ][$ _SESSION ['s ' ]['module ' ]['name ' ].$ app ->listform ->listDef ["name " ].$ app ->listform ->listDef ['table ' ]]['order ' ])){
103- $ order = str_replace (' DESC ' , '' , $ _SESSION ['search ' ][$ _SESSION ['s ' ]['module ' ]['name ' ].$ app ->listform ->listDef ["name " ].$ app ->listform ->listDef ['table ' ]]['order ' ]);
104- list ($ tmp_table , $ order ) = explode ('. ' , $ order );
105- if ($ order == 'mail_traffic_last_month ' ){
106- $ tmp_date = date ('Y-m ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
107- $ join .= ' INNER JOIN mail_traffic as mt ON ' .$ app ->listform ->listDef ['table ' ].'.mailuser_id = mt.mailuser_id ' ;
108- $ sql_where .= " AND mt.month like ' $ tmp_date%' " ;
109- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.mail_traffic_last_month ' , 'traffic ' , $ order_by_sql );
110- } elseif ($ order == 'mail_traffic_this_month ' ){
111- $ tmp_date = date ('Y-m ' );
112- $ join .= ' INNER JOIN mail_traffic as mt ON ' .$ app ->listform ->listDef ['table ' ].'.mailuser_id = mt.mailuser_id ' ;
113- $ sql_where .= " AND mt.month like ' $ tmp_date%' " ;
114- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.mail_traffic_this_month ' , 'traffic ' , $ order_by_sql );
115- } elseif ($ order == 'mail_traffic_last_year ' ){
116- $ tmp_date = date ('Y ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
117- $ extselect .= ', SUM(mt.traffic) as calctraffic ' ;
118- $ join .= ' INNER JOIN mail_traffic as mt ON ' .$ app ->listform ->listDef ['table ' ].'.mailuser_id = mt.mailuser_id ' ;
119- $ sql_where .= " AND mt.month like ' $ tmp_date%' " ;;
120- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.mail_traffic_last_year ' , 'calctraffic ' , $ order_by_sql );
121- $ order_by_sql = "GROUP BY mailuser_id " .$ order_by_sql ;
122- } elseif ($ order == 'mail_traffic_this_year ' ){
123- $ tmp_date = date ('Y ' );
124- $ extselect .= ', SUM(mt.traffic) as calctraffic ' ;
125- $ join .= ' INNER JOIN mail_traffic as mt ON ' .$ app ->listform ->listDef ['table ' ].'.mailuser_id = mt.mailuser_id ' ;
126- $ sql_where .= " AND mt.month like ' $ tmp_date%' " ;
127- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.mail_traffic_this_year ' , 'calctraffic ' , $ order_by_sql );
128- $ order_by_sql = "GROUP BY mailuser_id " .$ order_by_sql ;
129- }
130- }
131-
132- if ($ this ->SQLExtSelect != '' ) {
133- if (substr ($ this ->SQLExtSelect , 0 , 1 ) != ', ' ) $ this ->SQLExtSelect = ', ' .$ this ->SQLExtSelect ;
134- $ extselect .= $ this ->SQLExtSelect ;
135- }
136-
137- $ table_selects = array ();
138- $ table_selects [] = trim ($ app ->listform ->listDef ['table ' ]).'.* ' ;
139- $ app ->listform ->listDef ['additional_tables ' ] = trim ($ app ->listform ->listDef ['additional_tables ' ]);
140- if ($ app ->listform ->listDef ['additional_tables ' ] != '' ){
141- $ additional_tables = explode (', ' , $ app ->listform ->listDef ['additional_tables ' ]);
142- foreach ($ additional_tables as $ additional_table ){
143- $ table_selects [] = trim ($ additional_table ).'.* ' ;
144- }
145- }
146- $ select = implode (', ' , $ table_selects );
147-
148- $ sql = 'SELECT ' .$ select .$ extselect .' FROM ' .$ app ->listform ->listDef ['table ' ].($ app ->listform ->listDef ['additional_tables ' ] != '' ? ', ' .$ app ->listform ->listDef ['additional_tables ' ] : '' )."$ join WHERE $ sql_where $ order_by_sql $ limit_sql " ;
149- return $ sql ;
150- }
151-
15263}
15364
15465$ list = new list_action ;
0 commit comments