<commit_before><?php

class KeyController extends Controller
{
    public $layout = '//layouts/one-column-with-title';
    
    public function actionAll()
    {
        // Get the list of all active Keys.
        $keysDataProvider = new CActiveDataProvider('Key');
        
        // Render the page.
        $this->render('all', array(
            'keysDataProvider' => $keysDataProvider,
        ));
    }
    
    public function actionDelete($id)
    {
        // Get a reference to the current website user's User model.
        /* @var $user User */
        $user = \Yii::app()->user->user;
        
        // Try to retrieve the specified Key's data.
        /* @var $key Key */
        $key = \Key::model()->findByPk($id);
        
        // If this is not a Key that the current User is allowed to
        // delete/revoke, say so.
        if ( ! $user->canRevokeKey($key)) {
            throw new CHttpException(
                403,
                'That is not a Key that you have permission to delete.'
            );
        }
        
        // If the form has been submitted (POSTed)...
        if (Yii::app()->request->isPostRequest) {
            
            // Revoke the key, paying attention to the results.
            $revokeResults = Key::revokeKey($key->key_id);
            
            // If we were unable to delete that Key...
            if ( ! $revokeResults[0]) {
                
                // Record that in the log.
                Yii::log(
                    'Key deletion/revokation FAILED: ID ' . $key->key_id,
                    CLogger::LEVEL_ERROR,
                    __CLASS__ . '.' . __FUNCTION__
                );

                // Tell the user.
                Yii::app()->user->setFlash(
                    'error',
                    '<strong>Error!</strong> Unable to delete key: <pre>'
                    . $revokeResults[1] . '</pre>'
                );
            }
            // Otherwise...
            else {
                
                // Record that in the log.
                Yii::log(
                    'Key deleted/revoked: ID ' . $key->key_id,
                    CLogger::LEVEL_INFO,
                    __CLASS__ . '.' . __FUNCTION__
                );
                
                // If the user deleting the key is the owner of the key...<commit_msg>Updated KeyController's use of Key::revokeKey().<commit_after><?php

class KeyController extends Controller
{
    public $layout = '//layouts/one-column-with-title';
    
    public function actionAll()
    {
        // Get the list of all active Keys.
        $keysDataProvider = new CActiveDataProvider('Key');
        
        // Render the page.
        $this->render('all', array(
            'keysDataProvider' => $keysDataProvider,
        ));
    }
    
    public function actionDelete($id)
    {
        // Get a reference to the current website user's User model.
        /* @var $user User */
        $user = \Yii::app()->user->user;
        
        // Try to retrieve the specified Key's data.
        /* @var $key Key */
        $key = \Key::model()->findByPk($id);
        
        // If this is not a Key that the current User is allowed to
        // delete/revoke, say so.
        if ( ! $user->canRevokeKey($key)) {
            throw new CHttpException(
                403,
                'That is not a Key that you have permission to delete.'
            );
        }
        
        // If the form has been submitted (POSTed)...
        if (Yii::app()->request->isPostRequest) {
            
            // Revoke the key, paying attention to the results.
            $revokeResults = Key::revokeKey($key->key_id, $user);
            
            // If we were unable to delete that Key...
            if ( ! $revokeResults[0]) {
                
                // Record that in the log.
                Yii::log(
                    'Key deletion/revokation FAILED: ID ' . $key->key_id,
                    CLogger::LEVEL_ERROR,
                    __CLASS__ . '.' . __FUNCTION__
                );

                // Tell the user.
                Yii::app()->user->setFlash(
                    'error',
                    '<strong>Error!</strong> Unable to delete key: <pre>'
                    . $revokeResults[1] . '</pre>'
                );
            }
            // Otherwise...
            else {
                
                // Record that in the log.
                Yii::log(
                    'Key deleted/revoked: ID ' . $key->key_id,
                    CLogger::LEVEL_INFO,
                    __CLASS__ . '.' . __FUNCTION__
                );
                
                // If the user deleting the key is the owner of the key...
{'fraction_non_alphanumeric': 0.11514129059468578, 'fraction_numerical': 0.002108814846056516, 'mean_word_length': 1.1608200455580866, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1365036', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1208, 'n_words': 352}