[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/news_admin/inc/ -> class.uinews.inc.php (source)

   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      /* $Id: class.uinews.inc.php 22671 2006-10-18 06:15:59Z ralfbecker $ */
  16  
  17      class uinews
  18      {
  19          var $start = 0;
  20          var $query = '';
  21          var $sort  = '';
  22          var $order = ''; 
  23          var $cat_id;
  24          var $template;
  25          var $bo;
  26          var $news_data;
  27          var $news_id;
  28          var $sbox;
  29          var $public_functions = array(
  30              'write_news'  => True,
  31              'add'         => True,
  32              'edit'        => True,
  33              'delete'      => True,
  34              'delete_item' => True,
  35              'read_news'      => True,
  36              'show_news_home' => True
  37          );
  38  
  39  		function uinews()
  40          {
  41              $GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
  42              $this->nextmatchs =& CreateObject('phpgwapi.nextmatchs');
  43              $this->template = $GLOBALS['egw']->template;
  44              $this->bo   =& CreateObject('news_admin.bonews',True);
  45              $this->sbox =& CreateObject('phpgwapi.sbox');
  46              $this->start = $this->bo->start;
  47              $this->query = $this->bo->query;
  48              $this->order = $this->bo->order;
  49              $this->sort = $this->bo->sort;
  50              $this->cat_id = $this->bo->cat_id;
  51          }
  52  
  53          //with $default, we are called from the news form
  54  		function selectlist($type,$default=false)
  55          {
  56              $link_data['menuaction'] = ($type == 'read') ? 'news_admin.uinews.read_news' : 'news_admin.uinews.write_news';
  57              $link_data['start'] = 0;
  58              $right = ($type == 'read') ? EGW_ACL_READ : EGW_ACL_ADD;
  59              $selectlist = ($default === false) ? ('<option>' . lang($type . ' news') . '</option>') : '<option value="none">' . lang('PLEASE SELECT') . '...</option>';  // wbshang 2005-4-4
  60              foreach($this->bo->cats as $cat)
  61              {
  62                  if($this->bo->acl->is_permitted($cat['id'],$right))
  63                  {
  64                      $cat_id = (int)$cat['id'];
  65                      $link_data['cat_id'] = $cat_id;
  66                      $selectlist .= '<option value="';
  67                      $selectlist .= $default !== False ? $cat_id : $GLOBALS['egw']->link('/index.php',$link_data);
  68                      $selectlist .= '"';
  69                      $selectlist .= ($default === $cat_id) ? ' selected="selected"' : ''; 
  70                      $selectlist .= '>' . $cat['name'] . '</option>' . "\n";
  71                  }
  72              }
  73  
  74              if (!$default)
  75              {
  76                  if($type=='read' || $this->bo->acl->is_permitted('all',$right))
  77                  {
  78                      $link_data['cat_id'] = 'all';
  79                      $selectlist .= '<option style="font-weight:bold" value="' . $GLOBALS['egw']->link('/index.php',$link_data)  
  80                          . '">' . lang('All news') . '</option>'  . "\n";
  81                  }
  82              }
  83              return $selectlist;
  84          }
  85  
  86  		function read_news()
  87          {
  88              $limit = ($GLOBALS['egw_info']['common']['maxmatchs'] ? $GLOBALS['egw_info']['common']['maxmatchs'] : 5);
  89  
  90              $news_id = get_var('news_id',Array('GET'));
  91  
  92              $news = $news_id ? array($news_id => $this->bo->get_news($news_id)) :  
  93                  $this->bo->get_newslist($this->cat_id,$this->start,'','',$limit,True);
  94  
  95              $this->template->set_file(array(
  96                  'main' => 'read.tpl'
  97              ));
  98              $this->template->set_block('main','news_form');
  99              $this->template->set_block('main','row');
 100              $this->template->set_block('main','row_empty');
 101  
 102              $GLOBALS['egw']->common->egw_header();
 103              echo parse_navbar();
 104              $this->template->set_block('main','category');
 105              $var['lang_read'] = lang('Read');
 106              $var['lang_write'] = lang('Write');
 107              $var['readable'] = $this->selectlist('read');
 108              $var['maintainlink'] = (($this->cat_id != 'all') && $this->bo->acl->is_permitted($this->cat_id,EGW_ACL_ADD)) ? 
 109                  ('<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.write_news&start=0&cat_id='.$this->cat_id)
 110                  . '">' . lang('Maintain') . '</a>') : '';
 111              $var['cat_name'] = ($this->cat_id != 'all') ? $this->bo->catbo->id2name($this->cat_id) : lang('All news');
 112              $this->template->set_var($var);
 113              $this->template->parse('_category','category');
 114  
 115              $this->template->set_var('icon',$GLOBALS['egw']->common->image('news_admin','news-corner.gif'));
 116  
 117              foreach($news as $newsitem)
 118              {
 119                  $var = Array(
 120                      'subject' => $newsitem['subject'],
 121                      'submitedby' => lang('Submitted by') . ' ' . $GLOBALS['egw']->common->grab_owner_name($newsitem['submittedby']) . ' on ' . $GLOBALS['egw']->common->show_date($newsitem['date']),
 122                      'content' => $newsitem['content'],
 123                  );
 124  
 125                  $this->template->set_var($var);
 126                  $this->template->parse('rows','row',True);
 127              }
 128              if ($this->start)
 129              {
 130                  $link_data['menuaction'] = 'news_admin.uinews.read_news';
 131                  $link_data['start'] = $this->start - $limit;
 132                  $link_data['cat_id'] = $this->cat_id;
 133                  $this->template->set_var('lesslink',
 134                      '<a href="' . $GLOBALS['egw']->link('/index.php',$link_data) . '">&lt;&lt;&lt;</a>'
 135                  );
 136              }
 137              if ($this->bo->total > $this->start + $limit)
 138              {
 139                  $link_data['menuaction'] = 'news_admin.uinews.read_news';
 140                  $link_data['start'] = $this->start + $limit;
 141                  $link_data['cat_id'] = $this->cat_id;
 142                  $this->template->set_var('morelink',
 143                      '<a href="' . $GLOBALS['egw']->link('/index.php',$link_data) . '">' . lang('More news') . '</a>'
 144                  );
 145              }
 146              if (! $this->bo->total)
 147              {
 148                  $this->template->set_var('row_message',lang('No entries found'));
 149                  $this->template->parse('rows','row_empty',True);
 150              }
 151  
 152              $this->template->pfp('_out','news_form');
 153          }
 154  
 155          //this is currently broken
 156  		function show_news_home()
 157          {
 158              $title = '<font color="#FFFFFF">'.lang('News Admin').'</font>';
 159              $portalbox =& CreateObject('phpgwapi.listbox',array(
 160                  'title'     => $title,
 161                  'primary'   => $GLOBALS['egw_info']['theme']['navbar_bg'],
 162                  'secondary' => $GLOBALS['egw_info']['theme']['navbar_bg'],
 163                  'tertiary'  => $GLOBALS['egw_info']['theme']['navbar_bg'],
 164                  'width'     => '100%',
 165                  'outerborderwidth' => '0',
 166                  'header_background_image' => $GLOBALS['egw']->common->image('phpgwapi/templates/default','bg_filler')
 167              ));
 168  
 169              $app_id = $GLOBALS['egw']->applications->name2id('news_admin');
 170              $GLOBALS['portal_order'][] = $app_id;
 171  
 172              $var = Array(
 173                  'up'       => Array('url' => '/set_box.php', 'app' => $app_id),
 174                  'down'     => Array('url' => '/set_box.php', 'app' => $app_id),
 175                  'close'    => Array('url' => '/set_box.php', 'app' => $app_id),
 176                  'question' => Array('url' => '/set_box.php', 'app' => $app_id),
 177                  'edit'     => Array('url' => '/set_box.php', 'app' => $app_id)
 178              );
 179  
 180              while(list($key,$value) = each($var))
 181              {
 182                  $portalbox->set_controls($key,$value);
 183              }
 184  
 185              $newslist = $this->bo->get_newslist($cat_id);
 186  
 187              $image_path = $GLOBALS['egw']->common->get_image_path('news_admin');
 188  
 189              if(is_array($newslist))
 190              {
 191              foreach($newslist as $newsitem)
 192              {
 193                  $portalbox->data[] = array(
 194                      'text' => $newsitem['subject'] . ' - ' . lang('Submitted by') . ' ' . $GLOBALS['egw']->common->grab_owner_name($newsitem['submittedby']) . ' ' . lang('on') . ' ' . $GLOBALS['egw']->common->show_date($newsitem['date']),
 195                      'link' => $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.show_news&news_id=' . $newsitem['id'])
 196                  );
 197              }
 198              }
 199              else
 200              {
 201                  $portalbox->data[] = array('text' => lang('no news'));
 202              }
 203  
 204              $tmp = "\r\n"
 205                  . '<!-- start News Admin -->' . "\r\n"
 206                  . $portalbox->draw()
 207                  . '<!-- end News Admin -->'. "\r\n";
 208              $this->template->set_var('phpgw_body',$tmp,True);
 209          }
 210  
 211          //the following function is unmaintained
 212  		function show_news_website($section='mid')
 213          {
 214              $cat_id = $_GET['cat_id'];
 215              $start = $_GET['start'];
 216              $oldnews = $_GET['oldnews'];
 217              $news_id = $_GET['news_id'];
 218  
 219              if (! $cat_id)
 220              {
 221                  $cat_id = 0;
 222              }
 223  
 224              $this->template->set_file(array(
 225                  '_news' => 'news_' . $section . '.tpl'
 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['egw']->common->image('news_admin','news-corner.gif'));
 244  
 245              foreach($news as $newsitem)
 246              {
 247                  $var = Array(
 248                      'subject'=> $newsitem['subject'],
 249                      'submitedby' => lang('Submitted by') . ' ' . $GLOBALS['egw']->common->grab_owner_name($newsitem['submittedby']) . ' on ' . $GLOBALS['egw']->common->show_date($newsitem['date']),
 250                      'content'    => nl2br($newsitem['content'])
 251                  );
 252  
 253                  $this->template->set_var($var);
 254                  $this->template->parse('rows','row',True);
 255              }
 256  
 257              $out = $this->template->fp('out','news_form');
 258  
 259              if ($this->bo->total > 5 && ! $oldnews)
 260              {
 261                  $link_values = array(
 262                      'menuaction'    => 'news_admin.uinews.show_news',
 263                      'oldnews'       => 'True',
 264                      'cat_id'        => $cat_id,
 265                      'category_list' => 'True'
 266                  );
 267  
 268                  $out .= '<center><a href="' . $GLOBALS['egw']->link('/index.php',$link_values) . '">View news archives</a></center>';
 269              }
 270              return $out;
 271          }
 272  
 273  		function add()
 274          {
 275              if($_POST['cancel'])
 276              {
 277              // Changed by dawnlinux @ realss.com 
 278              // When a user has fininshed adding a news, it will jump to read news page.
 279              //Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.write_news'));
 280              Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.read_news'));
 281                  return;
 282              }
 283              if($_POST['submitit'])
 284              {
 285                  $this->news_data = $_POST['news'];
 286                  if(!$this->news_data['subject'])
 287                  {
 288                      $errors[] = lang('The subject is missing');
 289                  }
 290                  if(!$this->news_data['content'])
 291                  {
 292                      $errors[] = lang('The news content is missing');
 293                  }
 294                  if($this->news_data['category'] == "none")
 295                  {
 296                      $errors[] = lang('Please select a category');
 297                  }
 298                  if(!is_array($errors))
 299                  {
 300                      $this->news_data['date'] = time();
 301                      $this->bo->set_dates($_POST['from'],$_POST['until'],$this->news_data);
 302                      $this->news_id = $this->bo->add($this->news_data);
 303                      if(!$this->news_id)
 304                      {
 305                          $this->message = lang('failed to add message');
 306                      }
 307                      else
 308                      {
 309                          $this->message = lang('Message has been added');
 310  
 311                          //then send mail to receiver, wbshang 2005-5-12
 312                          if($this->news_data['mailto'])
 313                          {
 314                              $errors = $this->bo->send_mail($this->news_data);
 315                              if(is_array($errors))
 316                              {
 317                                  $this->message = $errors;
 318                              }
 319                          }
 320  
 321                          //after having added, we must switch to edit mode instead of stay in add
 322                          $this->modify('edit');
 323                          return;
 324                      }
 325                  }
 326                  else
 327                  {
 328                      $this->message = $errors;
 329                  }
 330              }
 331              else
 332              {
 333                  $this->news_data['category'] = $this->cat_id;
 334              }
 335              $this->modify('add');
 336          }
 337  
 338  		function delete()
 339          {
 340              $news_id = $_POST['news_id'] ? $_POST['news_id'] : $_GET['news_id'];
 341  
 342              $GLOBALS['egw']->common->egw_header();
 343              echo parse_navbar();
 344              $this->template->set_file(array(
 345                  'form' => 'admin_delete.tpl'
 346              ));
 347              $this->template->set_var('lang_message',lang('Are you sure you want to delete this entry ?'));
 348              $this->template->set_var('lang_yes',lang('Yes'));
 349              $this->template->set_var('lang_no',lang('No'));
 350  
 351              $this->template->set_var('link_yes',$GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.delete_item&news_id=' . $news_id));
 352              $this->template->set_var('link_no',$GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.write_news'));
 353  
 354              $this->template->pfp('_out','form');
 355          }
 356  
 357  		function delete_item()
 358          {
 359              $item = (int)get_var('news_id',array('GET','POST'));
 360              if($item)
 361              {
 362                  $this->bo->delete($item);
 363                  $msg = lang('Item has been deleted');
 364              }
 365              else
 366              {
 367                  $msg = lang('Item not found');
 368              }
 369              $this->write_news($msg);
 370          }
 371  
 372  		function edit()
 373          {
 374              $this->news_data = $_POST['news'];
 375              $this->news_id   = (isset($_GET['news_id']) ? $_GET['news_id'] : $_POST['news']['id']);
 376  
 377              if($_POST['cancel'])
 378              {
 379                  if(isset($this->news_data['category']))
 380                  {
 381                          Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.write_news&cat_id='.$this->news_data['category']));
 382                          return;
 383                  }
 384                  else
 385                  {
 386                          Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.write_news'));
 387                          return;
 388                  }
 389              }
 390  
 391              if(is_array($this->news_data))
 392              {
 393                  $this->news_data['subject'] = stripslashes($this->news_data['subject']);
 394                  $this->news_data['teaser'] = stripslashes($this->news_data['teaser']);
 395                  $this->news_data['content'] = stripslashes($this->news_data['content']);
 396                  
 397                  if(!$this->news_data['subject'])
 398                  {
 399                      $errors[] = lang('The subject is missing');
 400                  }
 401                  if(!$this->news_data['content'])
 402                  {
 403                      $errors[] = lang('The news content is missing');
 404                  }
 405                  if($this->news_data['category'] == "none")
 406                  {
 407                      $errors[] = lang('Please select a category');
 408                  }
 409  
 410                  if(!is_array($errors))
 411                  {
 412                      $this->bo->set_dates($_POST['from'],$_POST['until'],$this->news_data);
 413                      $this->bo->edit($this->news_data);
 414                      $this->message = lang('News item has been updated');
 415  
 416                      // send mail to receiver,wbshang 2005-5-12
 417                  /*    // the following code is used to detect whether there are new receivers,if do,send them mail.
 418                      // but I think it is necessary to send new mail to all receivers if the news is modified,so I comment it. wbshang 2005-5-12
 419                      $cat_id = $this->bo->get_receiver_cats($this->news_id);
 420                      foreach($this->news_data['mailto'] as $entry)
 421                      {
 422                          if(!in_array($entry,$cat_id))
 423                          {
 424                              $mailto[] = $entry;
 425                          }
 426                      }
 427                      if(!empty($mailto))
 428                      {
 429                          $this->bo->send_mail($news,$mailto);
 430                      } */
 431                      if($this->news_data['mailto'])
 432                      {
 433                          $errors = $this->bo->send_mail($this->news_data);
 434                          if(is_array($errors))
 435                          {
 436                              $this->message = $errors;
 437                          }
 438                      }
 439  
 440                  }
 441                  else
 442                  {
 443                      $this->message = $errors;
 444                  }
 445              }
 446              else
 447              {
 448                  $this->news_data = $this->bo->get_news($this->news_id,True);
 449                  $this->news_data['date_d'] = date('j',$this->news_data['begin']);
 450                  $this->news_data['date_m'] = date('n',$this->news_data['begin']);
 451                  $this->news_data['date_y'] = date('Y',$this->news_data['begin']);
 452              }
 453              $this->modify();
 454          }
 455  
 456  		function modify($type = 'edit')
 457          {
 458              $options = $this->bo->get_options($this->news_data);
 459              
 460              // init htmlarea with wysiwyg editor
 461              $style='width:600px; min-width:500px; height:400px;';
 462              $plugins = 'TableOperations,ContextMenu,ColorChooser,FontChooser,FileManager,SearchReplace,InsertDateTime';
 463              $GLOBALS['egw']->session->appsession('UploadImage','phpgwapi',array(
 464                  'app' => 'news_admin',
 465                  'upload_dir'   => $this->bo->config['upload_dir'],
 466                  'upload_url'   => $this->bo->config['upload_url'],
 467                  'admin_method' => $GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=news_admin'),
 468              ));
 469              $content = $GLOBALS['egw']->html->tinymce('news[content]',$this->news_data['content'],$style,$plugins);
 470              
 471              $GLOBALS['egw']->common->egw_header();
 472              echo parse_navbar();
 473              
 474              $this->template->set_file(array(
 475                  'form' => 'admin_form.tpl'
 476              ));
 477  
 478              if(is_array($this->message))
 479              {
 480                  $this->template->set_var('errors',$GLOBALS['egw']->common->error_list($this->message));
 481              }
 482              elseif($this->message)
 483              {
 484                  $this->template->set_var('errors',$this->message);
 485              }
 486  
 487              $category_list = $this->selectlist('write', (int)$this->news_data['category']);
 488  
 489              $this->template->set_var('lang_header',lang($type . ' news item'));
 490              $this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php',
 491                  array('menuaction'    => 'news_admin.uinews.'.$type,
 492                           'news_id'    => $this->news_id
 493                      )
 494                  )
 495              );
 496              $this->template->set_var(array(
 497                  'form_button' => '<input type="submit" name="submitit" value="' . lang('save') . '">',
 498                  'value_id' => $this->news_id,
 499                  'done_button' => '<input type="submit" name="cancel" value="' . lang('Done') . '">',
 500                  'label_subject' => lang('subject') . ':',
 501                  'value_subject' => '<input name="news[subject]" size="60" value="' . @htmlspecialchars($this->news_data['subject'],ENT_COMPAT,$GLOBALS['egw']->translation->charset()) . '">',
 502                  'label_teaser' => lang('teaser') . ':',
 503                  'value_teaser' => '<input name="news[teaser]" size="60" value="' . @htmlspecialchars($this->news_data['teaser'],ENT_COMPAT,$GLOBALS['egw']->translation->charset()) . '" maxLength="100">',
 504                  'label_content' => lang('Content') . ':',
 505                  'value_content' => $content,
 506                  'label_category' => lang('Category') . ':',
 507                  'value_category' => '<select name="news[category]">' . $this->selectlist('write', (int)$this->news_data['category']) . '</select>',
 508                  'label_visible' => lang('Visible') . ':',
 509                  'value_begin_d' =>  $this->sbox->getDays('news[begin_d]',date('j',$this->news_data['begin'])),
 510                  'value_begin_m' =>  $this->sbox->getMonthText('news[begin_m]',date('n',$this->news_data['begin'])),
 511                  'value_begin_y' =>  $this->sbox->getYears('news[begin_y]',date('Y',$this->news_data['begin']),date('Y')),
 512                  'select_from' => $options['from'],
 513                  'select_until' => $options['until'],
 514                  'value_end_d' =>  $this->sbox->getDays('news[end_d]',date('j',$this->news_data['end'])) ,
 515                  'value_end_m' =>  $this->sbox->getMonthText('news[end_m]',date('n',$this->news_data['end'])),
 516                  'value_end_y' =>  $this->sbox->getYears('news[end_y]',date('Y',$this->news_data['end']),date('Y')),
 517                  'label_is_html' => lang('Contains HTML'),
 518                  'value_is_html' => '<input type="checkbox" value="1" name="news[is_html]"' . ($this->news_data['is_html'] ? ' checked="1"' : '') .'>',
 519              ));
 520  
 521              //the following label is added by wbshang,2005-5-12
 522              if($GLOBALS['egw_info']['user']['preferences']['news_admin']['SendMail'])
 523              {
 524                  $contact_options = $this->cat_options($this->news_data['mailto']);   // added by wbshang,used to send mail
 525                  $this->template->set_var(array(
 526                      'label_send_mail' => lang('Send Mail to Others') . '?',
 527                      'value_send_mail' => '<select multiple="multiple" size="5" name="news[mailto][]">' . $contact_options . '</select>',
 528                  ));
 529              }
 530              
 531              $this->template->pfp('out','form');
 532          }
 533          
 534  		function write_news($message = '')
 535          {
 536              $this->template->set_file(array(
 537                  'main' => 'write.tpl'
 538              ));
 539              $this->template->set_block('main','list');
 540              $this->template->set_block('main','row');
 541              $this->template->set_block('main','row_empty');
 542  
 543              $GLOBALS['egw']->common->egw_header();
 544              echo parse_navbar();
 545              $this->template->set_block('main','category');
 546              $var['lang_read'] = lang('Read');
 547              $var['lang_write'] = lang('Write');
 548              $var['readable'] = $this->selectlist('read');
 549              $var['cat_name'] = $this->cat_id ? $this->bo->catbo->id2name($this->cat_id) : lang('Global news');
 550  
 551              $this->template->set_var($var);
 552              $this->template->parse('_category','category');
 553  
 554              if ($message)
 555              {
 556                  $this->template->set_var('message',$message);
 557              }
 558  
 559              $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'));
 560              $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'));
 561              $this->template->set_var('header_status',lang('Visible'));
 562              $this->template->set_var('header_edit',lang('Edit'));
 563              $this->template->set_var('header_delete',lang('Delete'));
 564              $this->template->set_var('header_view',lang('View'));
 565  
 566              $items      = $this->bo->get_newslist($this->cat_id,$this->start,$this->order,$this->sort);
 567  
 568              $left  = $this->nextmatchs->left('/index.php',$this->start,$this->bo->total,'menuaction=news_admin.uinews.write_news');
 569              $right = $this->nextmatchs->right('/index.php',$this->start,$this->bo->total,'menuaction=news_admin.uinews.write_news');
 570              
 571              $this->template->set_var(array(
 572                  'left' => $left,
 573                  'right' => $right,
 574                  'lang_showing' => $this->nextmatchs->show_hits($this->bo->total,$this->start),
 575              ));
 576  
 577              foreach($items as $item)
 578              {
 579                  $this->nextmatchs->template_alternate_row_color($this->template);
 580                  $this->template->set_var('row_date',$GLOBALS['egw']->common->show_date($item['date']));
 581                  if(strlen($item['news_subject']) > 40)
 582                  {
 583                      $subject = $GLOBALS['egw']->strip_html(substr($item['subject'],40,strlen($item['subject'])));
 584                  }
 585                  else
 586                  {
 587                      $subject = $GLOBALS['egw']->strip_html($item['subject']);
 588                  }
 589                  $this->template->set_var('row_subject',$subject);
 590                  $this->template->set_var('row_status',$this->bo->get_visibility($item));
 591  
 592                  $this->template->set_var('row_view','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.read_news&news_id=' . $item['id']) . '">' . lang('View') . '</a>');
 593                  $this->template->set_var('row_edit','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.edit&news_id=' . $item['id']) . '">' . lang('Edit') . '</a>');
 594                  $this->template->set_var('row_delete','<a href="' . $GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.delete&news_id=' . $item['id']) . '">' . lang('Delete') . '</a>');
 595  
 596                  $this->template->parse('rows','row',True);
 597              }
 598  
 599              if(!$this->bo->total)
 600              {
 601                  $this->nextmatchs->template_alternate_row_color($this->template);
 602                  $this->template->set_var('row_message',lang('No entries found'));
 603                  $this->template->parse('rows','row_empty',True);
 604              }
 605  
 606              $this->template->set_var('link_add',$GLOBALS['egw']->link('/index.php','menuaction=news_admin.uinews.add'));
 607              $this->template->set_var('lang_add',lang('Add new news'));
 608  
 609              $this->template->pfp('out','list');
 610          }
 611  
 612          // the following functions are added by wbshang @ realss, 2005-5-12
 613          // Get the categories list of addressbook,used to send mail
 614  		function cat_options($selected)
 615          {
 616              $cat =& CreateObject('phpgwapi.categories','','addressbook');
 617              $cat_id = is_array($selected) ? $selected : $this->bo->get_receiver_cats($this->news_id);
 618              return $cat->formated_list('select','all',$cat_id,True);
 619          }
 620      }
 621  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7