<?php

class wpActions extends sfActions {
    public function getCriteriaSortMethod() {
        $result = 'add';
        $result .= $this->hasRequestParameter('desc')?'De':'A';
        $result .= 'scendingOrderByColumn';
        return $result;
    }

    public function redirectWithErrorUnless($condition, $message = '', $url = '') {
        if (!$condition) {
            if ('' != $message) {
                wpFlashMessages::addError($message);
            }
            if ('' == $url) {
                $url = sprintf('%s/index', str_replace('Actions', '', get_class($this)));
            }
            return $this->redirect($url);
        }
        return true;
    }

    public function redirectWithErrorIf($condition, $message = '', $url = '') {
        return $this->redirectWithErrorUnless(!$condition, $message, $url);
    }
}