1: <?php
2:
3: /**
4: *
5: * An article vote class for user ratings
6: *
7: * @package alpha::model
8: * @since 1.0
9: * @author John Collins <dev@alphaframework.org>
10: * @version $Id: ArticleVoteObject.inc 1496 2012-02-12 20:32:21Z alphadev $
11: * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12: * @copyright Copyright (c) 2012, John Collins (founder of Alpha Framework).
13: * All rights reserved.
14: *
15: * <pre>
16: * Redistribution and use in source and binary forms, with or
17: * without modification, are permitted provided that the
18: * following conditions are met:
19: *
20: * * Redistributions of source code must retain the above
21: * copyright notice, this list of conditions and the
22: * following disclaimer.
23: * * Redistributions in binary form must reproduce the above
24: * copyright notice, this list of conditions and the
25: * following disclaimer in the documentation and/or other
26: * materials provided with the distribution.
27: * * Neither the name of the Alpha Framework nor the names
28: * of its contributors may be used to endorse or promote
29: * products derived from this software without specific
30: * prior written permission.
31: *
32: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
33: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
34: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
37: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
39: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
43: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
44: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45: * </pre>
46: *
47: */
48: class ArticleVoteObject extends AlphaDAO {
49: /**
50: * The article this comment belongs to
51: *
52: * @var Relation
53: * @since 1.0
54: */
55: protected $articleOID;
56:
57: /**
58: * The person who cast the vote
59: *
60: * @var Relation
61: * @since 1.0
62: */
63: protected $personOID;
64:
65: /**
66: * The actual vote score (default 1-10)
67: *
68: * @var Integer
69: * @since 1.0
70: */
71: protected $score;
72:
73: /**
74: * An array of data display labels for the class properties
75: *
76: * @var array
77: * @since 1.0
78: */
79: protected $dataLabels = array("OID"=>"Article Vote ID#","articleOID"=>"Article","personOID"=>"Voter","score"=>"Article Score");
80:
81: /**
82: * The name of the database table for the class
83: *
84: * @var string
85: * @since 1.0
86: */
87: const TABLE_NAME = 'ArticleVote';
88:
89: /**
90: * Trace logger
91: *
92: * @var Logger
93: * @since 1.1
94: */
95: private static $logger = null;
96:
97: /**
98: * Constructor for the class
99: *
100: * @since 1.0
101: */
102: public function __construct() {
103: self::$logger = new Logger('ArticleVoteObject');
104:
105: // ensure to call the parent constructor
106: parent::__construct();
107:
108: $this->articleOID = new Relation();
109: $this->articleOID->setRelatedClass('ArticleObject');
110: $this->articleOID->setRelatedClassField('OID');
111: $this->articleOID->setRelatedClassDisplayField('description');
112: $this->articleOID->setRelationType('MANY-TO-ONE');
113:
114: $this->personOID = new Relation();
115: $this->personOID->setRelatedClass('PersonObject');
116: $this->personOID->setRelatedClassField('OID');
117: $this->personOID->setRelatedClassDisplayField('email');
118: $this->personOID->setRelationType('MANY-TO-ONE');
119:
120: $this->score = new Integer();
121: }
122: }
123:
124: ?>