/**
  * Tags saving logic, runned after the object himself has been saved
  *
  * @param      BaseObject  $object
  */
 public function postSave(BaseObject $object)
 {
     $tags = self::get_tags($object);
     $removed_tags = self::get_removed_tags($object);
     // read some config parameters and defaults
     $anonymous_tagging = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_anonymous_tagging', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_anonymous_tagging', true));
     $allows_tagging_removal = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_allows_tagging_removal', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_allows_tagging_removal', 'all'));
     $tagging_removal_credentials = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_tagging_removal_credentials', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_tagging_removal_credentials', array()));
     $use_unique_triple_values = sfConfig::get(sprintf('propel_behavior_deppPropelActAsTaggableBehavior_%s_use_unique_triple_values', get_class($object)), sfConfig::get('app_deppPropelActAsTaggableBehaviorPlugin_use_unique_triple_values', false));
     $user = @sfContext::getInstance()->getUser();
     // save new tags
     foreach ($tags as $tagname) {
         if ($use_unique_triple_values) {
             $tag = TagPeer::retrieveOrCreateByTripleValue($tagname);
         } else {
             $tag = TagPeer::retrieveOrCreateByTagName($tagname);
         }
         $tag->save();
         $tagging = TaggingPeer::retrieveOrCreateByTagAndTaggable($tag->getId(), $object->getPrimaryKey(), get_class($object));
         $user_id = deppPropelActAsTaggableToolkit::getUserId();
         if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '') {
             if ($tagging->isNew()) {
                 $tagging->setUserId($user_id);
             }
         }
         $tagging->save();
     }
     // remove removed tags
     $removed_tag_ids = array();
     $c = new Criteria();
     $c->add(TagPeer::NAME, $removed_tags, Criteria::IN);
     if (Propel::VERSION >= '1.3') {
         $rs = TagPeer::doSelectStmt($c);
         while ($row = $rs->fetch(PDO::FETCH_ASSOC)) {
             $removed_tag_ids[] = intval($row['ID']);
         }
     } else {
         $rs = TagPeer::doSelectRS($c);
         while ($rs->next()) {
             $removed_tag_ids[] = $rs->getInt(1);
         }
     }
     $c = new Criteria();
     $c->add(TaggingPeer::TAG_ID, $removed_tag_ids, Criteria::IN);
     $c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey());
     $c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object));
     $user_id = deppPropelActAsTaggableToolkit::getUserId();
     // for authenticated users that do not have tagging_removal_credentials
     // if the only tags they're allowed to remove are their own
     // then, remove only those tags
     // this only works, if anonymnous_tagging is set to false
     if (!$anonymous_tagging && $user->isAuthenticated() && !is_null($user_id) && $user_id != '' && $allows_tagging_removal == 'self' && !$user->hasCredential($tagging_removal_credentials, false)) {
         $c->add(TaggingPeer::USER_ID, $user_id);
     }
     // delete e non doDelete, in modo che anche sul tagging si possano attivare i behavior (per le news)
     // TaggingPeer::doDelete($c);
     $tags_to_delete = TaggingPeer::doSelect($c);
     foreach ($tags_to_delete as $tag_to_delete) {
         $tag_to_delete->delete();
     }
     $tags = array_merge(self::get_tags($object), $this->getSavedTags($object));
     self::set_saved_tags($object, $tags);
     self::clear_tags($object);
     self::clear_removed_tags($object);
 }