User Tools

Site Tools


how_to_create_a_customer_module

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to_create_a_customer_module [2016/02/09 03:22]
admin [Newsletter Service Module]
how_to_create_a_customer_module [2020/05/20 22:07] (current)
admin
Line 39: Line 39:
     }     }
          
-    public function validate($data) { +    function settings() { 
-     +        
-      if (empty($this->settings['status'])) return; +      return array( 
-       +        array( 
-      // Validate some data and return an error +          'key' => 'status', 
-      // ... +          'default_value' => '1', 
-      //return array('error' => 'Your data is not valid'); +          'title' => language::translate(__CLASS__.':title_status', 'Status'), 
-       +          'description' => language::translate(__CLASS__.':description_status', 'Enables or disables the module.'), 
-      return true;+          'function' => 'toggle("e/d")', 
 +        ), 
 +        array( 
 +          'key' => 'priority', 
 +          'default_value' => '0', 
 +          'title' => language::translate(__CLASS__.':title_priority', 'Priority'), 
 +          'description' => language::translate(__CLASS__.':description_priority', 'Process this module in the given priority order.'), 
 +          'function' => 'int()', 
 +        ), 
 +      );
     }     }
          
-    public function update($data) {+    public function install() {} 
 +     
 +    public function uninstall() {} 
 +  } 
 + 
 +</file> 
 + 
 +===== Validate Customer Details ===== 
 + 
 +Use a customer module to validate customer details: 
 + 
 +<file php ~/includes/modules/customer/cm_validate.inc.php> 
 +<?php 
 + 
 +  class cm_validate { 
 +    public $id = __CLASS__; 
 +    public $name = 'Validate Something'; 
 +    public $description = ''; 
 +    public $author = 'ACME Corp.'; 
 +    public $version = '1.0'; 
 +    public $website = 'http://www.acme.com'; 
 +    public $priority = 0; 
 +     
 +    public function validate($data) {
          
       if (empty($this->settings['status'])) return;       if (empty($this->settings['status'])) return;
              
-      // The customer profile was saved. Do something with the saved data. +    // Validate some data and return an error 
-      // ... +      if ($something == 'bad') { 
-    }+        return array('error' => 'Something is just not good enough'); 
 +      } 
 +    } 
          
     function settings() {     function settings() {
Line 82: Line 116:
     public function uninstall() {}     public function uninstall() {}
   }   }
-   +
-?>+
 </file> </file>
  
Line 139: Line 172:
     public function uninstall() {}     public function uninstall() {}
   }   }
-   +
-?>+
 </file> </file>
how_to_create_a_customer_module.1454984564.txt.gz · Last modified: 2016/02/09 03:22 by admin