Changeset 16614

Show
Ignore:
Timestamp:
06/16/08 14:46:16 (3 months ago)
Author:
rambo
Message:

forward port r16613

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.admin.user/locale/default.en.txt

    r13543 r16614  
    44---LANGUAGE en 
    55 
     6---STRING User Management 
     7User Management 
     8---STRINGEND 
     9 
    610---STRING Your password has been changed. Your new password is __PASSWORD__ 
    711Your password has been changed. Your new password is __PASSWORD__ 
     
    280284---STRINGEND 
    281285 
    282 ---STRING User Management 
    283 User Management 
    284 ---STRINGEND 
    285  
     286---STRING enable unlocking locked objects 
     287Enable unlocking locked objects 
     288---STRINGEND 
     289 
  • trunk/midcom/midcom.admin.user/locale/default.fi.txt

    r13543 r16614  
    44---LANGUAGE fi 
    55 
     6---STRING User Management 
     7KÀyttÀjien hallinta 
     8---STRINGEND 
     9 
    610---STRING Your password has been changed. Your new password is __PASSWORD__ 
    711Salasanasi on vaihdettu. Uusi salasanasi on __PASSWORD__ 
     
    280284---STRINGEND 
    281285 
    282 ---STRING User Management 
    283 KÀyttÀjien hallinta 
    284 ---STRINGEND 
    285  
     286---STRING enable unlocking locked objects 
     287Salli lukitusten purkaminen 
     288---STRINGEND 
     289 
  • trunk/midcom/midcom.core/midcom/helper/metadata.php

    r16571 r16614  
    749749        if ($this->get('locked') == 0) 
    750750        { 
    751             return false; 
    752         } 
    753          
    754         if ($this->get('locked') - time() > $GLOBALS['midcom_config']['metadata_lock_timeout'] * 60) 
    755         { 
    756             return true; 
    757         } 
    758          
    759         // Get the person who locked the this 
    760         // Lock was created by the user, allow unquestionable editing 
     751            // Make sure locker is empty too 
     752            if ($this->get('locker') != '') 
     753            { 
     754                $this->set('locker', ''); 
     755            } 
     756            return false; 
     757        } 
     758 
     759        if (($this->get('locked') + ($GLOBALS['midcom_config']['metadata_lock_timeout'] * 60)) < time()) 
     760        { 
     761            // lock expired, explicitly clear lock 
     762            $this->set('locked', 0); 
     763            $this->set('locker', ''); 
     764            return false; 
     765        } 
     766 
     767        // Lock was created by the user, return "not locked" 
    761768        if (   isset($_MIDCOM->auth->user) 
    762769            && isset($_MIDCOM->auth->user->guid) 
    763             && $this->get('locker') !== $_MIDCOM->auth->user->guid) 
    764         { 
    765             return true; 
    766         } 
    767          
    768         // Locks checked, this isn't locked 
    769         return false; 
    770     } 
    771      
    772      
     770            && $this->get('locker') === $_MIDCOM->auth->user->guid) 
     771        { 
     772            return false; 
     773        } 
     774 
     775        // Unlocked states checked and none matched, consider locked 
     776        return true; 
     777    } 
     778 
    773779    /** 
    774780     * Set the object lock 
     
    805811 
    806812    /** 
     813     * Check whether current user can unlock the object 
     814     * 
     815     * @return boolean indicating privileges 
     816     * @todo enable specifying user ? 
     817     */ 
     818    function can_unlock() 
     819    { 
     820        if (   !$this->object->can_do('midcom:unlock') 
     821            && !$_MIDCOM->auth->can_user_do('midcom:unlock', null, 'midcom_services_auth', 'midcom')) 
     822        { 
     823            return false; 
     824        } 
     825        return true; 
     826    } 
     827 
     828    /** 
    807829     * Unlock the object 
    808830     *  
     
    812834    function unlock() 
    813835    { 
    814         if (!$_MIDCOM->auth->can_user_do('midcom:unlock', null, 'midcom_services_auth', 'midcom')) 
    815         { 
    816             return false; 
    817         } 
    818          
    819          
     836        if (!$this->can_unlock()) 
     837        { 
     838            return false; 
     839        } 
     840 
    820841        if (   !$this->set('locker', '') 
    821842            || !$this->set('locked', '')) 
     
    823844            return false; 
    824845        } 
    825          
     846 
    826847        return true; 
    827848    } 
  • trunk/midcom/midcom.helper.datamanager2/controller.php

    r16587 r16614  
    260260        { 
    261261            // Get the metadata object 
    262             $metadata = $this->datamanager->storage->object->get_metadata(); 
     262            $metadata =& $this->datamanager->storage->object->get_metadata(); 
    263263             
    264264            if ($metadata->is_locked()) 
     
    288288        else 
    289289        { 
     290            $metadata =& $this->datamanager->storage->object->get_metadata(); 
    290291            $person = new midcom_db_person($this->datamanager->storage->object->metadata->locker); 
    291292            ?> 
     
    294295                    <p> 
    295296                        <?php echo sprintf($this->_l10n->get('this object was locked by %s'), $person->name); ?>. 
    296                         <?php echo sprintf($this->_l10n->get('lock will expire on %s'), strftime('%x %X', $this->datamanager->storage->object->metadata->locked)); ?>. 
     297                        <?php echo sprintf($this->_l10n->get('lock will expire on %s'), strftime('%x %X', ($metadata->get('locked') + ($GLOBALS['midcom_config']['metadata_lock_timeout'] * 60)))); ?>. 
    297298                    </p> 
    298299            <?php 
    299             if ($_MIDCOM->auth->can_user_do('midcom:unlock', null, 'midcom_services_auth', 'midcom.core')) 
     300            if ($metadata->can_unlock()) 
    300301            { 
    301302                echo "<form method=\"post\">\n"; 
  • trunk/midcom/midcom.helper.datamanager2/formmanager.php

    r16514 r16614  
    10381038                     
    10391039                    // Remove the lock, if permission is granted 
    1040                     if ($_MIDCOM->auth->can_user_do('midcom:unlock', null, 'midcom_services_auth', 'midcom.core')) 
     1040                    if ($metadata->can_unlock()) 
    10411041                    { 
    10421042                        $metadata->unlock();