You are here

function password_policy_update_6000 in Password Policy 6

File

./password_policy.install, line 205
File module installation and upgrade code.

Code

function password_policy_update_6000() {
  $ret = array();
  db_add_field($ret, 'password_policy', 'weight', array(
    'description' => t("Weight of the policy, used to order active policies."),
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_create_table($ret, 'password_policy_role', array(
    'description' => t("Links policies with roles."),
    'fields' => array(
      'rid' => array(
        'description' => t("Role ID."),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'pid' => array(
        'description' => t("Policy ID."),
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'rid',
      'pid',
    ),
  ));

  // Ensure existing policies are active for all roles.
  $result = db_query("SELECT pid FROM {password_policy}");
  while ($row = db_fetch_object($result)) {
    $ret[] = update_sql("INSERT INTO {password_policy_role} (pid, rid) VALUES (" . $row->pid . ", " . DRUPAL_AUTHENTICATED_RID . ")");
    $ret[] = update_sql("INSERT INTO {password_policy_role} (pid, rid) VALUES (" . $row->pid . ", " . DRUPAL_ANONYMOUS_RID . ")");
  }
  return $ret;
}