source: extensions/NBC_News/trunk/admin/news_admin.php @ 5179

Last change on this file since 5179 was 5179, checked in by Eric, 14 years ago

[NBC_News]

  • Initial commit for Piwigo 2.0.x : Not fully functionnal and a lot work to do...
  • Property svn:eol-style set to LF
File size: 24.1 KB
Line 
1<?php
2
3global $user, $lang, $conf, $errors, $template, $page;
4
5if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
6// +-----------------------------------------------------------------------+
7// | Check Access and exit when user status is not ok                      |
8// +-----------------------------------------------------------------------+
9check_status(ACCESS_ADMINISTRATOR);
10
11//ini_set('error_reporting', E_ALL);
12//ini_set('display_errors', true);
13
14include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
15include_once (PHPWG_ROOT_PATH.'include/functions.inc.php');
16include_once (PHPWG_ROOT_PATH.'/include/constants.php');
17include_once (NBC_NEWS_PATH.'include/constants.php');
18include_once (NBC_NEWS_PATH.'include/functions_news.inc.php');
19
20load_language('plugin.lang', NBC_NEWS_PATH);
21
22$my_base_url = get_admin_plugin_menu_link(__FILE__);
23
24$conf_nbc_News = explode(";" , $conf['nbc_News']);
25$conf['nb_news_homepage'] = $conf_nbc_News[0];
26$conf['nb_news_page'] = $conf_nbc_News[1];
27$conf['nb_news_page_option'] = explode("," ,$conf_nbc_News[2]);
28
29
30// +-----------------------------------------------------------------------+
31// |                            Tabssheet                                  |
32// +-----------------------------------------------------------------------+
33if (!isset($_GET['tab']))
34        $page['tab'] = 'NewsAdmin';
35else
36  $page['tab'] = $_GET['tab'];
37
38$tabsheet = new tabsheet();
39$tabsheet->add('NewsAdmin',
40               l10n('title_admin_news'),
41               $my_base_url.'&amp;tab=NewsAdmin');
42$tabsheet->add('Users',
43               l10n('title_users'),
44               $my_base_url.'&amp;tab=Users');
45$tabsheet->add('Groups',
46               l10n('title_groups'),
47               $my_base_url.'&amp;tab=Groups');
48$tabsheet->add('Config',
49               l10n('config'),
50               $my_base_url.'&amp;tab=Config');
51$tabsheet->select($page['tab']);
52$tabsheet->assign();
53
54$page['NewsAdmin'] = array();
55$error = array();
56
57
58// +-----------------------------------------------------------------------+
59// |                            Tabssheet select                           |
60// +-----------------------------------------------------------------------+
61
62switch ($page['tab'])
63{
64// *************************************************************************
65// +-----------------------------------------------------------------------+
66// |                             NewsAdmin                                 |
67// +-----------------------------------------------------------------------+
68// *************************************************************************
69  case 'NewsAdmin':
70 
71  $page_news_admin = get_admin_plugin_menu_link(dirname(__FILE__).'/news_admin.php');
72
73  // detection of the start news to display
74  if ( !isset( $_GET['start'] )
75       or !is_numeric( $_GET['start'] )
76       or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
77  {
78    $page['start'] = 0;
79  }
80  else
81  {
82    $page['start'] = $_GET['start'];
83  }
84 
85  // detection of the number of news to display per page
86  if ( !isset( $_GET['nb_news_page'] ) or !is_numeric( $_GET['nb_news_page'] ) or ( is_numeric( $_GET['nb_news_page'] ) and $_GET['nb_news_page'] < 0 ) )
87  {
88    $page['nb_news_page'] = $conf['nb_news_page'];
89  }
90  else
91  {
92    $page['nb_news_page'] = $_GET['nb_news_page'];
93  }
94 
95  // +-----------------------------------------------------------------------+
96  // |                           news management                             |
97  // +-----------------------------------------------------------------------+
98 
99  //
100  // GET
101  //
102 
103  //delete a translation
104  if ( isset($_GET['action']) and ($_GET['action']=='delt') and isset($_GET['idt']) and is_numeric($_GET['idt']) and !is_adviser() )
105  {
106    //get new_id
107    $query = '
108    SELECT new_id
109      FROM '.NEWS_TRANSLATION_TABLE.'
110      WHERE id = \''.$_GET['idt'].'\'
111    ;';
112    $result = pwg_query($query);
113    $row = mysql_fetch_array($result);
114    $new_id=$row['new_id'];
115   
116    //delete news_translation
117        $query = '
118    DELETE FROM '.NEWS_TRANSLATION_TABLE.'
119    WHERE id = \''.$_GET['idt'].'\'
120    ;';
121    pwg_query($query);
122 
123    //get others translations of the news
124    $query = '
125    SELECT id
126    FROM '.NEWS_TRANSLATION_TABLE.'
127    WHERE new_id = \''.$new_id.'\'
128    ;';
129    $result = pwg_query($query);
130 
131    //if there is no others translations, delete the news
132    if (mysql_num_rows ($result) <= 0)
133    {
134      $query = '
135      DELETE FROM '.NEWS_TABLE.'
136      WHERE id = \''.$new_id.'\'
137      ;';
138      pwg_query($query);
139   
140        $query = '
141      DELETE FROM '.NEWS_TRANSLATION_TABLE.'
142      WHERE new_id = \''.$new_id.'\'
143      ;';
144      pwg_query($query);
145   
146      $query = '
147      DELETE FROM '.NEWS_GROUP_ACCESS_TABLE.'
148      WHERE new_id = \''.$new_id.'\'
149      ;';
150      pwg_query($query);
151   
152      $query = '
153      DELETE FROM '.NEWS_USER_ACCESS_TABLE.'
154      WHERE new_id = \''.$new_id.'\'
155      ;';
156      pwg_query($query);
157   
158      $query = '
159      DELETE FROM '.NEWS_GROUP_REFUSED_TABLE.'
160      WHERE new_id = \''.$new_id.'\'
161      ;';
162      pwg_query($query);
163   
164      $query = '
165      DELETE FROM '.NEWS_USER_REFUSED_TABLE.'
166      WHERE new_id = \''.$new_id.'\'
167      ;';
168      pwg_query($query);
169   
170      // information message
171      array_push($page['infos'], $lang['news_deleted']);
172    }
173    else
174    {
175          // information message
176      array_push($page['infos'], $lang['translation_deleted']);
177    }
178  }
179  //delete a news
180  else if ( isset($_GET['action']) and ($_GET['action']=='deln') and isset($_GET['idn']) and is_numeric($_GET['idn']) and !is_adviser() )
181  {
182    $query = '
183    DELETE FROM '.NEWS_TABLE.'
184    WHERE id = \''.$_GET['idn'].'\'
185    ;';
186    pwg_query($query);
187 
188        $query = '
189    DELETE FROM '.NEWS_TRANSLATION_TABLE.'
190    WHERE new_id = \''.$_GET['idn'].'\'
191    ;';
192    pwg_query($query);
193 
194    $query = '
195    DELETE FROM '.NEWS_GROUP_ACCESS_TABLE.'
196    WHERE new_id = \''.$_GET['idn'].'\'
197    ;';
198    pwg_query($query);
199 
200    $query = '
201    DELETE FROM '.NEWS_USER_ACCESS_TABLE.'
202    WHERE new_id = \''.$_GET['idn'].'\'
203    ;';
204    pwg_query($query);
205 
206    $query = '
207    DELETE FROM '.NEWS_GROUP_REFUSED_TABLE.'
208    WHERE new_id = \''.$_GET['idn'].'\'
209    ;';
210    pwg_query($query);
211 
212    $query = '
213    DELETE FROM '.NEWS_USER_REFUSED_TABLE.'
214    WHERE new_id = \''.$_GET['idn'].'\'
215    ;';
216    pwg_query($query);
217 
218    // information message
219    array_push($page['infos'], $lang['news_deleted']);
220  }
221  //
222  // POST
223  //
224 
225  //add translation
226  if (isset($_POST['addt']) and isset( $_POST['content'] ) and !empty($_POST['content']) and !is_adviser() )
227  {
228    $message=$_POST['content'];
229 
230    $query = '
231    INSERT INTO '.NEWS_TRANSLATION_TABLE.'
232    (new_id, language, title, content) VALUES (
233    '.$_POST['idn'].',
234    \''.$_POST['language'].'\',
235    \''.$_POST['title'].'\',
236    \''.$message.'\'
237    );';
238    pwg_query( $query );
239 
240    // information message
241    array_push($page['infos'], $lang['translation_added']);
242  }
243  //mod translation
244  else if (isset($_POST['modt']) and isset( $_POST['content'] ) and !empty($_POST['content']) and !is_adviser() )
245  {
246    $message=$_POST['content'];
247 
248    $query = '
249    UPDATE '.NEWS_TRANSLATION_TABLE.'
250    SET language=\''.$_POST['language'].'\',
251    title=\''.$_POST['title'].'\',
252    content=\''.$message.'\'
253    WHERE id=\''.$_POST['idt'].'\'
254    ;';
255    pwg_query( $query );
256 
257    // information message
258    array_push($page['infos'], $lang['translation_altered']);           
259  }
260  //add news
261  else if (isset($_POST['addn']) and isset( $_POST['content'] ) and !empty($_POST['content']) and !is_adviser() )
262  {
263    $message=$_POST['content'];
264 
265    $query = '
266    INSERT INTO '.NEWS_TABLE.'
267    (date, author) VALUES (
268    NOW(),
269    \''.$_POST['author'].'\'
270    );';
271    pwg_query( $query );
272 
273    $query = '
274    INSERT INTO '.NEWS_TRANSLATION_TABLE.'
275    (new_id, language, title, content) VALUES (
276    LAST_INSERT_ID(),
277    \''.$_POST['language'].'\',
278    \''.$_POST['title'].'\',
279    \''.$message.'\'
280    );';
281    pwg_query( $query );
282  //  \''.htmlspecialchars($_POST['title'], ENT_QUOTES).'\',
283 
284    // information message
285    array_push($page['infos'], $lang['news_added']);
286 
287    $page['start']=0;
288  }
289  else if (isset($_POST['change_status_submit']) and isset($_POST['idn']) and !is_adviser() )
290  {
291    $query = '
292    SELECT *
293      FROM '.NEWS_TABLE.'
294      WHERE id=\''.$_POST['idn'].'\'
295    ;';
296   
297    $result = pwg_query($query);
298    $row = mysql_fetch_array($result);
299 
300    $status = ($row['status']=='private')?'public':'private';
301   
302    $query = '
303    UPDATE '.NEWS_TABLE.'
304    SET status=\''.$status.'\'
305    WHERE id=\''.$_POST['idn'].'\'
306    ;';
307    pwg_query( $query );
308 
309    // information message
310    array_push($page['infos'], $lang['news_status_changed'].$lang[$status]);
311  }
312 
313 
314 
315  // +-----------------------------------------------------------------------+
316  // |                       page header and options                         |
317  // +-----------------------------------------------------------------------+
318
319  $template->assign(
320    array(
321      'F_ACTION' => add_url_params($page_news_admin, array()),
322      'U_POST_NEWS' => add_url_params($page_news_admin, array('action' => 'addn')),
323      /*'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=news_admin',*/
324      'U_NEWS' => add_url_params($page_news_admin, array(
325        'nb_news_page' => $page['nb_news_page'],
326        'start' => $page['start'],
327        )
328      ),
329    )
330  );
331 
332   // +-----------------------------------------------------------------------+
333  // |                        DISPLAY FORMS                                  |
334  // +-----------------------------------------------------------------------+
335 
336  //
337  //display form to add news
338  //
339  if (isset($_GET['action']) and $_GET['action']=='addn')
340  {
341     //donne le titre ajouter une news dans h2
342   
343    $template->assign('new_news',array());
344    //get every languages
345    $available_lang=get_languages();
346   
347        $lang_select=news_language_select($available_lang,$user['language']);
348 
349        $template->assign(
350      'form',
351      array(
352        'AUTHOR'=>$user['username'],
353        'LANG_SELECT'=>$lang_select,
354        'SUBMIT_NAME' =>'addn'
355      )
356    ); 
357  }
358 
359  //
360  //display form to add a translation
361  //
362  else if (isset($_GET['action']) and $_GET['action']=='addt' and isset($_GET['idn']) and is_numeric($_GET['idn'])
363  )
364  {
365    //donne le titre ajouter une news dans h2
366   
367    $template->assign('news_translation',array());
368     
369    //get every languages
370    $available_lang=get_languages();
371    $not_translated_languages=$available_lang;
372 
373    //display author and date
374    $query = '
375    SELECT DISTINCT(id) AS new_id, date, author
376      FROM '.NEWS_TABLE.'
377      WHERE id=\''.$_GET['idn'].'\'
378    ;';
379   
380    $result = pwg_query($query);
381    $row = mysql_fetch_array($result);
382   
383    $template->assign(
384      'news',
385      array(
386        'NEWS_AUTHOR'=>$row['author'],
387        'NEWS_DATE'=>format_date($row['date'],'mysql_datetime',true),
388      )
389    );
390       
391    //display the news translations
392    $query = '
393    SELECT id AS news_translation_id,language,title,content
394      FROM '.NEWS_TRANSLATION_TABLE.'
395      WHERE new_id = \''.$_GET['idn'].'\'
396    ;';
397 
398    $subresult = pwg_query($query);
399   
400    while ($subrow = mysql_fetch_array($subresult))
401    {
402      //ready for bbcode
403      $message=preg_replace('/\:[0-9a-z\:]+\]/si', ']', $subrow['content']);
404      $message = str_replace("\n", "\n<br />\n", $message);
405     
406      $template->assign(
407        'news.news_translation',
408        array(
409          'TITLE'=>$subrow['title'],
410          'CONTENT'=>$message,
411          'LANG_TITLE' => ucwords($available_lang[$subrow['language']]),
412        )
413      );   
414     
415      //delete language from not translated languages table
416      $keys_indexes=array_flip(array_keys($not_translated_languages));
417      array_splice ($not_translated_languages, $keys_indexes[$subrow['language']],1);
418    }
419       
420        $lang_select=news_language_select($not_translated_languages,$user['language']);
421 
422    $template->assign(
423      'form',
424      array(
425        'new_id'=>$_GET['idn'],
426        'LANG_SELECT'=>$lang_select,
427        'SUBMIT_NAME' =>'addt'
428      )
429    ); 
430  }
431 
432  //
433  //display form to alter a translation
434  //
435  else if (isset($_GET['action']) and $_GET['action']=='modt' and isset($_GET['idt']) and is_numeric($_GET['idt']))
436  {
437    //donne le titre edit news dans h2
438   
439    $template->assign('title_edit_news',array());
440    //get every languages
441    $available_lang=get_languages();
442    $not_translated_languages=$available_lang;
443       
444    //get the news translation
445    $query = '
446    SELECT id AS news_translation_id,language,title,content,new_id
447     FROM '.NEWS_TRANSLATION_TABLE.'
448     WHERE id = \''.$_GET['idt'].'\'
449    ;';
450 
451    $result = pwg_query($query);
452    $row = mysql_fetch_array($result);
453 
454    //
455    //display author and date
456    //
457    $query = '
458    SELECT DISTINCT(id) AS new_id, date, author
459     FROM '.NEWS_TABLE.'
460     WHERE id=\''.$row['new_id'].'\'
461    ;';
462 
463    $subresult = pwg_query($query);
464    $subrow = mysql_fetch_array($subresult);
465   
466    //
467   //display the news translations
468   //
469    $query = '
470    SELECT id AS news_translation_id,language,title,content
471     FROM '.NEWS_TRANSLATION_TABLE.'
472     WHERE new_id = \''.$row['new_id'].'\'
473     AND id!=\''.$_GET['idt'].'\'
474    ;';
475
476    while ($subrow = mysql_fetch_array($subresult))
477    {
478      //if ($_GET['idt']!=$subrow['news_translation_id'])
479      //{
480      $message=preg_replace('/\:[0-9a-z\:]+\]/si', ']', $subrow['content']);
481      $message = str_replace("\n", "\n<br />\n", $message);
482         
483      $template->assign(
484        'news.news_translation',
485        array(
486          'TITLE'=>$subrow['title'],
487          'CONTENT'=>$message,
488          'LANG_TITLE' => ucwords($available_lang[$subrow['language']]),
489        )
490      );   
491 
492      //delete language from not translated languages table
493      $keys_indexes=array_flip(array_keys($not_translated_languages));
494      array_splice ($not_translated_languages, $keys_indexes[$subrow['language']],1);
495    }
496 
497    $query = '
498    SELECT *
499      FROM '.NEWS_TRANSLATION_TABLE.'
500      WHERE id = \''.$_GET['idt'].'\'
501    ;';
502 
503    $category = mysql_fetch_array( pwg_query( $query ) );
504    $form_action = add_url_params($page_news_admin, array('new_id' => $_GET['idt']));
505   
506    //get every languages
507    $lang_select=news_language_select($not_translated_languages,$row['language']);
508   
509    $message=preg_replace('/\:[0-9a-z\:]+\]/si', ']', $row['content']);
510
511    $template->assign(
512      'form',
513      array(
514        'NEWS_TRANSLATION_ID'=>$_GET['idt'],
515        'LANG_SELECT'=>$lang_select,
516        'TITLE'=> $row['title'],
517        'CONTENT'=> $message,
518        'SUBMIT_NAME' =>'modt',
519      )
520    );
521  }
522   
523  //
524  // display news
525  //
526  else
527  {
528    $template->assign('adminnews',array());
529 
530    // +-----------------------------------------------------------------------+
531    // |               news per pages & nav bar display                        |
532    // +-----------------------------------------------------------------------+
533   
534    //get number of news
535 
536    // Nombre de news
537    $query = '
538                SELECT COUNT(DISTINCT(id)) as nb_news
539                FROM '.NEWS_TABLE.'
540        ;';             
541       
542    $result = pwg_query($query);
543 
544    $row = mysql_fetch_array($result);
545    $page['nb_news']=$row['nb_news'];
546 
547    //display number of news per page link
548   
549    $template->assign('adminnews.news_per_page',array());
550     
551    foreach ($conf['nb_news_page_option'] as $option)
552    {
553      $template->assign(
554        'adminnews.news_per_page.nb_option',
555        array(
556          'OPTION' => $option,
557          'T_STYLE' => ($option == $page['nb_news_page'])?'text-decoration:underline;':'',
558          'U_OPTION' => add_url_params($page_news_admin, array('nb_news_page' => $option)),
559        )
560      );
561    }
562   
563    //display nav bar
564    $page['navigation_bar'] = create_navigation_bar( add_url_params($page_news_admin, array('nb_news_page' => $page['nb_news_page'])), $page['nb_news'],$page['start'],$page['nb_news_page'], false );
565   
566    $template->assign(
567      'adminnews.navigation',
568      array(
569        'NAV_BAR' => $page['navigation_bar']
570      )
571    );
572   
573    // +-----------------------------------------------------------------------+
574    // |                          last news display                            |
575    // +-----------------------------------------------------------------------+
576   
577    //get every languages
578    $available_lang=get_languages();
579 
580    $query = '
581                SELECT DISTINCT(id) AS new_id, date, author, status
582                FROM '.NEWS_TABLE.'
583                ORDER BY date DESC
584                LIMIT '.$page['start'].','.$page['nb_news_page'].'             
585        ;';
586 
587    $result = pwg_query($query);
588 
589    while ($row = mysql_fetch_array($result))
590    {
591      $new_id = $row['new_id'];
592 
593      $template->assign(
594      'news',
595        array(
596          'NEWS_AUTHOR' => $row['author'],
597          'NEWS_DATE'   => format_date($row['date'],'mysql_datetime',true),
598          'STATUS_NEWS' => $lang[$row['status']],
599          'NEW_ID'      => $row['new_id'],
600          'U_NEWS_DELETE' => add_url_params($page_news_admin, array(
601            'action' => 'deln',
602            'idn' => $row['new_id'],
603          )),
604      )
605      );
606   
607      //get the news translation
608      $query = '
609      SELECT id AS news_translation_id,language,title,content
610        FROM '.NEWS_TRANSLATION_TABLE.'
611        WHERE new_id = \''.$new_id.'\'
612      ';
613     
614      $no_news_translation = false;
615     
616      //get every translations                         
617      $subresult = pwg_query($query);
618 
619      $not_translated_languages=$available_lang;
620         
621      //show every translation
622      while ($subrow = mysql_fetch_array($subresult))
623      {
624        $message=$subrow['content'];
625         
626        $template->assign(
627          'news.news_translation',
628          array(
629            'TITLE'=>$subrow['title'],
630            'CONTENT'=>$message,
631            'LANG_TITLE' => ucwords($subrow['language']),
632            'U_MODIFY' => add_url_params($page_news_admin, array(
633              'action' => 'modt',
634              'idt' => $subrow['news_translation_id'],
635            )),
636            'U_DELETE' => add_url_params($page_news_admin, array(
637              'action' => 'delt',
638              'idt' => $subrow['news_translation_id'],
639            )),
640          )
641        );     
642 
643        //delete language from not translated languages table
644        //$keys_indexes=array_flip(array_keys($not_translated_languages));
645        //array_splice ($not_translated_languages, $keys_indexes[$subrow['language']],1);
646      }
647 
648      //news not translated in every languages
649      if (count($not_translated_languages) > 0)
650      {
651        $template->assign(
652          'news.translate',
653          array(
654            'ICONPATH' => NBC_NEWS_PATH . 'template/icon',
655            'U_TRANSLATE' => add_url_params($page_news_admin, array(
656              'action' => 'addt',
657              'idn' => $new_id,
658            )),
659          )
660        );
661      }
662       
663      if ($row['status'] == 'private')
664      { 
665        $template->assign(
666          'news.perm',
667          array(
668            'U_PERM' => add_url_params(get_admin_plugin_menu_link(dirname(__FILE__).'/news_perm.php'), array('new_id' => $new_id)),
669          )
670        );
671      }
672    }
673  }
674
675// +-----------------------------------------------------------------------+
676// |                             errors display                            |
677// +-----------------------------------------------------------------------+
678  if (isset ($errors) and count($errors) != 0)
679  {
680          $template->assign('errors',array());
681          foreach ($errors as $error)
682          {
683                  array_push($page['errors'], $error);
684                }
685        } 
686
687// +-----------------------------------------------------------------------+
688// |                           templates display                           |
689// +-----------------------------------------------------------------------+
690  $template->set_filenames(array('news' => dirname(__FILE__) . '/template/news_admin.tpl'));
691  //$template->set_filename('news', dirname(__FILE__) . '/template/news_admin.tpl');
692  $template->assign_var_from_handle('ADMIN_CONTENT', 'news');
693
694  break;
695
696// *************************************************************************
697// +-----------------------------------------------------------------------+
698// |                             Users                                     |
699// +-----------------------------------------------------------------------+
700// *************************************************************************
701  case 'Users':
702 
703  $query = '
704  SELECT id, username
705    FROM '.USERS_TABLE.'
706    ORDER BY username ASC
707  ;';
708  $result = pwg_query($query);
709 
710  $num = 0;
711  while ($row = mysql_fetch_array($result))
712  {
713   
714    $template->assign(
715      'user',
716      array(
717        'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
718        'NAME' => $row['username'],
719        'U_PERM' => add_url_params(get_admin_plugin_menu_link(dirname(__FILE__).'/news_user_perm.php'), array('user_id' => $row['id'])),
720        )
721      );
722  }
723
724  $template->assign(
725    array(
726      'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=news_users',
727    )
728  );   
729
730  $template->set_filenames(array('news_user_list' => NBC_NEWS_PATH.'template/admin/news_user_list.tpl'));   
731  $template->assign_var_from_handle('ADMIN_CONTENT', 'news_user_list');
732
733  break;
734
735// *************************************************************************
736// +-----------------------------------------------------------------------+
737// |                             Groups                                    |
738// +-----------------------------------------------------------------------+
739// *************************************************************************
740  case 'Groups':
741 
742  $template->set_filenames(array('news_group_list' => NBC_NEWS_PATH . 'template/admin/news_group_list.tpl'));
743
744  $query = '
745  SELECT id, name
746    FROM '.GROUPS_TABLE.'
747    ORDER BY name ASC
748  ;';
749  $result = pwg_query($query);
750 
751  $num = 0;
752  while ($row = mysql_fetch_array($result))
753  {
754    $query = '
755  SELECT COUNT(*)
756    FROM '.USER_GROUP_TABLE.'
757    WHERE group_id = '.$row['id'].'
758  ;';
759    list($counter) = mysql_fetch_row(pwg_query($query));
760   
761    $template->assign(
762      'group',
763      array(
764        'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
765        'NAME' => $row['name'],
766        'MEMBERS' => sprintf(l10n('%d members'), $counter),
767        'U_MEMBERS' => PHPWG_ROOT_PATH.'admin.php?page=user_list&amp;group='.$row['id'],
768        'U_PERM' => add_url_params(get_admin_plugin_menu_link(dirname(__FILE__).'/news_group_perm.php'), array('group_id' => $row['id'])),
769        )
770      );
771  }
772 
773  $template->assign(
774    array(
775      'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=news_groups',
776    )
777  );   
778
779  $template->assign_var_from_handle('ADMIN_CONTENT', 'news_group_list');
780
781  break;
782
783// *************************************************************************
784// +-----------------------------------------------------------------------+
785// |                             Users                                     |
786// +-----------------------------------------------------------------------+
787// *************************************************************************
788  case 'Config':
789  $template->set_filenames(array('news_config' => NBC_NEWS_PATH . 'template/admin/news_config.tpl'));
790
791  $conf_nbc_News = explode(";" , $conf['nbc_News']);
792
793  if ( isset($_POST['submit']) and !is_adviser() )
794  {
795    $conf_nbc_News = array(
796      str_replace("\'", "'", $_POST['nb_homepage']),
797      str_replace("\'", "'", $_POST['nb_page']),
798      str_replace("\'", "'", $_POST['nb_page_option']),
799    );
800 
801    $newconf_nbc_News = implode (";" , $conf_nbc_News);
802   
803    $query = '
804      UPDATE '.CONFIG_TABLE.'
805      SET value="'.$newconf_nbc_News.'"
806      WHERE param="nbc_News"
807      LIMIT 1';
808    pwg_query($query);
809 
810    // information message
811    array_push($page['infos'], $lang['nbc_news_save_config']);
812  }
813
814  $template->assign(
815    array(
816      //'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=news_config',
817      'NBC_News_F_ACTION' => add_url_params($page_news_admin, array('tab' => 'Config')),
818      'nb_homepage_CONTENT' => $conf_nbc_News[0],
819      'nb_page_CONTENT' => $conf_nbc_News[1],
820      'nb_page_option_CONTENT' => $conf_nbc_News[2],
821    )
822  );   
823   
824  $template->assign_var_from_handle('ADMIN_CONTENT', 'news_config');
825 
826  break;
827
828}
829?>
Note: See TracBrowser for help on using the repository browser.