private function deleteAutosearch(\User $user)
 {
     $data = 'user_id = :user_id';
     $param = array(':user_id' => $user->id);
     if ($this->debug) {
         echo "    ... Autosearch: del " . Autosearch::model()->count($data, $param) . " \n";
     } else {
         Autosearch::model()->deleteAll($data, $param);
     }
 }
Exemplo n.º 2
0
 public function updateAutosearch($id, $name)
 {
     $crit = $this->getCriteria();
     if ($crit->params != []) {
         if (count($crit->params) == 1 && array_key_exists('status', $crit->params)) {
             Yii::app()->user->setFlash('error', Yii::t('default', 'Автопоиск не изменен. Необходимо задать критерии поиска'));
         } else {
             $Autosearch = Autosearch::model()->findByPk($id);
             $Autosearch->criteria = serialize($this->getCriteria());
             $Autosearch->name = $name;
             $Autosearch->update();
             Yii::app()->user->setFlash('success', Yii::t('default', 'Автопоиск успешно изменен.'));
         }
     } else {
         Yii::app()->user->setFlash('error', Yii::t('default', 'Автопоиск не изменены. Необходимо задать критерии поиска'));
     }
 }
Exemplo n.º 3
0
 public function autosearch()
 {
     $model = get_class($this);
     $arrComponents = Yii::app()->getComponents(false);
     //Yii::log("autosearch components=[".print_r( $arrComponents , true )."]" , 'info');
     if (isset($arrComponents['amqp'])) {
         //Yii::log("autosearch components amqp as present" , 'info');
         $strSerialize = @serialize($this);
         $this->sendByAMQPAutosearch($strSerialize);
         $Autosearch = Autosearch::model()->findAllByAttributes(['model' => $model, 'active' => Autosearch::ACTIVE]);
         foreach ($Autosearch as $element) {
             $element->checkOn($this);
         }
     } else {
         //Yii::log("autosearch components amqp as NOT present" , 'info');
         $Autosearch = Autosearch::model()->findAllByAttributes(['model' => $model, 'active' => Autosearch::ACTIVE]);
         foreach ($Autosearch as $element) {
             $element->checkOn($this);
         }
     }
     unset($arrComponents);
 }
Exemplo n.º 4
0
 public function processReceive(PhpAmqpLib\Message\AMQPMessage $msg)
 {
     //$this->logme("processReceive msg=[".print_r( $msg , true )."]" );
     $this->logme("processReceive msg=[" . $msg->body . "]");
     $data = $msg->body;
     if ($data) {
         try {
             $obj = @unserialize($data);
             if (is_a($obj, 'C2goActiveRecord')) {
                 $model = get_class($obj);
                 $this->logme("processReceive model=[{$model}]");
                 $Autosearch = Autosearch::model()->findAllByAttributes(['model' => $model]);
                 //$this->logme("processReceive count(Autosearch)=[".count( $Autosearch , true )."]" );
                 foreach ($Autosearch as $element) {
                     $element->checkOn($obj);
                 }
                 $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
             }
         } catch (Exception $e) {
             $this->logme("processReceive exception on process");
         }
     }
     $this->logme("processReceive end");
 }
 public function actionActivate($id)
 {
     Autosearch::model()->updateByPk($id, ['active' => Autosearch::ACTIVE]);
     Yii::app()->user->setFlash('success', Yii::t('CabinetModule.default', 'Автопоиск успешно активирован.'));
     $this->redirect('/cabinet/autosearch');
 }
Exemplo n.º 6
0
<?php

$variants = array_merge(['' => Yii::t('default', 'Все')], Autosearch::model()->getModul());
?>
<div class="row">
    <div class="col-sm-12">
        <table>
            <tr>
				<?php 
$curFilter = isset($_GET['filter']) ? $_GET['filter'] : '';
foreach ($variants as $filter => $name) {
    $counter = AutosearchResult::model()->resultTotalCount($filter != '' ? $filter : 'All');
    ?>
	                <td>
						<?php 
    if ($curFilter == $filter) {
        echo $name . '<sup>' . $counter . '</sup>';
    } else {
        ?>
							<a href="/autosearch/result?filter=<?php 
        echo $filter;
        ?>
"><?php 
        echo $name;
        ?>
</a>
							<sup><?php 
        echo $counter;
        ?>
</sup>
				<?php