CounterHandler::validate PHP Method

validate() public method

Redirects to the user index page if not properly authenticated.
public validate ( $canRedirect = true )
$canRedirect boolean Whether or not to redirect if the user cannot be validated; if not, the script simply terminates.
    function validate($canRedirect = true)
    {
        parent::validate();
        $journal = Request::getJournal();
        if (!Validation::isSiteAdmin()) {
            if ($canRedirect) {
                Validation::redirectLogin();
            } else {
                exit;
            }
        }
        $this->plugin = Registry::get('plugin');
        return true;
    }

Usage Example

 function clearLog()
 {
     list($plugin) = CounterHandler::validate(false);
     $logEntryDao =& DAORegistry::getDAO('LogEntryDAO');
     $logEntryDao->clearLog();
     Request::redirect(null, 'counter');
 }