Skip to main content

To list program/subchannel under a channel

--php opening--

//get all program/sub-channel
function getAllProgramsUnderThisChannel($channelCodeOrID) {
$ids = array();
$channel = new mxChannel;
$channel->getBy(array('id' => $channelCodeOrID, 'code' => array($channelCodeOrID, '=', 'OR')));
$programs = $channel->getAllPrograms();
foreach($programs as $program) {
$ids[] = $program->code;
}

$subchannels = $channel->getAllChildChannels();
foreach($subchannels as $subchannel) {
$tids = $this->getAllProgramsUnderThisChannel($subchannel->id);
$pids = array_merge($ids, $tids);
$ids = $pids;
}
return $ids;
}

--php closing--

Comments

Popular posts from this blog

[PHP] Rujukan Untuk Penyelesaian Masalah Serangan CSRF

Setiap kali membuat projek yang membuka aksesnya kepada orang awam, pasti akan "terdedah" dengan pelbagai jenis serangan siber. Antaranya; Cross-site scripting dan Cross Site Request Forgery (CSRF) Entri ini lebih kepada penyelesaian CSRF. Hasil carian di internet, beberapa penyelesaian ini (dan penduan untuk pemahaman) mungkin sesuai untuk dirujuk.   http://shiflett.org/articles/cross-site-request-forgeries   https://gist.github.com/ziadoz/3454607 http://resources.infosecinstitute.com/fixing-csrf-vulnerability-in-php-application/   https://www.sitepoint.com/preventing-cross-site-request-forgeries/   http://stackoverflow.com/questions/6287903/how-to-properly-add-csrf-token-using-php