How to make site admin member and admin of all OG groups

This is how you can make your site admin member and admin of all OG groups. Might be another way to do this is how make sure that I as a site admin even get access to groups created by other administrators.

<?php

/**
 * Will make sure that Siteadmin always have access to all groups
 * Called from atrium_opportunity_cron
 *
 */
function _add_siteadmin_to_all(){
   
    if(
$result = db_query("SELECT DISTINCT `og`.nid, `og`.og_description
                            FROM `og` LEFT JOIN `og_uid` ON ( `og`.nid = `og_uid`.nid AND `og_uid`.uid =1 ) WHERE uid IS NULL"
)) {
   
     
$ogs = array();
      while (
$data = db_fetch_object($result)) {
       
db_query("REPLACE INTO {og_uid} (nid, is_active, is_admin, uid, created, changed)
            VALUES (%d, %d, %d, %d, %d, %d)"
, $data->nid, 1, 1, 1, time(), time());
       
$ogs[] = $data->og_description;
      }
     
      if (
count($ogs) > 0) {
         
watchdog("og_access", "Added Siteadmin to: ".implode(", ", $ogs. " ".__FILE__.__LINE__));
      }
    }
}

?>
Knowledge keywords: