Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezauthor.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezauthor.php 9705 2002-08-15 14:20:29Z gl $
5 //
6 // Definition of eZAuthor class
7 //
8 // Created on: <31-May-2001 13:52:30 bf>
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
35 // include_once( "classes/ezdb.php" );
36 // include_once( "classes/eztexttool.php" );
37
38
39 class eZAuthor
40 {
44 function __construct( $id=-1 )
45 {
46 if ( $id != -1 )
47 {
48 $this->ID = $id;
49 $this->get( $this->ID );
50 }
51 }
52
56 function store()
57 {
58 $ret = false;
59 $db =& eZDB::globalDatabase();
60
61 $dbError = false;
62 $db->begin( );
63
64
65 $name = $db->escapeString( $this->Name );
66 $email = $db->escapeString( $this->EMail );
67
68 if ( !isset( $this->ID ) )
69 {
70 $db->lock( "eZUser_Author" );
71 $nextID = $db->nextID( "eZUser_Author", "ID" );
72
73 $res = $db->query( "INSERT INTO eZUser_Author
74 ( ID, Name, EMail )
75 VALUES
76 ( '$nextID', '$name', '$email' )" );
77
78 $this->ID = $nextID;
79 }
80 else
81 {
82 $res = $db->query( "UPDATE eZUser_Author SET
83 Name='$name',
84 EMail='$email'
85 WHERE ID='$this->ID'" );
86
87
88 }
89
90 $db->unlock();
91
92 if ( $res == false )
93 $db->rollback( );
94 else
95 {
96 $db->commit();
97 $ret = true;
98 }
99
100 return $ret;
101 }
102
106 function delete( $id )
107 {
108 $db =& eZDB::globalDatabase();
109
110 if ( is_numeric( $id ) )
111 {
112 $db->query( "DELETE FROM eZUser_Author WHERE ID='$id'" );
113 }
114 else if ( isset( $this->ID ) )
115 {
116 $db->query( "DELETE FROM eZUser_Author WHERE ID='$this->ID'" );
117 }
118
119 return true;
120 }
121
127 function get( $id=-1 )
128 {
129 $db =& eZDB::globalDatabase();
130
131 $ret = false;
132 if ( $id != "" )
133 {
134 $db->array_query( $author_array, "SELECT * FROM eZUser_Author WHERE ID='$id'" );
135 if( count( $author_array ) == 1 )
136 {
137 $this->ID =& $author_array[0][$db->fieldName("ID")];
138 $this->Name =& $author_array[0][$db->fieldName("Name")];
139 $this->EMail =& $author_array[0][$db->fieldName("EMail")];
140 $ret = true;
141 }
142 elseif( count( $author_array ) == 1 )
143 {
144 $this->ID = 0;
145 }
146 }
147 return $ret;
148 }
149
150
156 function getByName( $name )
157 {
158 $db =& eZDB::globalDatabase();
159
160 $ret = false;
161 $db->array_query( $author_array, "SELECT * FROM eZUser_Author WHERE Name='$name'" );
162 if( count( $author_array ) == 1 )
163 {
164 $this->ID =& $author_array[0][$db->fieldName("ID")];
165 $this->Name =& $author_array[0][$db->fieldName("Name")];
166 $this->EMail =& $author_array[0][$db->fieldName("EMail")];
167 $ret = true;
168 }
169 return $ret;
170 }
171
175 function &getAll( )
176 {
177 $db =& eZDB::globalDatabase();
178
179 $return_array = array();
180 $author_array = array();
181
182
183 $db->array_query( $author_array, "SELECT ID,Name FROM eZUser_Author
184 ORDER By Name" );
185
186 foreach ( $author_array as $author )
187 {
188 $return_array[] = new eZAuthor( $author[$db->fieldName("ID")] );
189 }
190 return $return_array;
191 }
192
196 function id()
197 {
198 return $this->ID;
199 }
200
204 function name( $html = true )
205 {
206 if ( $html )
207 return eZTextTool::fixhtmlentities( htmlspecialchars( $this->Name ) );
208 return $this->Name;
209 }
210
214 function email( )
215 {
216 return $this->EMail;
217 }
218
222 function setName( $value )
223 {
224 $this->Name = $value;
225 }
226
230 function setEmail( $value )
231 {
232 $this->EMail = $value;
233 }
234
235 var $ID;
236 var $Name;
237 var $EMail;
238 }
239
240 ?>
$author
$author
Definition: admin/articleedit.php:834
eZAuthor
Definition: ezauthor.php:40
eZAuthor\name
name( $html=true)
Definition: ezauthor.php:204
eZAuthor\setEmail
setEmail( $value)
Definition: ezauthor.php:230
eZAuthor\getByName
getByName( $name)
Definition: ezauthor.php:156
eZAuthor\$ID
$ID
Definition: ezauthor.php:235
eZAuthor\__construct
__construct( $id=-1)
Definition: ezauthor.php:44
eZAuthor\setName
setName( $value)
Definition: ezauthor.php:222
eZAuthor\store
store()
Definition: ezauthor.php:56
eZAuthor\$EMail
$EMail
Definition: ezauthor.php:237
eZAuthor\$Name
$Name
Definition: ezauthor.php:236
eZAuthor\id
id()
Definition: ezauthor.php:196
eZAuthor\getAll
& getAll()
Definition: ezauthor.php:175
eZAuthor\email
email()
Definition: ezauthor.php:214
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZTextTool\fixhtmlentities
static fixhtmlentities( $string)
Definition: eztexttool.php:156
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
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+.