? licensing.656770-1.patch
Index: hooks.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/licensing/hooks.php,v
retrieving revision 1.5
diff -u -p -r1.5 hooks.php
--- hooks.php	12 Jan 2010 09:19:44 -0000	1.5
+++ hooks.php	12 Jan 2010 10:24:28 -0000
@@ -130,4 +130,25 @@ function hook_licensing_operations($lice
   }
   
   return $ops;
+}
+
+/**
+ * If you wish to override what class is loaded in place of the default 'license' class, read this.
+ *
+ * As you can see at the top of licensing.module
+ *
+ * // Allow other modules to specify which class to load, they should be child
+ * // classes of license though.
+ * define('LICENSING_CLASS', variable_get('licensing_class', 'license'));
+ *
+ * Simply by doing a variable_set in your module's hook_enable (and removing it in hook_disable), 
+ * you can use your own child class in place of the license class. See this example:
+ */
+function hook_enable() {
+  variable_set('licensing_class', 'custom_class');
+}
+
+// Be sure to delete the variable when the module is disabled
+function hook_disable() {
+  variable_del('licensing_class');
 }
\ No newline at end of file
Index: licensing.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/licensing/licensing.module,v
retrieving revision 1.15
diff -u -p -r1.15 licensing.module
--- licensing.module	10 Jan 2010 22:50:12 -0000	1.15
+++ licensing.module	12 Jan 2010 10:24:29 -0000
@@ -23,6 +23,10 @@ define('LICENSING_USER_REGISTER_ENABLED_
 define('LICENSING_USER_REGISTER_MANDATORY_DEFAULT', FALSE);
 define('LICENSING_REGISTER_CONFIRMATION_ENABLED_DEFAULT', TRUE);
 
+// Allow other modules to specify which class to load, they should be child
+// classes of license though.
+define('LICENSING_CLASS', variable_get('licensing_class', 'license'));
+
 // Using a regular include_once to get around bug #658900
 if (function_exists('drupal_get_path')) {
   include_once(drupal_get_path('module', 'licensing') .'/includes/classes.inc');
@@ -151,7 +155,8 @@ function licensing_help($path, $arg) {
   break;
   }
   if (strpos(' '. $path, 'admin/settings/licensing') && $arg[6] == 'delete') {
-    $license = new license($arg[5]);
+    $class = LICENSING_CLASS;
+    $license = new $class($arg[5]);
     $message = t('Are you sure you want to delete license key '. $license->get_key() .'?');
     if ($license->get_uid()) {
       $message .= t('Beware that this license currently belongs to '. l($license->get_user()->name, 'user/'. $license->get_uid()) .'.');
@@ -367,14 +372,16 @@ function licensing_user($op, &$edit, &$a
   }
   if ($op == 'validate') {
     if ($edit['license']) {
-      $edit['#license'] = new license($edit['license']);
+      $class = LICENSING_CLASS;
+      $edit['#license'] = new $class($edit['license']);
       // invoke hook_licensing_register
       licensing_invoke_all('licensing_register', 'validate', $edit['#license'], $edit, $edit['form_id']);
     }
   }
   if ($op == 'insert') {
     if ($edit['license']) {
-      $edit['#license'] = new license($edit['license']);
+      $class = LICENSING_CLASS;
+      $edit['#license'] = new $class($edit['license']);
       // invoke hook_licensing_register
       licensing_invoke_all('licensing_register', 'submit', $edit['#license'], $edit, $edit['form_id']);
     }
@@ -418,7 +425,8 @@ function licensing_generate_key($qty) {
    while ($count <= $qty) {
     $brand = variable_get('licensing_license_branding', LICENSING_LICENSE_BRANDING_DEFAULT);
     $keyword = licensing_secretkeyword_get(FALSE);
-    $license = new license();
+    $class = LICENSING_CLASS;
+    $license = new $class();
     $license->new_lid = ($start + 1);
     licensing_invoke_all('licensingapi', 'generate', $license, NULL, $brand, $keyword);
     $license->save();
@@ -508,7 +516,8 @@ function licensing_get_user_license($uid
   $result = db_query("SELECT lid FROM {licensing_key} WHERE uid = %d", $uid);
   $licenses[$uid] = array();
   while ($row = db_fetch_object($result)) {
-    $licenses[$uid][] = new license($row->lid);
+    $class = LICENSING_CLASS;
+    $licenses[$uid][] = new $class($row->lid);
   }
   return $licenses[$uid];
 }
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/licensing/includes/form.inc,v
retrieving revision 1.5
diff -u -p -r1.5 form.inc
--- includes/form.inc	22 Dec 2009 01:02:35 -0000	1.5
+++ includes/form.inc	12 Jan 2010 10:24:29 -0000
@@ -82,7 +82,8 @@ function licensing_verify_form() {
 function licensing_verify_form_submit($form, &$form_state) {
   $keys = explode(', ', $form_state['values']['key']);
   foreach ($keys as $key) {
-    $licenses[] = new license($key);
+    $class = LICENSING_CLASS;
+    $licenses[] = new $class($key);
   }
   drupal_set_message(theme('licensing_verify_results', $licenses));
 }
@@ -166,7 +167,8 @@ function licensing_export_form_submit($f
  */
 function licensing_edit_license() {
   if (!is_numeric(arg(4))) { return array(); }
-  $license = new license(arg(4));
+  $class = LICENSING_CLASS;
+  $license = new $class(arg(4));
   $form = array(
     '#license' => $license,
     'lid' => array(
@@ -226,7 +228,8 @@ function licensing_edit_license_delete(&
 }
 
 function licensing_edit_license_submit($form, $form_state) {
-  $license = new license($form_state['values']['lid']);
+  $class = LICENSING_CLASS;
+  $license = new $class($form_state['values']['lid']);
   
   if ($form_state['values']['key'] && ($form_state['values']['key'] != $license->get_key())) {
     // if key exists in form state and is different to current licenes
@@ -256,9 +259,10 @@ function licensing_edit_license_submit($
  * Form builder for license delete page
  */
 function licensing_form_delete() {
+  $class = LICENSING_CLASS;
   return array(
     '#redirect' => array('admin/settings/licensing/key'),
-    '#license' => new license(arg(4)),
+    '#license' => new $class(arg(4)),
     'buttons' => array(
       'submit' => array(
         '#type' => 'submit',
@@ -310,7 +314,8 @@ function licensing_form_register() {
  * Form validation function for registration page
  */
 function licensing_form_register_validate(&$form, &$form_state) {
-  $form['#license'] = new license($form_state['values']['license']);
+  $class = LICENSING_CLASS;
+  $form['#license'] = new $class($form_state['values']['license']);
   // invoke hook_licensing_register
   licensing_invoke_all('licensing_register', 'validate', $form['#license'], $form_state['values'], str_replace('-', '_', $form['#id']));
 }
@@ -319,7 +324,8 @@ function licensing_form_register_validat
  * Form submission function for registration page
  */
 function licensing_form_register_submit(&$form, &$form_state) {
-  $form['#license'] = new license($form_state['values']['license']);
+  $class = LICENSING_CLASS;
+  $form['#license'] = new $class($form_state['values']['license']);
   // invoke hook_licensing_register
   licensing_invoke_all('licensing_register', 'submit', $form['#license'], $form_state['values'], str_replace('-', '_', $form['#id']));
 }
\ No newline at end of file
Index: views/handlers/views_handler_field_license_ops.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/licensing/views/handlers/views_handler_field_license_ops.inc,v
retrieving revision 1.1
diff -u -p -r1.1 views_handler_field_license_ops.inc
--- views/handlers/views_handler_field_license_ops.inc	9 Dec 2009 10:49:07 -0000	1.1
+++ views/handlers/views_handler_field_license_ops.inc	12 Jan 2010 10:24:29 -0000
@@ -36,7 +36,8 @@ class views_handler_field_license_ops ex
   function render($values) {
     // limitation of this, is it won't have a lid unless that field is presented first in the view
     $lid = ($values->lid) ? (int)$values->lid : 0;
-    $license = new license($lid);
+    $class = LICENSING_CLASS;
+    $license = new $class($lid);
     
     $ops = array();
     $ops = licensing_invoke_all('licensing_operations', $license, $_GET['q']);
