Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
load('api', null);
require_once('./includes/functions_datastore.php');
/**
* API: User help
*
* @author Blue Static
* @copyright Copyright ©2002 - 2007, Blue Static
* @version $Revision$
* @package Bugdar
*
*/
class UserHelpAPI extends API
{
/**
* Fields
* @var array
* @access private
*/
var $fields = array(
'keystring' => array(TYPE_STR, REQ_AUTO),
'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
'body' => array(TYPE_STR, REQ_YES)
);
/**
* Database table
* @var string
* @access private
*/
var $table = 'fieldhelp';
/**
* Table prefix
* @var string
* @access private
*/
var $prefix = TABLE_PREFIX;
// ###################################################################
/**
* A static function that returns an array of all the keystrings that
* are not allowed to be deleted
*
* @access public
*
* @return array Array of keystrings
*/
function not_able_to_delete()
{
return array(
'assignedto',
'bugid',
'dateline',
'dependency',
'duplicateof',
'priority',
'product',
'reporter',
'resolution',
'severity',
'status',
'summary',
'newreply',
'columnorder'
);
}
// ###################################################################
/**
* Pre-insert
*
* @access private
*/
function pre_insert()
{
if (($err = $this->verify_keystring()) !== true)
{
$this->error($err);
}
}
// ###################################################################
/**
* Post-insert
*
* @access private
*/
function post_insert()
{
build_user_help();
}
// ###################################################################
/**
* Post-update
*
* @access private
*/
function post_update()
{
build_user_help();
}
// ###################################################################
/**
* Pre-delete
*
* @access private
*/
function pre_delete()
{
if (in_array($this->values['keystring'], UserHelpAPI::not_able_to_delete()))
{
return false;
}
return true;
}
// ###################################################################
/**
* Post-delete
*
* @access private
*/
function post_delete()
{
build_user_help();
}
// ###################################################################
/**
* Verify: keystring
*
* @access private
*/
function verify_keystring()
{
if (!is_bool($ne = $this->verify_noempty('keystring')))
{
return $ne;
}
if (preg_match('#[^a-z0-9_]#', $this->values['keystring']))
{
return _('The unique key can only contain lowercase letters, underscores, and numbers.');
}
if ($this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "fieldhelp WHERE keystring = '" . $this->registry->escape($this->values['keystring']) . "'"))
{
return _('The unique key must be unique.');
}
return true;
}
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>