Exemple #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"]);
     }
 }
 public function up()
 {
     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) {
         $oUserTypeEntity = new \CUserTypeEntity();
         $sort = 500;
         foreach ($arHlData['FIELDS'] as $fieldName => $fieldValue) {
             $aUserField = array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName, 'USER_TYPE_ID' => $fieldValue[1], 'SORT' => $sort, 'MULTIPLE' => 'N', 'MANDATORY' => $fieldValue[0], 'SHOW_FILTER' => 'N', 'SHOW_IN_LIST' => 'Y', 'EDIT_IN_LIST' => 'Y', 'IS_SEARCHABLE' => 'N', 'SETTINGS' => array());
             if (isset($fieldValue[2]) && is_array($fieldValue[2])) {
                 $aUserField = array_merge($aUserField, $fieldValue[2]);
             }
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => $aUserField['ENTITY_ID'], 'FIELD_NAME' => $aUserField['FIELD_NAME']));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $idUserTypeProp = $aUserHasField['ID'];
                 if ($oUserTypeEntity->Update($idUserTypeProp, $aUserField)) {
                     $this->out('Обновлено свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']);
                 } else {
                     if ($ex = $APPLICATION->GetException()) {
                         $this->outError('Ошибка - ' . $ex->GetString());
                     }
                 }
             } else {
                 if ($idUserTypeProp = $oUserTypeEntity->Add($aUserField)) {
                     $this->out('Добавлено новое свойство - ' . $fieldValue[2]['EDIT_FORM_LABEL']['ru']);
                 } else {
                     if ($ex = $APPLICATION->GetException()) {
                         $this->outError('Ошибка - ' . $ex->GetString());
                     }
                 }
             }
             $sort += 100;
         }
         $arFilter = array();
         $arSelect = array("ID");
         $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => $arFilter, 'select' => $arSelect));
         while ($arRecord = $result->fetch()) {
             \Hawkart\Megatv\RecordTable::update($arRecord["ID"], array('UF_DATETIME_ADD' => new \Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s'), 'Y-m-d H:i:s')));
         }
         $oUserTypeEntity = new \CUserTypeEntity();
         $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_SOTAL_ID"));
         if ($aUserHasField = $resProperty->Fetch()) {
             $oUserTypeEntity->Delete($aUserHasField['ID']);
             $this->outSuccess("Свойство удалено!");
         }
         $this->outSuccess('Все готово на %d%%', 100);
     }
 }
Exemple #3
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;
Exemple #4
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"];
Exemple #5
0
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();
}
//Получим список записей для каждого пользователей, у которых нет еще ссылки на видео
$arUserRecords = array();
$arRecords = array();
$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_END" => $dt), '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_SOTAL_ID", "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);
    $arUserRecords[$arRecord["UF_USER_ID"]][] = $arRecord["UF_SOTAL_ID"];
    $arRecords[$arRecord["UF_SOTAL_ID"]] = $arRecord;
}
$filter = array("ACTIVE" => "Y", "!UF_SOTAL_LOGIN" => false);
$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();
Exemple #6
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;
<?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;
Exemple #8
0
 $result = \Hawkart\Megatv\SubscribeTable::getList(array('filter' => array("=UF_ACTIVE" => 1, "=UF_USER_ID" => $USER->GetID(), ">UF_CHANNEL_ID" => 0), 'select' => array("UF_CHANNEL_ID")));
 while ($arSub = $result->fetch()) {
     $selectedChannels[] = $arSub["UF_CHANNEL_ID"];
 }
 $USER_ID = $USER->GetID();
 $rsUser = \CUser::GetByID($USER_ID);
 $arUser = $rsUser->Fetch();
 //get inform about schedule
 $result = \Hawkart\Megatv\ScheduleTable::getList(array('filter' => array("=ID" => $prog_time), 'select' => array("ID", "UF_DATE_START", "UF_DATE_END", "UF_DATE", "UF_CHANNEL_BASE_ID" => "UF_CHANNEL.UF_BASE_ID", "UF_PROG_ID", "UF_CHANNEL_EPG_ID" => "UF_CHANNEL.UF_BASE.UF_EPG_ID", "UF_IMG_PATH" => "UF_PROG.UF_IMG.UF_PATH", "UF_PROG_EPG_ID" => "UF_PROG.UF_EPG_ID", "UF_EPG_ID", "UF_CHANNEL_ID"), 'limit' => 1));
 if ($arSchedule = $result->fetch()) {
     $arSchedule["UF_DATE_START"] = $arSchedule['UF_DATE_START']->toString();
     $arSchedule["UF_DATE_END"] = $arSchedule['UF_DATE_END']->toString();
 }
 //check if schedule in recording yet. Deleted to recordable
 $update = false;
 $result = \Hawkart\Megatv\RecordTable::getList(array('filter' => array("=UF_USER_ID" => $USER_ID, "=UF_SCHEDULE_ID" => $prog_time), 'select' => array("ID", "UF_DELETED"), 'limit' => 1));
 if ($arRecord = $result->fetch()) {
     if (intval($arRecord["UF_DELETED"]) == 1) {
         $update = true;
         $update_id = $arRecord["ID"];
     } else {
         exit(json_encode(array("status" => "error", "error" => "Такая запись уже есть.")));
     }
 }
 //money check
 $budget = \CUserEx::getBudget($user_id);
 if ($budget < 0) {
     exit(json_encode(array("status" => "error", "error" => "Для записи передачи пополните счет.")));
 }
 //Провеим, хватит ли пространства!
 $duration = strtotime($arSchedule["UF_DATE_END"]) - strtotime($arSchedule["UF_DATE_START"]);
Exemple #9
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;