Exemple #1
0
 function copyDataFromRoomToRoom($old_id, $new_id, $user_id = '', $id_array = '')
 {
     $retour = parent::copyDataFromRoomtoRoom($old_id, $new_id, $user_id, $id_array);
     // group all
     $this->reset();
     $this->setContextLimit($old_id);
     $this->setExactNameLimit('ALL');
     $this->select();
     $old_list = $this->get();
     if ($old_list->isNotEmpty() and $old_list->getCount() == 1) {
         $old_group_all = $old_list->getFirst();
         $this->reset();
         $this->setContextLimit($new_id);
         $this->setExactNameLimit('ALL');
         $this->select();
         $new_list = $this->get();
         if ($new_list->isNotEmpty() and $new_list->getCount() == 1) {
             $new_group_all = $new_list->getFirst();
             $retour[$old_group_all->getItemID()] = $new_group_all->getItemID();
             unset($new_group_all);
         }
         unset($old_group_all);
     }
     unset($old_list);
     // images of labels
     $query = '';
     $query .= 'SELECT * FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $new_id) . '" AND deleter_id IS NULL AND deletion_date IS NULL';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result)) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems getting data "' . $this->_db_table . '".', E_USER_WARNING);
     } else {
         foreach ($result as $query_result) {
             $extra_array = xml2Array($query_result['extras']);
             if (isset($extra_array['LABELPICTURE']) and !empty($extra_array['LABELPICTURE'])) {
                 $disc_manager = $this->_environment->getDiscManager();
                 $disc_manager->setPortalID($this->_environment->getCurrentPortalID());
                 if ($disc_manager->copyImageFromRoomToRoom($extra_array['LABELPICTURE'], $new_id)) {
                     $value_array = explode('_', $extra_array['LABELPICTURE']);
                     $value_array[0] = 'cid' . $new_id;
                     $extra_array['LABELPICTURE'] = implode('_', $value_array);
                     $update_query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET extras="' . encode(AS_DB, serialize($extra_array)) . '" WHERE item_id="' . $query_result['item_id'] . '"';
                     $update_result = $this->_db_connector->performQuery($update_query);
                     if (!isset($update_result) or !$update_result) {
                         include_once 'functions/error_functions.php';
                         trigger_error('Problems updating data "' . $this->_db_table . '".', E_USER_WARNING);
                     }
                 }
                 unset($disc_manager);
             }
         }
     }
     return $retour;
 }