Changeset 1057 for trunk/common
- Timestamp:
- 11/03/09 00:08:26 (3 years ago)
- Location:
- trunk/common
- Files:
-
- 2 edited
-
db/textblock.php (modified) (3 diffs)
-
textblock.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/textblock.php
r1030 r1057 1 <?php 1 <?php 2 2 3 3 require_once(IA_ROOT_DIR."common/db/db.php"); … … 40 40 // copy current version to revision table 41 41 db_insert('ia_textblock_revision', $current_revision); 42 42 43 43 // replace current version 44 44 $query = sprintf("DELETE FROM ia_textblock … … 323 323 } 324 324 325 function textblock_copy($old_name, $new_name, $user_id, $remote_ip_info) { 326 $old_name = normalize_page_name($old_name); 325 // Copy a textblock to new_name. 326 // Also copies attachments. 327 function textblock_copy($old_textblock, $new_name, $user_id, $remote_ip_info) { 328 log_assert(!textblock_validate($old_textblock)); 327 329 $new_name = normalize_page_name($new_name); 328 log_assert(is_normal_page_name($old_name));329 330 log_assert(is_normal_page_name($new_name)); 330 331 331 $new_textblock = textblock_get_revision($old_name);332 $new_textblock = $old_textblock; 332 333 $new_textblock['name'] = $new_name; 333 334 $new_textblock['user_id'] = $user_id; 335 $new_textblock['creation_timestamp'] = null; 336 // Keep creation_timestamp correct when textblock with new name already exists 337 $aux = textblock_get_revision($new_name); 338 if ($aux) { 339 $new_textblock['creation_timestamp'] = $aux['creation_timestamp']; 340 } 334 341 textblock_add_revision($new_textblock['name'], $new_textblock['title'], 335 342 $new_textblock['text'], $new_textblock['user_id'], 336 343 $new_textblock['security'], 337 $new_textblock['forum_topic'], null, null, 344 $new_textblock['forum_topic'], 345 null, $new_textblock['creation_timestamp'], 338 346 $remote_ip_info); 339 347 340 348 // Get a list of attachments. 341 $files = attachment_get_all($old_ name);349 $files = attachment_get_all($old_textblock["name"]); 342 350 343 351 // Copy attachments in db and hard drive -
trunk/common/textblock.php
r997 r1057 152 152 $user_id, $remote_ip_info = null) { 153 153 assert($srcprefix != $dstprefix); 154 assert( is_textblock_security_descriptor($security));154 assert($security === null || is_textblock_security_descriptor($security)); 155 155 assert(is_whole_number($user_id)); 156 156 … … 160 160 textblock_template_replace($textblock, $replace); 161 161 } 162 if ($ replace!== null) {162 if ($security !== null) { 163 163 $textblock['security'] = $security; 164 164 } 165 $textblock['name'] = preg_replace('/^'.preg_quote($srcprefix, '/').'/i', $dstprefix, $textblock['name']); 165 $new_name = preg_replace('/^'.preg_quote($srcprefix, '/').'/i', 166 $dstprefix, $textblock['name']); 166 167 167 //FIXME: hack to keep creation_timestamp correct when textblock already exists 168 $first_textblock = textblock_get_revision($textblock['name']); 169 if (!$first_textblock) { 170 $first_textblock['creation_timestamp'] = null; 171 } 172 173 textblock_add_revision($textblock['name'], $textblock['title'], 174 $textblock['text'], $user_id, $textblock['security'], 175 $textblock['forum_topic'], null, 176 $first_textblock['creation_timestamp'], $remote_ip_info); 168 textblock_copy($textblock, $new_name, $user_id, $remote_ip_info); 177 169 } 178 170 }
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)