[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare SiteMgr - Web Content Management * 4 * http://www.egroupware.org * 5 * Rewritten with the new db-functions by RalfBecker-AT-outdoor-training.de * 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 13 /* $Id: class.Sites_SO.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 class Sites_SO 16 { 17 var $db; 18 var $sites_table = 'egw_sitemgr_sites'; // only reference to the db-prefix 19 20 function Sites_SO() 21 { 22 $this->db = clone($GLOBALS['egw']->db); 23 $this->db->set_app('sitemgr'); 24 } 25 26 function list_siteids() 27 { 28 $this->db->select($this->sites_table,'site_id',False,__LINE__,__FILE__); 29 30 $result = array(); 31 while ($this->db->next_record()) 32 { 33 $result[] = $this->db->f('site_id'); 34 } 35 return $result; 36 } 37 38 function getWebsites($limit,$start,$sort,$order,$query,&$total) 39 { 40 if ($limit) 41 { 42 if ($query) 43 { 44 $query = $this->db->quote('%'.$query.'%'); 45 $whereclause = "site_name LIKE $query OR site_url LIKE $query OR site_dir LIKE $query"; 46 } 47 if (preg_match('/^[a-z_0-9]+$/i',$order) && preg_match('/^(asc|desc)*$/i',$sort)) 48 { 49 $orderclause = "ORDER BY $order " . ($sort ? $sort : 'DESC'); 50 } 51 else 52 { 53 $orderclause = 'ORDER BY site_name ASC'; 54 } 55 $this->db->select($this->sites_table,'COUNT(*)',$whereclause,__LINE__,__FILE__); 56 $total = $this->db->next_record() ? $this->db->f(0) : 0; 57 58 $this->db->select($this->sites_table,'site_id,site_name,site_url',$whereclause,__LINE__,__FILE__,$start,$orderclause); 59 } 60 else 61 { 62 $this->db->select($this->sites_table,'site_id,site_name,site_url',False,__LINE__,__FILE__); 63 } 64 while ($this->db->next_record()) 65 { 66 foreach(array('site_id', 'site_name', 'site_url') as $col) 67 { 68 $site[$col] = $this->db->f($col); 69 } 70 $result[$site['site_id']] = $site; 71 } 72 return $result; 73 } 74 75 function getnumberofsites() 76 { 77 $this->db->select($this->sites_table,'COUNT(*)',False,__LINE__,__FILE__); 78 79 return $this->db->next_record() ? $this->db->f(0) : 0; 80 } 81 82 function urltoid($url) 83 { 84 $this->db->select($this->sites_table,'site_id',array( 85 'site_url' => $url, 86 ),__LINE__,__FILE__); 87 88 return $this->db->next_record() ? $this->db->f('site_id') : False; 89 } 90 91 function read($site_id) 92 { 93 $this->db->select($this->sites_table,'*',array( 94 'site_id' => $site_id, 95 ),__LINE__,__FILE__); 96 97 if ($this->db->next_record()) 98 { 99 foreach( 100 array( 101 'site_id', 'site_name', 'site_url', 'site_dir', 'themesel', 102 'site_languages', 'home_page_id', 'anonymous_user','anonymous_passwd', 103 'upload_dir','upload_url' 104 ) as $col 105 ) 106 { 107 $site[$col] = $this->db->f($col); 108 } 109 return $site; 110 } 111 return false; 112 } 113 114 function read2($site_id) 115 { 116 $this->db->select($this->sites_table,'site_url,site_dir',array( 117 'site_id' => $site_id, 118 ),__LINE__,__FILE__); 119 120 if ($this->db->next_record()) 121 { 122 foreach( 123 array( 124 'site_url', 'site_dir' 125 ) as $col 126 ) 127 { 128 $site[$col] = $this->db->f($col); 129 } 130 return $site; 131 } 132 return false; 133 } 134 135 function add($site) 136 { 137 $cats =& CreateObject('phpgwapi.categories',-1,'sitemgr'); 138 $site_id = $cats->add(array( 139 'name' => $site['name'], 140 'descr' => '', 141 'access' => 'public', 142 'parent' => 0, 143 'old_parent' => 0 144 )); 145 $this->db->insert($this->sites_table,array( 146 'site_id' => $site_id, 147 'site_name' => $site['name'], 148 'site_url' => $site['url'], 149 'site_dir' => $site['dir'], 150 'anonymous_user' => $site['anonuser'], 151 'anonymous_passwd' => $site['anonpasswd'], 152 ),False,__LINE__,__FILE__); 153 154 return $site_id; 155 } 156 157 function update($site_id,$site) 158 { 159 return $this->db->update($this->sites_table,array( 160 'site_name' => $site['name'], 161 'site_url' => $site['url'], 162 'site_dir' => $site['dir'], 163 'anonymous_user' => $site['anonuser'], 164 'anonymous_passwd' => $site['anonpasswd'], 165 'upload_dir' => $site['upload_dir'], 166 'upload_url' => $site['upload_url'], 167 ),array( 168 'site_id' => $site_id 169 ),__LINE__,__FILE__); 170 } 171 172 function delete($site_id) 173 { 174 return $this->db->delete($this->sites_table,array( 175 'site_id' => $site_id 176 ),__LINE__,__FILE__); 177 } 178 179 function saveprefs($prefs,$site_id=CURRENT_SITE_ID) 180 { 181 return $this->db->update($this->sites_table,array( 182 'themesel' => $prefs['themesel'], 183 'site_languages' => $prefs['site_languages'], 184 'home_page_id' => $prefs['home_page_id'], 185 'upload_dir' => $prefs['upload_dir'], 186 'upload_url' => $prefs['upload_url'], 187 ),array( 188 'site_id' => $site_id 189 ),__LINE__,__FILE__); 190 } 191 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |