/**
  * Post save() hook provided by Doctrine.
  *
  *
  * @return void
  *
  * @param Doctrine_Event $event
  */
 public function postSave($event)
 {
     /*
      * Clear the current projects and orgs RSS feed cache(s).
      */
     if ($this->ProjectInquiry) {
         foreach ($this->ProjectInquiry as $pi) {
             if (file_exists($pi->Project->get_rss_cache_path())) {
                 unlink($pi->Project->get_rss_cache_path());
             }
         }
     }
     if ($this->InqOrg) {
         foreach ($this->InqOrg as $io) {
             if (file_exists($io->Organization->get_rss_cache_path())) {
                 unlink($io->Organization->get_rss_cache_path());
             }
         }
     }
     /*
      * Clear the RSS feed cache for all projects.
      */
     if (file_exists(Project::get_combined_rss_cache_path())) {
         unlink(Project::get_combined_rss_cache_path());
     }
     // manual entry has no need of default questions
     if ($this->inq_type != self::$TYPE_MANUAL_ENTRY) {
         // see about default questions.
         $this->_check_default_questions();
         $this->check_permission_question(false);
     }
 }
 /**
  * RSS feed for displaying a project's - or multiple projects' - inquiries.
  *
  * @return void
  * @param string  $prj_name (optional)
  */
 public function project($prj_name = null)
 {
     // only RSS available
     $this->airoutput->view = 'rss';
     $this->airoutput->format = 'application/rss+xml';
     $project = null;
     $inquiries = null;
     if ($prj_name) {
         // Sanitize and standardize prj_name.
         $prj_name = strtolower($prj_name);
         // Get actual project, to tailor the feed.
         $q = Doctrine_Query::create()->from('Project p');
         $q->leftJoin('p.OrgDefault');
         $q->andWhere('lower(prj_name) = ?', $prj_name);
         $project = $q->fetchOne();
         if (!$project) {
             show_404();
             return;
         }
         $inquiries = $project->get_inquiries_in_rss_feed();
     } else {
         $inquiries = Inquiry::get_all_published_rss();
     }
     // Publish date of the feed. Default to now, in case there are no inquiries.
     $pub_date = $this->_rss_datetime();
     if (count($inquiries) > 0) {
         // Use the publish date and time of the most recent inquiry as the
         // publish date-time of the feed.
         $pub_date = $this->_rss_datetime($inquiries[0]->inq_publish_dtim);
     }
     $items = $this->_build_inquiries_feed($inquiries);
     // defaults
     $title = 'Queries from the Public Insight Network';
     $description = 'Answer these questions to inform Public Insight Network reporting.  Share what you know!';
     $link = 'http://www.publicinsightnetwork.org';
     $logo_uri = 'http://www.publicinsightnetwork.org/user/signup/support/standard/images/apm.jpg';
     $cache_path = Project::get_combined_rss_cache_path();
     // override defaults is we were asked for a specific project
     if ($project && count($project->OrgDefault) > 0) {
         $org = $project->OrgDefault[0];
         $logo = $org->Logo;
         if ($logo) {
             $logo_uris = $logo->get_image(true);
             if (trim($logo_uris['original'])) {
                 $logo_uri = $logo_uris['original'];
             }
         }
         if (strlen($org->org_summary)) {
             $description = $org->org_summary;
         }
         if (strlen($org->org_site_uri)) {
             $link = $org->org_site_uri;
         }
     }
     // title and cache regardless of OrgDefault
     if ($project) {
         $title = $project->prj_display_name;
         $cache_path = $project->get_rss_cache_path();
     }
     $this->_build_response($items, $title, $description, $link, $logo_uri, $pub_date, $cache_path);
 }