From c4e862f97f7ff4e46529fb6541595a90c31f3921 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 6 Sep 2008 16:12:42 -0400 Subject: [PATCH] Update api_usergroup.php --- includes/api_usergroup.php | 97 +++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/includes/api_usergroup.php b/includes/api_usergroup.php index 2344287..d8190d4 100644 --- a/includes/api_usergroup.php +++ b/includes/api_usergroup.php @@ -19,8 +19,7 @@ || ################################################################### \*=====================================================================*/ -$GLOBALS['isso:callback']->load('api', null); - +require_once ISSO . '/Api.php'; require_once('./includes/functions_datastore.php'); /** @@ -32,86 +31,88 @@ require_once('./includes/functions_datastore.php'); * @package Bugdar * */ -class UsergroupAPI extends API +class UsergroupAPI extends BSApi { /** - * Fields - * @var array - * @access private - */ - var $fields = array( - 'usergroupid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'), - 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'), + * Fields + * @var array + */ + protected $fields = array( + 'usergroupid' => array(TYPE_UINT, REQ_AUTO), + 'title' => array(TYPE_STR, REQ_YES), 'displaytitle' => array(TYPE_STR, REQ_NO), 'permissions' => array(TYPE_UINT, REQ_NO) ); /** - * Database table - * @var string - * @access private - */ - var $table = 'usergroup'; + * Database table + * @var string + */ + protected $table = 'usergroup'; /** - * Table prefix - * @var string - * @access private - */ - var $prefix = TABLE_PREFIX; + * Table prefix + * @var string + */ + protected $prefix = TABLE_PREFIX; - // ################################################################### /** - * Post-insert - * - * @access private - */ - function post_insert() + * Post-insert + */ + protected function post_insert() { build_usergroups(); } - // ################################################################### /** - * Post-update - * - * @access private - */ - function post_update() + * Post-update + */ + protected function post_update() { build_usergroups(); build_assignedto(); } - // ################################################################### /** - * Pre-delete - * - * @access private - */ - function pre_delete() + * Pre-delete + */ + protected function pre_delete() { if ($this->values['usergroupid'] < 7) { - return T('You can\'t delete a default usergroup.'); + throw new FieldException(T('You can\'t delete a default usergroup.'), 'usergroupid'); + return false; } } - // ################################################################### /** - * Post-delete - * - * @access private - */ - function post_delete() + * Post-delete + */ + protected function post_delete() { - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . $this->values['usergroupid']); - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid = " . $this->values['usergroupid']); - $this->registry->db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = 2 WHERE usergroupid = " . $this->values['usergroupid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . $this->values['usergroupid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid = " . $this->values['usergroupid']); + BSApp::$db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = 2 WHERE usergroupid = " . $this->values['usergroupid']); build_usergroups(); build_permissions(); build_assignedto(); } + + /** + * Validate: usergroupid + */ + protected function validate_usergroupid($field) + { + return $this->_verifyIsNotZero($field); + } + + /** + * Validate: usergroup + */ + protected function validate_usergroup($field) + { + return $this->_verifyIsNotEmpty($field); + } } /*=====================================================================*\ -- 2.43.5