Fixed minor things and added missing file
[vanilla-miry.git] / library / Vanilla / Vanilla.Class.Category.php
blob273580b5c69609ae8e1d68c19446509d4ed54a86
1 <?php
2 /**
3 * Category class
5 * Copyright 2003 Mark O'Sullivan
6 * This file is part of Lussumo's Software Library.
7 * Lussumo's Software Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
8 * Lussumo's Software Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9 * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10 * The latest source code is available at www.lussumo.com
11 * Contact Mark O'Sullivan at mark [at] lussumo [dot] com
13 * @author Mark O'Sullivan
14 * @copyright 2003 Mark O'Sullivan
15 * @license http://lussumo.com/community/gpl.txt GPL 2
16 * @package Vanilla
17 * @version 1.1.10
21 /**
22 * Object representation of a category.
23 * @package Vanilla
25 class Category {
26 var $CategoryID;
27 var $Name;
28 var $CleanName;
29 var $Description;
30 var $Blocked; // Is this category blocked by the viewing user
31 var $RoleBlocked; // Is this category blocked to the role of the viewing user
32 var $AllowedRoles; // Contains the roles that are allowed to take part in this category
33 var $DiscussionCount; // aggregate - display only
35 function Category() {
36 $this->Clear();
39 // Clears all properties
40 function Clear() {
41 $this->CategoryID = 0;
42 $this->Name = '';
43 $this->CleanName = '';
44 $this->Description = '';
45 $this->DiscussionCount = 0;
46 $this->Blocked = 0;
47 $this->RoleBlocked = 0;
48 $this->AllowedRoles = array();
51 function FormatPropertiesForDatabaseInput() {
52 $this->Name = FormatStringForDatabaseInput($this->Name, 1);
53 $this->Description = FormatStringForDatabaseInput($this->Description, 1);
56 function FormatPropertiesForDisplay() {
57 $this->Name = FormatStringForDisplay($this->Name, 1);
58 $this->Description = FormatStringForDisplay($this->Description, 1);
61 function GetPropertiesFromDataSet($DataSet) {
62 $this->CategoryID = ForceInt(@$DataSet['CategoryID'], 0);
63 $this->Name = ForceString(@$DataSet['Name'], '');
64 $this->Description = ForceString(@$DataSet['Description'], '');
65 $this->DiscussionCount = ForceInt(@$DataSet['DiscussionCount'], 0);
66 $this->Blocked = ForceBool(@$DataSet['Blocked'], 0);
67 $this->RoleBlocked = ForceBool(@$DataSet['RoleBlocked'], 0);
70 function GetPropertiesFromForm(&$Context) {
71 $this->CategoryID = ForceIncomingInt('CategoryID', 0);
72 $this->Name = ForceIncomingString('Name', '');
73 $this->Description = ForceIncomingString('Description', '');
74 $this->AllowedRoles = ForceIncomingArray('CategoryRoleBlock', array());
77 function GetCleanName() {
78 if ($this->CleanName != false)
79 return $this->CleanName;
80 $this->CleanName = CleanName($this->Name);
81 return $this->CleanName;