<commit_before><?php

class NotesModule extends CWebModule {

    /**
     * Inits the Module
     */
    public function init() {
        $this->setImport(array(
            'notes.models.*',
            'notes.behaviors.*',
            'notes.widgets.*',
            'wall.*',
        ));
    }

    /**
     * On User delete, also delete all comments 
     * 
     * @param type $event
     */
    public static function onUserDelete($event) {
        foreach (Content::model()->findAllByAttributes(array('created_by' => $event->sender->id, 'object_model' => 'Note')) as $content) {
            $content->delete();
        }

        return true;
    }

    /**
     * On workspace deletion make sure to delete all comments
     * 
     * @param type $event
     */
    public static function onSpaceDelete($event) {

        foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Note')) as $content) {
            $content->delete();
        }
    }

    /**
     * After the module was disabled globally
     * Do Cleanup
     * 
     * @param type $event
     */
    public static function onDisableModule($event) {
        if ($event->params == 'notes') {
            foreach (Content::model()->findAllByAttributes(array('object_model' => 'Note')) as $content) {
                $content->delete();
            }
        }
    }

    /**
     * After the module was uninstalled from a workspace.
     * Do Cleanup
     * 
     * @param type $event
     */
    public static function onSpaceUninstallModule($event) {
        if ($event->params == 'notes') {
            foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Note')) as $content) {
                $content->delete();
            }
        }
    }

    /**
     * On build of a Space Navigation, check if this module is enabled.
     * When enabled add a menu item
     * 
     * @param type $event
     */
    public static function onSpaceMenuInit($event) {

        $space = Yii::app()->getController()->getSpace();
        
        // Is Module enabled on this workspace?
        if ($space->isModuleEnabled('notes')) {
            $event->sender->addItem(array(
                'label' => Yii::t('NotesModule.base', 'Notes'),
                'url' => Yii::app()->createUrl('/notes/note/show', array('guid' => $space->guid)),
                'icon' => '<i class="icon-file-text"></i>',
                'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'notes'),
            ));
        }
    }

    /**
     * On run of integrity check command, validate all module data
     * 
     * @param type $event<commit_msg>Updated to Font Awesome Version 4.0.3<commit_after><?php

class NotesModule extends CWebModule {

    /**
     * Inits the Module
     */
    public function init() {
        $this->setImport(array(
            'notes.models.*',
            'notes.behaviors.*',
            'notes.widgets.*',
            'wall.*',
        ));
    }

    /**
     * On User delete, also delete all comments 
     * 
     * @param type $event
     */
    public static function onUserDelete($event) {
        foreach (Content::model()->findAllByAttributes(array('created_by' => $event->sender->id, 'object_model' => 'Note')) as $content) {
            $content->delete();
        }

        return true;
    }

    /**
     * On workspace deletion make sure to delete all comments
     * 
     * @param type $event
     */
    public static function onSpaceDelete($event) {

        foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Note')) as $content) {
            $content->delete();
        }
    }

    /**
     * After the module was disabled globally
     * Do Cleanup
     * 
     * @param type $event
     */
    public static function onDisableModule($event) {
        if ($event->params == 'notes') {
            foreach (Content::model()->findAllByAttributes(array('object_model' => 'Note')) as $content) {
                $content->delete();
            }
        }
    }

    /**
     * After the module was uninstalled from a workspace.
     * Do Cleanup
     * 
     * @param type $event
     */
    public static function onSpaceUninstallModule($event) {
        if ($event->params == 'notes') {
            foreach (Content::model()->findAllByAttributes(array('space_id' => $event->sender->id, 'object_model' => 'Note')) as $content) {
                $content->delete();
            }
        }
    }

    /**
     * On build of a Space Navigation, check if this module is enabled.
     * When enabled add a menu item
     * 
     * @param type $event
     */
    public static function onSpaceMenuInit($event) {

        $space = Yii::app()->getController()->getSpace();
        
        // Is Module enabled on this workspace?
        if ($space->isModuleEnabled('notes')) {
            $event->sender->addItem(array(
                'label' => Yii::t('NotesModule.base', 'Notes'),
                'url' => Yii::app()->createUrl('/notes/note/show', array('guid' => $space->guid)),
                'icon' => '<i class="fa fa-file-text"></i>',
                'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'notes'),
            ));
        }
    }

    /**
     * On run of integrity check command, validate all module data
     * 
     * @param type $event
{'fraction_non_alphanumeric': 0.15673409877893202, 'fraction_numerical': 0.0005467468562055768, 'mean_word_length': 1.9584905660377359, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 89, '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': '7341639', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1502, 'n_words': 363}