Changeset 22752

Show
Ignore:
Timestamp:
06/30/09 18:14:14 (8 months ago)
Author:
flack
Message:

preparations for "object deleted" page, ref #2236

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ragnaroek/midcom/midgard.admin.asgard/handler/object/manage.php

    r22473 r22752  
    8686        $this->_component = 'midgard.admin.asgard'; 
    8787        parent::__construct(); 
     88    } 
     89 
     90    /** 
     91     * Helper function to retrieve the object from the db 
     92     *  
     93     * @param string $guid GUID 
     94     */ 
     95    private function _load_object($guid) 
     96    { 
     97        $this->_object = $_MIDCOM->dbfactory->get_object_by_guid($guid); 
     98 
     99        if (   !$this->_object 
     100            || !$this->_object->guid) 
     101        { 
     102            if (midgard_connection::get_error() == MGD_ERR_OBJECT_DELETED) 
     103            { 
     104                //TODO: redirect to "object deleted" page (see #236)  
     105            } 
     106 
     107            $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The GUID '{$guid}' was not found."); 
     108            // This will exit. 
     109        } 
    88110    } 
    89111 
     
    728750        midgard_admin_asgard_plugin::init_language($handler_id, $args, $data); 
    729751 
    730         $this->_object = $_MIDCOM->dbfactory->get_object_by_guid($args[0]); 
    731  
    732         if (   !$this->_object 
    733             || !$this->_object->guid) 
    734         { 
    735             $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The GUID '{$args[0]}' was not found."); 
    736             // This will exit. 
    737         } 
     752        $this->_load_object($args[0]); 
    738753 
    739754        $_MIDCOM->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); 
     
    792807    { 
    793808        midgard_admin_asgard_plugin::init_language($handler_id, $args, $data); 
    794         $this->_object = $_MIDCOM->dbfactory->get_object_by_guid($args[0]); 
    795         if (   !$this->_object 
    796             || !$this->_object->guid) 
    797         { 
    798             $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The GUID '{$args[0]}' was not found."); 
    799             // This will exit 
    800         } 
    801         midgard_admin_asgard_plugin::set_last_visited($this->_object->guid); 
     809 
     810        $this->_load_object($args[0]); 
    802811 
    803812        $this->_object->require_do('midgard:update'); 
    804813        $_MIDCOM->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); 
     814 
     815        midgard_admin_asgard_plugin::set_last_visited($this->_object->guid); 
    805816 
    806817        // Set the object language 
     
    11651176    { 
    11661177        midgard_admin_asgard_plugin::init_language($handler_id, $args, $data); 
    1167         $this->_object = $_MIDCOM->dbfactory->get_object_by_guid($args[0]); 
    1168         if (   !$this->_object 
    1169             || !$this->_object->guid) 
    1170         { 
    1171             $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The GUID '{$args[0]}' was not found."); 
    1172             // This will exit. 
    1173         } 
     1178 
     1179        $this->_load_object($args[0]); 
    11741180         
    11751181        $this->_object->require_do('midgard:delete'); 
     
    13341340 
    13351341        // Get the object that will be copied 
    1336         $this->_object = $_MIDCOM->dbfactory->get_object_by_guid($args[0]); 
    1337         if (   !$this->_object 
    1338             || !$this->_object->guid) 
    1339         { 
    1340             $_MIDCOM->generate_error(MIDCOM_ERRNOTFOUND, "The GUID '{$args[0]}' was not found."); 
    1341             // This will exit. 
    1342         } 
     1342        $this->_load_object($args[0]); 
    13431343 
    13441344        $_MIDCOM->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); 
     1345 
     1346        midgard_admin_asgard_plugin::set_last_visited($this->_object->guid); 
    13451347 
    13461348        static $targets = array();