Esempio n. 1
0
function fncEdit($id, $edt_flg, $msg = '', $errmsg = "", $mode = "edit")
{
    $pi_name = "userbox";
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_USER;
    global $LANG28;
    global $_SCRIPTS;
    global $_USERBOX_CONF;
    global $LANG_USERBOX_ADMIN;
    global $LANG_USERBOX;
    $retval = '';
    $delflg = false;
    $addition_def = DATABOX_getadditiondef($pi_name);
    //メッセージ表示
    if (!empty($msg)) {
        $retval .= COM_showMessage($msg, $pi_name);
        $retval .= $errmsg;
        // clean 'em up
        $code = COM_applyFilter($_POST['code']);
        //@@@@@
        $title = COM_applyFilter($_POST['title']);
        //@@@@@
        $username = COM_applyFilter($_POST['username']);
        //@@@@@
        $fullname = COM_applyFilter($_POST['fullname']);
        //@@@@@
        $page_title = COM_applyFilter($_POST['page_title']);
        $description = $_POST['description'];
        //COM_applyFilter($_POST['description']);
        $defaulttemplatesdirectory = COM_applyFilter($_POST['defaulttemplatesdirectory']);
        //@@@@@@
        $draft_flag = COM_applyFilter($_POST['draft_flag'], true);
        $hits = COM_applyFilter($_POST['hits'], true);
        $comments = COM_applyFilter($_POST['comments'], true);
        $commentcode = COM_applyFilter($_POST['commentcode'], true);
        $trackbackcode = COM_applyFilter($_POST['trackbackcode'], true);
        $cache_time = COM_applyFilter($_POST['cache_time'], true);
        //@@@@@
        $comment_expire_flag = COM_applyFilter($_POST['comment_expire_flag'], true);
        if ($comment_expire_flag === 0) {
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $comment_expire_year = date('Y', $w);
            $comment_expire_month = date('m', $w);
            $comment_expire_day = date('d', $w);
            $comment_expire_hour = 0;
            $comment_expire_minute = 0;
        } else {
            $comment_expire_month = COM_applyFilter($_POST['comment_expire_month'], true);
            $comment_expire_day = COM_applyFilter($_POST['comment_expire_day'], true);
            $comment_expire_year = COM_applyFilter($_POST['comment_expire_year'], true);
            $comment_expire_hour = COM_applyFilter($_POST['comment_expire_hour'], true);
            $comment_expire_minute = COM_applyFilter($_POST['comment_expire_minute'], true);
        }
        $meta_description = COM_applyFilter($_POST['meta_description']);
        $meta_keywords = COM_applyFilter($_POST['meta_keywords']);
        $language_id = COM_applyFilter($_POST['language_id']);
        $category = $_POST['category'];
        $additionfields = $_POST['afield'];
        $additionfields_fnm = $_POST['afield_fnm'];
        //@@@@@
        $additionfields_del = $_POST['afield_del'];
        $additionfields_date = array();
        $additionfields_alt = $_POST['afield_alt'];
        $additionfields = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt, false);
        $owner_id = COM_applyFilter($_POST['owner_id'], true);
        $group_id = COM_applyFilter($_POST['group_id'], true);
        //
        $array['perm_owner'] = $_POST['perm_owner'];
        $array['perm_group'] = $_POST['perm_group'];
        $array['perm_members'] = $_POST['perm_members'];
        $array['perm_anon'] = $_POST['perm_anon'];
        if (is_array($array['perm_owner']) || is_array($array['perm_group']) || is_array($array['perm_members']) || is_array($array['perm_anon'])) {
            list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($array['perm_owner'], $array['perm_group'], $array['perm_members'], $array['perm_anon']);
        } else {
            $perm_owner = $array['perm_owner'];
            $perm_group = $array['perm_group'];
            $perm_members = $array['perm_members'];
            $perm_anon = $array['perm_anon'];
        }
        //編集日
        $modified_autoupdate = COM_applyFilter($_POST['modified_autoupdate'], true);
        $modified_month = COM_applyFilter($_POST['modified_month'], true);
        $modified_day = COM_applyFilter($_POST['modified_day'], true);
        $modified_year = COM_applyFilter($_POST['modified_year'], true);
        $modified_hour = COM_applyFilter($_POST['modified_hour'], true);
        $modified_minute = COM_applyFilter($_POST['modified_minute'], true);
        //公開日
        $released_month = COM_applyFilter($_POST['released_month'], true);
        $released_day = COM_applyFilter($_POST['released_day'], true);
        $released_year = COM_applyFilter($_POST['released_year'], true);
        $released_hour = COM_applyFilter($_POST['released_hour'], true);
        $released_minute = COM_applyFilter($_POST['released_minute'], true);
        //公開終了日
        $expired_available = COM_applyFilter($_POST['expired_available'], true);
        $expired_flag = COM_applyFilter($_POST['expired_flag'], true);
        if ($expired_flag === 0) {
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $expired_year = date('Y', $w);
            $expired_month = date('m', $w);
            $expired_day = date('d', $w);
            $expired_hour = 0;
            $expired_minute = 0;
        } else {
            $expired_month = COM_applyFilter($_POST['expired_month'], true);
            $expired_day = COM_applyFilter($_POST['expired_day'], true);
            $expired_year = COM_applyFilter($_POST['expired_year'], true);
            $expired_hour = COM_applyFilter($_POST['expired_hour'], true);
            $expired_minute = COM_applyFilter($_POST['expired_minute'], true);
        }
        //作成日付
        $created = COM_applyFilter($_POST['created']);
        $created_un = COM_applyFilter($_POST['created_un']);
        $orderno = COM_applyFilter($_POST['orderno']);
        $uuid = $_USER['uid'];
        $udatetime = COM_applyFilter($_POST['udatetime']);
        //"";
        $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
        //"";
        $fieldset_name = COM_applyFilter($_POST['fieldset_name']);
        //"";
    } else {
        $sql = "SELECT ";
        $sql .= " t.*";
        $sql .= " ,t2.name AS fieldset_name" . LB;
        $sql .= " ,t1.username";
        $sql .= " ,t1.fullname";
        $sql .= " ,UNIX_TIMESTAMP(t.modified) AS modified_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.released) AS released_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.comment_expire) AS comment_expire_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.expired) AS expired_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.udatetime) AS udatetime_un" . LB;
        $sql .= " ,UNIX_TIMESTAMP(t.created) AS created_un" . LB;
        $sql .= " FROM ";
        $sql .= $_TABLES['USERBOX_base'] . " AS t";
        $sql .= "," . $_TABLES['users'] . " AS t1";
        $sql .= "," . $_TABLES['USERBOX_def_fieldset'] . " AS t2 " . LB;
        $sql .= " WHERE ";
        $sql .= " t.id = {$id}";
        $sql .= " AND t.id = t1.uid";
        $sql .= " AND t.fieldset_id = t2.fieldset_id" . LB;
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
        $fieldset_id = COM_stripslashes($A['fieldset_id']);
        $fieldset_name = COM_stripslashes($A['fieldset_name']);
        $code = COM_stripslashes($A['code']);
        //@@@@@
        $title = COM_stripslashes($A['title']);
        //@@@@@
        $username = COM_stripslashes($A['username']);
        //@@@@@
        $fullname = COM_stripslashes($A['fullname']);
        //@@@@@
        $page_title = COM_stripslashes($A['page_title']);
        $description = COM_stripslashes($A['description']);
        $defaulttemplatesdirectory = COM_stripslashes($A['defaulttemplatesdirectory']);
        $hits = COM_stripslashes($A['hits']);
        $comments = COM_stripslashes($A['comments']);
        $comment_expire = COM_stripslashes($A['comment_expire']);
        if ($comment_expire === "0000-00-00 00:00:00") {
            $comment_expire_flag = 0;
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $comment_expire_year = date('Y', $w);
            $comment_expire_month = date('m', $w);
            $comment_expire_day = date('d', $w);
            $comment_expire_hour = 0;
            $comment_expire_minute = 0;
        } else {
            $comment_expire_flag = 1;
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['comment_expire_un']));
            $comment_expire = $wary[1];
            $comment_expire_year = date('Y', $comment_expire);
            $comment_expire_month = date('m', $comment_expire);
            $comment_expire_day = date('d', $comment_expire);
            $comment_expire_hour = date('H', $comment_expire);
            $comment_expire_minute = date('i', $comment_expire);
        }
        $commentcode = COM_stripslashes($A['commentcode']);
        $trackbackcode = COM_stripslashes($A['trackbackcode']);
        $cache_time = COM_stripslashes($A['cache_time']);
        $meta_description = COM_stripslashes($A['meta_description']);
        $meta_keywords = COM_stripslashes($A['meta_keywords']);
        $language_id = COM_stripslashes($A['language_id']);
        $owner_id = COM_stripslashes($A['owner_id']);
        $group_id = COM_stripslashes($A['group_id']);
        $perm_owner = COM_stripslashes($A['perm_owner']);
        $perm_group = COM_stripslashes($A['perm_group']);
        $perm_members = COM_stripslashes($A['perm_members']);
        $perm_anon = COM_stripslashes($A['perm_anon']);
        $category = DATABOX_getdatas("category_id", $_TABLES['USERBOX_category'], "id = {$id}");
        $additionfields = DATABOX_getadditiondatas($id, $pi_name);
        $additionfields_fnm = array();
        //@@@@@
        $additionfields_del = array();
        $additionfields_date = "";
        $draft_flag = COM_stripslashes($A['draft_flag']);
        //編集日
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['modified_un']));
        $modified = $wary[1];
        //$modified = strtotime(COM_stripslashes($A['modified']));
        $modified_month = date('m', $modified);
        $modified_day = date('d', $modified);
        $modified_year = date('Y', $modified);
        $modified_hour = date('H', $modified);
        $modified_minute = date('i', $modified);
        //公開日
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['released_un']));
        $released = $wary[1];
        //$released = strtotime(COM_stripslashes($A['released']));
        $released_month = date('m', $released);
        $released_day = date('d', $released);
        $released_year = date('Y', $released);
        $released_hour = date('H', $released);
        $released_minute = date('i', $released);
        //公開終了日
        $expired = COM_stripslashes($A['expired']);
        if ($expired === "0000-00-00 00:00:00") {
            $expired_flag = 0;
            $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
            $expired_year = date('Y', $w);
            $expired_month = date('m', $w);
            $expired_day = date('d', $w);
            $expired_hour = 0;
            $expired_minute = 0;
        } else {
            $expired_flag = 1;
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['expired_un']));
            $expired = $wary[1];
            $expired_year = date('Y', $expired);
            $expired_month = date('m', $expired);
            $expired_day = date('d', $expired);
            $expired_hour = date('H', $expired);
            $expired_minute = date('i', $expired);
        }
        //作成日付
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['created_un']));
        $created = $wary[0];
        $created_un = $wary[1];
        $orderno = COM_stripslashes($A['orderno']);
        $uuid = COM_stripslashes($A['uuid']);
        $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['udatetime_un']));
        $udatetime = $wary[0];
        if ($edt_flg == FALSE) {
            $delflg = true;
        }
    }
    //template フォルダ
    $tmplfld = DATABOX_templatePath('admin', 'default', $pi_name);
    $templates = new Template($tmplfld);
    $templates->set_file(array('editor' => 'profile_editor.thtml', 'row' => 'row.thtml', 'col' => "profile_col_detail.thtml"));
    // Add JavaScript geeklog >=2.1.0
    // Loads jQuery UI datepicker and timepicker-addon
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.button');
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n');
    //    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-slideraccess');
    $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js');
    $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/datepicker.js');
    $langCode = COM_getLangIso639Code();
    $toolTip = $MESSAGE[118];
    $imgUrl = $_CONF['site_url'] . '/images/calendar.png';
    $_SCRIPTS->setJavaScript("jQuery(function () {" . "  geeklog.hour_mode = {$_CONF['hour_mode']};" . "  geeklog.datetimepicker.set('comment_expire', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('modified', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('released', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('expired', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE);
    //--
    if ($_CONF['meta_tags'] > 0 && $_USERBOX_CONF['meta_tags'] > 0) {
        $templates->set_var('hide_meta', '');
    } else {
        $templates->set_var('hide_meta', ' style="display:none;"');
    }
    $templates->set_var('maxlength_description', $_USERBOX_CONF['maxlength_description']);
    $templates->set_var('maxlength_meta_description', $_USERBOX_CONF['maxlength_meta_description']);
    $templates->set_var('maxlength_meta_keywords', $_USERBOX_CONF['maxlength_meta_keywords']);
    $templates->set_var('about_thispage', $LANG_USERBOX_ADMIN['about_admin_profile']);
    $templates->set_var('lang_must', $LANG_USERBOX_ADMIN['must']);
    $templates->set_var('site_url', $_CONF['site_url']);
    $templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $templates->set_var('lang_ref', $LANG_USERBOX_ADMIN['ref']);
    $templates->set_var('lang_view', $LANG_USERBOX_ADMIN['view']);
    $token = SEC_createToken();
    $retval .= SEC_getTokenExpiryNotice($token);
    $templates->set_var('gltoken_name', CSRF_TOKEN);
    $templates->set_var('gltoken', $token);
    $templates->set_var('xhtml', XHTML);
    $templates->set_var('script', THIS_SCRIPT);
    $templates->set_var('dateformat', $_USERBOX_CONF['dateformat']);
    //ビューリンク@@@@@
    $url = $_CONF['site_url'] . "/userbox/profile.php";
    $url .= "?";
    if ($_USERBOX_CONF['datacode']) {
        $url .= "code=" . $A['username'];
        $url .= "&m=code";
    } else {
        $url .= "id=" . $A['id'];
        $url .= "&m=id";
    }
    $url = COM_buildUrl($url);
    $view = COM_createLink($LANG_USERBOX['view'], $url);
    $templates->set_var('view', $view);
    //
    $templates->set_var('lang_link_admin', $LANG_USERBOX_ADMIN['link_admin']);
    $templates->set_var('lang_link_admin_top', $LANG_USERBOX_ADMIN['link_admin_top']);
    $templates->set_var('lang_link_public', $LANG_USERBOX_ADMIN['link_public']);
    $templates->set_var('lang_link_list', $LANG_USERBOX_ADMIN['link_list']);
    $templates->set_var('lang_link_detail', $LANG_USERBOX_ADMIN['link_detail']);
    //fieldset_id
    $templates->set_var('lang_fieldset', $LANG_USERBOX_ADMIN['fieldset']);
    $templates->set_var('fieldset_id', $fieldset_id);
    $templates->set_var('fieldset_name', $fieldset_name);
    //id
    $templates->set_var('lang_id', $LANG_USERBOX_ADMIN['id']);
    //@@@@@ $templates->set_var('help_id', $LANG_USERBOX_ADMIN['help']);
    $templates->set_var('id', $id);
    //下書
    $templates->set_var('lang_draft', $LANG_USERBOX_ADMIN['draft']);
    if ($draft_flag == 1) {
        $templates->set_var('draft_flag', "checked=checked");
    } else {
        $templates->set_var('draft_flag', "");
    }
    //
    $templates->set_var('lang_field', $LANG_USERBOX_ADMIN['field']);
    $templates->set_var('lang_fields', $LANG_USERBOX_ADMIN['fields']);
    $templates->set_var('lang_content', $LANG_USERBOX_ADMIN['content']);
    $templates->set_var('lang_templatesetvar', $LANG_USERBOX_ADMIN['templatesetvar']);
    //基本項目
    $templates->set_var('lang_basicfields', $LANG_USERBOX_ADMIN['basicfields']);
    //コード&タイトル&説明&テンプレートセット値@@@@@
    $templates->set_var('lang_code', $LANG_USERBOX_ADMIN['code']);
    if ($_USERBOX_CONF['datacode']) {
        $templates->set_var('lang_must_code', $LANG_USERBOX_ADMIN['must']);
    } else {
        $templates->set_var('lang_must_code', "");
    }
    $templates->set_var('code', $code);
    $templates->set_var('lang_title', $LANG_USERBOX_ADMIN['title']);
    $templates->set_var('title', $title);
    //$LANG28 = array(
    //    2 => 'ユーザID',
    //    3 => 'ユーザ名', username
    //    4 => '氏名', fullname
    $templates->set_var('lang_uid', $LANG28['2']);
    $templates->set_var('lang_username', $LANG28['3']);
    $templates->set_var('username', $username);
    $templates->set_var('lang_fullname', $LANG28['4']);
    $templates->set_var('fullname', $fullname);
    //
    $templates->set_var('lang_page_title', $LANG_USERBOX_ADMIN['page_title']);
    $templates->set_var('page_title', $page_title);
    $templates->set_var('lang_description', $LANG_USERBOX_ADMIN['description']);
    $templates->set_var('description', $description);
    $templates->set_var('lang_defaulttemplatesdirectory', $LANG_USERBOX_ADMIN['defaulttemplatesdirectory']);
    $templates->set_var('defaulttemplatesdirectory', $defaulttemplatesdirectory);
    $select_defaulttemplatesdirectory = fnctemplatesdirectory($defaulttemplatesdirectory);
    $templates->set_var('select_defaulttemplatesdirectory', $select_defaulttemplatesdirectory);
    //@@@@@
    //meta_description
    $templates->set_var('lang_meta_description', $LANG_USERBOX_ADMIN['meta_description']);
    $templates->set_var('meta_description', $meta_description);
    //meta_keywords
    $templates->set_var('lang_meta_keywords', $LANG_USERBOX_ADMIN['meta_keywords']);
    $templates->set_var('meta_keywords', $meta_keywords);
    //language_id
    if (is_array($_CONF['languages'])) {
        $templates->set_var('hide_language_id', '');
        $select_language_id = DATABOX_getoptionlist("language_id", $language_id, 0, $pi_name, "", 0);
    } else {
        $templates->set_var('hide_language_id', ' style="display:none;"');
        $select_language_id = "";
    }
    $templates->set_var('lang_language_id', $LANG_USERBOX_ADMIN['language_id']);
    $templates->set_var('language_id', $language_id);
    $templates->set_var('select_language_id', $select_language_id);
    //@@@@@
    //hits
    $templates->set_var('lang_hits', $LANG_USERBOX_ADMIN['hits']);
    $templates->set_var('hits', $hits);
    //comments
    $templates->set_var('lang_comments', $LANG_USERBOX_ADMIN['comments']);
    $templates->set_var('comments', $comments);
    //commentcode
    $templates->set_var('lang_commentcode', $LANG_USERBOX_ADMIN['commentcode']);
    $templates->set_var('commentcode', $commentcode);
    $optionlist_commentcode = COM_optionList($_TABLES['commentcodes'], 'code,name', $commentcode);
    $templates->set_var('optionlist_commentcode', $optionlist_commentcode);
    //trackbackcode
    $templates->set_var('lang_trackbackcode', $LANG_USERBOX_ADMIN['trackbackcode']);
    $templates->set_var('trackbackcode', $trackbackcode);
    $optionlist_trackbackcode = COM_optionList($_TABLES['trackbackcodes'], 'code,name', $trackbackcode);
    $templates->set_var('optionlist_trackbackcode', $optionlist_trackbackcode);
    $templates->set_var('lang_cache_time', $LANG_USERBOX_ADMIN['cache_time']);
    $templates->set_var('lang_cache_time_desc', $LANG_USERBOX_ADMIN['cache_time_desc']);
    $templates->set_var('cache_time', $cache_time);
    //comment_expire
    $templates->set_var('lang_enabled', $LANG_USERBOX_ADMIN['enabled']);
    if ($comment_expire_flag === 0) {
        $templates->set_var('show_comment_expire', 'false');
        $templates->set_var('is_checked_comment_expire', '');
    } else {
        $templates->set_var('show_comment_expire', 'true');
        $templates->set_var('is_checked_comment_expire', 'checked="checked"');
    }
    $templates->set_var('lang_comment_expire', $LANG_USERBOX_ADMIN['comment_expire']);
    $w = COM_convertDate2Timestamp($comment_expire_year . "-" . $comment_expire_month . "-" . $comment_expire_day, $comment_expire_hour . ":" . $comment_expire_minute . "::00");
    $datetime_comment_expire = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "comment_expire");
    $templates->set_var('datetime_comment_expire', $datetime_comment_expire);
    //編集日
    $templates->set_var('lang_modified_autoupdate', $LANG_USERBOX_ADMIN['modified_autoupdate']);
    $templates->set_var('lang_modified', $LANG_USERBOX_ADMIN['modified']);
    $w = COM_convertDate2Timestamp($modified_year . "-" . $modified_month . "-" . $modified_day, $modified_hour . ":" . $modified_minute . "::00");
    $datetime_modified = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "modified");
    $templates->set_var('datetime_modified', $datetime_modified);
    //公開日
    $templates->set_var('lang_released', $LANG_USERBOX_ADMIN['released']);
    $w = COM_convertDate2Timestamp($released_year . "-" . $released_month . "-" . $released_day, $released_hour . ":" . $released_minute . "::00");
    $datetime_released = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "released");
    $templates->set_var('datetime_released', $datetime_released);
    //公開終了日
    $templates->set_var('lang_expired', $LANG_USERBOX_ADMIN['expired']);
    //if ($expired=="0000-00-00 00:00:00"){
    if ($expired_flag == 0) {
        $templates->set_var('show_expired', 'false');
        $templates->set_var('is_checked_expired', '');
    } else {
        $templates->set_var('show_expired', 'true');
        $templates->set_var('is_checked_expired', 'checked="expired"');
    }
    $templates->set_var('lang_expired', $LANG_USERBOX_ADMIN['expired']);
    $w = COM_convertDate2Timestamp($expired_year . "-" . $expired_month . "-" . $expired_day, $expired_hour . ":" . $expired_minute . "::00");
    $datetime_expired = DATABOX_datetimeedit($w, "LANG_USERBOX_ADMIN", "expired");
    $templates->set_var('datetime_expired', $datetime_expired);
    //順序
    $templates->set_var('lang_orderno', $LANG_USERBOX_ADMIN['orderno']);
    $templates->set_var('orderno', $orderno);
    //koko
    //カテゴリ
    $templates->set_var('lang_category', $LANG_USERBOX_ADMIN['category']);
    $checklist_category = DATABOX_getcategoriesinp($category, $fieldset_id, $pi_name);
    $templates->set_var('checklist_category', $checklist_category);
    //追加項目
    $templates->set_var('lang_additionfields', $LANG_USERBOX_ADMIN['additionfields']);
    $rt = DATABOX_getaddtionfieldsEdit($additionfields, $addition_def, $templates, 9999, $pi_name, $additionfields_fnm, $additionfields_del, $fieldset_id, $additionfields_date);
    //保存日時
    $templates->set_var('lang_udatetime', $LANG_USERBOX_ADMIN['udatetime']);
    $templates->set_var('udatetime', $udatetime);
    $templates->set_var('lang_uuid', $LANG_USERBOX_ADMIN['uuid']);
    $templates->set_var('uuid', $uuid);
    //作成日付
    $templates->set_var('lang_created', $LANG_USERBOX_ADMIN['created']);
    $templates->set_var('created', $created);
    $templates->set_var('created_un', $created_un);
    //アクセス権
    $templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $owner_name = COM_getDisplayName($owner_id);
    $templates->set_var('owner_name', $owner_name);
    $templates->set_var('owner_id', $owner_id);
    $templates->set_var('lang_group', $LANG_ACCESS['group']);
    $templates->set_var('group_dropdown', SEC_getGroupDropdown($group_id, 3));
    $templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $templates->set_var('permissions_editor', SEC_getPermissionsHTML($perm_owner, $perm_group, $perm_members, $perm_anon));
    $templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    // SAVE、CANCEL ボタン
    $templates->set_var('lang_save', $LANG_ADMIN['save']);
    $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $templates->set_var('lang_preview', $LANG_ADMIN['preview']);
    //delete_option
    //$delflg=false;//@@@@@ 削除不可
    if ($delflg) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
    }
    //
    $templates->parse('output', 'editor');
    $retval .= $templates->finish($templates->get_var('output'));
    return $retval;
}
Esempio n. 2
0
function fncEdit($id, $edt_flg, $msg = '', $errmsg = "", $mode = "edit", $fieldset_id = 0, $template = "", $old_mode = "")
{
    $pi_name = "databox";
    global $_CONF;
    global $_TABLES;
    global $LANG_DATABOX_ADMIN;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_DATABOX_CONF;
    global $_USER;
    global $_SCRIPTS;
    $retval = '';
    $delflg = false;
    $addition_def = DATABOX_getadditiondef();
    //メッセージ表示
    if (!empty($msg)) {
        $retval .= COM_showMessage($msg, $pi_name);
        $retval .= $errmsg;
        // clean 'em up
        $code = COM_applyFilter($_POST['code']);
        $title = COM_stripslashes($_POST['title']);
        $page_title = COM_applyFilter($_POST['page_title']);
        $description = $_POST['description'];
        //COM_applyFilter($_POST['description']);
        $draft_flag = COM_applyFilter($_POST['draft_flag'], true);
        $cache_time = COM_applyFilter($_POST['cache_time'], true);
        $language_id = COM_applyFilter($_POST['language_id']);
        $category = $_POST['category'];
        $additionfields = $_POST['afield'];
        $additionfields_fnm = $_POST['afield_fnm'];
        //@@@@@
        $additionfields_del = $_POST['afield_del'];
        $additionfields_date = array();
        $additionfields_alt = $_POST['afield_alt'];
        $additionfields = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt, false);
        //作成日付
        $created = COM_applyFilter($_POST['created']);
        $created_un = COM_applyFilter($_POST['created_un']);
        $orderno = COM_applyFilter($_POST['orderno']);
        $uuid = $_USER['uid'];
        $udatetime = COM_applyFilter($_POST['udatetime']);
        //"";
        $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
        //"";
        $fieldset_name = COM_applyFilter($_POST['fieldset_name']);
        //"";
    } else {
        if (empty($id)) {
            $fieldset_name = DB_getItem($_TABLES['DATABOX_def_fieldset'], "name", "fieldset_id=" . $fieldset_id);
            $fieldset_name = COM_stripslashes($fieldset_name);
            $id = 0;
            $code = "";
            $title = "";
            $description = "";
            $language_id = "";
            $category = "";
            $additionfields = array();
            $additionfields_fnm = array();
            //@@@@@
            $additionfields_del = array();
            $additionfields_date = "";
            $additionfields = DATABOX_getadditiondatas(0, $pi_name);
            //
            $draft_flag = $_DATABOX_CONF['user_draft_default'];
            $cache_time = $_DATABOX_CONF['default_cache_time'];
            //作成日付
            $created = 0;
            $created_un = 0;
            $uuid = 0;
            $udatetime = "";
            //"";
            $defaulttemplatesdirectory = "";
        } else {
            $sql = "SELECT ";
            $sql .= " t.*" . LB;
            $sql .= " ,t2.name AS fieldset_name" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.modified) AS modified_un" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.released) AS released_un" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.comment_expire) AS comment_expire_un" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.expired) AS expired_un" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.udatetime) AS udatetime_un" . LB;
            $sql .= " ,UNIX_TIMESTAMP(t.created) AS created_un" . LB;
            $sql .= " FROM ";
            $sql .= $_TABLES['DATABOX_base'] . " AS t " . LB;
            $sql .= "," . $_TABLES['DATABOX_def_fieldset'] . " AS t2 " . LB;
            $sql .= " WHERE " . LB;
            $sql .= " id = {$id}" . LB;
            $sql .= " AND t.fieldset_id = t2.fieldset_id" . LB;
            //編集権のないデータ はのぞく//@@@@@
            $sql .= COM_getPermSql('AND', 0, 3);
            $result = DB_query($sql);
            $A = DB_fetchArray($result);
            $A = array_map('stripslashes', $A);
            $fieldset_id = COM_stripslashes($A['fieldset_id']);
            $fieldset_name = COM_stripslashes($A['fieldset_name']);
            $code = COM_stripslashes($A['code']);
            $title = COM_stripslashes($A['title']);
            $page_title = COM_stripslashes($A['page_title']);
            $description = COM_stripslashes($A['description']);
            $language_id = COM_stripslashes($A['language_id']);
            $category = DATABOX_getdatas("category_id", $_TABLES['DATABOX_category'], "id = {$id}");
            //追加項目
            $additionfields = DATABOX_getadditiondatas($id, $pi_name);
            $additionfields_fnm = array();
            //@@@@@
            $additionfields_del = array();
            $additionfields_date = "";
            $draft_flag = COM_stripslashes($A['draft_flag']);
            $cache_time = COM_stripslashes($A['cache_time']);
            //編集日
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['modified_un']));
            $modified = $wary[1];
            $modified_month = date('m', $modified);
            $modified_day = date('d', $modified);
            $modified_year = date('Y', $modified);
            $modified_hour = date('H', $modified);
            $modified_minute = date('i', $modified);
            //作成日付
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['created_un']));
            $created = $wary[0];
            $created_un = $wary[1];
            $orderno = COM_stripslashes($A['orderno']);
            $uuid = COM_stripslashes($A['uuid']);
            $wary = COM_getUserDateTimeFormat(COM_stripslashes($A['udatetime_un']));
            $udatetime = $wary[0];
            $defaulttemplatesdirectory = $A['defaulttemplatesdirectory'];
            if ($_DATABOX_CONF['allow_data_delete']) {
                if ($edt_flg == FALSE) {
                    $delflg = true;
                }
            }
        }
    }
    if ($mode === "copy") {
        $id = 0;
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        $code = "";
        //作成日付
        $created = 0;
        $created_un = 0;
        //公開日
        $released_month = $modified_month;
        $released_day = $modified_day;
        $released_year = $modified_year;
        $released_hour = $modified_hour;
        $released_minute = $modified_minute;
        //公開終了日
        $expired_flag = 0;
        $w = mktime(0, 0, 0, date('m'), date('d') + $_CONF['article_comment_close_days'], date('Y'));
        $expired_year = date('Y', $w);
        $expired_month = date('m', $w);
        $expired_day = date('d', $w);
        $expired_hour = 0;
        $expired_minute = 0;
        //
        $delflg = false;
        $old_mode = "copy";
    }
    $chk_user = DATABOX_chkuser($group_id, $owner_id, "databox.admin");
    //template フォルダ
    if (is_null($template) or $template === "") {
        $set_defaulttemplatesdirectory = DB_getItem($_TABLES['DATABOX_def_fieldset'], "defaulttemplatesdirectory", "fieldset_id=" . $fieldset_id);
        if ($defaulttemplatesdirectory != "") {
            $template = $defaulttemplatesdirectory;
        } elseif ($set_defaulttemplatesdirectory != "") {
            $template = $set_defaulttemplatesdirectory;
        } else {
            $template = "default";
        }
    }
    $tmplfld = DATABOX_templatePath('mydata', $template, 'databox');
    $templates = new Template($tmplfld);
    $templates->set_file('editor', "data_editor.thtml");
    $templates->set_file(array('editor' => 'data_editor.thtml', 'row' => 'row.thtml', 'col' => "data_col_detail.thtml"));
    // Loads jQuery UI datepicker geeklog >=2.1.0
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon');
    $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n');
    $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js');
    $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/datepicker.js');
    $langCode = COM_getLangIso639Code();
    $toolTip = $MESSAGE[118];
    $imgUrl = $_CONF['site_url'] . '/images/calendar.png';
    //--
    if ($_CONF['meta_tags'] > 0 && $_DATABOX_CONF['meta_tags'] > 0) {
        $templates->set_var('hide_meta', '');
    } else {
        $templates->set_var('hide_meta', ' style="display:none;"');
    }
    $templates->set_var('maxlength_description', $_DATABOX_CONF['maxlength_description']);
    $templates->set_var('about_thispage', $LANG_DATABOX_ADMIN['about_admin_data']);
    $templates->set_var('lang_must', $LANG_DATABOX_ADMIN['must']);
    $templates->set_var('site_url', $_CONF['site_url']);
    $templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $templates->set_var('lang_view', $LANG_DATABOX_ADMIN['view']);
    $templates->set_var('dateformat', $_DATABOX_CONF['dateformat']);
    $token = SEC_createToken();
    $retval .= SEC_getTokenExpiryNotice($token);
    $templates->set_var('gltoken_name', CSRF_TOKEN);
    $templates->set_var('gltoken', $token);
    $templates->set_var('xhtml', XHTML);
    $script = THIS_SCRIPT;
    $script .= "?template=" . $template;
    $templates->set_var('script', $script);
    //
    $templates->set_var('lang_link_admin', $LANG_DATABOX_ADMIN['link_admin']);
    $templates->set_var('lang_link_admin_top', $LANG_DATABOX_ADMIN['link_admin_top']);
    $templates->set_var('lang_link_public', $LANG_DATABOX_ADMIN['link_public']);
    $templates->set_var('lang_link_list', $LANG_DATABOX_ADMIN['link_list']);
    $templates->set_var('lang_link_detail', $LANG_DATABOX_ADMIN['link_detail']);
    //field_id
    $templates->set_var('lang_fieldset', $LANG_DATABOX_ADMIN['fieldset']);
    $templates->set_var('fieldset_id', $fieldset_id);
    $templates->set_var('fieldset_name', $fieldset_name);
    //id
    $templates->set_var('lang_id', $LANG_DATABOX_ADMIN['id']);
    //@@@@@ $templates->set_var('help_id', $LANG_DATABOX_ADMIN['help']);
    $templates->set_var('id', $id);
    //下書
    $templates->set_var('lang_draft', $LANG_DATABOX_ADMIN['draft']);
    if ($draft_flag == 1) {
        $templates->set_var('draft_flag', "checked=checked");
        $templates->set_var('draft_msg', $LANG_DATABOX_ADMIN['draft_msg']);
    } else {
        $templates->set_var('draft_flag', "");
        $templates->set_var('draft_msg', "");
    }
    //
    $templates->set_var('lang_field', $LANG_DATABOX_ADMIN['field']);
    $templates->set_var('lang_fields', $LANG_DATABOX_ADMIN['fields']);
    $templates->set_var('lang_content', $LANG_DATABOX_ADMIN['content']);
    $templates->set_var('lang_templatesetvar', $LANG_DATABOX_ADMIN['templatesetvar']);
    //基本項目
    $templates->set_var('lang_basicfields', $LANG_DATABOX_ADMIN['basicfields']);
    //コード&タイトル&説明&テンプレートセット値
    $templates->set_var('lang_code', $LANG_DATABOX_ADMIN['code']);
    if ($_DATABOX_CONF['datacode']) {
        $templates->set_var('lang_must_code', $LANG_DATABOX_ADMIN['must']);
    } else {
        $templates->set_var('lang_must_code', "");
    }
    $templates->set_var('code', $code);
    $templates->set_var('lang_title', $LANG_DATABOX_ADMIN['title']);
    $templates->set_var('title', $title);
    $templates->set_var('lang_page_title', $LANG_DATABOX_ADMIN['page_title']);
    $templates->set_var('page_title', $page_title);
    $templates->set_var('lang_description', $LANG_DATABOX_ADMIN['description']);
    $templates->set_var('description', $description);
    //language_id
    if (is_array($_CONF['languages'])) {
        $templates->set_var('hide_language_id', '');
        $select_language_id = DATABOX_getoptionlist("language_id", $language_id, 0, $pi_name, "", 0);
    } else {
        $templates->set_var('hide_language_id', ' style="display:none;"');
        $select_language_id = "";
    }
    $templates->set_var('lang_language_id', $LANG_DATABOX_ADMIN['language_id']);
    $templates->set_var('language_id', $language_id);
    $templates->set_var('select_language_id', $select_language_id);
    //@@@@@
    //編集日
    $templates->set_var('lang_modified_autoupdate', $LANG_DATABOX_ADMIN['modified_autoupdate']);
    $templates->set_var('lang_modified', $LANG_DATABOX_ADMIN['modified']);
    $w = COM_convertDate2Timestamp($modified_year . "-" . $modified_month . "-" . $modified_day, $modified_hour . ":" . $modified_minute . "::00");
    $datetime_modified = DATABOX_datetimeedit($w, "LANG_DATABOX_ADMIN", "modified");
    $templates->set_var('datetime_modified', $datetime_modified);
    //カテゴリ
    $templates->set_var('lang_category', $LANG_DATABOX_ADMIN['category']);
    $checklist_category = DATABOX_getcategoriesinp($category, $fieldset_id, "databox");
    $templates->set_var('checklist_category', $checklist_category);
    //追加項目
    $templates->set_var('lang_additionfields', $LANG_DATABOX_ADMIN['additionfields']);
    $rt = DATABOX_getaddtionfieldsEdit($additionfields, $addition_def, $templates, $chk_user, $pi_name, $additionfields_fnm, $additionfields_del, $fieldset_id, $additionfields_date);
    //$rt=DATABOX_getaddtionfieldsJS($additionfields,$addition_def,$chk_user,$pi_name);
    //保存日時
    $templates->set_var('lang_udatetime', $LANG_DATABOX_ADMIN['udatetime']);
    $templates->set_var('udatetime', $udatetime);
    $templates->set_var('lang_uuid', $LANG_DATABOX_ADMIN['uuid']);
    $templates->set_var('uuid', $uuid);
    //作成日付
    $templates->set_var('lang_created', $LANG_DATABOX_ADMIN['created']);
    $templates->set_var('created', $created);
    $templates->set_var('created_un', $created_un);
    // SAVE、CANCEL ボタン
    $templates->set_var('lang_save', $LANG_ADMIN['save']);
    $templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $templates->set_var('lang_preview', $LANG_ADMIN['preview']);
    //delete_option
    if ($delflg) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
    }
    $templates->set_var('old_mode', $old_mode);
    //
    $templates->parse('output', 'editor');
    $retval .= $templates->finish($templates->get_var('output'));
    return $retval;
}