Beispiel #1
0
 public function refreshInDescLinks($context_id, $id_array)
 {
     $query = '';
     $query .= 'SELECT item_id, description FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $context_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) {
             $replace = false;
             $item_id = $query_result['item_id'];
             $desc = $query_result['description'];
             preg_match_all('~\\[[0-9]*(\\]|\\|)~u', $query_result['description'], $matches);
             if (isset($matches[0])) {
                 foreach ($matches[0] as $match) {
                     $id = mb_substr($match, 1);
                     $last_char = mb_substr($id, mb_strlen($id));
                     $id = mb_substr($id, 0, mb_strlen($id) - 1);
                     if (isset($id_array[$id])) {
                         $desc = str_replace('[' . $id . $last_char, '[' . $id_array[$id] . $last_char, $desc);
                         $replace = true;
                     }
                 }
             }
             #preg_match_all('~\(:item ([0-9]*) ~u', $query_result['description'], $matches);
             // because of html tags from (f)ckeditor
             preg_match_all('~\\(:item[^0-9]*([0-9]*) ~u', $query_result['description'], $matches);
             if (isset($matches[1]) and !empty($matches[1])) {
                 foreach ($matches[1] as $key => $match) {
                     $id = $match;
                     if (isset($id_array[$id])) {
                         #$desc = str_replace('(:item '.$id,'(:item '.$id_array[$id],$desc);
                         $match2 = str_replace($id, $id_array[$id], strip_tags($matches[0][$key]));
                         # if there are html tags, then there are double spaces, don't know why (IJ 27.10.2011)
                         $match2 = str_replace('  ', ' ', $match2);
                         $desc = str_replace($matches[0][$key], $match2, $desc);
                         $replace = true;
                     }
                 }
             }
             if (strstr($desc, '<!-- KFC TEXT') and $replace) {
                 include_once 'functions/security_functions.php';
                 $desc = renewSecurityHash($desc);
             }
             $query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET description="' . encode(AS_DB, $desc) . '" WHERE item_id=' . encode(AS_DB, $item_id);
             $result_update = $this->_db_connector->performQuery($query);
             if (!isset($result_update) or !$result_update) {
                 include_once 'functions/error_functions.php';
                 trigger_error('Problems refresh links in description "' . $this->_db_table . '".', E_USER_WARNING);
             } else {
                 unset($result_update);
             }
         }
         unset($result);
     }
 }
Beispiel #2
0
        preg_match_all('~cid=([0-9]*) ~xu', $value, $matches);
        if (isset($matches[0]) and !empty($matches[0])) {
            foreach ($matches[1] as $match) {
                $id = $match;
                if (isset($new_id_array[$id])) {
                    $value = str_replace('cid=' . $id, 'cid=' . $new_room->getItemID(), $value);
                    $replace = true;
                }
            }
            $new_array[$key] = $value;
        }
        // html textarea security
        if (!empty($new_array[$key]) and $replace) {
            if (strstr($new_array[$key], '<!-- KFC TEXT')) {
                include_once 'functions/security_functions.php';
                $new_array[$key] = renewSecurityHash($new_array[$key]);
            }
        }
    }
    $new_room->setUsageInfoFormTextArray($new_array);
}
// information box
if ($copy_array['informationbox']) {
    if ($old_room->withInformationBox() and isset($new_id_array) and !empty($new_id_array[$old_room->getInformationBoxEntryID()])) {
        $new_room->setInformationBoxEntryID($new_id_array[$old_room->getInformationBoxEntryID()]);
    }
}
$new_room->save();
############################################
# FLAG: group rooms
############################################