Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezonlinetype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezonlinetype.php 6482 2001-08-17 12:29:18Z jhe $
5 //
6 // Definition of eZOnline class
7 //
8 // Created on: <09-Nov-2000 18:44:38 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
29 //
32
44 // // include_once( "ezaddress/classes/ezperson.php" );
45 // // include_once( "ezaddress/classes/ezcompany.php" );
46
47 class eZOnlineType
48 {
55 function __construct( $id= -1 )
56 {
57 if ( is_array( $id ) )
58 {
59 $this->fill( $id );
60 }
61 else if ( $id != -1 )
62 {
63 $this->ID = $id;
64 $this->get( $this->ID );
65 }
66 }
67
71 function store()
72 {
73 $db =& eZDB::globalDatabase();
74 $db->begin();
75 $name = $db->escapeString( $this->Name );
76
77 if ( !isset( $this->ID ) )
78 {
79 $db->lock( "eZAddress_OnlineType" );
80 $nextID = $db->nextID( "eZAddress_OnlineType", "ID" );
81
82 $db->query_single( $qry, "SELECT ListOrder FROM eZAddress_OnlineType ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
83 $listorder = $qry[$db->fieldName("ListOrder")] + 1;
84 $this->ListOrder = $listorder;
85
86 $result = $db->query( "INSERT INTO eZAddress_OnlineType
87 ( ID, Name, ListOrder, URLPrefix, PrefixLink, PrefixVisual )
88 VALUES ( '$nextID',
89 '$name',
90 '$this->ListOrder',
91 '$this->URLPrefix',
92 '$this->PrefixLink',
93 '$this->PrefixVisual') " );
94
95 $this->ID = $nextID;
96
97 }
98 else
99 {
100 $result = $db->query( "UPDATE eZAddress_OnlineType SET
101 Name='$name',
102 ListOrder='$this->ListOrder',
103 URLPrefix='$this->URLPrefix',
104 PrefixLink='$this->PrefixLink',
105 PrefixVisual='$this->PrefixVisual'
106 WHERE ID='$this->ID'" );
107 }
108
109 $db->unlock();
110
111 if ( $result == false )
112 $db->rollback( );
113 else
114 $db->commit();
115
116 return $dbError;
117 }
118
119 /*
120 Deletes from the database where id = $this->ID,
121 */
122 function delete( $id = false )
123 {
124 $db =& eZDB::globalDatabase();
125 if ( !$id )
126 $id = $this->ID;
127
128 $db->begin( );
129 $result = $db->query( "UPDATE eZAddress_OnlineType SET Removed=1 WHERE ID='$id'" );
130 if ( $result == false )
131 $db->rollback( );
132 else
133 $db->commit();
134 }
135
136 /*
137 Fetches out a online type where id = $id
138 */
139 function get( $id )
140 {
141 $db =& eZDB::globalDatabase();
142 if ( $id != "" )
143 {
144 $db->array_query( $online_type_array, "SELECT * FROM eZAddress_OnlineType WHERE ID='$id'",
145 0, 1 );
146 if ( count( $online_type_array ) == 1 )
147 {
148 $this->fill( $online_type_array[0] );
149 }
150 else
151 {
152 $this->ID = "";
153 }
154 }
155 }
156
160 function fill( &$online_type_array )
161 {
162 $db =& eZDB::globalDatabase();
163
164 $this->ID = $online_type_array[$db->fieldName( "ID" )];
165 $this->Name = $online_type_array[$db->fieldName( "Name" )];
166 $this->ListOrder = $online_type_array[$db->fieldName( "ListOrder" )];
167 $this->URLPrefix = $online_type_array[$db->fieldName( "URLPrefix" )];
168 $this->PrefixLink = $online_type_array[$db->fieldName( "PrefixLink" )];
169 $this->PrefixVisual = $online_type_array[$db->fieldName( "PrefixVisual" )];
170 }
171
172 /*
173 Fetches out all the online types that is stored in the database.
174 */
175 static public function &getAll( $as_object = true )
176 {
177
178 $db =& eZDB::globalDatabase();
179 $online_type_array = 0;
180
181 $online_type_array = array();
182 $return_array = array();
183
184 if ( $as_object )
185 $select = "*";
186 else
187 $select = "ID";
188
189 $db->array_query( $online_type_array, "SELECT $select FROM eZAddress_OnlineType
190 WHERE Removed=0
191 ORDER BY ListOrder" );
192
193 if ( $as_object )
194 {
195 foreach ( $online_type_array as $onlineTypeItem )
196 {
197 $return_array[] = new eZOnlineType( $onlineTypeItem );
198 }
199 }
200 else
201 {
202 foreach ( $online_type_array as $onlineTypeItem )
203 {
204 $return_array[] = $onlineTypeItem[ $db->fieldName( "ID" ) ];
205 }
206 }
207
208 return $return_array;
209 }
210
214 function setName( $value )
215 {
216 $this->Name = $value;
217 }
218
222 function setURLPrefix( $value )
223 {
224 $this->URLPrefix = $value;
225 }
226
230 function setPrefixLink( $value )
231 {
232 if ( $value )
233 $this->PrefixLink = 1;
234 else
235 $this->PrefixLink = 0;
236 }
237
241 function setPrefixVisual( $value )
242 {
243 if ( $value )
244 $this->PrefixVisual = 1;
245 else
246 $this->PrefixVisual = 0;
247 }
248
252 function name()
253 {
254 return $this->Name;
255 }
256
260 function urlPrefix()
261 {
262 return $this->URLPrefix;
263 }
264
268 function prefixLink()
269 {
270 return $this->PrefixLink == 1;
271 }
272
276 function prefixVisual()
277 {
278 return $this->PrefixVisual == 1;
279 }
280
284 function id()
285 {
286 return $this->ID;
287 }
288
293 function &count()
294 {
295 $db =& eZDB::globalDatabase();
296 // $db->array_query( $person_qry, "SELECT count( Pe.ID ) as Count
297 // FROM eZContact_Person AS Pe, eZContact_PersonOnlineDict AS POD,
298 // eZAddress_Online AS Online, eZAddress_OnlineType AS OT
299 // WHERE Pe.ID = POD.PersonID AND POD.OnlineID = Online.ID AND Online.OnlineTypeID = OT.ID AND OnlineTypeID='$this->ID'" );
300 // $db->array_query( $company_qry, "SELECT count( Co.ID ) as Count
301 // FROM eZContact_Company AS Co, eZContact_CompanyOnlineDict AS COD,
302 // eZAddress_Online AS Online, eZAddress_OnlineType AS OT
303 // WHERE Co.ID = COD.CompanyID AND COD.OnlineID = Online.ID AND Online.OnlineTypeID = OT.ID AND OnlineTypeID='$this->ID'" );
304 $db->array_query( $qry, "SELECT count( Online.ID ) as Count
305 FROM eZAddress_Online AS Online, eZAddress_OnlineType AS OT
306 WHERE Online.OnlineTypeID = OT.ID AND OnlineTypeID='$this->ID'" );
307 $cnt = 0;
308 // if ( count( $company_qry ) > 0 )
309 // $cnt += $company_qry[0]["Count"];
310 // if ( count( $person_qry ) > 0 )
311 // $cnt += $person_qry[0]["Count"];
312 if ( count( $qry ) > 0 )
313 $cnt += $qry[0][ $db->fieldName( "Count" ) ];
314 return $cnt;
315 }
316
321 function moveUp()
322 {
323 $db =& eZDB::globalDatabase();
324 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_OnlineType
325 WHERE Removed=0 AND ListOrder<'$this->ListOrder' ORDER BY ListOrder DESC", array( "Limit" => "1" ) );
326 $listorder = $qry[$db->fieldName( "ListOrder" )];
327 $listid = $qry[$db->fieldName( "ID" )];
328
329 $db->begin();
330 $res[] = $db->query( "UPDATE eZAddress_OnlineType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
331 $res[] = $db->query( "UPDATE eZAddress_OnlineType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
332 eZDB::finish( $res, $db );
333 }
334
339 function moveDown()
340 {
341 $db =& eZDB::globalDatabase();
342 $db->query_single( $qry, "SELECT ID, ListOrder FROM eZAddress_OnlineType
343 WHERE Removed=0 AND ListOrder>'$this->ListOrder' ORDER BY ListOrder ASC", array( "Limit" => "1" ) );
344 $listorder = $qry[$db->fieldName( "ListOrder" )];
345 $listid = $qry[$db->fieldName( "ID" )];
346
347 $db->begin();
348 $res[] = $db->query( "UPDATE eZAddress_OnlineType SET ListOrder='$listorder' WHERE ID='$this->ID'" );
349 $res[] = $db->query( "UPDATE eZAddress_OnlineType SET ListOrder='$this->ListOrder' WHERE ID='$listid'" );
350 eZDB::finish( $res, $db );
351 }
352
353 var $ID;
354 var $Name;
355 var $ListOrder;
356 var $URLPrefix;
357 var $PrefixLink;
358 var $PrefixVisual;
359 }
360
361 ?>
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$res
$res
Definition: ezstats/admin/cron.php:45
$Name
$Name
Definition: polledit.php:250
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.