source: trunk/Upload/sources/dashboard.php @ 64

Revision 64, 6.1 KB checked in by someotherguy, 3 years ago (diff)

User registration, resend validation, forgot password, and reset password complete. Antispam complete.

  • Property svn:executable set to *
Line 
1<?php
2
3/*
4#======================================================
5|    <#TAG_NAME_TAG#>
6|    =====================================
7|    <#TAG_DEVELOPERS_TAG#>
8|    <#TAG_COPYRIGHT_TAG#>
9|    <#TAG_URL_TAG#>
10|    =====================================
11|    Email: <#TAG_EMAIL_TAG#>
12#======================================================
13|    @ Version: <#TAG_VER_HUMAN_TAG#>
14|    @ Version Int: <#TAG_VER_INT_TAG#>
15|    @ Version Num: <#TAG_VER_NUM_TAG#>
16|    @ Build: <#TAG_VER_BUILD_TAG#>
17#======================================================
18|    | Sources :: Dashboard
19#======================================================
20*/
21
22class td_source_dashboard {
23
24        #=======================================
25        # @ Auto Run
26        #=======================================
27
28        public function auto_run()
29        {
30                #=============================
31                # Grab News
32                #=============================
33
34                if ( $this->trellis->cache->data['settings']['news']['enable'] && $this->trellis->cache->data['settings']['news']['portal'] )
35                {
36                        $final_a = array();
37                        $row_count = 0;
38                        $news = 0;
39
40                        if ( ! empty( $this->trellis->cache->data['news'] ) )
41                        {
42                                while ( list( $id, $a ) = each( $this->trellis->cache->data['news'] ) )
43                                {
44                                        #=============================
45                                        # Fix Up Information
46                                        #=============================
47
48                                        $row_count ++;
49
50                                        ( $row_count & 1 ) ? $a['class'] = 1 : $a['class'] = 2;
51
52                                        $a['date'] = $this->trellis->td_timestamp( array( 'time' => $a['date'], 'format' => 'short' ) );
53
54                                        $final_a[] = $a;
55                                }
56
57                                $this->trellis->skin->set_var( 'news', $final_a );
58                        }
59                }
60
61                #=============================
62                # Grab Tickets
63                #=============================
64
65                if ( $this->trellis->user['g_ticket_access'] )
66                {
67                        $this->trellis->load_functions('tickets');
68
69                        if ( $this->trellis->user['id'] || $this->trellis->user['s_tkey'] )
70                        {
71                                if ( $this->trellis->user['id'] )
72                                {
73                                        $tickets = $this->trellis->func->tickets->get( array(
74                                                                                                                                   'select'     => array(
75                                                                                                                                                                         't' => array( 'id', 'mask', 'subject', 'priority', 'last_reply', 'escalated', 'status' ),
76                                                                                                                                                                         'd' => array( array( 'name' => 'dname' ) ),
77                                                                                                                                                                         'p' => array( array( 'name' => 'pname' ), 'icon_regular', 'icon_assigned' ),
78                                                                                                                                                                 's' => array( array( 'name_user' => 'status_name' ), array( 'abbr_user' => 'status_abbr' ) ),
79                                                                                                                                                                 ),
80                                                                                                                                   'from'       => array( 't' => 'tickets' ),
81                                                                                                                                   'join'       => array(
82                                                                                                                                                                 array( 'from' => array( 'd' => 'departments' ), 'where' => array( 't' => 'did', '=', 'd' => 'id' ) ),
83                                                                                                                                                                 array( 'from' => array( 'p' => 'priorities' ), 'where' => array( 't' => 'priority', '=', 'p' => 'id' ) ),
84                                                                                                                                                                 array( 'from' => array( 's' => 'statuses' ), 'where' => array( 't' => 'status', '=', 's' => 'id' ) ),
85                                                                                                                                                                 ),
86                                                                                                                                   'where'      => array( array( 't' => 'uid' ), '=', $this->trellis->user['id'] ),
87                                                                                                                                   'order'      => array( 'last_reply' => array( 't' => 'desc' ) ),
88                                                                                                                                   'limit'      => array( 0, 8 ),
89                                                                                                                        )          );
90                                }
91                                elseif ( $this->trellis->user['s_tkey'] )
92                                {
93                                        $this->trellis->db->construct( array(
94                                                                                                                         'select'       => array( 'id', 'dname', 'subject', 'priority', 'date', 'status' ),
95                                                                                                                         'from'         => 'tickets',
96                                                                                                                         'where'        => array( array( 'email', '=', $this->trellis->user['s_email'] ), array( 'guest', '=', 1, 'and' ) ),
97                                                                                                                         'order'        => array( 'date' => 'DESC' ),
98                                                                                                                         'limit'        => array( 0, 8 ),
99                                                                                                          )     );
100                                }
101
102                                $ticket_rows = array();
103                                $row_count = 0;
104
105                                if ( $tickets )
106                                {
107                                        foreach ( $tickets as $t )
108                                        {
109                                                #=============================
110                                                # Fix Up Information
111                                                #=============================
112
113                                                $row_count ++;
114
115                                                ( $row_count & 1 ) ? $t['class'] = 1 : $t['class'] = 2;
116
117                                                if ( $t['date'] ) $t['date'] = $this->trellis->td_timestamp( array( 'time' => $t['date'], 'format' => 'short' ) );
118                                                if ( $t['last_reply'] ) $t['last_reply'] = $this->trellis->td_timestamp( array( 'time' => $t['last_reply'], 'format' => 'short' ) );
119
120                                        if ( ! $t['status_abbr'] ) $t['status_abbr'] = $t['status_name'];
121
122                                                $ticket_rows[] = $t;
123                                        }
124
125                                        $this->trellis->skin->set_var( 'tickets', $ticket_rows );
126                                }
127                        }
128                }
129
130                if ( $this->trellis->cache->data['settings']['kb']['enable'] && $this->trellis->user['g_kb_access'] )
131                {
132                        #=============================
133                        # Grab Recent Articles
134                        #=============================
135
136                        $this->trellis->db->construct( array(
137                                                                                                         'select'       => array( 'id', 'title', 'description' ),
138                                                                                                         'from'         => 'articles',
139                                                                                                         'order'        => array( 'date' => 'desc' ),
140                                                                                                         'limit'        => array( 0, $this->trellis->cache->data['settings']['kb']['recent_articles_count'] ),
141                                                                                          )     );
142
143                        $this->trellis->db->execute();
144
145                        if ( $this->trellis->db->get_num_rows() )
146                        {
147                                $recent = array();
148
149                                while( $a = $this->trellis->db->fetch_row() )
150                                {
151                                        $recent[] = $a;
152                                }
153
154                                $this->trellis->skin->set_var( 'recent_articles', $recent );
155                        }
156
157                        #=============================
158                        # Grab Most Popular
159                        #=============================
160
161                        $this->trellis->db->construct( array(
162                                                                                                         'select'       => array( 'id', 'title', 'description' ),
163                                                                                                         'from'         => 'articles',
164                                                                                                         'order'        => array( 'rating' => 'desc' ),
165                                                                                                         'limit'        => array( 0, $this->trellis->cache->data['settings']['kb']['popular_articles_count'] ),
166                                                                                          )     );
167
168                        $this->trellis->db->execute();
169
170                        if ( $this->trellis->db->get_num_rows() )
171                        {
172                                $popular = array();
173
174                                while( $a = $this->trellis->db->fetch_row() )
175                                {
176                                        $popular[] = $a;
177                                }
178
179                                $this->trellis->skin->set_var( 'popular_articles', $popular );
180                        }
181                }
182
183                #=============================
184                # Do Output
185                #=============================
186
187                $this->trellis->skin->set_var( 'sub_tpl', 'dashboard.tpl' );
188
189                $this->trellis->skin->do_output( array( 'nav' => array( '<a href="'. $this->trellis->config['hd_url'] .'/index.php?page=dashboard">'. $this->trellis->lang['dashboard'] .'</a>' ) ) );
190        }
191
192}
193
194?>
Note: See TracBrowser for help on using the repository browser.