[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/preferences/inc/ -> class.bocategories.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare - Preferences - categories                                    *
   4      * http://www.egroupware.org                                                *
   5      * Written by Bettina Gille [ceb@phpgroupware.org]                          *
   6      * -----------------------------------------------                          *
   7      *  This program is free software; you can redistribute it and/or modify it *
   8      *  under the terms of the GNU General Public License as published by the   *
   9      *  Free Software Foundation; either version 2 of the License, or (at your  *
  10      *  option) any later version.                                              *
  11      \**************************************************************************/
  12      /* $Id: class.bocategories.inc.php 20532 2006-03-10 10:00:41Z ralfbecker $ */
  13  
  14      class bocategories
  15      {
  16          var $cats;
  17  
  18          var $start;
  19          var $query;
  20          var $sort;
  21          var $order;
  22  
  23  		function bocategories($cats_app='')
  24          {
  25              $this->cats           =& CreateObject('phpgwapi.categories','',$cats_app);
  26  
  27              $this->read_sessiondata($cats_app);
  28  
  29              $start  = $_POST['start']  ? $_POST['start']  : $_GET['start'];
  30              $query  = $_POST['query']  ? $_POST['query']  : $_GET['query'];
  31              $sort   = $_POST['sort']   ? $_POST['sort']   : $_GET['sort'];
  32              $order  = $_POST['order']  ? $_POST['order']  : $_GET['order'];
  33  
  34              if(!empty($start) || $start == '0' || $start == 0)
  35              {
  36                  $this->start = $start;
  37              }
  38              if((empty($query) && !empty($this->query)) || !empty($query))
  39              {
  40                  $this->query = $query;
  41              }
  42  
  43              if(isset($sort) && !empty($sort))
  44              {
  45                  $this->sort = $sort;
  46              }
  47              if(isset($order) && !empty($order))
  48              {
  49                  $this->order = $order;
  50              }
  51          }
  52  
  53  		function save_sessiondata($data, $cats_app)
  54          {
  55              $GLOBALS['egw']->session->appsession($cats_app . '_cats','preferences',$data);
  56          }
  57  
  58  		function read_sessiondata($cats_app)
  59          {
  60              $data = $GLOBALS['egw']->session->appsession($cats_app . '_cats','preferences');
  61  
  62              $this->start  = $data['start'];
  63              $this->query  = $data['query'];
  64              $this->sort   = $data['sort'];
  65              $this->order  = $data['order'];
  66              $this->referer = $data['referer'];
  67          }
  68  
  69  		function get_list($global_cats)
  70          {
  71              return $this->cats->return_sorted_array($this->start,True,$this->query,$this->sort,$this->order,$global_cats);
  72          }
  73  
  74  		function save_cat($values)
  75          {
  76              if ($values['access'])
  77              {
  78                  $values['access'] = 'private';
  79              }
  80              else
  81              {
  82                  $values['access'] = 'public';
  83              }
  84  
  85              if ($values['id'] && $values['id'] != 0)
  86              {
  87                  return $this->cats->edit($values);
  88              }
  89              else
  90              {
  91                  return $this->cats->add($values);
  92              }
  93          }
  94  
  95  		function exists($data)
  96          {
  97              $data['type']   = $data['type'] ? $data['type'] : '';
  98              $data['cat_id'] = $data['cat_id'] ? $data['cat_id'] : '';
  99              return $this->cats->exists($data['type'],$data['cat_name'],$data['type'] == 'subs' ? 0 : $data['cat_id'],$data['type'] != 'subs' ? 0 : $data['cat_id']);
 100          }
 101  
 102  		function formatted_list($format,$type,$cat_parent,$global_cats)
 103          {
 104              return $this->cats->formated_list($format,$type,$cat_parent,$global_cats);
 105          }
 106  
 107  		function delete($cat_id,$subs)
 108          {
 109              return $this->cats->delete($cat_id,$subs,!$subs);    // either delete the subs or modify them
 110          }
 111  
 112  		function check_values($values)
 113          {
 114              if (strlen($values['descr']) >= 255)
 115              {
 116                  $error[] = lang('Description can not exceed 255 characters in length !');
 117              }
 118  
 119              if (!$values['name'])
 120              {
 121                  $error[] = lang('Please enter a name');
 122              }
 123              else
 124              {
 125                  if (!$values['parent'])
 126                  {
 127                      $exists = $this->exists(array
 128                      (
 129                          'type'     => 'appandmains',
 130                          'cat_name' => $values['name'],
 131                          'cat_id'   => $values['id']
 132                      ));
 133                  }
 134                  else
 135                  {
 136                      $exists = $this->exists(array
 137                      (
 138                          'type'     => 'appandsubs',
 139                          'cat_name' => $values['name'],
 140                          'cat_id'   => $values['id']
 141                      ));
 142                  }
 143  
 144                  if ($exists == True)
 145                  {
 146                      $error[] = lang('This name has been used already');
 147                  }
 148              }
 149  
 150              if (is_array($error))
 151              {
 152                  return $error;
 153              }
 154          }
 155      }


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