private function toggleVisibility($recordId, $newState)
    {
        if (!$this->hasAccess()) {
            $this->log(
                sprintf('Not enough permission to show/shide record ID "%s"', $recordId),
                __METHOD__,
                TL_ERROR
            );

            $this->redirect('contao/main.php?act=error');
        }

        $versions = new \Versions($this->table, $recordId);

        if (isset($GLOBALS['TL_DCA'][$this->table]['fields'][$this->column]['save_callback'])) {
            foreach ((array) $GLOBALS['TL_DCA'][$this->table]['fields'][$this->column]['save_callback'] as $callback) {
                $instance = new $callback[0];
                $instance->{$callback[1]}($newState, $this);
            }
        }

        $this->database
            ->prepare(sprintf('UPDATE %s %s WHERE id=?', $this->table, '%s'))
            ->set(array('tstamp' => time(), $this->column => $newState ? '1' : ''))
            ->execute($recordId);

        $versions->create();
    }
private function toggleVisibility($recordId, $newState)
    {
        if (!$this->hasAccess()) {
            $this->log(
                sprintf('Not enough permission to show/shide record ID "%s"', $recordId),
                __METHOD__,
                TL_ERROR
            );

            $this->redirect('contao/main.php?act=error');
        }

        $versions = new \Versions($this->table, $recordId);

        if (isset($GLOBALS['TL_DCA'][$this->table]['fields'][$this->column]['save_callback'])) {
            foreach ((array) $GLOBALS['TL_DCA'][$this->table]['fields'][$this->column]['save_callback'] as $callback) {
                $instance = new $callback[0];
                $instance->{$callback[1]}($newState, $this);
            }
        }

        $this->database
            ->prepare(sprintf('UPDATE %s %s WHERE id=?', $this->table, '%s'))
            ->set(array('tstamp' => time(), $this->column => $newState ? '1' : ''))
            ->execute($recordId);

        $versions->create();
    }
private function toggleVisibility ( $ recordId , $ newState ) { if ( ! $ this -> hasAccess ( ) ) { $ this -> log ( sprintf ( 'Not enough permission to show/shide record ID "%s"' , $ recordId ) , __METHOD__ , TL_ERROR ) ; $ this -> redirect ( 'contao/main.php?act=error' ) ; } $ versions = new \ Versions ( $ this -> table , $ recordId ) ; if ( isset ( $ GLOBALS [ 'TL_DCA' ] [ $ this -> table ] [ 'fields' ] [ $ this -> column ] [ 'save_callback' ] ) ) { foreach ( ( array ) $ GLOBALS [ 'TL_DCA' ] [ $ this -> table ] [ 'fields' ] [ $ this -> column ] [ 'save_callback' ] as $ callback ) { $ instance = new $ callback [ 0 ] ; $ instance -> { $ callback [ 1 ] } ( $ newState , $ this ) ; } } $ this -> database -> prepare ( sprintf ( 'UPDATE %s %s WHERE id=?' , $ this -> table , '%s' ) ) -> set ( array ( 'tstamp' => time ( ) , $ this -> column => $ newState ? '1' : '' ) ) -> execute ( $ recordId ) ; $ versions -> create ( ) ; }
Toggle the visibility state.

@param int  $recordId Record id.
@param bool $newState New state.

@return void

@SuppressWarnings(PHPMD.Superglobals)
Toggle the visibility state .