/**
  * After save method. Called after all saves
  *
  * Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
  * parameters to be saved.
  * 
  * Will trigger counterCache updates if enabled, tries to set the scope based on passed data.
  *
  * @param AppModel $Model Model instance.
  * @param boolean $created indicates whether the node just saved was created or updated
  * @return boolean true on success, false on failure
  * @access public
  */
 public function afterSave($Model, $created)
 {
     if ($this->scoped($Model)) {
         $this->__setScope($Model, $Model->data[$Model->alias]);
     }
     //Pass on to TreeBehavior to do stuff that trees like to do
     $return = parent::afterSave($Model, $created);
     if ($this->counterCacheEnabled($Model)) {
         $parent_id = $Model->field($this->settings[$Model->alias]['parent']);
         if ($parent_id) {
             $this->updateTreeCounterCache($Model, $parent_id);
         }
         if ($this->counterCacheEnabled($Model) && isset($this->__oldParentId) && !empty($this->__oldParentId)) {
             $this->updateTreeCounterCache($Model, $this->__oldParentId);
             $this->__oldParentId = null;
         }
     }
     return $return;
 }
 /**
  * Trigger the update counter cache
  *
  * @param AppModel $model The model object that the behavior is attached to
  * @param boolean $created Whether the record was created, or false if edited
  * @access public
  */
 function afterSave(&$model, $created)
 {
     // Get parent after save logic out of the way
     parent::afterSave($model, $created);
     // Trigger the update counter cache
     $result = $this->_updateCounterCache($model);
     return $result;
 }