Copysite.pm
NAME
Communiware::Copysite - package for site manipulations
SYNOPSIS
copy_site ($old_site, $new_site, $moderator, $old_prefix, $new_prefix, @types)
DESCRIPTION
Copies all items of given type from one site to another
FUNCTIONS
fixtempl
Recieves template and hash of renamed items Finds all occurences of this items in template and changes them
Dynamic elements processed:
- List
-
First argument - filter parameters
-
Second argument - template ID
-
Fourth argument - if grouping on template occurs
-
=cut
-
my %args;
-
$args{'List'} = [ 0, 1, 3 ];
- Loop
-
First argument - filter parameters
-
Third argument - if grouping on template occurs
- Include
-
First argument
- ItemLink
-
First argument Fourth argument
- LinkBox
-
First argument, second argument
- Post
-
Third argument (redirection template)
- Continuation
-
Third argument
- MailTo
-
First argument
- Subscribe
-
Second argument
- If
-
If operation is "IN", check filter argument
- Surround
-
First argument is template
- Image
-
Image has keyed arguments. If arg matches ^item=(.*) it is item_id
- Form
-
Form has keyed arguments. 'submitto' may contain item id(s),
- Text
- Text has keyed arguments link_text, link_template and cut_mark
copy_site
copy_site - main procedure for copying site Algorythm (modified)
assemble_params
Performs somewhat reverse to parse_template. - recieves list of parameters, escapes and quotes them, and returns a single string starting with space with space-separate parameters
map_names
recieves single unescaped dynamic element parameters, which potentially can contain item names to be replaced, and replaces them.
Modifies value in place
Recieves original site name, two prefixes, old and new and list of item types. Returns 3 hashes with keys of old item_ids, one with value of new one, other with value of item type, and 3rd - with new template's names if exists. The last hash contains pairs template - include
Copiing item. altering site and item_id always, template_id if neccessary.
Arguments: Old item id, site, type, replacement hash, template_hash, result of prepare_copy_queries
May be we should create temporary table?
prepare_copy_queries
Recieves same params of make_list.
Returns hash of statement handles which perform copiing from table to table.
There are following elements in the hash:
ITEM - requires two args - old item_id and new item_id copies data from one item to other;
ITEM_T - requires three args - old item_id, new item_id and new template_id;
FILTER_LINK - inserts records TEMPLATE_FILTER table;
SUBS_ITEM_TYPE - copies records in SUBS_ITEM_TYPE;
These copy record in the item table.
@TYPE_ID - copies extended attributes for given type.
copy_links
copies all the links from one type to another site
copy_template calls itself recursively for included templates and copies template as item