Changeset 4313

Show
Ignore:
Timestamp:
10/06/06 21:45:48 (2 years ago)
Author:
rambo
Message:

1.7 compatibility, better ViewerGroups? conversion

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/support/migrate_26.php

    r4184 r4313  
    5050if (PEAR::isError($args))  
    5151{ 
    52     $header = "Usage: " .basename($_SERVER['SCRIPT_NAME'])." [options]\n\n" ; 
     52    $header = "Usage: " .basename($GLOBALS['argv'][0])." [options]\n\n" ; 
    5353    if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER)  
    5454    { 
     
    8383 
    8484// Map components 
    85 $qb_component = new midgard_query_builder('midgard_parameter'); 
     85$qb_component = new MidgardQueryBuilder('midgard_parameter'); 
    8686$qb_component->add_constraint('domain', '=', 'midcom'); 
    8787$qb_component->add_constraint('name', '=', 'component'); 
     
    123123 
    124124// Clear style parameters 
    125 $qb_style = new midgard_query_builder('midgard_parameter'); 
     125$qb_style = new MidgardQueryBuilder('midgard_parameter'); 
    126126$qb_style->add_constraint('domain', '=', 'midcom'); 
    127127$qb_style->add_constraint('tablename', '=', 'topic'); 
     
    144144 
    145145// Convert topic owner to midcom_core_privilege_db object 
    146 $qb_topic = new midgard_query_builder('midgard_topic'); 
     146$qb_topic = new MidgardQueryBuilder('midgard_topic'); 
    147147$qb_topic->add_constraint('owner', '<>', 0); 
    148148$topics = $qb_topic->execute(); 
     
    175175 
    176176// Convert old ViewerGroups parameters to midcom_core_privilege_db objects 
    177 $qb_vg = new midgard_query_builder('midgard_parameter'); 
     177$qb_vg = new MidgardQueryBuilder('midgard_parameter'); 
    178178$qb_vg->add_constraint('domain', '=', 'ViewerGroups'); 
    179179$qb_vg->add_constraint('tablename', '=', 'topic'); 
     
    198198        $topic_cache[$topic_id] = $topic; 
    199199    } 
     200    // Any other privileges that may be inherited stupidly and possibly override the midgard:read 
     201    $names = array ('midgard:read', 'midcom.admin.folder:topic_management'); 
    200202    $topic =& $topic_cache[$topic_id]; 
    201     $acl = new midcom_core_privilege_db(); 
    202     $acl->objectguid = $topic->guid; 
    203     $acl->name = 'midgard:read'; 
    204     $acl->assignee = 'EVERYONE'; 
    205     $acl->value = 2; //MIDCOM_PRIVILEGE_DENY 
    206     if (!$acl->create()) 
    207     { 
    208         echo "ERROR: could not create '{$acl->name} / {$acl->value}' privilige for '{$acl->assignee}' (concerning object {$acl->objectguid})\n"; 
    209         continue; 
     203    foreach ($names as $name) 
     204    { 
     205        $acl = new midcom_core_privilege_db(); 
     206        $acl->objectguid = $topic->guid; 
     207        $acl->name = $name; 
     208        $acl->assignee = 'EVERYONE'; 
     209        $acl->value = 2; //MIDCOM_PRIVILEGE_DENY 
     210        if (!$acl->create()) 
     211        { 
     212            echo "ERROR: could not create '{$acl->name} / {$acl->value}' privilige for '{$acl->assignee}' (concerning object {$acl->objectguid})\n"; 
     213            continue; 
     214        } 
    210215    } 
    211216    foreach ($grp_guids as $grp_guid) 
     
    214219        $acl->objectguid = $topic->guid; 
    215220        $acl->name = 'midgard:read'; 
    216         $acl->assignee = "group:{$grp_guid}"; 
     221        if ($grp_guid == 'all') 
     222        { 
     223            $acl->assignee = 'USERS'; 
     224        } 
     225        else 
     226        { 
     227            $acl->assignee = "group:{$grp_guid}"; 
     228        } 
    217229        $acl->value = 1; //MIDCOM_PRIVILEGE_ALLOW 
    218230        if (!$acl->create()) 
     
    234246// Convert parameters metadata/keywords & metadata/target values CSV to PSV (and add extr pipes to start and end as well fro DM2s benefit) 
    235247/* 
    236 $qb_md = new midgard_query_builder('midgard_parameter'); 
     248$qb_md = new MidgardQueryBuilder('midgard_parameter'); 
    237249$qb_md->add_constraint('domain', '=', 'metadata'); 
    238250$qb_md->begin_group('OR'); 
     
    255267// Clean up article expiry 
    256268/* 
    257 $qb_exp = new midgard_query_builder('midgard_article'); 
     269$qb_exp = new MidgardQueryBuilder('midgard_article'); 
    258270$qb_exp->begin_group('OR'); 
    259271    $qb_exp->add_constraint('extra1', 'LIKE', '%.%.%');