Changeset 12094

Show
Ignore:
Timestamp:
09/10/07 11:09:39 (1 year ago)
Author:
bergie
Message:

According to good old Midgard semantics, "owner" is a group

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/application.php

    r12085 r12094  
    14621462     * @access private 
    14631463     */ 
    1464     function _set_context_data($value, $param1, $param2 = null) { 
    1465  
    1466         global $midcom_errstr; 
    1467  
     1464    function _set_context_data($value, $param1, $param2 = null)  
     1465    { 
    14681466        if (is_null($param2)) 
    14691467        { 
  • trunk/midcom/midcom.core/midcom/baseclasses/core/dbobject.php

    r11911 r12094  
    190190            } 
    191191         
    192             // Default the owner to current user 
     192            // Default the owner to first group of current user 
    193193            if (!$object->metadata->owner) 
    194194            { 
    195                 $object->metadata->owner = $_MIDCOM->auth->user->_storage->guid; 
     195                $groups = $_MIDCOM->auth->user->list_all_memberships(); 
     196                if (count($groups) > 0) 
     197                { 
     198                    $first_group = array_shift($groups); 
     199                    $object->metadata->owner = str_replace('group:', '', $first_group->id); 
     200                } 
    196201            }          
    197202        } 
  • trunk/midcom/midcom.core/midcom/baseclasses/database/group.php

    r3766 r12094  
    3030 
    3131    /** 
     32     * Updates all computed members. 
     33     * 
     34     * @access protected 
     35     */ 
     36    function _on_loaded() 
     37    { 
     38        if (! parent::_on_loaded()) 
     39        { 
     40            return false; 
     41        } 
     42 
     43        if (empty($this->official)) 
     44        { 
     45            $this->official = $this->name; 
     46        } 
     47         
     48        if (empty($this->official)) 
     49        { 
     50            $this->official = "Group #{$this->id}"; 
     51        } 
     52        return true; 
     53    } 
     54 
     55    /** 
    3256     * Gets the parent object of the current one.  
    3357     *  
  • trunk/midcom/midcom.core/midcom/config/metadata_default.inc

    r5873 r12094  
    151151            'widget_config' => array 
    152152            ( 
    153                 'class' => 'midcom_db_person', 
    154                 'component' => 'net.nemein.personnel', 
    155                 'titlefield' => 'name', 
    156                 'idfield' => 'guid', 
    157                 'constraints' => array 
    158                 ( 
    159                 ), 
    160                 'searchfields' => array 
    161                 ( 
    162                     'firstname', 
    163                     'lastname', 
    164                 ), 
    165                 'orders' => array(array('lastname', 'ASC')), 
     153                'class' => 'midcom_db_group', 
     154                'component' => 'net.nemein.personnel', 
     155                'titlefield' => 'official', 
     156                'idfield' => 'guid', 
     157                'constraints' => array 
     158                ( 
     159                ), 
     160                'searchfields' => array 
     161                ( 
     162                    'official', 
     163                    'name', 
     164                ), 
     165                'orders' => array(array('official', 'ASC')), 
    166166            ), 
    167167        ), 
  • trunk/midcom/midcom.core/midcom/helper/metadata.php

    r11906 r12094  
    371371            case 'approver': 
    372372            case 'authors': 
     373                $value = $this->object->metadata->$key; 
     374                if (!$value) 
     375                { 
     376                    // Fall back to "Midgard admin" if person is not found 
     377                    $value = 1; 
     378                } 
     379                break; 
     380                 
     381            // Group property 
    373382            case 'owner': 
    374383                $value = $this->object->metadata->$key; 
    375384                if (!$value) 
    376385                { 
    377                     // Fall back to "Midgard admin" if person is not found 
    378                     $value = 1; 
     386                    // Fall back to SG admin group if owner is not found 
     387                    static $sg = null; 
     388                    if (is_null($sg)) 
     389                    { 
     390                        $sg = mgd_get_sitegroup($_MIDGARD['sitegroup']); 
     391                    } 
     392                    $value = $sg->admingroup; 
    379393                } 
    380394                break;