Skip to content

Instantly share code, notes, and snippets.

@egi
Created May 6, 2011 21:47
Show Gist options
  • Save egi/959852 to your computer and use it in GitHub Desktop.
Save egi/959852 to your computer and use it in GitHub Desktop.
move icross add
<?php
function channel_shift($channel)
{
$tomorrow = $channel->since + 86400;
if (0 < channel_count(array('type'=>$channel->type, 'time'=>$tomorrow)))
{
$aChannels = $channel->load(array('since'=>$tomorrow));
foreach ($aChannels as $ch)
channel_shift($ch);
}
channel_update($channel, array('since'=>$tomorrow));
if ($channel->state>=4)
{
$aInsertions = $channel->getInsertion();
foreach ($aInsertions as $in)
insertion_update($in, array('time'=>$in->time + 86400));
}
}
function replace_forward($channel)
{
if ($channel->state<4)
return to_fail($channel);
if (channel_within($channel, $today, $tomorrow))
{
list($ch_today, /*$ch_tomorrow*/) = channel_explode($channel);
// ignore $ch_tomorrow because it has different channel type
}
else
{
list(/*$ch_yesterday*/, $ch_today) = channel_explode($channel);
// ignore $ch_yesterday. no action need to be taken.
}
$ch_tomorrow = $channel->load(array('type'=>$channel->type, 'since'=>$tomorrow));
channel_shift($ch_tomorrow);
channel_copy($ch_today, array('time'=>$tomorrow, 'state'=>5));
to_fail($ch_today);
}
replace_forward($channel->load(array('type'=>'R', 'time'=>$today)));
replace_forward($channel->load(array('type'=>'C', 'time'=>$today)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment