Example #1
0
 static function processNew(File $file, Notice $notice)
 {
     static $seen = array();
     $file_id = $file->getID();
     $notice_id = $notice->getID();
     if (!array_key_exists($notice_id, $seen)) {
         $seen[$notice_id] = array();
     }
     if (empty($seen[$notice_id]) || !in_array($file_id, $seen[$notice_id])) {
         try {
             $f2p = File_to_post::getByPK(array('post_id' => $notice_id, 'file_id' => $file_id));
         } catch (NoResultException $e) {
             $f2p = new File_to_post();
             $f2p->file_id = $file_id;
             $f2p->post_id = $notice_id;
             $f2p->insert();
             $file->blowCache();
         }
         $seen[$notice_id][] = $file_id;
     }
 }