Update api_automation.php
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 16 Sep 2008 16:58:02 +0000 (12:58 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 16 Sep 2008 16:58:02 +0000 (12:58 -0400)
includes/api_attachment.php
includes/api_automation.php

index cb8c51059dbb6ab9c4dff8335bd5d997d1d228da..c98530d50ef7a3505782bb1c40796357a44eac2e 100644 (file)
 require_once ISSO . '/Api.php';
 
 /**
-* API: Attachment
-*
-* @author              Blue Static
-* @copyright   Copyright ©2002 - 2007, Blue Static
-* @version             $Revision$
-* @package             Bugdar
-* 
-*/
+ * API: Attachment
+ *
+ * @author             Blue Static
+ * @copyright  Copyright ©2002 - 2007, Blue Static
+ * @version            $Revision$
+ * @package            Bugdar
+ 
+ */
 class AttachmentAPI extends BSApi
 {
        /**
index becfda365fbc45d34bcaa07395f98510ee245af3..0e079f8695b8aee4c0ab32232d9735c1b9e8f4fc 100644 (file)
 || ###################################################################
 \*=====================================================================*/
 
-$GLOBALS['isso:callback']->load('api', null);
-
+require_once ISSO . '/Api.php';
 require_once('./includes/functions_datastore.php');
 
 /**
-* API: Automation
-*
-* @author              Blue Static
-* @copyright   Copyright ©2002 - 2007, Blue Static
-* @version             $Revision$
-* @package             Bugdar
-* 
-*/
-class AutomationAPI extends API
+ * API: Automation
+ *
+ * @author             Blue Static
+ * @copyright  Copyright ©2002 - 2007, Blue Static
+ * @version            $Revision$
+ * @package            Bugdar
+ 
+ */
+class AutomationAPI extends BSApi
 {
        /**
-       * Fields
-       * @var  array
-       * @access       private
-       */
-       var $fields = array(
-               'actionid'              => array(TYPE_UINT,             REQ_AUTO,       'verify_nozero'),
-               'name'                  => array(TYPE_STR,              REQ_YES,        'verify_noempty'),
+        * Fields
+        * @var array
+        */
+       protected $fields = array(
+               'actionid'              => array(TYPE_UINT,             REQ_AUTO),
+               'name'                  => array(TYPE_STR,              REQ_YES),
                'description'   => array(TYPE_STR,              REQ_NO),
-               'fieldchanges'  => array(TYPE_NONE,             REQ_YES,        ':self'),
+               'fieldchanges'  => array(TYPE_NONE,             REQ_YES),
                'comment'               => array(TYPE_STR,              REQ_NO)
        );
        
        /**
-       * Table
-       * @var  string
-       * @access       private
-       */
-       var $table = 'automation';
+        * Table
+        * @var string
+        */
+       protected $table = 'automation';
        
        /**
-       * 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_automations();
        }
        
-       // ###################################################################
        /**
-       * Post-update
-       *
-       * @access       private
-       */
-       function post_update()
+        * Post-update
+        */
+       protected function post_update()
        {
                build_automations();
        }
        
-       // ###################################################################
        /**
-       * Post-delete
-       *
-       * @access       private
-       */
-       function post_delete()
+        * Post-delete
+        */
+       protected function post_delete()
        {
                build_automations();
        }
        
-       // ###################################################################
        /**
-       * Verify: fieldchanges
-       *
-       * @access       private
-       */
-       function verify_fieldchanges()
+        * Validate: actionid
+        */
+       protected function validate_actionid($field)
+       {
+               return $this->_verifyIsNotZero($field);
+       }
+       
+       /**
+        * Validate: name
+        */
+       protected function validate_name($field)
+       {
+               return $this->_verifyIsNotEmpty($field);
+       }
+       
+       /**
+        * Validate: fieldchanges
+        */
+       protected function validate_fieldchanges()
        {
-               if (!is_array($this->values['fieldchanges']) OR sizeof($this->values['fieldchanges']) != 2 OR !is_array($this->values['fieldchanges']['custom']) OR !is_array($this->values['fieldchanges']['builtin']))
+               if (!is_array($this->values['fieldchanges']) || sizeof($this->values['fieldchanges']) != 2 || !is_array($this->values['fieldchanges']['custom']) || !is_array($this->values['fieldchanges']['builtin']))
                {
                        return T('Invalid array type passed. The fieldchaneges array must be a two-dimensional array: array("builtin" => array("fieldname" => "newvalue" ...), "custom" => array("fieldname" => "fieldvalue" ...))');
                }
                
-               if (sizeof($this->values['fieldchanges']['custom']) < 1 AND sizeof($this->values['fieldchanges']['builtin']) < 1)
+               if (sizeof($this->values['fieldchanges']['custom']) < 1 && sizeof($this->values['fieldchanges']['builtin']) < 1)
                {
                        return T('You need to specify some fields to change.');
                }