publishcontent.install 1012 B

1234567891011121314151617181920212223
  1. <?php
  2. function publishcontent_update_6001() {
  3. $ret = $node_types = array();
  4. $query = 'SELECT pid, perm FROM {permission}';
  5. $result = db_query($query);
  6. $update_sql = 'UPDATE {permission} SET perm = "%s" WHERE pid = %d';
  7. while ($row = db_fetch_array($result)) {
  8. $old_perm = $row['perm'];
  9. $subjects = array('*all*');
  10. $replacements = array('any');
  11. foreach (node_get_types() as $type) {
  12. $subjects[] = 'publish ' . check_plain($type->type) . ' content';
  13. $subjects[] = 'unpublish ' . check_plain($type->type) . ' content';
  14. $replacements[] = 'publish any ' . check_plain($type->type) . ' content';
  15. $replacements[] = 'unpublish any '. check_plain($type->type) . ' content';
  16. }
  17. $new_perm = str_replace($subjects, $replacements, $row['perm']);
  18. $ret[] = array('success' => db_query($update_sql, $new_perm, $row['pid']), 'query' => t('Updated permission set @set', array('@set' => $row['pid'])));
  19. }
  20. variable_set('menu_rebuild_needed', TRUE);
  21. return $ret;
  22. }