Changeset 162
- Timestamp:
- 07/18/2006 06:10:19 AM (4 years ago)
- Files:
-
- 1 modified
-
trunk/handlers/page/clone.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/handlers/page/clone.php
r161 r162 8 8 * name of the target page to be created, the user's read-access to the source 9 9 * page and write-access to the target page. 10 * If the editoption is selected, the user is redirected to the target page for10 * If the "Edit after creation" option is selected, the user is redirected to the target page for 11 11 * edition immediately after its creation. 12 * If the "Clone ACL" option is selected, ACL settings are copied to the target page, 13 * otherwise default ACL are applied to the new page. 12 14 * 13 15 * @package Handlers 14 16 * @subpackage Page 17 * @version $Id$ 18 * @since Wikka 1.1.6.0 15 19 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 16 20 * @filesource 17 21 * 18 * @author {@link http://wikkawiki.org/ChristianBarthelemy Christian Barthelemy} - original idea and code. 19 * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} - bugs fixed, code improved, removed popup alerts. 20 * @version $Id$ 21 * @since Wikka 1.1.6.0 22 * 22 * @author {@link http://wikkawiki.org/ChristianBarthelemy Christian Barthelemy} - original idea and code. 23 * @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} - bugs fixed, code improved, removed popup alerts. 24 * @author {@link http://wikkawiki.org/BrianKoontz Brian Koontz} - clone ACL option 25 * 23 26 * @input string $to required: the page to be created 24 * must be a non existing page and current user must be authorizedto create it27 * must be a non-existing page and current user must have privs to create it 25 28 * default is source page name 26 29 * … … 30 33 * @input boolean $editoption optional: if true, the new page will be opened for edition on creation 31 34 * default is false (to allow multiple cloning of the same source) 35 * 36 * @input boolean $cloneaclsoption optional: if true, ACLs are copied from the source page to the new page 37 * default is false 32 38 * 33 39 * @uses Wakka::ExistsPage() … … 53 59 * i18n 54 60 */ 55 define('CLONE_HEADER', '==== Clone current page ===='); 56 define('CLONE_SUCCESSFUL', '%s was succesfully created!'); 57 define('CLONE_X_TO', 'Clone %s to:'); 58 define('CLONED_FROM', 'Cloned from %s'); 59 define('EDIT_NOTE', 'Edit note:'); 60 define('ERROR_ACL_READ', 'You are not allowed to read the source of this page.'); 61 define('ERROR_ACL_WRITE', 'Sorry! You don\'t have write-access to %s'); 62 define('ERROR_INVALID_PAGENAME', 'This page name is invalid. Valid page names must start with a letter and contain only letters and numbers.'); 63 define('ERROR_PAGE_ALREADY_EXIST', 'Sorry, the destination page already exists'); 64 define('ERROR_PAGE_NOT_EXIST', ' Sorry, page %s does not exist.'); 65 define('LABEL_CLONE', 'Clone'); 66 define('LABEL_EDIT_OPTION', ' Edit after creation '); 67 define('PLEASE_FILL_VALID_TARGET', 'Please fill in a valid target ""PageName"" and an (optional) edit note.'); 61 if (!defined('CLONE_HEADER')) define('CLONE_HEADER', '==== Clone current page ===='); 62 if (!defined('CLONE_SUCCESSFUL')) define('CLONE_SUCCESSFUL', '%s was succesfully created!'); 63 if (!defined('CLONE_X_TO')) define('CLONE_X_TO', 'Clone %s to:'); 64 if (!defined('CLONED_FROM')) define('CLONED_FROM', 'Cloned from %s'); 65 if (!defined('EDIT_NOTE')) define('EDIT_NOTE', 'Edit note:'); 66 if (!defined('ERROR_ACL_READ')) define('ERROR_ACL_READ', 'You are not allowed to read the source of this page.'); 67 if (!defined('ERROR_ACL_WRITE')) define('ERROR_ACL_WRITE', 'Sorry! You don\'t have write-access to %s'); 68 if (!defined('ERROR_INVALID_PAGENAME')) define('ERROR_INVALID_PAGENAME', 'This page name is invalid. Valid page names must start with a letter and contain only letters and numbers.'); 69 if (!defined('ERROR_PAGE_ALREADY_EXIST')) define('ERROR_PAGE_ALREADY_EXIST', 'Sorry, the destination page already exists'); 70 if (!defined('ERROR_PAGE_NOT_EXIST')) define('ERROR_PAGE_NOT_EXIST', ' Sorry, page %s does not exist.'); 71 if (!defined('LABEL_CLONE')) define('LABEL_CLONE', 'Clone'); 72 if (!defined('LABEL_EDIT_OPTION')) define('LABEL_EDIT_OPTION', ' Edit after creation'); 73 if (!defined('LABEL_ACL_OPTION')) define('LABEL_ACL_OPTION', ' Clone ACL'); 74 if (!defined('PLEASE_FILL_VALID_TARGET')) define('PLEASE_FILL_VALID_TARGET', 'Please fill in a valid target ""PageName"" and an (optional) edit note.'); 68 75 69 76 // initialization … … 72 79 $note = sprintf(CLONED_FROM, $from); 73 80 $editoption = ''; 81 $cloneaclsoption = ''; 74 82 $box = PLEASE_FILL_VALID_TARGET; 75 83 … … 100 108 $note = isset($_POST['note']) && $_POST['note'] ? $_POST['note'] : $note; 101 109 $editoption = (isset($_POST['editoption']))? 'checked="checked"' : ''; 110 $cloneaclsoption = (isset($_POST['cloneaclsoption']))? 'checked="checked"' : ''; 102 111 103 112 // 3. check target pagename validity … … 122 131 { 123 132 // 6. Valid request - proceed to page cloning 124 $thepage=$this->LoadPage($from); # load the source page 125 if ($thepage) $pagecontent = $thepage['body']; # get its content 126 $this->SavePage($to, $pagecontent, $note); #create target page 133 $thepage=$this->LoadPage($from); 134 if ($thepage) $pagecontent = $thepage['body']; 135 $this->SavePage($to, $pagecontent, $note); 136 // Clone ACLs if requested 137 if ($cloneaclsoption == 'checked="checked"') 138 { 139 $acl = $this->LoadAllACLs($from, 0); 140 $this->SaveACL($to, 'read', $this->TrimACLs($acl['read_acl'])); 141 $this->SaveACL($to, 'write', $this->TrimACLs($acl['write_acl'])); 142 $this->SaveACL($to, 'comment', $this->TrimACLs($acl['comment_acl'])); 143 } 144 // Open editor if requested 127 145 if ($editoption == 'checked="checked"') 128 146 { … … 153 171 '<td>'."\n". 154 172 '<input type="checkbox" name="editoption" '.$editoption.' id="editoption" /><label for="editoption">'.LABEL_EDIT_OPTION.'</label>'."\n". 173 '<input type="checkbox" name="cloneaclsoption" '.$cloneaclsoption.' id="cloneaclsoption" /><label for="cloneaclsoption">'.LABEL_ACL_OPTION.'</label>'."\n". 174 '</tr>'."\n". 175 '<tr>'."\n". 176 '<td></td>'."\n". 177 '<td>'."\n". 155 178 '<input type="submit" name="create" value="'.LABEL_CLONE.'" />'."\n". 156 179 '</td>'."\n".