You are here

function og_update_3 in Organic groups 5.3

Same name and namespace in other branches
  1. 5.8 og.install \og_update_3()
  2. 5 og.install \og_update_3()
  3. 5.2 og.install \og_update_3()
  4. 5.7 og.install \og_update_3()

File

./og.install, line 140

Code

function og_update_3() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    case 'pgsql':
      $sql = "DELETE FROM {node_access} WHERE realm = 'og_uid'";
      db_query($sql);
      $sql = "SELECT DISTINCT(n.nid) FROM {node} n INNER JOIN {node_access} na ON n.nid = na.nid WHERE type != 'og' AND na.realm = 'og_group'";
      $result = db_query($sql);
      while ($row = db_fetch_object($result)) {
        $sql = "UPDATE {node_access} SET grant_view=1, grant_update=1, grant_delete=1 WHERE realm = 'og_group' AND nid = %d AND gid != 0";
        db_query($sql, $row->nid);
      }
      $sql = "SELECT nid FROM {node} WHERE type = 'og'";
      $result = db_query($sql);
      while ($row = db_fetch_object($result)) {
        og_deleteifpresent_2keys('node_access', array(
          'nid',
          'gid',
        ), array(
          '%d',
          '%d',
        ), array(
          $object->nid,
          $object->gid,
        ));
        $sql = "INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, 'og_group', 1, 1, 0)";
        db_query($sql, $row->nid, $row->nid);
      }
  }
  return array();
}