Craft\RetourService::saveStaticRedirect PHP Method

saveStaticRedirect() public method

[saveStaticRedirect description]
public saveStaticRedirect ( Retour_StaticRedirectsRecord $record ) : [type]
$record Retour_StaticRedirectsRecord the static redirect record to save
return [type]
    public function saveStaticRedirect($record)
    {
        $error = "";
        if (isset($record)) {
            if ($record->redirectSrcUrl == "" || $record->redirectDestUrl == "") {
                $id = $record->id;
                $affectedRows = craft()->db->createCommand()->delete('retour_static_redirects', array('id' => $id));
                RetourPlugin::log("Deleted Redirected: " . $id, LogLevel::Info, false);
                $error = craft()->cache->flush();
                RetourPlugin::log("Cache flushed: " . print_r($error, true), LogLevel::Info, false);
                $error = -1;
            } else {
                if ($record->save()) {
                    $error = craft()->cache->flush();
                    RetourPlugin::log("Cache flushed: " . print_r($error, true), LogLevel::Info, false);
                    craft()->userSession->setNotice(Craft::t('Retour Redirect saved.'));
                    $error = "";
                    /* -- To prevent redirect loops, see if any static redirects have our destUrl as their srcUrl */
                    $redir = $this->getRedirectByRedirectSrcUrl($record->redirectDestUrl, $record->locale);
                    if ($redir) {
                        $id = $redir->id;
                        $affectedRows = craft()->db->createCommand()->delete('retour_static_redirects', array('id' => $id));
                    }
                } else {
                    $error = $record->getErrors();
                    RetourPlugin::log(print_r($error, true), LogLevel::Info, false);
                    craft()->userSession->setError(Craft::t('Couldn’t save Retour Redirect.'));
                }
            }
        }
        return $error;
    }