<?php

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

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

require_once cot_incfile('portfolio', 'module');

list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('portfolio', 'any', 'RWA');
if(!$usr['isadmin'] && in_array('portfolio', $moderauth)) $usr['isadmin'] = true;

if ($usr['isadmin'])
{
	$portfoliosql = $db->query("SELECT * FROM $db_portfolio WHERE item_state=2")->fetchAll();

  foreach($portfoliosql as $item) {
    if(($item['item_update_real'] > 0 && $lastdate < $item['item_update_real']) || ($lastdate < $item['item_date'])) {
      $return['push']['notify'][] = '<a class="bold fs13 db nowrap" href="'.cot_url('portfolio', 'm=edit&id='.$item['item_id']).'">
                                        Портфолио #'.$item['item_id'].' ожидает модерации
                                     </a>';
      if(($item['item_update_real'] > 0 && $item['item_update_real'] > $return['lastdate']) || ($item['item_date'] > 0 && $item['item_date'] > $return['lastdate'])) $return['lastdate'] = ($item['item_update_real'] > 0 ? $item['item_update_real'] : $item['item_date'] > 0);
    }

    $return['push']['cnt']['notify']++;
    $return['push']['cntnew']['notify']++;
  }
}
