Index: password_policy.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/password_policy/password_policy.install,v
retrieving revision 1.10
diff -u -p -r1.10 password_policy.install
--- password_policy.install	14 Apr 2010 16:47:25 -0000	1.10
+++ password_policy.install	1 Dec 2010 00:28:28 -0000
@@ -13,11 +13,29 @@ function password_policy_schema() {
   return array(
     'password_policy' => array(
       'description' => t("Stores password policies."),
+      'export' => array (
+      // unique key to identify an object
+      'key' => 'name',
+      //object type identifier
+      'identifier' => 'password_policy',
+      // Function hook name in Features dump
+      'default hook' => 'default_password_policy',
+      'api' => array(
+         // Which module "owns" these objects?
+	 'owner' => 'password_policy',
+	 //Base name for Features include file
+	 'api' => 'default_password_policy',
+	 // Exportables API version numbers: 
+	 'minimum_version' => 1,
+	 'current_version' => 1,
+	 ),
+      ),
       'fields' => array(
         'pid' => array(
           'description' => t("Primary Key: Unique password policy ID."),
           'type' => 'serial',
           'not null' => TRUE,
+	  'no export' => TRUE, // Do not export database-only keys
         ),
         'name' => array(
           'description' => t("The name of the policy."),
@@ -70,6 +88,9 @@ function password_policy_schema() {
         ),
       ),
       'primary key' => array('pid'),
+      'unique keys' => array (
+         'name' => array('name'),
+	 ),
     ),
     'password_policy_history' => array(
       'description' => t("Stores users' old password hashes."),
@@ -139,6 +160,28 @@ function password_policy_schema() {
     ),
     'password_policy_role' => array(
       'description' => t("Links policies with roles."),
+      'export' => array (
+      // unique key to identify an object
+      // NOTE: this will only work for admin,anon,authenticated users (1,0,2)
+      // as other rids could vary from machine to machine db only id
+      // so this needs work to support roles beyond those for a machine name
+      // but roles doesn't lend itself to that easily as name is not unique
+      // must also change to join based on name instead of pid on password_policy_role table
+      'key' => 'name',
+      //object type identifier
+      'identifier' => 'password_policy_role',
+      // Function hook name in Features dump
+      'default hook' => 'default_password_policy_role',
+      'api' => array(
+         // Which module "owns" these objects?
+	 'owner' => 'password_policy',
+	 //Base name for Features include file
+	 'api' => 'default_password_policy_role',
+	 // Exportables API version numbers: 
+	 'minimum_version' => 1,
+	 'current_version' => 1,
+	 ),
+      ),
       'fields' => array(
         'rid' => array(
           'description' => t("Role ID."),
@@ -151,9 +194,21 @@ function password_policy_schema() {
           'type' => 'int',
           'not null' => TRUE,
           'default' => 0,
+	  'no export' => TRUE, // Do not export database-only keys
+        'name' => array(
+          'description' => t("The name of the policy."),
+          'type' => 'varchar',
+          'length' => 64,
+          'not null' => TRUE,
+          'default' => '',
+        ),
         ),
+
       ),
       'primary key' => array('rid', 'pid'),
+      'unique keys' => array (
+         'name' => array('rid','name'),
+	 ),
     ),
   );
 
@@ -258,3 +313,48 @@ function password_policy_update_6002() {
   ));
   return $ret;
 }
+
+/**
+ * Make sure name on password_policy is unique for exportables (features)
+ */
+function password_policy_update_6003() {
+  $ret = array();
+  $ret[] = db_add_unique_key($ret, 'password_policy','name',
+  array('name'));
+  return $ret;
+}
+
+/**
+ * Make sure name column on password_policy_role for exportables (features)
+ */
+function password_policy_update_6004() {
+  $ret = array();
+  $ret[] = db_add_field($ret, 'password_policy_role','name',
+     array('type' => 'varchar', 'length' => 64,'not null' => TRUE,'default' => ''));
+  return $ret;
+}
+
+/**
+ * Make sure name column on password_policy_role is set with corrsponding name
+ */
+function password_policy_update_6005() {
+  $ret = array();
+// update name based on name from password_policy table where pid's match
+// update password_policy_role pr, password_policy
+// set pr.name = pp.name
+// where pr.pid = pp.pid;
+  $ret[] = update_sql("update {password_policy_role} pr, {password_policy} pp set pr.name = pp.name where pr.pid = pp.pid");
+  return $ret;
+}
+
+/**
+ * Add unique key on password_policy_role for exportables (rid,name)
+ */
+function password_policy_update_6006() {
+  $ret = array();
+// could drop past primary key, and add new primary key but this 
+// works for now leaving old primary in place
+  $ret[] = db_add_unique_key($ret, 'password_policy_role','name',
+  array('rid','name'));
+  return $ret;
+}
