<?php
/**
 * [BEGIN_COT_EXT]
 * Hooks=api.track_stack.main
 * [END_COT_EXT]
 */

defined('COT_CODE') or die('Wrong URL');

if($usr['id'] > 0) {
  require_once cot_incfile('rewards', 'plug');

  $rewardsql = $db->query("SELECT * FROM $db_rewards_owners as rewards_owners
    JOIN $db_rewards as rewards ON rewards.r_id=rewards_owners.rid
    WHERE rewards_owners.uid=".$usr['id']." AND rewards_owners.oview=0
    ORDER BY rewards_owners.odate DESC
    ")->fetchAll();

  foreach($rewardsql as $reward) {
    if($reward['odate'] > $lastdate) {
      $return['push']['notify'][] = '<a class="bold fs13 db nowrap" href="'.cot_url('users', 'm=details&id='.$usr['id'].'&u='.$usr['name']).'">
          Получена новая награда "'.$reward['r_title'].'"
        </a>';
      $return['push']['cntnew']['notify']++;
    }
    $return['push']['cnt']['notify']++;
    //'img' => $rewards_path.(file_exists($rewards_path . $reward['r_id'] . '.png') ? $reward['r_id'] : '0').'.png',
  }
}

?>