/**
  * Make sure new Organizations get default projects
  *
  * @param Doctrine_Event $event
  */
 public function postInsert($event)
 {
     if (self::$CREATE_DEFAULT_PRJ && $this->org_default_prj_id == 1 && $this->org_type != 'T') {
         $p = new Project();
         $p->prj_name = air2_urlify($this->org_name);
         $p->prj_display_name = 'Project ' . $this->org_display_name;
         $p->prj_desc = 'Default project for organization "' . $this->org_display_name . '"';
         $p->ProjectOrg[0]->porg_org_id = $this->org_id;
         $p->ProjectOrg[0]->porg_contact_user_id = $this->org_cre_user;
         // make sure prj_name is unique
         $count = 0;
         $orig = $p->prj_name;
         $tbl = Doctrine::getTable('Project');
         $name = $tbl->findOneBy('prj_name', $p->prj_name);
         while ($name) {
             $p->prj_name = $orig . '_' . $count;
             $name = $tbl->findOneBy('prj_name', $p->prj_name);
         }
         // save, and make default
         $p->save();
         $this->org_default_prj_id = $p->prj_id;
         $this->save();
     }
     parent::postInsert($event);
 }
/**
 * Get the full URI for a relative path
 *
 * @param string  $path
 * @param array   $query (optional)
 * @return string $uri
 */
function air2_uri_for($path, $query = array())
{
    $base = 'air';
    // try really hard to get the actual base
    if (function_exists('base_url')) {
        $base = base_url();
    } elseif (getenv('AIR2_BASE_URL')) {
        $base = getenv('AIR2_BASE_URL');
    } elseif (defined('AIR2_BASE_URL')) {
        $base = AIR2_BASE_URL;
    }
    // cleanup and add path
    $base = preg_replace('/\\/$/', '', $base);
    $path = preg_replace('/^\\//', '', $path);
    $uri = strlen($path) ? "{$base}/{$path}" : $base;
    // version all css/js files
    if (preg_match('/\\.js$|\\.css$/', $uri) && defined('AIR2_SYSTEM_DISP_NAME')) {
        $query['v'] = air2_urlify(AIR2_VERSION);
    }
    // add query variables
    if (count($query)) {
        $uri .= '?' . http_build_query($query);
    }
    return $uri;
}
 /**
  *
  * @return string $uri_path
  */
 public function get_uri_path()
 {
     $title = $this->get_title();
     return sprintf("%s/insight/%s/%s", $this->InqOrg[0]->Organization->org_name, $this->inq_uuid, air2_urlify($title));
 }