/campsite/src/admin-files/article_types/fields/do_retype.php
PHP | 80 lines | 67 code | 12 blank | 1 comment | 4 complexity | 22edc50c9a972eb4bc1b2a4372bc3428 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, LGPL-2.1, Apache-2.0
- <?php
- camp_load_translation_strings("article_type_fields");
- camp_load_translation_strings("api");
- require_once($GLOBALS['g_campsiteDir'].'/classes/Input.php');
- require_once($GLOBALS['g_campsiteDir'].'/classes/Log.php');
- require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleType.php');
- // Check permissions
- if (!$g_user->hasPermission('ManageArticleTypes')) {
- camp_html_display_error(getGS("You do not have the right to add article type fields."));
- exit;
- }
- $articleTypeName = Input::Get('f_article_type');
- $fieldName = trim(Input::Get('f_field_name'));
- $fieldType = trim(Input::Get('f_article_field_type'));
- $field = new ArticleTypeField($articleTypeName, $fieldName);
- $correct = true;
- $errorMsgs = array();
- if (!$field->exists()) {
- $errorMsgs[] = getGS('The field $1 does not exist.', '<B>'.urlencode($fieldName).'</B>');
- $correct = false;
- }
- if (array_search($fieldType, $field->getConvertibleToTypes()) === false) {
- $errorMsgs[] = getGS('Can not convert the field $1 from $2 to type $3.',
- $fieldName, $field->getType(), $fieldType);
- $correct = false;
- }
- if ($correct) {
- $field->setType($fieldType);
- camp_html_goto_page("/$ADMIN/article_types/fields/?f_article_type=".urlencode($articleTypeName));
- }
- $crumbs = array();
- $crumbs[] = array(getGS("Configure"), "");
- $crumbs[] = array(getGS("Article Types"), "/$ADMIN/article_types/");
- $crumbs[] = array($articleTypeName, '');
- $crumbs[] = array(getGS("Article type fields"), "/$ADMIN/article_types/fields/?f_article_type=".urlencode($articleTypeName));
- $crumbs[] = array(getGS("Adding new field"), "");
- echo camp_html_breadcrumbs($crumbs);
- ?>
- <P>
- <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box">
- <TR>
- <TD COLSPAN="2">
- <B> <?php putGS("Adding new field"); ?> </B>
- <HR NOSHADE SIZE="1" COLOR="BLACK">
- </TD>
- </TR>
- <TR>
- <TD COLSPAN="2">
- <BLOCKQUOTE><ul>
- <?php
- foreach ($errorMsgs as $errorMsg) { ?>
- <li><?php p($errorMsg); ?></li>
- <?php
- }
- ?>
- </ul></BLOCKQUOTE>
- </TD>
- </TR>
- <TR>
- <TD COLSPAN="2">
- <DIV ALIGN="CENTER">
- <INPUT TYPE="button" class="button" NAME="Ok" VALUE="<?php putGS('OK'); ?>" ONCLICK="location.href='/<?php p($ADMIN); ?>/article_types/fields/add.php?f_article_type=<?php print urlencode($articleTypeName); ?>'">
- </DIV>
- </TD>
- </TR>
- </TABLE>
- <P>
- <?php camp_html_copyright_notice(); ?>