Hook containing the actual save code.

Call's afterSave() for user interaction.

@see afterSave()
3427
public function saveData()
    {
        $model = $this->getModel();

        if ($this->formData['gto_valid_until']) {
            // Make sure date based units are valid until the end of the day.
            $date = new \MUtil_Date(
                    $this->formData['gto_valid_until'],
                    $model->get('gto_valid_until', 'dateFormat')
                    );
            $date->setTimeToDayEnd();
            $this->formData['gto_valid_until'] = $date;
        }

        // Save the token using the model
        parent::saveData();
        // $this->token->setValidFrom($this->formData['gto_valid_from'], $this->formData['gto_valid_until'], $this->loader->getCurrentUser()->getUserId());

        // \MUtil_Echo::track($this->formData);

        // Refresh (NOT UPDATE!) token with current form data
        $updateData['gto_valid_from']         = $this->formData['gto_valid_from'];
        $updateData['gto_valid_from_manual']  = $this->formData['gto_valid_from_manual'];
        $updateData['gto_valid_until']        = $this->formData['gto_valid_until'];
        $updateData['gto_valid_until_manual'] = $this->formData['gto_valid_until_manual'];
        $updateData['gto_comment']            = $this->formData['gto_comment'];

        $this->token->refresh($updateData);

        $respTrack = $this->token->getRespondentTrack();
        $userId    = $this->loader->getCurrentUser()->getUserId();
        $changed   = $respTrack->checkTrackTokens($userId, $this->token);

        if ($changed) {
            $this->addMessage(sprintf($this->plural(
                    '%d token changed by recalculation.',
                    '%d tokens changed by recalculation.',
                    $changed
                    ), $changed));
        }
    }
588101
public void save() {
        SC.ask("Do you want to save changes", new BooleanCallback() {
            @Override
            public void execute(Boolean yesSelected) {
                if (yesSelected) {
                    jcrService().save(repository(), workspace(), new BaseCallback<Object>() {
                            @Override
                            public void onSuccess(Object result) {
                                session().setHasChanges(false);
                                updateControls();
                            }
                    });
                }
            }
        });
    }
159574
function onSaveSuccess(model, params, result) {
  Flux.dispatch(actionTypes.API_SAVE_SUCCESS, {
    model: model,
    params: params,
    result: result,
  })
  return result
}
441761
function save(callback) {
            var model, request;

            model = this;

            this.constructor.dispatch('beforeSave', {
                data : {
                    model : this
                }
            });
            this.dispatch('beforeSave');

            this.isValid(function (isValid) {
                if (isValid) {
                    if (model.hasOwnProperty('id') && model.id !== '') {
                        request = {
                            action : 'update',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.update(request, function updateCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                    else {
                        request = {
                            action : 'create',
                            data : model,
                            model : model.constructor
                        };
                        model.constructor.storage.create(request, function createCallback(data) {
                            model.constructor.dispatch('afterSave', {
                                data : {
                                    model : model
                                }
                            });

                            model.dispatch('afterSave');
                            if (callback) {
                                callback(data);
                            }
                        });
                    }
                } else {
                    if (callback) {
                        callback(data);
                    }
                }
            });

        }
102241
public function save()
    {
        $this->hook('beforeSave', array($this->id));

        $is_update = $this->loaded();
        if ($is_update) {
            $source = array();
            foreach ($this->dirty as $name => $junk) {
                $source[$name] = $this->get($name);
            }

            // No save needed, nothing was changed
            if (empty($source)) {
                return $this;
            }

            $this->hook('beforeUpdate', array(&$source));
        } else {

            // Collect all data of a new record
            $source = $this->get();

            $this->hook('beforeInsert', array(&$source));
        }

        if ($this->controller) {
            $this->id = $this->controller->save($this, $this->id, $source);
        }

        if ($is_update) {
            $this->hook('afterUpdate');
        } else {
            $this->hook('afterInsert');
        }

        if ($this->loaded()) {
            $this->dirty = array();
            $this->hook('afterSave', array($this->id));
        }

        return $this;
    }
129839
protected function setAfterSaveRoute()
    {
        parent::setAfterSaveRoute();

        if (is_array($this->afterSaveRouteUrl)) {
            if (isset($this->afterSaveRouteUrl['action'], $this->formData['gr2t_id_respondent_track']) &&
                    'index' !== $this->afterSaveRouteUrl['action']) {
                $this->afterSaveRouteUrl[\Gems_Model::RESPONDENT_TRACK] = $this->formData['gr2t_id_respondent_track'];
            }
        }
    }
982509
public void actionSave() {

        HttpServletRequest request = getJsp().getRequest();
        // save initialized instance of this class in request attribute for included sub-elements
        request.setAttribute(SESSION_WORKPLACE_CLASS, this);

        // special case: set the preferred editor settings in the user settings object
        CmsUserSettings userSettings = new CmsUserSettings(getSettings().getUser());
        // first set the old preferred editors
        m_userSettings.setEditorSettings(userSettings.getEditorSettings());
        // also set the old start gallery settings
        m_userSettings.setStartGalleriesSetting(userSettings.getStartGalleriesSettings());
        // then set the old synchronization settings
        m_userSettings.setSynchronizeSettings(userSettings.getSynchronizeSettings());
        Enumeration<String> en = request.getParameterNames();
        while (en.hasMoreElements()) {
            // search all request parameters for the presence of the preferred editor parameters
            String paramName = en.nextElement();
            if (paramName.startsWith(PARAM_PREFERREDEDITOR_PREFIX)) {
                String paramValue = request.getParameter(paramName);
                if ((paramValue != null) && !INPUT_DEFAULT.equals(paramValue.trim())) {
                    // set selected editor for this resource type
                    m_userSettings.setPreferredEditor(
                        paramName.substring(PARAM_PREFERREDEDITOR_PREFIX.length()),
                        CmsEncoder.decode(paramValue));
                } else {
                    // reset preferred editor for this resource type
                    m_userSettings.setPreferredEditor(paramName.substring(PARAM_PREFERREDEDITOR_PREFIX.length()), null);
                }
            } else if (paramName.startsWith(PARAM_STARTGALLERY_PREFIX)) {
                String paramValue = request.getParameter(paramName);
                if (paramValue != null) {
                    // set the selected start gallery for the gallery type
                    m_userSettings.setStartGallery(
                        paramName.substring(PARAM_STARTGALLERY_PREFIX.length()),
                        CmsEncoder.decode(paramValue));
                }
            }
        }

        // set the current user in the settings object
        m_userSettings.setUser(getSettings().getUser());
        m_userSettings.setAdditionalPreferencesFrom(userSettings);

        try {
            // write the user settings to the db
            m_userSettings.save(getCms());
        } catch (CmsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }

        // update the preferences and project after saving
        updatePreferences(getCms(), getJsp().getRequest());

        try {
            String projectName = m_userSettings.getStartProject();
            CmsProject project = getCms().readProject(projectName);
            getCms().getRequestContext().setCurrentProject(project);
            getSettings().setProject(project.getUuid());
        } catch (Exception e) {
            // should usually never happen
            LOG.error(e.getLocalizedMessage());
        }

        // now determine if the dialog has to be closed or not
        try {
            if (DIALOG_SET.equals(getParamAction())) {
                // after "set" action, leave dialog open
                Map<String, String[]> params = new HashMap<String, String[]>();
                params.put(PARAM_TAB, new String[] {String.valueOf(getActiveTab())});
                params.put(PARAM_SETPRESSED, new String[] {Boolean.TRUE.toString()});
                sendForward(getJsp().getRequestContext().getUri(), params);
            } else {
                // forward to dialog with action set to reload the workplace
                Map<String, String[]> params = new HashMap<String, String[]>();
                params.put(PARAM_ACTION, new String[] {DIALOG_RELOAD});
                sendForward(getJsp().getRequestContext().getUri(), params);
            }
        } catch (IOException e) {
            // error during forward, do nothing
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        } catch (ServletException e) {
            // error during forward, do nothing
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
        }
    }
154266
protected function saveData()
    {
        $this->beforeSave();

        $changed = $this->setReceptionCode(
                $this->formData[$this->receptionCodeItem],
                $this->loader->getCurrentUser()->getUserId()
                );

        $this->afterSave($changed);

        $this->accesslog->logChange($this->request, null, $this->formData);
    }
1004204
def _save(execute_hooks = true)
      loaded_entries = self.loaded_entries
      loaded_entries.each { |resource| set_default_attributes(resource) }
      @removed.clear
      loaded_entries.all? { |resource| resource.__send__(execute_hooks ? :save : :save!) }
    end
1248716
protected function afterCreate()
    {
        $this->dispatcher->getEventsManager()->fire(Events::AFTER_CREATE, $this);
        return $this->afterSave();
    }
202191
public function save()
    {
        // Can only update the name and output_params
        $params = array('id' => $this->getId(), 'name' => $this->getName());
        foreach ($this->_output_params as $key => $val) {
            $params[DataSift_Push_Definition::OUTPUT_PARAMS_PREFIX . $key] = $val;
        }

        // Call the API and pass the returned object into init to update this object
        $this->init($this->_user->post('push/update', $params));
    }
35249
private function save() {
        update_option( 'wp_easy_notify_' . $this->prefix, $this->notices );
        update_option( 'wp_easy_notify_active_' . $this->prefix, $this->active );
    }
102336
def do_autosave(self):
        """"""
        logger.debug('Autosave triggered')
        stack = self.editor.get_current_editorstack()
        stack.autosave.autosave_all()
        self.start_autosave_timer()
444685
protected function afterSave()
    {
        parent::afterSave();
        CategoryListStore::instance()->top_level->clear();

        $this->checkFieldChanges('active', CategoryListStore::instance()->active);
    }
277686
protected function AfterGather()
    {
        if ($this->fileCacher->MustStoreToCache())
        {
            $this->fileCacher->StoreToCache($this->output);
        }
        parent::AfterGather();
    }
102504
public function afterSave()
    {
        $this->savePriceValue(null, $this->fSavedPrice, $this->fSavedOldPrice);
        $this->savePriceListValue();
    }
27256
protected function saveData()
    {
        if ($this->trackEngine) {
            // concatenate user input (gtf_field fields)
            // before the data is saved (the fields them
            $this->formData['gr2t_track_info'] = $this->trackEngine->calculateFieldsInfo($this->formData);
        }

        // Perform the save
        $model          = $this->getModel();
        $this->formData = $model->save($this->formData);
        $changed        = $model->getChanged();
        $refresh        = false;

        // Retrieve the key if just created
        if ($this->createData) {
            $this->respondentTrackId = $this->formData['gr2t_id_respondent_track'];
            $this->respondentTrack   = $this->loader->getTracker()->getRespondentTrack($this->formData);
            
            // Explicitly save the fields as the transformer in the model only handles
            // before save event (like default values) for existing respondenttracks
            $this->respondentTrack->setFieldData($this->formData);

            // Create the actual tokens!!!!
            $this->trackEngine->checkRoundsFor($this->respondentTrack, $this->userId);
            $refresh = true;

        } else {
            // Check if the input has changed, i.e. one of the dates may have changed
            $refresh = (boolean) $changed;
        }

        if ($refresh) {
            // Perform a refresh from the database, to avoid date trouble
            $this->respondentTrack->refresh();
            $this->respondentTrack->checkTrackTokens($this->userId);
        }


        // Communicate with the user
        $this->afterSave($changed);
    }