Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezonline.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezonline.php 6471 2001-08-16 13:57:05Z jhe $
5 //
6 // Definition of eZOnline class
7 //
8 // Created on: <09-Nov-2000 18:05:07 ce>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
44 // include_once( "classes/ezdb.php" );
45 // include_once( "ezaddress/classes/ezonlinetype.php" );
46
47 class eZOnline
48 {
52 function __construct( $id = "" )
53 {
54 $this->OnlineTypeID = 0;
55
56 if ( !empty( $id ) )
57 {
58 $this->ID = $id;
59 $this->get( $this->ID );
60 }
61 }
62
66 function store()
67 {
68 $db =& eZDB::globalDatabase();
69 $db->begin();
70
71 $ret = false;
72 $url = $db->escapeString( $this->URL );
73 $onlineTypeID = $db->escapeString( $this->OnlineTypeID );
74 if ( !isset( $this->ID ) )
75 {
76 $db->lock( "eZAddress_Online" );
77 $this->ID = $db->nextID( "eZAddress_Online", "ID" );
78
79 $queryText = "INSERT INTO eZAddress_Online
80 (ID, URL, OnlineTypeID)
81 VALUES
82 ('$this->ID', '$url', '$onlineTypeID')";
83
84 $res[] = $db->query( $queryText );
85 $db->unlock();
86 $ret = true;
87 }
88 else
89 {
90 $res[] = $db->query( "UPDATE eZAddress_Online SET
91 URL='$url',
92 OnlineTypeID='$this->OnlineTypeID'
93 WHERE ID='$this->ID'" );
94
95 $ret = true;
96 }
97
98 eZDB::finish( $res, $db );
99 return $ret;
100 }
101
105 function delete( $id = false )
106 {
107 if ( !$id )
108 $id = $this->ID;
109 $db =& eZDB::globalDatabase();
110 $db->begin();
111 $res[] = $db->query( "DELETE FROM eZAddress_Online WHERE ID='$id'" );
112 eZDB::finish( $res, $db );
113 }
114
115
119 function get( $id=-1 )
120 {
121 $db =& eZDB::globalDatabase();
122 if ( $id != "" )
123 {
124 $db->array_query( $online_array, "SELECT * FROM eZAddress_Online WHERE ID='$id'" );
125 if ( count( $online_array ) > 1 )
126 {
127 die( "Feil: Flere onlineer med samme ID funnet i database, dette skal ikke v�re mulig. " );
128 }
129 else if ( count( $online_array ) == 1 )
130 {
131 $this->ID =& $online_array[ 0 ][ $db->fieldName( "ID" ) ];
132 $this->URL =& $online_array[ 0 ][ $db->fieldName( "URL" ) ];
133
134 if( is_null( $online_array[ 0 ][ $db->fieldName( "OnlineTypeID" ) ] ) )
135 {
136 $this->OnlineTypeID = 0;
137 }
138 else
139 {
140 $this->OnlineTypeID =& $online_array[ 0 ][ $db->fieldName( "OnlineTypeID" ) ];
141 }
142 }
143 }
144 }
145
149 function getAll( )
150 {
151 $db =& eZDB::globalDatabase();
152 $online_array = 0;
153
154 $online_array = array();
155 $return_array = array();
156
157 $db->array_query( $online_array, "SELECT ID FROM eZAddress_Online" );
158
159 foreach ( $online_array as $addresItem )
160 {
161 $return_array[] = new eZOnline( $onlineItem[ $db->fieldName( "ID" ) ] );
162 }
163
164 return $online_array;
165 }
166
170 function id()
171 {
172 return $this->ID;
173 }
174
178 function url()
179 {
180 return $this->URL;
181 }
182
187 function onlineTypeID()
188 {
189 return $this->OnlineTypeID;
190 }
191
195 function onlineType()
196 {
197 $onlineType = new eZOnlineType( $this->OnlineTypeID );
198 return $onlineType;
199 }
200
204 function setURL( $value )
205 {
206 $this->URL= $value;
207 }
208
212 function setOnlineTypeID( $value )
213 {
214 if( is_numeric( $value ) )
215 {
216 $this->OnlineTypeID= $value;
217 }
218
219 if( is_a( $value, "eZOnlineType" ) )
220 {
221 $this->OnlineTypeID = $value->id();
222 }
223 }
224
228 function setOnlineType( $value )
229 {
230 if( is_numeric( $value ) )
231 {
232 $this->OnlineTypeID= $value;
233 }
234
235 if( is_a( $value, "eZOnlineType" ) )
236 {
237 $this->OnlineTypeID = $value->id();
238 }
239 }
240
241 // /*!
242 // Returns the url type options
243 // */
244 // function workStatusTypes()
245 // {
246 // $db =& eZDB::globalDatabase();
247 // $db->array_query( $itemArray, $query="SHOW COLUMNS FROM eZAddress_Online LIKE 'URLType'" );
248 // $items=preg_split( "/'|\,/", $itemArray[0]["Type"], 0, PREG_SPLIT_NO_EMPTY );
249
250 // $count=count( $items );
251
252 // for( $i=1; $i < $count - 1; $i++ )
253 // {
254 // $returnArray[]=$items[$i];
255 // }
256
257 // return $returnArray;
258 // }
259
260 var $ID;
261 var $URL;
263 var $OnlineTypeID;
264 }
265
266 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$URL
$URL
Definition: ezgroupeventcalendar/user/dayview.php:80
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$url
$url
Definition: messagereviewlist.php:153
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.