1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - News * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * -------------------------------------------- * |
---|
6 | * This program is free software; you can redistribute it and/or modify it * |
---|
7 | * under the terms of the GNU General Public License as published by the * |
---|
8 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
9 | * option) any later version. * |
---|
10 | * -------------------------------------------- * |
---|
11 | * This program was sponsered by Golden Glair productions * |
---|
12 | * http://www.goldenglair.com * |
---|
13 | \**************************************************************************/ |
---|
14 | |
---|
15 | |
---|
16 | class uinews |
---|
17 | { |
---|
18 | var $start = 0; |
---|
19 | var $query = ''; |
---|
20 | var $sort = ''; |
---|
21 | var $order = ''; |
---|
22 | var $cat_id; |
---|
23 | var $template; |
---|
24 | var $bo; |
---|
25 | var $news_data; |
---|
26 | var $news_id; |
---|
27 | var $sbox; |
---|
28 | var $public_functions = array( |
---|
29 | 'write_news' => True, |
---|
30 | 'add' => True, |
---|
31 | 'edit' => True, |
---|
32 | 'delete' => True, |
---|
33 | 'delete_item' => True, |
---|
34 | 'read_news' => True, |
---|
35 | 'show_news_home' => True |
---|
36 | ); |
---|
37 | |
---|
38 | function uinews() |
---|
39 | { |
---|
40 | $this->nextmatchs = createobject('phpgwapi.nextmatchs'); |
---|
41 | $this->template = $GLOBALS['phpgw']->template; |
---|
42 | $this->bo = CreateObject('news_admin.bonews',True); |
---|
43 | $this->sbox = createObject('phpgwapi.sbox'); |
---|
44 | $this->start = $this->bo->start; |
---|
45 | $this->query = $this->bo->query; |
---|
46 | $this->order = $this->bo->order; |
---|
47 | $this->sort = $this->bo->sort; |
---|
48 | $this->cat_id = $this->bo->cat_id; |
---|
49 | } |
---|
50 | |
---|
51 | //with $default, we are called from the news form |
---|
52 | function selectlist($type,$default=false) |
---|
53 | { |
---|
54 | $link_data['menuaction'] = ($type == 'read') ? 'news_admin.uinews.read_news' : 'news_admin.uinews.write_news'; |
---|
55 | $link_data['start'] = 0; |
---|
56 | $right = ($type == 'read') ? PHPGW_ACL_READ : PHPGW_ACL_ADD; |
---|
57 | $selectlist = ($default === false) ? ('<option>' . lang($type . ' news') . '</option>') : ''; |
---|
58 | foreach($this->bo->cats as $cat) |
---|
59 | { |
---|
60 | if($this->bo->acl->is_permitted($cat['id'],$right)) |
---|
61 | { |
---|
62 | $cat_id = (int)$cat['id']; |
---|
63 | $link_data['cat_id'] = $cat_id; |
---|
64 | $selectlist .= '<option value="'; |
---|
65 | $selectlist .= $default !== False ? $cat_id : $GLOBALS['phpgw']->link('/index.php',$link_data); |
---|
66 | $selectlist .= '"'; |
---|
67 | $selectlist .= ($default === $cat_id) ? ' selected="selected"' : ''; |
---|
68 | $selectlist .= '>' . $cat['name'] . '</option>' . "\n"; |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | if (!$default) |
---|
73 | { |
---|
74 | if($type=='read' || $this->bo->acl->is_permitted('all',$right)) |
---|
75 | { |
---|
76 | $link_data['cat_id'] = 'all'; |
---|
77 | $selectlist .= '<option style="font-weight:bold" value="' . $GLOBALS['phpgw']->link('/index.php',$link_data) |
---|
78 | . '">' . lang('All news') . '</option>' . "\n"; |
---|
79 | } |
---|
80 | } |
---|
81 | return $selectlist; |
---|
82 | } |
---|
83 | |
---|
84 | function read_news() |
---|
85 | { |
---|
86 | $limit = ($GLOBALS['phpgw_info']['common']['maxmatchs'] ? $GLOBALS['phpgw_info']['common']['maxmatchs'] : 5); |
---|
87 | |
---|
88 | $news_id = get_var('news_id',Array('GET')); |
---|
89 | |
---|
90 | $news = $news_id ? array($news_id => $this->bo->get_news($news_id)) : |
---|
91 | $this->bo->get_newslist($this->cat_id,$this->start,'','',$limit,True); |
---|
92 | |
---|
93 | $this->template->set_file(array( |
---|
94 | 'main' => 'read.tpl' |
---|
95 | )); |
---|
96 | $this->template->set_block('main','news_form'); |
---|
97 | $this->template->set_block('main','row'); |
---|
98 | $this->template->set_block('main','row_empty'); |
---|
99 | |
---|
100 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
101 | echo parse_navbar(); |
---|
102 | $this->template->set_block('main','category'); |
---|
103 | $var['lang_read'] = lang('Read'); |
---|
104 | $var['lang_write'] = lang('Write'); |
---|
105 | $var['readable'] = $this->selectlist('read'); |
---|
106 | $var['maintainlink'] = (($this->cat_id != 'all') && $this->bo->acl->is_permitted($this->cat_id,PHPGW_ACL_ADD)) ? |
---|
107 | ('<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news&start=0&cat_id='.$this->cat_id) |
---|
108 | . '">' . lang('Maintain') . '</a>') : ''; |
---|
109 | $var['cat_name'] = ($this->cat_id != 'all') ? $this->bo->catbo->id2name($this->cat_id) : lang('All news'); |
---|
110 | $this->template->set_var($var); |
---|
111 | $this->template->parse('_category','category'); |
---|
112 | |
---|
113 | $this->template->set_var('icon',$GLOBALS['phpgw']->common->image('news_admin','news-corner.gif')); |
---|
114 | $this->template->set_var('icon-right',$GLOBALS['phpgw']->common->image('news_admin','news-corner-right.gif')); |
---|
115 | |
---|
116 | foreach($news as $newsitem) |
---|
117 | { |
---|
118 | $var = Array( |
---|
119 | 'subject' => $newsitem['subject'], |
---|
120 | 'submitedby' => lang('Submitted by') . ' ' . $GLOBALS['phpgw']->common->grab_owner_name($newsitem['submittedby']) . ' ' . lang('on') . ' ' . $GLOBALS['phpgw']->common->show_date($newsitem['date']), |
---|
121 | 'content' => $newsitem['content'], |
---|
122 | ); |
---|
123 | |
---|
124 | $this->template->set_var($var); |
---|
125 | $this->template->parse('rows','row',True); |
---|
126 | } |
---|
127 | if ($this->start) |
---|
128 | { |
---|
129 | $link_data['menuaction'] = 'news_admin.uinews.read_news'; |
---|
130 | $link_data['start'] = $this->start - $limit; |
---|
131 | $link_data['cat_id'] = $this->cat_id; |
---|
132 | $this->template->set_var('lesslink', |
---|
133 | '<a href="' . $GLOBALS['phpgw']->link('/index.php',$link_data) . '"><<<</a>' |
---|
134 | ); |
---|
135 | } |
---|
136 | if ($this->bo->total > $this->start + $limit) |
---|
137 | { |
---|
138 | $link_data['menuaction'] = 'news_admin.uinews.read_news'; |
---|
139 | $link_data['start'] = $this->start + $limit; |
---|
140 | $link_data['cat_id'] = $this->cat_id; |
---|
141 | $this->template->set_var('morelink', |
---|
142 | '<a href="' . $GLOBALS['phpgw']->link('/index.php',$link_data) . '">' . lang('More news') . '</a>' |
---|
143 | ); |
---|
144 | } |
---|
145 | if (! $this->bo->total) |
---|
146 | { |
---|
147 | $this->template->set_var('row_message',lang('No entries found')); |
---|
148 | $this->template->parse('rows','row_empty',True); |
---|
149 | } |
---|
150 | |
---|
151 | $this->template->pfp('_out','news_form'); |
---|
152 | } |
---|
153 | |
---|
154 | //this is currently broken |
---|
155 | function show_news_home() |
---|
156 | { |
---|
157 | $title = '<font color="#FFFFFF">'.lang('News Admin').'</font>'; |
---|
158 | $portalbox = CreateObject('phpgwapi.listbox',array( |
---|
159 | 'title' => $title, |
---|
160 | 'primary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
161 | 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
162 | 'tertiary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], |
---|
163 | 'width' => '100%', |
---|
164 | 'outerborderwidth' => '0', |
---|
165 | 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/' . ($GLOBALS['phpgw_info']['server']['template_set'] ? $GLOBALS['phpgw_info']['server']['template_set'] : 'default'), 'bg_filler') |
---|
166 | )); |
---|
167 | |
---|
168 | $app_id = $GLOBALS['phpgw']->applications->name2id('news_admin'); |
---|
169 | $GLOBALS['portal_order'][] = $app_id; |
---|
170 | |
---|
171 | $var = Array( |
---|
172 | 'up' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
173 | 'down' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
174 | 'close' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
175 | 'question' => Array('url' => '/set_box.php', 'app' => $app_id), |
---|
176 | 'edit' => Array('url' => '/set_box.php', 'app' => $app_id) |
---|
177 | ); |
---|
178 | |
---|
179 | while(list($key,$value) = each($var)) |
---|
180 | { |
---|
181 | $portalbox->set_controls($key,$value); |
---|
182 | } |
---|
183 | |
---|
184 | $newslist = $this->bo->get_newslist($cat_id); |
---|
185 | |
---|
186 | $image_path = $GLOBALS['phpgw']->common->get_image_path('news_admin'); |
---|
187 | |
---|
188 | if(is_array($newslist)) |
---|
189 | { |
---|
190 | foreach($newslist as $newsitem) |
---|
191 | { |
---|
192 | $portalbox->data[] = array( |
---|
193 | 'text' => $newsitem['subject'] . ' - ' . lang('Submitted by') . ' ' . $GLOBALS['phpgw']->common->grab_owner_name($newsitem['submittedby']) . ' ' . lang('on') . ' ' . $GLOBALS['phpgw']->common->show_date($newsitem['date']), |
---|
194 | 'link' => $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.show_news&news_id=' . $newsitem['id']) |
---|
195 | ); |
---|
196 | } |
---|
197 | } |
---|
198 | else |
---|
199 | { |
---|
200 | $portalbox->data[] = array('text' => lang('no news')); |
---|
201 | } |
---|
202 | |
---|
203 | $tmp = "\r\n" |
---|
204 | . '<!-- start News Admin -->' . "\r\n" |
---|
205 | . $portalbox->draw() |
---|
206 | . '<!-- end News Admin -->'. "\r\n"; |
---|
207 | $this->template->set_var('phpgw_body',$tmp,True); |
---|
208 | } |
---|
209 | |
---|
210 | //the following function is unmaintained |
---|
211 | function show_news_website($section='mid') |
---|
212 | { |
---|
213 | $cat_id = $_GET['cat_id']; |
---|
214 | $start = $_GET['start']; |
---|
215 | $oldnews = $_GET['oldnews']; |
---|
216 | $news_id = $_GET['news_id']; |
---|
217 | |
---|
218 | if (! $cat_id) |
---|
219 | { |
---|
220 | $cat_id = 0; |
---|
221 | } |
---|
222 | |
---|
223 | $this->template->set_file(array( |
---|
224 | '_news' => 'news_' . $section . '.tpl' |
---|
225 | )); |
---|
226 | |
---|
227 | $this->template->set_block('_news','news_form'); |
---|
228 | $this->template->set_block('_news','row'); |
---|
229 | $this->template->set_block('_news','category'); |
---|
230 | |
---|
231 | |
---|
232 | if($news_id) |
---|
233 | { |
---|
234 | $news = array($news_id => $this->bo->get_news($news_id)); |
---|
235 | } |
---|
236 | else |
---|
237 | { |
---|
238 | $news = $this->bo->get_NewsList($cat_id,$oldnews,$start,$total); |
---|
239 | } |
---|
240 | |
---|
241 | $var = Array(); |
---|
242 | |
---|
243 | $this->template->set_var('icon',$GLOBALS['phpgw']->common->image('news_admin','news-corner.gif')); |
---|
244 | $this->template->set_var('icon-right',$GLOBALS['phpgw']->common->image('news_admin','news-corner-right.gif')); |
---|
245 | |
---|
246 | foreach($news as $newsitem) |
---|
247 | { |
---|
248 | $var = Array( |
---|
249 | 'subject'=> $newsitem['subject'], |
---|
250 | 'submitedby' => lang('Submitted by') . ' ' . $GLOBALS['phpgw']->common->grab_owner_name($newsitem['submittedby']) . ' ' . lang('on') . ' ' . $GLOBALS['phpgw']->common->show_date($newsitem['date']), |
---|
251 | 'content' => nl2br($newsitem['content']) |
---|
252 | ); |
---|
253 | |
---|
254 | $this->template->set_var($var); |
---|
255 | $this->template->parse('rows','row',True); |
---|
256 | } |
---|
257 | |
---|
258 | $out = $this->template->fp('out','news_form'); |
---|
259 | |
---|
260 | if ($this->bo->total > 5 && ! $oldnews) |
---|
261 | { |
---|
262 | $link_values = array( |
---|
263 | 'menuaction' => 'news_admin.uinews.show_news', |
---|
264 | 'oldnews' => 'True', |
---|
265 | 'cat_id' => $cat_id, |
---|
266 | 'category_list' => 'True' |
---|
267 | ); |
---|
268 | |
---|
269 | $out .= '<center><a href="' . $GLOBALS['phpgw']->link('/index.php',$link_values) . '">View news archives</a></center>'; |
---|
270 | } |
---|
271 | |
---|
272 | return $out; |
---|
273 | } |
---|
274 | |
---|
275 | function add() |
---|
276 | { |
---|
277 | if($_POST['cancel']) |
---|
278 | { |
---|
279 | Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news')); |
---|
280 | return; |
---|
281 | } |
---|
282 | if($_POST['submitit']) |
---|
283 | { |
---|
284 | $this->news_data = $_POST['news']; |
---|
285 | if(!$this->news_data['subject']) |
---|
286 | { |
---|
287 | $errors[] = lang('The subject is missing.'); |
---|
288 | } |
---|
289 | if(!$this->news_data['content']) |
---|
290 | { |
---|
291 | $errors[] = lang('The news content is missing.'); |
---|
292 | } |
---|
293 | if(!is_array($errors)) |
---|
294 | { |
---|
295 | $this->news_data['date'] = (time() - $GLOBALS['phpgw']->datetime->tz_offset); |
---|
296 | |
---|
297 | $this->bo->set_dates($_POST['from'],$_POST['until'],$this->news_data); |
---|
298 | $this->news_id = $this->bo->add($this->news_data); |
---|
299 | if(!$this->news_id) |
---|
300 | { |
---|
301 | $this->message = lang('failed to add message'); |
---|
302 | } |
---|
303 | else |
---|
304 | { |
---|
305 | $this->message = lang('Message has been added'); |
---|
306 | //after having added, we must switch to edit mode instead of stay in add |
---|
307 | $this->modify('edit'); |
---|
308 | return; |
---|
309 | } |
---|
310 | } |
---|
311 | else |
---|
312 | { |
---|
313 | $this->message = $errors; |
---|
314 | } |
---|
315 | } |
---|
316 | else |
---|
317 | { |
---|
318 | $this->news_data['category'] = $this->cat_id; |
---|
319 | } |
---|
320 | $this->modify('add'); |
---|
321 | } |
---|
322 | |
---|
323 | function delete() |
---|
324 | { |
---|
325 | $news_id = $_POST['news_id'] ? $_POST['news_id'] : $_GET['news_id']; |
---|
326 | |
---|
327 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
328 | echo parse_navbar(); |
---|
329 | $this->template->set_file(array( |
---|
330 | 'form' => 'admin_delete.tpl' |
---|
331 | )); |
---|
332 | $this->template->set_var('lang_message',lang('Are you sure you want to delete this entry ?')); |
---|
333 | $this->template->set_var('lang_yes',lang('Yes')); |
---|
334 | $this->template->set_var('lang_no',lang('No')); |
---|
335 | |
---|
336 | $this->template->set_var('link_yes',$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.delete_item&news_id=' . $news_id)); |
---|
337 | $this->template->set_var('link_no',$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news')); |
---|
338 | |
---|
339 | $this->template->pfp('_out','form'); |
---|
340 | } |
---|
341 | |
---|
342 | function delete_item() |
---|
343 | { |
---|
344 | $item = (int)get_var('news_id',array('GET','POST')); |
---|
345 | if($item) |
---|
346 | { |
---|
347 | $this->bo->delete($item); |
---|
348 | $msg = lang('Item has been deleted'); |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | $msg = lang('Item not found'); |
---|
353 | } |
---|
354 | $this->write_news($msg); |
---|
355 | } |
---|
356 | |
---|
357 | function edit() |
---|
358 | { |
---|
359 | $this->news_data = $_POST['news']; |
---|
360 | $this->news_id = (isset($_GET['news_id']) ? $_GET['news_id'] : $_POST['news']['id']); |
---|
361 | |
---|
362 | if($_POST['cancel']) |
---|
363 | { |
---|
364 | if(isset($this->news_data['category'])) |
---|
365 | { |
---|
366 | Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news&cat_id='.$this->news_data['category'])); |
---|
367 | return; |
---|
368 | } |
---|
369 | else |
---|
370 | { |
---|
371 | Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.write_news')); |
---|
372 | return; |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | if(is_array($this->news_data)) |
---|
377 | { |
---|
378 | if(!$this->news_data['subject']) |
---|
379 | { |
---|
380 | $errors[] = lang('The subject is missing'); |
---|
381 | } |
---|
382 | if(!$this->news_data['content']) |
---|
383 | { |
---|
384 | $errors[] = lang('The news content is missing'); |
---|
385 | } |
---|
386 | |
---|
387 | if(!is_array($errors)) |
---|
388 | { |
---|
389 | $this->bo->set_dates($_POST['from'],$_POST['until'],$this->news_data); |
---|
390 | $this->bo->edit($this->news_data); |
---|
391 | $this->message = lang('News item has been updated'); |
---|
392 | } |
---|
393 | else |
---|
394 | { |
---|
395 | $this->message = $errors; |
---|
396 | } |
---|
397 | } |
---|
398 | else |
---|
399 | { |
---|
400 | $this->news_data = $this->bo->get_news($this->news_id,True); |
---|
401 | $this->news_data['date_d'] = date('j',$this->news_data['begin']); |
---|
402 | $this->news_data['date_m'] = date('n',$this->news_data['begin']); |
---|
403 | $this->news_data['date_y'] = date('Y',$this->news_data['begin']); |
---|
404 | } |
---|
405 | $this->modify(); |
---|
406 | } |
---|
407 | |
---|
408 | function modify($type = 'edit') |
---|
409 | { |
---|
410 | $this->news_data['is_html'] = ($type == 'add' ? '1' : $this->news_data['is_html'] ); |
---|
411 | $options = $this->bo->get_options($this->news_data); |
---|
412 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
413 | echo parse_navbar(); |
---|
414 | |
---|
415 | $this->template->set_file(array( |
---|
416 | 'form' => 'admin_form.tpl' |
---|
417 | )); |
---|
418 | |
---|
419 | if(is_array($this->message)) |
---|
420 | { |
---|
421 | $this->template->set_var('errors',$GLOBALS['phpgw']->common->error_list($this->message)); |
---|
422 | } |
---|
423 | elseif($this->message) |
---|
424 | { |
---|
425 | $this->template->set_var('errors',$this->message); |
---|
426 | } |
---|
427 | |
---|
428 | $category_list = $this->selectlist('write', (int)$this->news_data['category']); |
---|
429 | |
---|
430 | if ($category_list == '') |
---|
431 | $this->deny(); |
---|
432 | |
---|
433 | $this->template->set_var('lang_header',lang($type . ' news item')); |
---|
434 | $this->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php', |
---|
435 | array('menuaction' => 'news_admin.uinews.'.$type, |
---|
436 | 'news_id' => $this->news_id |
---|
437 | ) |
---|
438 | ) |
---|
439 | ); |
---|
440 | |
---|
441 | $ckeditor = '<script type="text/javascript" src="./library/ckeditor/ckeditor.js"></script> |
---|
442 | <textarea cols="80" id="news[content]" name="news[content]" rows="10">' . $this->news_data['content'] . '</textarea> |
---|
443 | <script type="text/javascript"> CKEDITOR.replace( \'news[content]\',{ |
---|
444 | removePlugins : \'elementspath\', |
---|
445 | skin : \'moono_blue\', |
---|
446 | toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print", |
---|
447 | "Undo","Redo","-","Find","Replace","-","SelectAll" ], |
---|
448 | ["Table","HorizontalRule","SpecialChar","PageBreak","-","Bold", |
---|
449 | "Italic","Underline","Smiley","Strike","-","Subscript","Superscript", |
---|
450 | "NumberedList","BulletedList","-","Outdent","Indent","Blockquote", |
---|
451 | "JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock", |
---|
452 | "Link", "TextColor","BGColor","Maximize"], |
---|
453 | ["Styles","Format","Font","FontSize"]] |
---|
454 | });</script>'; |
---|
455 | |
---|
456 | $this->template->set_var(array( |
---|
457 | 'form_button' => '<input type="submit" name="submitit" value="' . lang('save') . '">', |
---|
458 | 'value_id' => $this->news_id, |
---|
459 | 'done_button' => '<input type="submit" name="cancel" value="' . lang('Done') . '">', |
---|
460 | 'label_subject' => lang('subject') . ':', |
---|
461 | 'value_subject' => '<input name="news[subject]" autocomplete="off" size="60" value="' . @htmlspecialchars($this->news_data['subject'],ENT_COMPAT,$GLOBALS['phpgw']->translation->charset()) . '">', |
---|
462 | 'label_teaser' => lang('teaser') . ':', |
---|
463 | 'value_teaser' => '<input name="news[teaser]" autocomplete="off" size="60" value="' . @htmlspecialchars($this->news_data['teaser'],ENT_COMPAT,$GLOBALS['phpgw']->translation->charset()) . '" maxLength="100">', |
---|
464 | 'label_content' => lang('Content') . ':', |
---|
465 | 'value_content' => $ckeditor, |
---|
466 | 'label_category' => lang('Category') . ':', |
---|
467 | 'value_category' => '<select name="news[category]">' . $this->selectlist('write', (int)$this->news_data['category']) . '</select>', |
---|
468 | 'label_visible' => lang('Visible') . ':', |
---|
469 | 'value_begin_d' => $this->sbox->getDays('news[begin_d]',date('j',$this->news_data['begin'])), |
---|
470 | 'value_begin_m' => $this->sbox->getMonthText('news[begin_m]',date('n',$this->news_data['begin'])), |
---|
471 | 'value_begin_y' => $this->sbox->getYears('news[begin_y]',date('Y',$this->news_data['begin']),date('Y')), |
---|
472 | 'select_from' => $options['from'], |
---|
473 | 'select_until' => $options['until'], |
---|
474 | 'value_end_d' => $this->sbox->getDays('news[end_d]',date('j',$this->news_data['end'])) , |
---|
475 | 'value_end_m' => $this->sbox->getMonthText('news[end_m]',date('n',$this->news_data['end'])), |
---|
476 | 'value_end_y' => $this->sbox->getYears('news[end_y]',date('Y',$this->news_data['end']),date('Y')), |
---|
477 | 'label_is_html' => lang('Contains HTML'), |
---|
478 | 'value_is_html' => '<input type="checkbox" value="1" name="news[is_html]" ' . ($this->news_data['is_html'] ? ' checked="1"' : '') .'>', |
---|
479 | )); |
---|
480 | |
---|
481 | $this->template->pfp('out','form'); |
---|
482 | } |
---|
483 | |
---|
484 | function write_news($message = '') |
---|
485 | { |
---|
486 | $this->template->set_file(array( |
---|
487 | 'main' => 'write.tpl' |
---|
488 | )); |
---|
489 | $this->template->set_block('main','list'); |
---|
490 | $this->template->set_block('main','row'); |
---|
491 | $this->template->set_block('main','row_empty'); |
---|
492 | |
---|
493 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
494 | echo parse_navbar(); |
---|
495 | |
---|
496 | $category_list = $this->selectlist('write', (int)$this->news_data['category']); |
---|
497 | if ($category_list == '') |
---|
498 | $this->deny(); |
---|
499 | |
---|
500 | $this->template->set_block('main','category'); |
---|
501 | $var['lang_read'] = lang('Read'); |
---|
502 | $var['lang_write'] = lang('Write'); |
---|
503 | $var['readable'] = $this->selectlist('read'); |
---|
504 | $var['cat_name'] = $this->cat_id ? $this->bo->catbo->id2name($this->cat_id) : lang('Global news'); |
---|
505 | |
---|
506 | $this->template->set_var($var); |
---|
507 | $this->template->parse('_category','category'); |
---|
508 | |
---|
509 | if ($message) |
---|
510 | { |
---|
511 | $this->template->set_var('message',$message); |
---|
512 | } |
---|
513 | |
---|
514 | $this->template->set_var('header_date',$this->nextmatchs->show_sort_order($this->sort,'news_date',$this->order,'/index.php',lang('Date'),'&menuaction=news_admin.uinews.write_news')); |
---|
515 | $this->template->set_var('header_subject',$this->nextmatchs->show_sort_order($this->sort,'news_subject',$this->order,'/index.php',lang('Subject'),'&menuaction=news_admin.uinews.write_news')); |
---|
516 | $this->template->set_var('header_status',lang('Visible')); |
---|
517 | $this->template->set_var('header_edit',lang('Edit')); |
---|
518 | $this->template->set_var('header_delete',lang('Delete')); |
---|
519 | $this->template->set_var('header_view',lang('View')); |
---|
520 | |
---|
521 | $items = $this->bo->get_newslist($this->cat_id,$this->start,$this->order,$this->sort); |
---|
522 | |
---|
523 | $left = $this->nextmatchs->left('/index.php',$this->start,$this->bo->total,'menuaction=news_admin.uinews.write_news'); |
---|
524 | $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->total,'menuaction=news_admin.uinews.write_news'); |
---|
525 | |
---|
526 | $this->template->set_var(array( |
---|
527 | 'left' => $left, |
---|
528 | 'right' => $right, |
---|
529 | 'lang_showing' => $this->nextmatchs->show_hits($this->bo->total,$this->start), |
---|
530 | )); |
---|
531 | |
---|
532 | foreach($items as $item) |
---|
533 | { |
---|
534 | $this->nextmatchs->template_alternate_row_color($this->template); |
---|
535 | $this->template->set_var('row_date',$GLOBALS['phpgw']->common->show_date($item['date'])); |
---|
536 | if(strlen($item['news_subject']) > 40) |
---|
537 | { |
---|
538 | $subject = $GLOBALS['phpgw']->strip_html(substr($item['subject'],40,strlen($item['subject']))); |
---|
539 | } |
---|
540 | else |
---|
541 | { |
---|
542 | $subject = $GLOBALS['phpgw']->strip_html($item['subject']); |
---|
543 | } |
---|
544 | $this->template->set_var('row_subject',$subject); |
---|
545 | $this->template->set_var('row_status',$this->bo->get_visibility($item)); |
---|
546 | |
---|
547 | $this->template->set_var('row_view','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.read_news&news_id=' . $item['id']) . '">' . lang('View') . '</a>'); |
---|
548 | $this->template->set_var('row_edit','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.edit&news_id=' . $item['id']) . '">' . lang('Edit') . '</a>'); |
---|
549 | $this->template->set_var('row_delete','<a href="' . $GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.delete&news_id=' . $item['id']) . '">' . lang('Delete') . '</a>'); |
---|
550 | |
---|
551 | $this->template->parse('rows','row',True); |
---|
552 | } |
---|
553 | |
---|
554 | if(!$this->bo->total) |
---|
555 | { |
---|
556 | $this->nextmatchs->template_alternate_row_color($this->template); |
---|
557 | $this->template->set_var('row_message',lang('No entries found')); |
---|
558 | $this->template->parse('rows','row_empty',True); |
---|
559 | } |
---|
560 | |
---|
561 | $this->template->set_var('link_add',$GLOBALS['phpgw']->link('/index.php','menuaction=news_admin.uinews.add')); |
---|
562 | $this->template->set_var('lang_add',lang('Add new news')); |
---|
563 | |
---|
564 | $this->template->pfp('out','list'); |
---|
565 | } |
---|
566 | |
---|
567 | function deny() |
---|
568 | { |
---|
569 | echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; |
---|
570 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
571 | } |
---|
572 | |
---|
573 | } |
---|
574 | ?> |
---|