4 * Arthrology for Elxis CMS 2008.x and 2009.x+
10 * @author Apostolos Koutsoulelos <akoutsoulelos@yahoo.gr>
11 * @copyright Copyright (C) 2009 Apostolos Koutsoulelos. All rights reserved.
12 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
16 // Prevent direct inclusion of this file
17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
19 if (!defined('ARTHBASE')) {
21 if (($_VERSION->RELEASE
>= 2009) && ($_VERSION->DEV_LEVEL
>= 1)) {
22 define('ARTHBASE', 'arthrology');
24 define('ARTHBASE', 'com_arthology');
28 /*********************************************************/
29 /* THE CLASS THAT WILL CONTAIN THE EVENT FUNCTIONALITY */
30 /*********************************************************/
31 class mosArthrology_Article
extends mosDBTable
{
44 public $checked_out = '0';
45 public $checked_out_time = '1979-12-19 00:00:00';
54 public function __construct($database) {
55 $this->mosDBTable( '#__arthrology', 'id', $database);
58 /******************************************************/
59 /* Implement load function to have additional stuff */
60 /******************************************************/
61 function load( $oid = null ) {
73 $class_vars = get_class_vars( get_class( $this ) );
74 foreach ($class_vars as $name => $value) {
75 if (($name != $k) and ($name != "_db") and ($name != "_tbl") and ($name != "_tbl_key")) {
76 $this->$name = $value;
80 $query = "SELECT e.*, c.name AS category, c.params AS cat_params"
81 . "\n FROM $this->_tbl e"
82 . "\n LEFT JOIN #__categories c ON c.id = e.catid"
83 . "\n WHERE e.$this->_tbl_key = $oid";
84 $this->_db
->setQuery( $query );
86 return $this->_db
->loadObject( $this );
89 /*******************************************/
90 /* Implement the database check function */
91 /*******************************************/
92 function check( $error_msg ) {
98 /*******************************************/
99 /* Implement the database store function */
100 /*******************************************/
101 function store( $updateNulls=false ) {
102 $k = $this->_tbl_key
;
104 //eliminate the unvalid params
105 $this->category
= null;
106 $this->cat_params
= null;
109 $ret = $this->_db
->updateObject( $this->_tbl
, $this, $this->_tbl_key
, $updateNulls );
111 $ret = $this->_db
->insertObject( $this->_tbl
, $this, $this->_tbl_key
);
114 $this->_error
= strtolower( get_class( $this ) ) . '::store failed <br />' . $this->_db
->getErrorMsg();
121 /******************************************/
122 /* Implement the database bind function */
123 /******************************************/
124 //de- / encoding of some passed variables as dates to timestamps and arrays to strings is necessary
125 function bind( $array, $ignore='' ) {
128 if (!is_array( $array )) {
129 $this->_error
= strtolower(get_class( $this ))."::bind failed.";
133 //check if articles for this category have to be published by an administrator
134 $category = new mosCategory ( $database );
135 $category->load( $array['catid'] );
136 $parameter = new mosParameters( $category->params
);
137 if ($parameter->get( 'autopublish' )) {
138 $array['published'] = '1';
141 return mosBindArrayToObject( $array, $this, $ignore );
144 /***********************************************************/
145 /* Bind this object to an array of a raw database result */
146 /***********************************************************/
147 function bindRaw( $array, $ignore='' ) {
148 return mosBindArrayToObject( $array, $this, $ignore, null, false );