Ejemplo n.º 1
0
 public static function getTopRateSerialByUser($user_id, $arStatistic)
 {
     uasort($arStatistic["SERIALS"], function ($a, $b) {
         return $b - $a;
     });
     $arStatistic["SERIALS"] = array_keys($arStatistic["SERIALS"]);
     $ids = array();
     $dateStart = date("Y-m-d H:i:s", time() - 86400 * 7);
     $result = RecordTable::getList(array('filter' => array("=UF_USER_ID" => $user_id, "!UF_URL" => false, ">UF_DATE_START" => new \Bitrix\Main\Type\DateTime($dateStart, 'Y-m-d H:i:s')), 'select' => array("UF_ID" => "UF_PROG.UF_EPG_ID"), 'order' => array("UF_DATE_END" => "DESC")));
     while ($arRecord = $result->fetch()) {
         $ids[] = $arRecord["UF_ID"];
     }
     $sortedIds = array();
     foreach ($arStatistic["SERIALS"] as $id) {
         if (in_array($id, $ids)) {
             $key = array_search($id, $ids);
             $sortedIds[] = $id;
             unset($ids[$key]);
         }
     }
     if (count($ids) > 0) {
         $sortedIds = array_merge($sortedIds, $ids);
     }
     unset($ids);
     $sortedIds = array_unique($sortedIds);
     return $sortedIds;
 }
Ejemplo n.º 2
0
 /**
  * @param array $newHeader must be associative array with format:
  * <code>
  *      oldColName1 => newColName1,
  *      array('join', array(oldA, oldB), newColName2),
  *      array('split', oldColName3, array(newA, newB)),
  *      oldColName4 => newColName4
  *      ...
  * </code>
  * Order is hold by order in array
  * @return RecordTable
  */
 public function renameColumns(array $newHeader)
 {
     $newTable = new RecordTable();
     foreach ($newHeader as $oldname => $newname) {
         if (is_array($newname)) {
             if ($newname[0] == 'join') {
                 $this->joinCols($newname[1], $newname[2]);
                 $newTable->appendCol($this->getColByName($newname[2]), $newname[2]);
             }
             if ($newname[0] == 'split') {
                 $this->splitCol($newname[1], $newname[2]);
                 foreach ($newname[2] as $col) {
                     $newTable->appendCol($this->getColByName($col), $col);
                 }
             }
         } else {
             $col = $this->getColByName($oldname);
             $newTable->appendCol($col, $newname);
         }
     }
     return $newTable;
 }