Location: PHPKode > projects > Echelon - A Writing Center Portal > echelon-1.0.0/include/goaldata.php
<?php
/* goaldata.php -- Defines the DO_GoalData type */

define('DB_DATAOBJECT_NO_OVERLOAD',true);

require_once("config.php");
require_once("DataObjectInclude/DataObject.php");
require_once("util.php");

/* Parse configuration data for DB_DataObject */
$config = parse_ini_file('DO_config.ini.php',TRUE);
foreach($config as $class=>$values)
{
    $options = &PEAR::getStaticProperty($class,'options');
    $options = $values;
}

// DB_DataObject::DebugLevel(5);	// Uncomment for debugging purposes

global $DATABASE;
define ('DO_GOALDATA_TABLE', $DATABASE['prefix'] . 'goaldata');

class DO_GoalData extends DB_DataObject
{	
	/* BEGIN data member declarations */

	/* Database and table config */
	var $_database_dsn = CONFIG_DSN_STR;
	var $__table = DO_GOALDATA_TABLE;
	
	/* The "actual" class member variables */

	// Auto-set by the the database
	public $id;

	public $appointment_id;
	public $goaltemplate_id;

	// Format: "ValueForCategory1;ValueForCategory2..."
	// (-1 for None Selected)
	public $regulardata_str;

	public $other_issues;
	public $accomplishments;
	public $suggestions;

	public $regulardata_arr;
	
	// Used to delete an entry when a new entry is created while providing illegal values
	public $creation_instance;
	
	/* END data member declarations */

	function __construct($create_new = false)
	{
		$this->regulardata_arr = array();

		$this->creation_instance = $create_new;
		if ($create_new)
		{
			$this->insert();
		}
	}
	
	/* BEGIN functions required by DB_DataObject */

	function staticGet($k, $v = NULL)
	{
		return DB_DataObject::staticGet('DO_GoalData',$k,$v);
	} 

	// Returns an array with the table structure
	function table()
	{
		return array (
			'id' => DB_DATAOBJECT_INT,
			'appointment_id' => DB_DATAOBJECT_INT,
			'goaltemplate_id' => DB_DATAOBJECT_INT,
			'regulardata_str' => DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT,
			'other_issues' => DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT,
			'accomplishments' => DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT,
			'suggestions' => DB_DATAOBJECT_STR + DB_DATAOBJECT_TXT
		);
	}

	function id()
	{
		return array('id');
	}

	/* END functions required by DB_DataObject */

	function load_regulardata_arr($arg_id)
	{
		$this->get((int) $arg_id);
		$tmp_arr = explode(';', $this->regulardata_str);
		foreach ($tmp_arr as $key => $value)
		{
			$tmp_arr[$key] = code2chars($value);
		}
		$this->regulardata_arr = $tmp_arr;
	}
	
	function build_regulardata_str($input_arr)
	{
		foreach ($input_arr as $key => $value)
		{
			if (is_illegal($value))
			{
				if ($this->creation_instance)
				{
					$this->delete();
				}
				die('Illegal values provided.  Following strings are disallowed: ' . get_illegal_values());
			}
			$input_arr[$key] = chars2code($value);
		}
		$this->regulardata_str = implode(';', $input_arr);
		$this->update();
	}

	/* BEGIN data member set functions */
	
	function set_goaltemplate_id($inid)
	{
		$this->goaltemplate_id = $inid;
		$this->update();
	}
	
	function set_appointment_id($inid)
	{
		$this->appointment_id = $inid;
		$this->update();
	}
	
	function set_other_issues($input)
	{
		$this->other_issues = trim($input);
		$this->update();
	}

	function set_accomplishments($input)
	{
		$this->accomplishments = trim($input);
		$this->update();
	}

	function set_suggestions($input)
	{
		$this->suggestions = trim($input);
		$this->update();
	}
	
	/* END data member set functions */

	/* BEGIN data member return functions */
	
	function get_regulardata_arr()
	{
		return $this->regulardata_arr;
	}

	function get_other_issues()
	{
		return $this->other_issues;
	}
	
	function get_accomplishments()
	{
		return $this->accomplishments;
	}

	function get_suggestions()
	{
		return $this->suggestions;
	}

	function get_goaltemplate_id()
	{
		return $this->goaltemplate_id;
	}

	function get_id()
	{
		return $this->id;
	}
	
	/* END data member return functions */
}
?>
Return current item: Echelon - A Writing Center Portal