Changeset 26387


Ignore:
Timestamp:
06/18/10 10:35:58 (7 years ago)
Author:
flack
Message:

synchronize with ragna branch

Location:
branches/developers/flack/acltuning
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/developers/flack/acltuning/midcom.core/midcom/config/midcom_config.php

    r26370 r26387  
    658658 * then too. Important: If you don't have the same lang0 and auto workflow
    659659 * configuration in all language hosts you need to run the multilang.php
    660  * script instead and that one needs to be run at all language hosts and in
    661  * reverse language preference order!)
     660 * script instead and it needs to be run at all language hosts and in reverse
     661 * language preference order! It handles current language and configured
     662 * workflow(s) only and doesn't therefore e.g. delete removed untranslated
     663 * languages like the multilangs.php script does. Note: The scripts have
     664 * subtree support also. You can give a topic guid/id as a GET parameter:
     665 * 'topic'.)
    662666 * The order of languages matters. Content is synced to lang0 from the first
    663667 * matching language from the array. (If you copy exactly the same data as in
     
    692696 * workflow related code is only active when either of the settings is set.
    693697 *
    694  * Note: If you later disable this feature and execute the multilangs.php or
    695  * multilang.php script automatically generated lang0 content is deleted. If
    696  * you want duplicate langX content to be deleted instead (so that master
    697  * content is left to lang0 instead of langX - please note that you might of
    698  * course get mixed language contents to lang0 then - it's a feature not a
    699  * bug), define this setting as array('') before you run the script. (Naturally
    700  * you can remove it after you've executed the script.)
     698 * Note: If you later disable this feature and execute the multilangs.php
     699 * script automatically generated lang0 content is deleted. If you want
     700 * duplicate langX content to be deleted instead (so that master content is
     701 * left to lang0 instead of langX - please note that you might of course get
     702 * mixed language contents to lang0 then - it's a feature not a bug), define
     703 * this setting as array('') before you run the script. (Naturally you can
     704 * remove it after you've executed the script.)
    701705 *
    702706 * If disabled, define an empty array or false/null.
     
    730734 * then too. Important: If you don't have the same auto and lang0 workflow
    731735 * configuration in all language hosts you need to run the multilang.php
    732  * script instead and that one needs to be run at all language hosts and in
    733  * reverse language preference order!)
     736 * script instead and it needs to be run at all language hosts and in reverse
     737 * language preference order! It handles current language and configured
     738 * workflow(s) only and doesn't therefore e.g. delete removed untranslated
     739 * languages like the multilangs.php script does. Note: The scripts have
     740 * subtree support also. You can give a topic guid/id as a GET parameter:
     741 * 'topic'.)
    734742 * The order of languages matters. Untranslated content is being kept in sync
    735743 * with content from the first matching language from the array. Translated
     
    761769 * want to happen if you actually use lang0 content for something.
    762770 *
    763  * Note: If you later disable this feature and execute the multilangs.php or
    764  * multilang.php script automatically generated langX content is deleted.
     771 * Note: If you later disable this feature and execute the multilangs.php
     772 * script automatically generated langX content is deleted.
    765773 *
    766774 * If disabled, define an empty array or false/null.
  • branches/developers/flack/acltuning/midcom.core/midcom/exec/multilang.php

    r26251 r26387  
    88{
    99    $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to get root topic. Aborting.');
     10}
     11
     12if (isset($_REQUEST['topic']))
     13{
     14    try
     15    {
     16        $topic = new midgard_topic($_REQUEST['topic']);
     17    }
     18    catch (Exception $e)
     19    {
     20        $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to get topic {$_REQUEST['topic']}. Aborting.");
     21    }
    1022}
    1123
     
    2335<p>Done.</p>
    2436
    25 <p>Note:
    26 If you have the same workflow languages in all language hosts, you can run
     37<h2>Notes</h2>
     38
     39<h3>Subtree support</h3>
     40<p>If you want to sync only certain subtree, give its guid/id as GET parameter: 'topic'.</p>
     41
     42<h3>multilangs.php</h3>
     43<p>If you have the same workflow languages in all language hosts, you can run
    2744/midcom-exec-midcom/multilangs.php which will sync the site tree in all
    28 languages in one go - and in correct order. Also: If you have workflow
    29 languages included which aren't actually accessible, the multilangs.php
    30 script will also handle those languages properly. So use it if you can
    31 (you have the same language configuration in all hosts).</p>
     45languages in one go - and in correct order.</p>
     46<p>If you have workflow languages included which aren't actually accessible,
     47the multilangs.php script will also handle those languages properly. Also if
     48you remove languages from the workflow or disable a workflow only the
     49multilangs.php script handles them.</p>
     50<p>So use it if you can (you have the same language configuration in all
     51hosts).</p>
  • branches/developers/flack/acltuning/midcom.core/midcom/exec/multilangs.php

    r26253 r26387  
    88{
    99    $_MIDCOM->generate_error(MIDCOM_ERRCRIT, 'Failed to get root topic. Aborting.');
     10}
     11
     12if (isset($_REQUEST['topic']))
     13{
     14    try
     15    {
     16        $topic = new midgard_topic($_REQUEST['topic']);
     17    }
     18    catch (Exception $e)
     19    {
     20        $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to get topic {$_REQUEST['topic']}. Aborting.");
     21    }
    1022}
    1123
     
    2941
    3042$real_lang = midcom_services_multilang::get_lang();
     43$synced = array();
    3144while ($lang = array_pop($langs))
    3245{
     46    if (isset($synced[$lang])) continue;
    3347    midgard_connection::set_lang($lang);
    3448    midcom_services_multilang::tree($topic);
     49    $synced[$lang] = true;
    3550}
    3651midgard_connection::set_lang($real_lang);
     52
     53midcom_services_multilang::tree($topic, false);
    3754
    3855?>
     
    4057<p>Done.</p>
    4158
    42 <p>Note:
    43 If you don't have the same workflow languages in all language hosts, you should run
    44 /midcom-exec-midcom/multilang.php which will sync the site tree in the host language only.</p>
     59<h2>Notes</h2>
     60
     61<h3>Subtree support</h3>
     62<p>If you want to sync only certain subtree, give its guid/id as GET parameter: 'topic'.</p>
     63
     64<h3>multilang.php</h3>
     65<p>If you don't have the same workflow languages in all language hosts, you
     66should run /midcom-exec-midcom/multilang.php which will sync the site tree in
     67the host language only.</p>
  • branches/developers/flack/acltuning/midcom.core/midcom/services/auth/acl.php

    r26386 r26387  
    996996        //debug_pop();
    997997
    998         if ($this->_load_content_privilege($privilege, $object_guid, $object_class, $user_id))
     998        if (self::_load_content_privilege($privilege, $object_guid, $object_class, $user_id))
    999999        {
    10001000            return self::$_privileges_cache[$cache_key][$privilege];
     
    10651065     * @return boolean True when privilege was found, otherwise false
    10661066     */
    1067     private function _load_content_privilege($privilegename, $guid, $class, $user_id)
     1067    private static function _load_content_privilege($privilegename, $guid, $class, $user_id)
    10681068    {
    10691069        $cache_id = $user_id . '::' . $guid;
     
    10771077
    10781078        $last_scope = -1;
     1079        $last_owner_scope = -1;
    10791080        $content_privilege = null;
    10801081
     
    11301131            if (array_key_exists($privilegename, $owner_privileges))
    11311132            {
    1132                 $found = $this->_load_content_privilege('midgard:owner', $guid, $class, $user_id);
     1133                $found = self::_load_content_privilege('midgard:owner', $guid, $class, $user_id);
    11331134                if (    $found
    11341135                     && self::$_privileges_cache[$cache_id]['midgard:owner'])
     
    11701171            }
    11711172
    1172             if ($this->_load_content_privilege($privilegename, $parent_guid, null, $user_id))
     1173            if (self::_load_content_privilege($privilegename, $parent_guid, null, $user_id))
    11731174            {
    11741175                self::$_privileges_cache[$cache_id][$privilegename] = self::$_privileges_cache[$parent_cache_id][$privilegename];
  • branches/developers/flack/acltuning/midcom.core/midcom/services/multilang.php

    r26370 r26387  
    297297        if ($is_update)
    298298        {
     299            $parent = null;
    299300            $lang_exists = false;
    300301            $lang0_exists = false;
     
    304305                foreach ($languages as $language)
    305306                {
    306                     if (   isset($langs[$language->code])
    307                         && !$object->get_parameter($domain, $language->code))
    308                     {
    309                         $langs[$language->code] = false;
     307                    if (isset($langs[$language->code]))
     308                    {
     309                        if (!$object->get_parameter($domain, $language->code))
     310                        {
     311                            $langs[$language->code] = false;
     312                        }
     313
     314                        if (!$lang0)
     315                        {
     316                            if (   is_null($parent)
     317                                && $language->code != $real_lang)
     318                            {
     319                                $parent = $language->code;
     320                            }
     321                        }
    310322                    }
    311323
     
    322334
    323335            $detach = true;
    324             $parent = null;
    325336
    326337            foreach ($langs as $lang => $enabled)
     
    330341                    continue;
    331342                }
    332                
     343
    333344                if (!$enabled)
    334345                {
     
    345356            if ($detach)
    346357            {
    347                 $constraints = array
    348                 (
    349                     'domain' => $domain,
    350                     'name' => $real_lang,
    351                 );
    352                 $object->purge_parameters($constraints);
     358                if (  !(   $lang0
     359                        && $GLOBALS['midcom_config']['multilang_auto_langs']
     360                        && in_array($real_lang, $GLOBALS['midcom_config']['multilang_auto_langs']))
     361                   )
     362                {
     363                    $constraints = array
     364                    (
     365                        'domain' => $domain,
     366                        'name' => $real_lang,
     367                    );
     368                    $object->purge_parameters($constraints);
     369                }
    353370            }
    354371            else
     
    389406                                self::set_default_lang_back();
    390407                                self::is_real(true);
     408
     409                                $lang_exists = false;
    391410                            }
    392411                        }
     
    397416                    $object->set_parameter($domain, $real_lang, true);
    398417                }
    399 
    400                 return;
    401418            }
    402419
     
    414431            }
    415432
    416             if ($lang0 === true || !$lang0)
    417             {
    418                 if (   !$lang_exists
    419                     && !midgard_connection::get_default_lang())
     433            if (!$lang0)
     434            {
     435                if (!$lang_exists)
    420436                {
    421437                    self::is_real(false);
     
    424440
    425441                    $lang_exists = true;
    426                 }
    427             }
    428 
    429             if (   $lang0 !== true
    430                 && !$GLOBALS['midcom_config']['multilang_lang0_langs']
    431                 && !isset($langs['']))
    432             {
    433                 if (   $lang_exists
    434                     && $lang0_exists
    435                     && $object_in_lang0 = self::get_object_in_lang($object, '', true)
    436                     && self::are_objects_equal($object, $object_in_lang0))
    437                 {
    438                     self::is_real(false);
    439                     self::set_default_lang_to_lang();
    440 
    441                     midgard_connection::set_lang('');
    442                     $object_in_lang0->delete();
    443                     midgard_connection::set_lang($real_lang);
    444 
    445                     self::set_default_lang_back();
    446                     self::is_real(true);
     442
     443                    $object->set_parameter($domain, $real_lang, true);
    447444                }
    448445            }
     
    475472    }
    476473
    477     function syncs($object, $is_update = null)
     474    function syncs($object, $is_update = true)
    478475    {
    479476        if (!self::is_real()) return;
     
    492489        }
    493490
    494         if ($GLOBALS['midcom_config']['multilang_auto_langs'])
    495         {
    496             self::sync($object, self::langs($GLOBALS['midcom_config']['multilang_auto_langs']), $domain, $is_update, false);
    497         }
    498 
    499         if ($GLOBALS['midcom_config']['multilang_lang0_langs'])
    500         {
    501             self::sync($object, self::langs($GLOBALS['midcom_config']['multilang_lang0_langs']), $domain, $is_update, true);
    502         }
    503 
    504         if (!$auto)
     491        if ($auto)
     492        {
     493            if ($GLOBALS['midcom_config']['multilang_auto_langs'])
     494            {
     495                self::sync($object, self::langs($GLOBALS['midcom_config']['multilang_auto_langs']), $domain, $is_update, false);
     496            }
     497
     498            if ($GLOBALS['midcom_config']['multilang_lang0_langs'])
     499            {
     500                self::sync($object, self::langs($GLOBALS['midcom_config']['multilang_lang0_langs']), $domain, $is_update, true);
     501            }
     502        }
     503        else
    505504        {
    506505            if ($languages = $object->get_languages())
     
    531530                    }
    532531
     532                    $object_in_lang = $object;
     533
    533534                    $langs = array($language->code);
    534535
     
    536537                    if (!in_array($language->code, $object_langs))
    537538                    {
    538                         $delete = true;
     539                        if ($object_in_lang = self::get_object_in_lang($object, $language->code, true))
     540                        {
     541                            $delete = true;
     542                        }
     543                        else
     544                        {
     545                            $object_in_lang = $object;
     546                        }
    539547                    }
    540548                    else if ($GLOBALS['midcom_config']['multilang_lang0_langs'] == array(''))
    541549                    {
    542                         array_unshift($langs, '');
     550                        if ($object_in_lang = self::get_object_in_lang($object, $language->code, true))
     551                        {
     552                            array_unshift($langs, '');
     553                        }
     554                        else
     555                        {
     556                            $object_in_lang = $object;
     557                        }
    543558                    }
    544559
    545560                    midgard_connection::set_lang($language->code);
    546                     self::sync($object, self::langs($langs), $domain, $is_update, 'disabled');
     561                    self::sync($object_in_lang, self::langs($langs), $domain, $is_update, 'disabled');
    547562                    midgard_connection::set_lang($real_lang);
     563
     564                    if (   !$GLOBALS['midcom_config']['multilang_lang0_langs']
     565                        && $language->code == ''
     566                        && $object_in_lang0 = self::get_object_in_lang($object, '', true))
     567                    {
     568                        foreach ($object_langs as $lang)
     569                        {
     570                            if (   $object_in_lang = self::get_object_in_lang($object, $lang, true)
     571                                && self::are_objects_equal($object_in_lang, $object_in_lang0))
     572                            {
     573                                $delete = true;
     574                                break;
     575                            }
     576                        }
     577                        $object_in_lang = $object_in_lang0;
     578                    }
    548579
    549580                    if ($delete)
     
    551582                        self::is_real(false);
    552583                        $default_lang = self::get_default_lang();
    553                         if ($lang = array_shift($object_langs))
     584                        while ($lang = array_shift($object_langs))
     585                        {
     586                            if ($language->code == '')
     587                            {
     588                                if ($lang == '') continue;
     589                            }
     590                            else
     591                            {
     592                                break;
     593                            }
     594                        }
     595                        if ($lang)
    554596                        {
    555597                            // Not at all needed but prefer lang0 if it can be used
     
    569611                        }
    570612                        midgard_connection::set_lang($language->code);
    571                         $object->delete();
     613                        $object_in_lang->delete();
    572614                        midgard_connection::set_default_lang($default_lang);
    573615                        midgard_connection::set_lang($real_lang);
     
    711753    // These can e.g. use $_MIDCOM freely.
    712754
    713     function tree($object, $memory_limit = null)
    714     {
     755    function tree($object, $auto = true, $memory_limit = null)
     756    {
     757        $is_update = null;
     758        if ($auto) $is_update = true;
     759
    715760        $restore_memory_limit = false;
    716761        if (!$memory_limit)
     
    720765        }
    721766
    722         self::syncs($object);
     767        self::syncs($object, $is_update);
    723768
    724769        if (   !empty($object->symlink)
     
    732777            {
    733778                $object = $topic;
    734                 self::syncs($object);
     779                self::syncs($object, $is_update);
    735780            }
    736781            else
     
    758803                while ($object = array_pop($objects))
    759804                {
    760                     self::tree($object, $memory_limit);
     805                    self::tree($object, $auto, $memory_limit);
    761806                }
    762807            }
  • branches/developers/flack/acltuning/midcom.helper.datamanager2/type/image.php

    r25328 r26387  
    380380            $att = $this->attachments['original'];
    381381        }
     382        else if (array_key_exists('main', $this->attachments))
     383        {
     384            // Copy main as original
     385            $att = $this->attachments['main'];
     386        }
    382387        else
    383388        {
    384             // Copy main as original
    385             $att = $this->attachments['main']->id;
    386         }
     389            return false;
     390        }
     391       
    387392        $src = $att->open('r');
    388393
     
    981986        debug_push_class(__CLASS__, __FUNCTION__);
    982987        debug_add("\$this->_original_mimetype: {$this->_original_mimetype}");
    983         switch ($this->_original_mimetype)
     988        switch (preg_replace('/;.+$/', '', $this->_original_mimetype))
    984989        {
    985990            case 'image/png':
  • branches/developers/flack/acltuning/org.openpsa.directmarketing/campaign/ruleresolver.php

    r23975 r26387  
    336336            }
    337337        }
    338         $mc_group = new midgard_collector('org_openpsa_campaign_member', 'sitegroup' , $_MIDGARD['sitegroup']);
     338        $mc_group = new midgard_collector('midgard_member', 'sitegroup' , $_MIDGARD['sitegroup']);
    339339        $mc_group->set_key_property('guid');
    340340        $mc_group->add_constraint("gid.{$rule['property']}" , $match , $rule['value']);
     
    384384            $guid = $mc_parameter->get_subkey($parameter_key , 'parentguid');
    385385            $parent = $_MIDCOM->dbfactory->get_object_by_guid($guid);
    386             var_dump($guid);
    387             var_dump($parent);
     386
    388387            switch (true)
    389388            {
Note: See TracChangeset for help on using the changeset viewer.