public static function save_versions($post = null, $versions = array())
 {
     if (isset($post) && count($versions) !== 0) {
         $vocabulary = Vocabulary::get(self::CATALOG_VOCABULARY);
         $extant_terms = $vocabulary->get_associations($post->id, 'addon');
         foreach ($versions as $key => $version) {
             $version_display = "{$version['habari_version']}-{$version['version']}";
             echo "Incoming Version: {$version_display}\n\n";
             $found = false;
             foreach ($extant_terms as $eterm) {
                 $extant_display = "{$eterm->info->habari_version}-{$eterm->info->version}";
                 echo ">> Extant Version: {$extant_display}\n\n";
                 if ($extant_display == $version_display) {
                     $found = true;
                     $term = $eterm;
                     break;
                 }
             }
             if (!$found) {
                 $term = new Term(array('term_display' => $version_display, 'term' => Utils::slugify("{$post->id} {$version_display} {$post->info->repo_url}", '-')));
             }
             foreach ($version as $field => $value) {
                 $term->info->{$field} = $value;
             }
             if ($found) {
                 $term->update();
             } else {
                 $vocabulary->add_term($term);
                 $term->associate('addon', $post->id);
             }
         }
     } else {
         // post didn't work or there was no version.
     }
 }
 public static function save_version($post = null, $versions = array())
 {
     if (isset($post) && count($versions) !== 0) {
         $vocabulary = Vocabulary::get(self::$vocabulary);
         $extant_terms = $vocabulary->get_associations($post->id, 'addon');
         foreach ($versions as $key => $version) {
             $term_display = "{$post->id} {$key} {$post->info->repo_url}";
             $found = false;
             foreach ($extant_terms as $eterm) {
                 if ($eterm->term_display == $term_display) {
                     // This is super-cheesy!
                     $found = true;
                     $term = $eterm;
                     break;
                 }
             }
             if (!$found) {
                 $term = new Term(array('term_display' => $post->id . " {$key}"));
             }
             foreach ($version as $field => $value) {
                 $term->info->{$field} = $value;
             }
             if ($found) {
                 $term->update();
             } else {
                 $vocabulary->add_term($term);
                 $term->associate('addon', $post->id);
             }
         }
     } else {
         // post didn't work or there was no version.
     }
 }