Esempio n. 1
0
 public function testStopPropagation()
 {
     $e = new Event(null, 'test');
     $this->assertFalse($e->isPropagationStopped());
     $e->stopPropagation();
     $this->assertTrue($e->isPropagationStopped());
 }
Esempio n. 2
0
 public function loadShippingMethods($package = array())
 {
     if (!empty($package)) {
         $shipping_methods = Event::trigger('loadShippingMethods', array('package' => $package), 'filter');
         $this->shipping_methods = $this->zones->getZoneEligibility();
         if (!empty($this->shipping_methods)) {
             return $this->shipping_methods;
         } else {
             $this->shipping_methods = array();
             return $this->shipping_methods;
         }
     }
     return array();
 }
Esempio n. 3
0
    public function getPartnerInfoAction($userId = 0)
    {
        $userId = (int) $userId;
        $result = new \Server\Result();
        if (!$userId) {
            $result->success = FALSE;
            $result->content = 'Не указан пользователь';
            $result->send();
        }
        $partners = App::$cur->users->getUserPartners(Users\User::$cur, 8);
        if (empty($partners['users'][$userId])) {
            $result->success = FALSE;
            $result->content = 'Этот пользователь не находится в вашей структуре';
            $result->send();
        }
        $user = $partners['users'][$userId];
        ob_start();
        echo "id:{$user->id}<br />";
        echo "E-mail: <a href='mailto:{$user->mail}'>{$user->mail}</a>";
        $rewards = Money\Reward::getList(['where' => ['active', 1]]);
        $levelTypes = ['procent' => 'Процент', 'amount' => 'Сумма'];
        $itemTypes = ['event' => 'Событие'];
        foreach ($rewards as $reward) {
            foreach ($reward->conditions as $condition) {
                $complete = $condition->checkComplete($userId);
                ?>
                <h5 class="<?php 
                echo $complete ? 'text-success' : 'text-danger';
                ?>
"><?php 
                echo $condition->name();
                ?>
</h5>
                <ul>
                  <?php 
                foreach ($condition->items as $item) {
                    $itemComplete = $item->checkComplete($userId);
                    switch ($item->type) {
                        case 'event':
                            $name = \Events\Event::get($item->value, 'event')->name();
                            break;
                    }
                    ?>
                      <li> 
                        <b class="<?php 
                    echo $itemComplete ? 'text-success' : 'text-danger';
                    ?>
"><?php 
                    echo $name;
                    ?>
 <?php 
                    echo $item->recivedCount($userId);
                    ?>
</b>/<?php 
                    echo $item->count;
                    ?>
 <br />
                      </li>
                      <?php 
                }
                ?>
                </ul>
                <?php 
            }
        }
        $result->content = ob_get_contents();
        ob_end_clean();
        $result->send();
    }
Esempio n. 4
0
        $complete = $condition->checkComplete();
        ?>
            <h4 class="<?php 
        echo $complete ? 'text-success' : 'text-danger';
        ?>
"><?php 
        echo $condition->name();
        ?>
</h4>
            <ul>
              <?php 
        foreach ($condition->items as $item) {
            $itemComplete = $item->checkComplete();
            switch ($item->type) {
                case 'event':
                    $name = \Events\Event::get($item->value, 'event')->name();
                    break;
            }
            ?>
                  <li> 
                    <b class="<?php 
            echo $itemComplete ? 'text-success' : 'text-danger';
            ?>
"><?php 
            echo $name;
            ?>
 <?php 
            echo $item->recivedCount();
            ?>
</b>/<?php 
            echo $item->count;
Esempio n. 5
0
 public function testTriggerArray()
 {
     $params = ['Allen', 21];
     $expect = implode('=>', $params);
     $event = new Event($this->closure);
     $eventOutput = $event->triggerArray($params);
     $this->assertEqual($expect, $eventOutput);
 }