<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/
require_once __DIR__ . '/../../src/server/server/config/boot_global.php';
require_once __DIR__ . '/../../src/server/server/config/boot_local.php';

function patch_AddTeamCategoriesToAdminProfiles()
{

    return NULL;
    /*
     *
Francis_Utils_Config::set( 'db.tbteamdata.host', 'XXXXXXXXXXXX' );
Francis_Utils_Config::set( 'db.tbteamdata.name', 'd02e620f' );
Francis_Utils_Config::set( 'db.tbteamdata.user', 'd02e620f' );
Francis_Utils_Config::set( 'db.tbteamdata.pass', 'NT7uSbtaebV9Gedq' );
     */


    $adminProfiles = TB_Shared_Ent_TeamData_Profile::getProfilesByRole( TB_Shared_Ent_TeamData_Profile::ROLE_COTRAINER );
    /** @var TB_Shared_Ent_TeamData_Profile $ap */
    foreach ( $adminProfiles as $ap )
    {
        $tIds = $ap->getTeamIds();
        foreach( $tIds as $tId )
        {
            if ( $ap->isAdminOfTeam( $tId ) )
            {
                /** @var TB_Shared_Ent_TeamData_Team $team */
                $team = TB_Shared_Ent_TeamData_Team::get( $tId );
                if ( is_array( $team->course_categories_js ) )
                {
                    $teamCategoryIds = $ap->getTeamIds();
                    foreach( $team->course_categories_js as $courseCategory )
                    {
                        $ap->addToCategoryId( $courseCategory[ 'id' ] );
                    }

                    $ap->save();
                }
            }
        }
    }


    echo "DONE...";
}

patch_AddTeamCategoriesToAdminProfiles();
