Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezmodulelink.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezmodulelink.php 7848 2001-10-15 11:32:18Z ce $
5 //
6 // Definition of eZModuleLink class
7 //
8 // Created on: <16-Mar-2001 18:51:22 amos>
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
64 class eZModuleLink
65 {
69 function __construct( $module, $type, $id )
70 {
71 $this->Module = $module;
72 $this->Type = $type;
73 $this->ID = $id;
74 }
75
81 function &sections( $as_object = true )
82 {
83 $db =& eZDB::globalDatabase();
84 $table_name = $this->Module . "_LinkSection";
85 $link_table_name = $this->Module . "_$this->Type" . "SectionDict";
86 $type_column = $this->Type . "ID";
87 $db->array_query( $qry_array,
88 "SELECT Link.SectionID FROM $link_table_name AS Link, $table_name AS Section
89 WHERE Link.SectionID=Section.ID AND Link.$type_column=$this->ID
90 ORDER BY Link.Placement ASC" );
91 $ret_array = array();
92 foreach( $qry_array as $row )
93 {
94 $id = $row[$db->fieldName( "SectionID" )];
95 $ret_array[] = $as_object ? new eZLinkSection( $id, $this->Module ) : $id;
96 }
97 return $ret_array;
98 }
99
103 function sectionCount()
104 {
105 $db =& eZDB::globalDatabase();
106 $table_name = $this->Module . "_LinkSection";
107 $link_table_name = $this->Module . "_$this->Type" . "SectionDict";
108 $type_column = $this->Type . "ID";
109 $db->query_single( $row,
110 "SELECT count( Link.SectionID ) AS Count FROM $link_table_name AS Link, $table_name AS Section
111 WHERE Link.SectionID=Section.ID AND Link.$type_column=$this->ID" );
112 return $row[$db->fieldName( "Count" )];
113 }
114
119 function addSection( $section )
120 {
121 $db =& eZDB::globalDatabase();
122 $db->begin();
123 $link_table_name = $this->Module . "_$this->Type" . "SectionDict";
124 $section_id = $section->id();
125 $type_column = $this->Type . "ID";
126 $db->array_query( $qry_array,
127 "SELECT Placement FROM $link_table_name
128 WHERE $type_column='$this->ID'
129 ORDER BY Placement DESC", array( "Limit" => 1 ) );
130 $placement = count( $qry_array ) == 1 ? $qry_array[0][$db->fieldName( "Placement" )] + 1 : 1;
131
132 $db->lock( $link_table_name );
133 $nextID = $db->nextID( $link_table_name, "ID" );
134
135 $res = $db->query( "INSERT INTO $link_table_name
136 ( ID, SectionID, Placement, $type_column )
137 VALUES ( '$nextID', '$section_id', '$placement', '$this->ID' )" );
138
139 if ( $res == false )
140 $db->rollback( );
141 else
142 $db->commit();
143 }
144
149 function removeSection( $section )
150 {
151 if ( is_a( $section, "eZLinkSection" ) )
152 $id = $section->id();
153 else
154 $id = $section;
155 $db =& eZDB::globalDatabase();
156 $db->begin();
157 $link_table_name = $this->Module . "_$this->Type" . "SectionDict";
158 $res = $db->query( "DELETE FROM $link_table_name
159 WHERE SectionID='$id'" );
160 if ( $res == false )
161 $db->rollback( );
162 else
163 $db->commit();
164 }
165
166 var $Module;
167 var $Type;
168 var $ID;
169 }
170
171 ?>
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZLinkSection
Definition: ezlinksection.php:43
eZModuleLink
Definition: ezmodulelink.php:65
eZModuleLink\sectionCount
sectionCount()
Definition: ezmodulelink.php:103
eZModuleLink\__construct
__construct( $module, $type, $id)
Definition: ezmodulelink.php:69
eZModuleLink\$Type
$Type
Definition: ezmodulelink.php:167
eZModuleLink\sections
& sections( $as_object=true)
Definition: ezmodulelink.php:81
eZModuleLink\removeSection
removeSection( $section)
Definition: ezmodulelink.php:149
eZModuleLink\$Module
$Module
Definition: ezmodulelink.php:166
eZModuleLink\$ID
$ID
Definition: ezmodulelink.php:168
eZModuleLink\addSection
addSection( $section)
Definition: ezmodulelink.php:119
$type
$type
Definition: classes/admin/linkselect.php:220
$module
$module
Definition: classes/admin/linkselect.php:219
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$row
$row
Definition: ezcalendar/user/dayview.php:403
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$res
$res
Definition: ezstats/admin/cron.php:45
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.