Example #1
0
 function OnBeforeUserDeleteHandler($user_id)
 {
     \CModule::IncludeModule("iblock");
     \CModule::IncludeModule("sale");
     //Привязки к соц. сетям
     $arrFilter = array("IBLOCK_ID" => USER_SOCIAL_IB, "PROPERTY_USER_ID" => $user_id);
     $arSelect = array("ID");
     $rsRes = \CIBlockElement::GetList($arOrder, $arrFilter, false, false, $arSelect);
     while ($arItem = $rsRes->GetNext()) {
         \CIBlockElement::Delete($arItem["ID"]);
     }
     //Удаляем записи
     $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_USER_ID" => $user_id), 'select' => array("ID")));
     while ($arRecord = $result->fetch()) {
         \CRecordEx::delete($arRecord["ID"]);
     }
     //Удаляем счет
     if ($arAccount = \CSaleUserAccount::GetByUserID($user_id, "RUR")) {
         \CSaleUserAccount::Delete($arAccount["ID"]);
     }
     //Удаляем заказы
     $arFilter = array("USER_ID" => $user_id);
     $db_sales = \CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
     while ($ar_sales = $db_sales->Fetch()) {
         \CSaleOrder::Delete($ar_sales["ID"]);
     }
     //Удаляем подписки
     $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_USER_ID" => $user_id), 'select' => array("ID")));
     if ($arSub = $result->fetch()) {
         \Hawkart\Megatv\SubscribeTable::delete($arSub["ID"]);
     }
 }
Example #2
0
 public function down()
 {
     global $APPLICATION;
     $arHlData = $this->arHlData;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\RecordTable::getTableName())))->fetch();
     if ($arHlblock) {
         foreach ($arHlData as $fieldName => $fieldValue) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство удалено!");
             }
         }
     }
 }
Example #3
0
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
} else {
    foreach ($arResult["PROGS"] as $key => $arProg) {
        $category = $arProg["UF_CATEGORY"];
        $str = \CDev::translit($category, "ru", array("replace_space" => "-", "replace_other" => "-"));
        $arResult["CATEGORIES"][$category] = $str;
    }
}
if ($_REQUEST["AJAX"] == "Y") {
    $APPLICATION->RestartBuffer();
    /**
     * Get records statuses by user
     */
    $arRecordsStatuses = \Hawkart\Megatv\RecordTable::getListStatusesByUser();
    foreach ($arResult["PROGS"] as $key => $arProg) {
        $arProg["CAT_CODE"] = $arResult["CATEGORIES"][$arProg["UF_CATEGORY"]];
    }
    $arRecords = array();
    foreach ($arResult["PROGS"] as $arRecord) {
        $datetime = $arRecord['UF_DATE_START'];
        $date = substr($datetime, 0, 10);
        $time = substr($datetime, 11, 5);
        $arStatus = \Hawkart\Megatv\CScheduleTemplate::status($arRecord, $arRecordsStatuses);
        $status = $arStatus["status"];
        $status_icon = $arStatus["status-icon"];
        $img = \Hawkart\Megatv\CFile::getCropedPath($arRecord["UF_IMG_PATH"], array(288, 288));
        ob_start();
        if ($status == "viewed") {
            $path = $_SERVER["DOCUMENT_ROOT"] . $arProg["PICTURE"]["SRC"];
Example #4
0
<?php

$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . '/../');
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
global $USER, $APPLICATION;
if (!is_object($USER)) {
    $USER = new CUser();
}
$arRecords = array();
$arFilter = array();
$dateStart = date("Y-m-d H:i:s", time() + 86400);
$arFilter[">=UF_DATETIME_ADD"] = new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s');
$arFilter["=UF_DELETED"] = 1;
$arSelect = array("ID");
$result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
while ($arRecord = $result->fetch()) {
    \Hawkart\Megatv\RecordTable::delete($arRecord["ID"]);
}
die;
Example #5
0
        /**
         * Показ передачи
         */
        $broadcastID = intval($_GET["broadcastID"]);
        if ($_GET["record"] != "false") {
            $arFilter = array("=ID" => $broadcastID);
        } else {
            $arFilter = array("=UF_USER_ID" => $USER->GetID(), "=UF_SCHEDULE_ID" => $broadcastID);
        }
        $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => array("ID", "UF_PROG_ID", "UF_URL", "UF_PROGRESS_SECS", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH"), 'limit' => 1));
        $arRecord = $result->fetch();
        $arRecord["UF_NAME"] = \Hawkart\Megatv\ProgTable::getName($arRecord);
        $arRecord["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arRecord["UF_IMG_PATH"], array(300, 300), true);
        //get count watched
        $countWatched = 0;
        $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_WATCHED" => 1, "=UF_PROG_ID" => $arRecord["UF_PROG_ID"]), 'select' => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(*)', array('ID')))));
        $arWatched = $result->fetch();
        ?>
        <div class="broadcast-player" data-module="broadcast-player">
        	<script type="text/x-config">
        		{
        			"seekTime": "<?php 
        echo intval($arRecord["UF_PROGRESS_SECS"]);
        ?>
",
        			"broadcastID": "<?php 
        echo $broadcastID;
        ?>
",
        			"streamURL": "<?php 
        echo $arRecord["UF_URL"];
Example #6
0
$rsUsers = \CUser::GetList($by = "LAST_NAME", $order = "asc", $filter, array("SELECT" => array("UF_CAPACITY_BUSY", "UF_CAPACITY"), "FIELDS" => array("ID", "EMAIL", "NAME")));
while ($arUser = $rsUsers->GetNext()) {
    //Если у пользователя есть программы, ожидающие записи
    if (isset($arUserRecords[$arUser["ID"]]) && !empty($arUserRecords[$arUser["ID"]])) {
        $ids = $arUserRecords[$arUser["ID"]];
        $Sotal = new \Hawkart\Megatv\CSotal($arUser["ID"]);
        $Sotal->getSubscriberToken();
        $arSchedules = $Sotal->getScheduleList();
        foreach ($arSchedules["schedule"] as $arSchedule) {
            $record_id = $arSchedule["id"];
            $status = $arSchedule["state"];
            if (intval($status) == 3 && in_array($record_id, $ids)) {
                $arStream = $Sotal->getStreamUrl($record_id);
                $url = $arStream["url"];
                if (!empty($url)) {
                    $arRecord = $arRecords[$record_id];
                    //Если достаточно пространства
                    if (intval($arUser["UF_CAPACITY_BUSY"]) < intval($arUser["UF_CAPACITY"])) {
                        \CNotifyEx::afterRecord(array("USER_ID" => $arUser["ID"], "USER_NAME" => $arUser["NAME"], "USER_EMAIL" => $arUser["EMAIL"], "RECORD_ID" => $arRecord["ID"], "RECORD_NAME" => $arRecord["NAME"], "PICTURE" => "http://tvguru.com" . $arRecord["PICTURE"]["SRC"], "URL" => "http://tvguru.com/personal/records/?record_id=" . $arRecord["ID"] . "&play=yes"));
                        \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array("UF_URL" => $url, "UF_AFTER_NOTIFY" => 1));
                    }
                }
            }
        }
        unset($Sotal);
    }
}
unset($arUserRecords);
unset($arRecords);
echo "loaded";
die;
Example #7
0
}
global $USER;
$arResult["RECORDS"] = array();
$offset = 0;
if ($_REQUEST["AJAX"] == "Y") {
    $offset = $_REQUEST["offset"];
}
$arDatetime = \CTimeEx::getDatetime();
$date_now = $arDatetime["SERVER_DATETIME_WITH_OFFSET"];
$key = 0;
$arFilter = array("=UF_USER_ID" => $USER->GetID(), "=UF_DELETED" => 0);
if (!empty($_REQUEST["categoryID"]) && $_REQUEST["categoryID"] != "Все" && $_REQUEST["categoryID"] != "false") {
    $arFilter["=UF_CATEGORY"] = trim($_REQUEST["categoryID"]);
}
$arSelect = array("ID", "UF_DATE_START", "UF_DATE_END", "UF_PROG_ID", "UF_WATCHED", "UF_PROGRESS_PERS", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_CATEGORY" => "UF_PROG.UF_CATEGORY", "UF_URL", "UF_CHANNEL_CODE" => "UF_CHANNEL.UF_BASE.UF_CODE", "UF_PROG_CODE" => "UF_PROG.UF_CODE", "UF_EPG_ID");
$result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => $arSelect, 'order' => array("UF_DATE_END" => "DESC"), 'limit' => intval($arParams["NEWS_COUNT"]), 'offset' => $offset));
while ($arRecord = $result->fetch()) {
    $arRecord["UF_NAME"] = \Hawkart\Megatv\ProgTable::getName($arRecord);
    $arRecord["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arRecord["UF_IMG_PATH"], array(300, 300), true);
    $arRecord["DETAIL_PAGE_URL"] = "/channels/" . $arRecord["UF_CHANNEL_CODE"] . "/" . $arRecord["UF_PROG_CODE"] . "/";
    $arRecord["STATUS"] = "";
    if (!empty($arRecord["DATE_START"])) {
        $arRecord["DATE_START"] = \CTimeEx::dateOffset($arRecord["UF_DATE_START"]->toString());
        $minutes = intval(strtotime($date_now) - strtotime($arRecord["UF_DATE_START"])) / 60;
    }
    if ((!\CTimeEx::dateDiff($arRecord["DATE_START"], $date_now) || $minutes < 5) && !empty($arRecord["DATE_START"]) && !empty($arRecord["UF_URL"])) {
        $arRecord["STATUS"] = "status-recording";
    } elseif (!empty($arRecord["UF_URL"])) {
        $arRecord["STATUS"] = "status-recorded";
    }
    $arResult["RECORDS"][] = $arRecord;
Example #8
0
<?php

define('STOP_STATISTICS', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
$GLOBALS['APPLICATION']->RestartBuffer();
global $USER;
if (!is_object($USER)) {
    $USER = new \CUser();
}
$broadcastID = intval($_GET["broadcastID"]);
if ($_GET["record"] == "false") {
    $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("=UF_USER_ID" => $USER->GetID(), "=UF_SCHEDULE_ID" => $broadcastID), 'select' => array("ID", "UF_PROGRESS_PERS", "UF_PROG_ID"), 'limit' => 1));
    if ($arRecord = $result->fetch()) {
        $broadcastID = $arRecord["ID"];
    }
}
$arFields = array("UF_PROGRESS_SECS" => intval($_GET["progressInSeconds"]), "UF_PROGRESS_PERS" => intval($_GET["progressPosition"]));
if (intval($_GET["progressPosition"]) > 3) {
    $arFields["UF_WATCHED"] = 1;
}
\Hawkart\Megatv\RecordTable::update($broadcastID, $arFields);
//add to statistic
//$qunatityQuanters = abs($arRecord["UF_PROGRESS_PERS"]-$arFields["UF_PROGRESS_PERS"]);
$qunatityQuanters = intval($arFields["UF_PROGRESS_PERS"]);
if ($qunatityQuanters > 0) {
    \Hawkart\Megatv\CStat::addByRecord($broadcastID, "quaterShow_" . $qunatityQuanters);
}
die;
Example #9
0
<?php

define('STOP_STATISTICS', true);
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
$GLOBALS['APPLICATION']->RestartBuffer();
global $USER;
if (!is_object($USER)) {
    $USER = new \CUser();
}
$status = false;
$record_id = intval($_REQUEST["broadcastID"]);
if ($USER->IsAuthorized() && $record_id > 0 && $_REQUEST["delete"]) {
    $result = \Hawkart\Megatv\RecordTable::getById($record_id);
    $arRecord = $result->fetch();
    if ($arRecord["UF_USER_ID"] == $USER->GetID()) {
        $USER_ID = $USER->GetID();
        $rsUser = \CUser::GetByID($USER_ID);
        $arUser = $rsUser->Fetch();
        $arRecord["UF_DATE_START"] = $arRecord['UF_DATE_START']->toString();
        $arRecord["UF_DATE_END"] = $arRecord['UF_DATE_END']->toString();
        $duration = strtotime($arRecord["UF_DATE_END"]) - strtotime($arRecord["UF_DATE_START"]);
        $minutes = ceil($duration / 60);
        $gb = $minutes * (18.5 / 1024);
        $busy = floatval($arUser["UF_CAPACITY_BUSY"]) - $gb;
        $user = new \CUser();
        $user->Update($arUser["ID"], array("UF_CAPACITY_BUSY" => $busy));
        \Hawkart\Megatv\RecordTable::update($record_id, array("UF_DELETED" => 1));
        $status = "success";
    }
}
exit(json_encode(array("status" => $status)));
Example #10
0
 }
 //Провеим, хватит ли пространства!
 $duration = strtotime($arSchedule["UF_DATE_END"]) - strtotime($arSchedule["UF_DATE_START"]);
 $minutes = ceil($duration / 60);
 $gb = $minutes * 18.5 / 1024;
 $busy = floatval($arUser["UF_CAPACITY_BUSY"]) + $gb;
 if ($busy >= floatval($arUser["UF_CAPACITY"])) {
     exit(json_encode(array("status" => "require-space", "error" => "Не достаточно места на диске для записи")));
 } else {
     if (in_array($arSchedule["UF_CHANNEL_BASE_ID"], $selectedChannels)) {
         $log_file = "/logs/sotal/sotal_" . date("d_m_Y_H") . ".txt";
         \CDev::log(array("ACTION" => "PUT_TO_RECORD", "DATA" => array("SCHEDULE_ID" => $prog_time, "DATE" => date("d.m.Y H:i:s"))), false, $log_file);
         if ($update) {
             \Hawkart\Megatv\RecordTable::update($update_id, array("UF_DELETED" => 0));
         } else {
             \Hawkart\Megatv\RecordTable::create($arSchedule);
         }
         //Inc rating for prog
         \Hawkart\Megatv\ProgTable::addByEpgRating($arSchedule["UF_PROG_EPG_ID"], 1);
         //change capacity for user
         $cuser = new \CUser();
         $cuser->Update($arUser["ID"], array("UF_CAPACITY_BUSY" => $busy));
         /**
          * Данные в статистику
          */
         \Hawkart\Megatv\CStat::addByShedule($arSchedule["ID"], "record");
         $status = "success";
     } else {
         exit(json_encode(array("status" => "error", "error" => "Нельзя записать")));
     }
 }
Example #11
0
<?php

/**
 * Delete script
 */
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__) . '/../');
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
header('Content-Type: text/html; charset=utf-8');
ini_set('mbstring.func_overload', '2');
ini_set('mbstring.internal_encoding', 'UTF-8');
global $USER, $APPLICATION;
if (!is_object($USER)) {
    $USER = new \CUser();
}
/**
 * Уведомление на email в момент начала записи
 */
$dt = new Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s', time()), 'Y-m-d H:i:s');
$result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("UF_URL" => false, ">UF_DATE_START" => $dt, "<UF_DATE_END" => $dt, "!UF_BEFORE_NOTIFY" => 1), 'select' => array("ID", "UF_TITLE" => "UF_PROG.UF_TITLE", "UF_SUB_TITLE" => "UF_PROG.UF_SUB_TITLE", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_USER_ID")));
while ($arRecord = $result->fetch()) {
    $arRecord["NAME"] = \Hawkart\Megatv\ProgTable::getName($arRecord);
    $arRecord["PICTURE"]["SRC"] = \Hawkart\Megatv\CFile::getCropedPath($arRecord["UF_IMG_PATH"], array(300, 300), true);
    \CNotifyEx::onRecord(array("USER_ID" => $arRecord["UF_USER_ID"], "RECORD_ID" => $arRecord["ID"], "PICTURE" => "http://megatv.su" . $arRecord["PICTURE"]["SRC"], "RECORD_NAME" => trim($arRecord["NAME"])));
    \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array("UF_BEFORE_NOTIFY" => 1));
}
die;