<commit_before><?php
/**
 * Created by PhpStorm.
 * User: KozminVA
 * Date: 06.05.2015
 * Time: 9:29
 */

namespace app\components;

use Yii;
use yii\db\ActiveRecord;
use yii\base\Behavior;
use yii\base\Event;
use app\modules\task\models\Tasklist;
use app\modules\user\models\Department;
use app\modules\user\models\User;

class NotifyBehavior extends Behavior {

    public function events() {
        return [
            ActiveRecord::EVENT_AFTER_INSERT => 'notyfyUsers',
        ];
    }

    /**
     * @param Event $event
     */
    public function notyfyUsers($event) {
        /** @var Tasklist $model */
        $model = $event->sender;
        $dep = $model->department;
//        Yii::info('Department: ' . print_r($dep->attributes, true));
        $aUsers = $dep->leaders;
        $curId = Yii::$app->user->identity->getId();
        $sTitle = 'Новая задача в Системе мониторинга задач ГАУ ТемоЦентр';
        $sTemplate = 'new_task';

        foreach($aUsers As $ob) {
            /** @var User $ob */
            if( $ob->us_id != $curId ) {
                $ob->sendNotificate($sTemplate, $sTitle, ['task' => $model, 'department' => $dep]);
            }
        }
        if( $model->department->dep_id != 1 ) {
            $aUsers = User::find()
                ->where([
                    'us_dep_id' => 1,
                    'us_active' => User::STATUS_ACTIVE,
                ])
                ->all();
            foreach($aUsers As $ob) {
                /** @var User $ob */
                if( $ob->us_id != $curId ) {
                    $ob->sendNotificate($sTemplate, $sTitle, ['task' => $model, 'department' => $dep]);
                }
            }
        }
    }
}<commit_msg>Stop notify control department<commit_after><?php
/**
 * Created by PhpStorm.
 * User: KozminVA
 * Date: 06.05.2015
 * Time: 9:29
 */

namespace app\components;

use Yii;
use yii\db\ActiveRecord;
use yii\base\Behavior;
use yii\base\Event;
use app\modules\task\models\Tasklist;
use app\modules\user\models\Department;
use app\modules\user\models\User;

class NotifyBehavior extends Behavior {

    public function events() {
        return [
            ActiveRecord::EVENT_AFTER_INSERT => 'notyfyUsers',
        ];
    }

    /**
     * @param Event $event
     */
    public function notyfyUsers($event) {
        /** @var Tasklist $model */
        $model = $event->sender;
        $dep = $model->department;
//        Yii::info('Department: ' . print_r($dep->attributes, true));
        $aUsers = $dep->leaders;
        $curId = Yii::$app->user->identity->getId();
        $sTitle = 'Новая задача в Системе мониторинга задач ГАУ ТемоЦентр';
        $sTemplate = 'new_task';

        foreach($aUsers As $ob) {
            /** @var User $ob */
            if( $ob->us_id != $curId ) {
                $ob->sendNotificate($sTemplate, $sTitle, ['task' => $model, 'department' => $dep]);
            }
        }

        // Тут письма в отдел контроля
                /** @var User $ob */
/*
        if( $model->department->dep_id != 1 ) {
            $aUsers = User::find()
                ->where([
                    'us_dep_id' => 1,
                    'us_active' => User::STATUS_ACTIVE,
                ])
                ->all();
            foreach($aUsers As $ob) {
                if( $ob->us_id != $curId ) {
                    $ob->sendNotificate($sTemplate, $sTitle, ['task' => $model, 'department' => $dep]);
                }
            }
        }
*/
    }
}
{'fraction_non_alphanumeric': 0.1593579822298653, 'fraction_numerical': 0.007451991974777874, 'mean_word_length': 1.7501970055161544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, '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': '6411796', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1124, 'n_words': 224}