/** make sure that enterd detail information is correctly or not.
 * called from register confirmation and edit confirmation
 */
function xnppresentationCheckRegisterParameters(&$message)
{
    $xnpsid = $_SESSION['XNPSID'];
    $messages = array();
    $formdata =& xoonips_getutility('formdata');
    $creator = xoonips_get_multi_field_array_from_post('xnppresentation', 'creator');
    $presentation_fileFileID = $formdata->getValue('post', 'presentation_fileFileID', 'i', true);
    $presentation_file = $formdata->getFile('presentation_file', false);
    $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', true);
    if (empty($creator)) {
        $messages[] = _MD_XNPPRESENTATION_CREATOR_REQUIRED;
    }
    if (empty($presentation_fileFileID) && empty($presentation_file['name'])) {
        $messages[] = _MD_XNPPRESENTATION_PRESENTATION_FILE_REQUIRED;
    }
    // notify that license statement is required when register into public indexes.
    $xids = explode(',', $xoonipsCheckedXID);
    $indexes = array();
    if ($xids[0] != $xoonipsCheckedXID) {
        foreach ($xids as $i) {
            $index = array();
            if (xnp_get_index($xnpsid, $i, $index) == RES_OK) {
                $indexes[] = $index;
            } else {
                $messages[] = '<font color=\'#ff0000\'>' . xnp_get_last_error_string() . '</font>';
                $result = false;
                break;
            }
        }
    }
    if (count($indexes) > 0) {
        foreach ($indexes as $i) {
            if ($i['open_level'] <= OL_GROUP_ONLY) {
                $readmeEncText = $formdata->getValue('post', 'readmeEncText', 's', true);
                $rightsEncText = $formdata->getValue('post', 'rightsEncText', 's', true);
                $rightsUseCC = $formdata->getValue('post', 'rightsUseCC', 'i', true);
                if ($readmeEncText == '') {
                    // readme is not filled
                    $messages[] = '<font color=\'#ff0000\'>' . _MD_XNPPRESENTATION_README_REQUIRED . '</font>';
                }
                if ($rightsEncText == '' && $rightsUseCC == '0') {
                    // license is not filled
                    $messages[] = '<font color=\'#ff0000\'>' . _MD_XNPPRESENTATION_RIGHTS_REQUIRED . '</font>';
                }
                break;
            }
        }
    }
    if (count($messages) == 0) {
        return true;
    }
    $message = "<br />\n" . implode("<br />\n", $messages);
    return false;
}
function xnpmodelCheckRegisterParameters(&$msg)
{
    $formdata =& xoonips_getutility('formdata');
    $xnpsid = $_SESSION['XNPSID'];
    $result = true;
    $model_data = $formdata->getFile('model_data', false);
    $model_dataFileID = $formdata->getValue('post', 'model_dataFileID', 'i', false);
    $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false);
    $creators = xoonips_get_multi_field_array_from_post('xnpmodel', 'creator');
    if (empty($creators)) {
        $messages[] = _MD_XNPMODEL_CREATOR_REQUIRED;
    }
    if ((!isset($model_data) || $model_data['name'] == '') && $model_dataFileID == '') {
        // model_data is not filled
        $msg = $msg . '<br /><font color="#ff0000">' . _MD_XNPMODEL_MODEL_FILE_REQUIRED . '</font>';
        $result = false;
    }
    // require Readme and License if register to public indexes
    $xids = explode(',', $xoonipsCheckedXID);
    $indexes = array();
    if ($xids[0] != $xoonipsCheckedXID) {
        foreach ($xids as $i) {
            $index = array();
            if (xnp_get_index($xnpsid, $i, $index) == RES_OK) {
                $indexes[] = $index;
            } else {
                $msg = $msg . '<br /><font color="#ff0000">' . xnp_get_last_error_string() . '</font>';
                $result = false;
                break;
            }
        }
    }
    if (count($indexes) > 0) {
        foreach ($indexes as $i) {
            if ($i['open_level'] <= OL_GROUP_ONLY) {
                $readmeEncText = $formdata->getValue('post', 'readmeEncText', 's', false);
                $rightsEncText = $formdata->getValue('post', 'rightsEncText', 's', false);
                $rightsUseCC = $formdata->getValue('post', 'rightsUseCC', 'i', false);
                if ($readmeEncText == '') {
                    // readme is not filled
                    $msg = $msg . '<br /><font color="#ff0000">' . _MD_XNPMODEL_README_REQUIRED . '</font>';
                    $result = false;
                }
                if ($rightsEncText == '' && $rightsUseCC == '0') {
                    // license is not filled
                    $msg = $msg . '<br /><font color="#ff0000">' . _MD_XNPMODEL_RIGHTS_REQUIRED . '</font>';
                    $result = false;
                }
                break;
            }
        }
    }
    return $result;
}
/** check DetailInformation input
 * called from confirm/registered page
 */
function xnpconferenceCheckRegisterParameters(&$message)
{
    $xnpsid = $_SESSION['XNPSID'];
    $formdata =& xoonips_getutility('formdata');
    $messages = array();
    $conference_title = $formdata->getValue('post', 'conference_title', 's', false);
    $place = $formdata->getValue('post', 'place', 's', false);
    $author = xoonips_get_multi_field_array_from_post('xnpconference', 'author');
    $conference_fileFileID = $formdata->getValue('post', 'conference_fileFileID', 'i', false);
    $conference_file = $formdata->getFile('conference_file', false);
    $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false);
    $conferenceFromMonth = $formdata->getValue('post', 'conferenceFromMonth', 'i', false);
    $conferenceFromDay = $formdata->getValue('post', 'conferenceFromDay', 'i', false);
    $conferenceFromYear = $formdata->getValue('post', 'conferenceFromYear', 'i', false);
    $conferenceToMonth = $formdata->getValue('post', 'conferenceToMonth', 'i', false);
    $conferenceToDay = $formdata->getValue('post', 'conferenceToDay', 'i', false);
    $conferenceToYear = $formdata->getValue('post', 'conferenceToYear', 'i', false);
    if (empty($conference_title)) {
        $messages[] = _MD_XNPCONFERENCE_CONFERENCE_TITLE_REQUIRED;
    }
    if (empty($place)) {
        $messages[] = _MD_XNPCONFERENCE_PLACE_REQUIRED;
    }
    if (empty($author)) {
        $messages[] = _MD_XNPCONFERENCE_AUTHOR_REQUIRED;
    }
    if (empty($conference_fileFileID) && empty($conference_file['name'])) {
        $messages[] = _MD_XNPCONFERENCE_PRESENTATION_FILE_REQUIRED;
    }
    $conference_from = date('U', mktime(0, 0, 0, $conferenceFromMonth, $conferenceFromDay, $conferenceFromYear));
    $conference_to = date('U', mktime(0, 0, 0, $conferenceToMonth, $conferenceToDay, $conferenceToYear));
    if ($conference_from > $conference_to) {
        $messages[] = _MD_XNPCONFERENCE_DATE_ERROR;
    }
    // require Readme, License and Rights if register to public indexes
    $xids = explode(',', $xoonipsCheckedXID);
    $indexes = array();
    if ($xids[0] != $xoonipsCheckedXID) {
        foreach ($xids as $i) {
            $index = array();
            if (xnp_get_index($xnpsid, $i, $index) == RES_OK) {
                $indexes[] = $index;
            } else {
                $messages[] = '<font color=\'#ff0000\'>' . xnp_get_last_error_string() . '</font>';
                $result = false;
                break;
            }
        }
    }
    if (count($messages) == 0) {
        return true;
    }
    $message = "<br />\n" . implode("<br />\n", $messages);
    return false;
}
/** make sure that enterd detail information is correctly or not.
 * called from register confirmation and edit confirmation
 */
function xnppaperCheckRegisterParameters(&$message)
{
    $messages = array();
    $formdata =& xoonips_getutility('formdata');
    $author = xoonips_get_multi_field_array_from_post('xnppaper', 'author');
    $journal = $formdata->getValue('post', 'journal', 's', false);
    $publicationDateYear = $formdata->getValue('post', 'publicationDateYear', 'i', false);
    if (empty($author)) {
        $messages[] = _MD_XNPPAPER_AUTHOR_REQUIRED;
    }
    if (empty($journal)) {
        $messages[] = _MD_XNPPAPER_JOURNAL_REQUIRED;
    }
    if (empty($publicationDateYear)) {
        $messages[] = _MD_XNPPAPER_YEAR_OF_PUBLICATION_REQUIRED;
    }
    if (count($messages) == 0) {
        return true;
    }
    $message = implode('', $messages);
    return false;
}
function xnpsimulatorCheckRegisterParameters(&$msg)
{
    $formdata =& xoonips_getutility('formdata');
    $xnpsid = $_SESSION['XNPSID'];
    $result = true;
    $developer = xoonips_get_multi_field_array_from_post('xnpsimulator', 'developer');
    $simulator_data = $formdata->getFile('simulator_data', false);
    $simulator_dataFileID = $formdata->getValue('post', 'simulator_dataFileID', 'i', false);
    $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false);
    if (empty($developer)) {
        // developer is not filled
        $msg = $msg . '<br/><font color=\'#ff0000\'>' . _MD_XNPSIMULATOR_DEVELOPER_REQUIRED . '</font>';
        $result = false;
    }
    if ((empty($simulator_data) || $simulator_data['name'] == '') && $simulator_dataFileID == '') {
        // simulator_data is not filled
        $msg = $msg . '<br/><font color=\'#ff0000\'>' . _MD_XNPSIMULATOR_SIMULATOR_FILE_REQUIRED . '</font>';
        $result = false;
    }
    // notify that license statement is required when register into public indexes.
    $xids = explode(',', $xoonipsCheckedXID);
    $indexes = array();
    if ($xids[0] != $xoonipsCheckedXID) {
        foreach ($xids as $i) {
            $index = array();
            if (xnp_get_index($xnpsid, $i, $index) == RES_OK) {
                $indexes[] = $index;
            } else {
                $msg = $msg . '<br/><font color=\'#ff0000\'>' . xnp_get_last_error_string() . '</font>';
                $result = false;
                break;
            }
        }
    }
    if (count($indexes) > 0) {
        foreach ($indexes as $i) {
            if ($i['open_level'] <= OL_GROUP_ONLY) {
                $readmeEncText = $formdata->getValue('post', 'readmeEncText', 's', false);
                $rightsEncText = $formdata->getValue('post', 'rightsEncText', 's', false);
                $rightsUseCC = $formdata->getValue('post', 'rightsUseCC', 'i', false);
                if ($readmeEncText == '') {
                    // readme is not filled
                    $msg = $msg . '<br/><font color=\'#ff0000\'>' . _MD_XNPSIMULATOR_README_REQUIRED . '</font>';
                    $result = false;
                }
                if ($rightsEncText == '' && $rightsUseCC == '0') {
                    // license is not filled
                    $msg = $msg . '<br/><font color=\'#ff0000\'>' . _MD_XNPSIMULATOR_RIGHTS_REQUIRED . '</font>';
                    $result = false;
                }
                break;
            }
        }
    }
    return $result;
}
/** check DetailInformation input
 * called from confirm/registered page
 */
function xnpdataCheckRegisterParameters(&$message)
{
    $xnpsid = $_SESSION['XNPSID'];
    $formdata =& xoonips_getutility('formdata');
    $messages = array();
    $experimenter = xoonips_get_multi_field_array_from_post('xnpdata', 'experimenter');
    $data_file = $formdata->getFile('data_file', false);
    $data_fileFileID = $formdata->getValue('post', 'data_fileFileID', 'i', false);
    $xoonipsCheckedXID = $formdata->getValue('post', 'xoonipsCheckedXID', 's', false);
    $readmeEncText = $formdata->getValue('post', 'readmeEncText', 's', false);
    $rightsEncText = $formdata->getValue('post', 'rightsEncText', 's', false);
    $rightsUseCC = $formdata->getValue('post', 'rightsUseCC', 'i', false);
    if (empty($experimenter)) {
        $messages[] = _MD_XNPDATA_EXPERIMENTER_REQUIRED;
    }
    if (empty($data_fileFileID) && empty($data_file['name'])) {
        $messages[] = _MD_XNPDATA_DATA_FILE_REQUIRED;
    }
    // require Readme and License if register to public indexes
    $xids = explode(',', $xoonipsCheckedXID);
    $indexes = array();
    if ($xids[0] != $xoonipsCheckedXID) {
        foreach ($xids as $i) {
            $index = array();
            if (xnp_get_index($xnpsid, $i, $index) == RES_OK) {
                $indexes[] = $index;
            } else {
                $messages[] = '<font color="#ff0000">' . xnp_get_last_error_string() . '</font>';
                $result = false;
                break;
            }
        }
    }
    if (count($indexes) > 0) {
        foreach ($indexes as $i) {
            if ($i['open_level'] <= OL_GROUP_ONLY) {
                if ($readmeEncText == '') {
                    // readme is not filled
                    $messages[] = '<font color="#ff0000">' . _MD_XNPDATA_README_REQUIRED . '</font>';
                }
                if ($rightsEncText == '' && $rightsUseCC == '0') {
                    // rights is not filled
                    $messages[] = '<font color="#ff0000">' . _MD_XNPDATA_RIGHTS_REQUIRED . '</font>';
                }
                break;
            }
        }
    }
    if (count($messages) == 0) {
        return true;
    }
    $message = "<br />\n" . implode("<br />\n", $messages);
    return false;
}