Exemple #1
0
/**
* Shows the block editor
*
* This will show a block edit form.  If this is a glFusion default block it will
* send it off to BLOCK_editDefault().
*
* @param    string  $bid    ID of block to edit
* @param    array   $B      An array of block fields (optional)
* @return   string          HTML for block editor
*
*/
function BLOCK_edit($bid = '', $B = array())
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG01, $LANG21, $LANG24, $LANG_ACCESS, $LANG_ADMIN, $LANG_postmodes, $MESSAGE, $_IMAGE_TYPE;
    USES_lib_admin();
    $retval = '';
    $A = array();
    if (!empty($bid)) {
        $result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE bid ='" . DB_escapeString($bid) . "'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 2 || $access == 0 || BLOCK_hasTopicAccess($A['tid']) < 3) {
            $retval .= COM_showMessageText($LANG21[45], $LANG_ACCESS['accessdenied'], true);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit block " . $bid);
            return $retval;
        }
        if ($A['type'] == 'gldefault') {
            $retval .= BLOCK_editDefault($A, $access);
            return $retval;
        }
    } else {
        $A['bid'] = isset($B['bid']) ? $B['bid'] : 0;
        $A['is_enabled'] = isset($B['is_enabled']) ? $B['is_enabled'] : 1;
        $A['name'] = isset($B['name']) ? $B['name'] : '';
        $A['type'] = isset($B['type']) ? $B['type'] : 'normal';
        $A['title'] = isset($B['title']) ? $B['title'] : '';
        $A['tid'] = isset($B['tid']) ? $B['tid'] : 'All';
        $A['blockorder'] = isset($B['blockorder']) ? $B['blockorder'] : 0;
        $A['content'] = isset($B['content']) ? $B['content'] : '';
        $A['allow_autotags'] = isset($B['allow_autotags']) && $B['allow_autotags'] == 1 ? 1 : 0;
        $A['rdfurl'] = isset($B['rdfurl']) ? $B['rdfurl'] : '';
        $A['rdfupdated'] = isset($B['rdfupdated']) ? $B['rdfupdated'] : '';
        $A['rdflimit'] = isset($B['rdflimit']) ? $B['rdflimit'] : 0;
        $A['onleft'] = isset($B['onleft']) ? $B['onleft'] : 0;
        $A['phpblockfn'] = isset($B['phpblockfn']) ? $B['phpblockfn'] : '';
        $A['help'] = isset($B['help']) ? $B['help'] : '';
        $A['owner_id'] = isset($B['owner_id']) ? $B['owner_id'] : $_USER['uid'];
        if (isset($B['group_id'])) {
            $A['group_id'] = $B['group_id'];
        } else {
            if (isset($_GROUPS['Block Admin'])) {
                $A['group_id'] = $_GROUPS['Block Admin'];
            } else {
                $A['group_id'] = SEC_getFeatureGroup('block.edit');
            }
        }
        if (isset($B['perm_owner'])) {
            $A['perm_owner'] = SEC_getPermissionValue($B['perm_owner']);
            $A['perm_group'] = SEC_getPermissionValue($B['perm_group']);
            $A['perm_members'] = SEC_getPermissionValue($B['perm_members']);
            $A['perm_anon'] = SEC_getPermissionValue($B['perm_anon']);
        } else {
            SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        }
        $access = 3;
    }
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/block.php', 'text' => $LANG_ADMIN['block_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $block_templates = new Template($_CONF['path_layout'] . 'admin/block');
    $block_templates->set_file('editor', 'blockeditor.thtml');
    $block_templates->set_var('start_block_editor', COM_startBlock($LANG21[3], '', COM_getBlockTemplate('_admin_block', 'header')));
    if (!empty($bid) && SEC_hasrights('block.delete')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s >';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $block_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $block_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $block_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $block_templates->set_var('lang_delete_confirm', $MESSAGE[76]);
    }
    $block_templates->set_var('block_bid', $A['bid']);
    // standard Admin strings
    $block_templates->set_var('lang_blocktitle', $LANG_ADMIN['title']);
    $block_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']);
    $block_templates->set_var('lang_blockhelpurl', $LANG_ADMIN['help_url']);
    $block_templates->set_var('lang_topic', $LANG_ADMIN['topic']);
    $block_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $block_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $block_templates->set_var('lang_blocktype', $LANG_ADMIN['type']);
    $block_templates->set_var('lang_allowed_html', $LANG01[123]);
    $block_templates->set_var('block_title', htmlspecialchars($A['title'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('lang_enabled', $LANG21[53]);
    if ($A['is_enabled'] == 1) {
        $block_templates->set_var('is_enabled', 'checked="checked"');
    } else {
        $block_templates->set_var('is_enabled', '');
    }
    $block_templates->set_var('block_help', $A['help']);
    $block_templates->set_var('lang_includehttp', $LANG21[51]);
    $block_templates->set_var('lang_explanation', $LANG21[52]);
    $block_templates->set_var('block_name', $A['name']);
    $block_templates->set_var('lang_blockname', $LANG21[48]);
    $block_templates->set_var('lang_nospaces', $LANG21[49]);
    $block_templates->set_var('lang_all', $LANG21[7]);
    $block_templates->set_var('lang_homeonly', $LANG21[43]);
    $block_templates->set_var('lang_nohomepage', $LANG21[44]);
    if ($A['tid'] == 'all') {
        $block_templates->set_var('all_selected', 'selected="selected"');
    } else {
        if ($A['tid'] == 'homeonly') {
            $block_templates->set_var('homeonly_selected', 'selected="selected"');
        } else {
            if ($A['tid'] == 'allnhp') {
                $block_templates->set_var('nohomepage_selected', 'selected="selected"');
            }
        }
    }
    $block_templates->set_var('topic_options', COM_topicList('tid,topic', $A['tid'], 1, true));
    $block_templates->set_var('lang_side', $LANG21[39]);
    $block_templates->set_var('lang_left', $LANG21[40]);
    $block_templates->set_var('lang_right', $LANG21[41]);
    if ($A['onleft'] == 1) {
        $block_templates->set_var('left_selected', 'selected="selected"');
    } else {
        if ($A['onleft'] == 0) {
            $block_templates->set_var('right_selected', 'selected="selected"');
        }
    }
    $block_templates->set_var('lang_blockorder', $LANG21[9]);
    $block_templates->set_var('block_order', $A['blockorder']);
    $block_templates->set_var('lang_normalblock', $LANG21[12]);
    $block_templates->set_var('lang_phpblock', $LANG21[27]);
    $block_templates->set_var('lang_portalblock', $LANG21[11]);
    if ($A['type'] == 'normal') {
        $block_templates->set_var('normal_selected', 'selected="selected"');
    } else {
        if ($A['type'] == 'phpblock') {
            $block_templates->set_var('php_selected', 'selected="selected"');
        } else {
            if ($A['type'] == 'portal') {
                $block_templates->set_var('portal_selected', 'selected="selected"');
            }
        }
    }
    $block_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $block_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $block_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = '{$A['owner_id']}'"));
    $block_templates->set_var('owner_name', $ownername);
    $block_templates->set_var('owner', $ownername);
    $block_templates->set_var('owner_id', $A['owner_id']);
    $block_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $block_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $block_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $block_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $block_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $block_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $block_templates->set_var('lang_phpblockoptions', $LANG21[28]);
    $block_templates->set_var('lang_blockfunction', $LANG21[29]);
    $block_templates->set_var('block_phpblockfn', $A['phpblockfn']);
    $block_templates->set_var('lang_phpblockwarning', $LANG21[30]);
    $block_templates->set_var('lang_portalblockoptions', $LANG21[13]);
    $block_templates->set_var('lang_rdfurl', $LANG21[14]);
    $block_templates->set_var('max_url_length', 255);
    $block_templates->set_var('block_rdfurl', $A['rdfurl']);
    $block_templates->set_var('lang_rdflimit', $LANG21[62]);
    $block_templates->set_var('block_rdflimit', $A['rdflimit']);
    $block_templates->set_var('lang_lastrdfupdate', $LANG21[15]);
    if ($A['rdfupdated'] == '1000-01-01 00:00:00') {
        $block_templates->set_var('block_rdfupdated', '');
    } else {
        $block_templates->set_var('block_rdfupdated', $A['rdfupdated']);
    }
    $block_templates->set_var('lang_normalblockoptions', $LANG21[16]);
    $block_templates->set_var('lang_blockcontent', $LANG21[17]);
    $block_templates->set_var('lang_autotags', $LANG21[66]);
    $block_templates->set_var('lang_use_autotags', $LANG21[67]);
    $block_templates->set_var('block_content', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('block_text', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('block_html', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    if ($A['allow_autotags'] == 1) {
        $block_templates->set_var('allow_autotags', 'checked="checked"');
    } else {
        $block_templates->set_var('allow_autotags', '');
    }
    $block_templates->set_var('gltoken_name', CSRF_TOKEN);
    $block_templates->set_var('gltoken', SEC_createToken());
    $block_templates->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG21[71], $_CONF['layout_url'] . '/images/icons/block.' . $_IMAGE_TYPE));
    $block_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    PLG_templateSetVars('blockeditor', $block_templates);
    $block_templates->parse('output', 'editor');
    $retval .= $block_templates->finish($block_templates->get_var('output'));
    return $retval;
}
 function _initVars()
 {
     global $_USER, $_GROUPS, $_DLM_CONF, $mytree;
     $this->_cid = $this->_createID();
     $this->_old_cid = '';
     $this->_pid = $mytree->getRootid();
     $this->_is_enabled = 1;
     $this->_title = '';
     $this->_imgurl = '';
     $this->_corder = 0;
     $this->_owner_id = $_USER['uid'];
     if (isset($_GROUPS['Downloads Admin'])) {
         $this->_group_id = $_GROUPS['Downloads Admin'];
     } else {
         $this->_group_id = SEC_getFeatureGroup('downloads.edit');
     }
     SEC_setDefaultPermissions($A, $_DLM_CONF['default_permissions']);
     foreach ($A as $key => $val) {
         $this->{'_' . $key} = $val;
     }
 }
Exemple #3
0
/**
* Plugin postinstall
*
* We're inserting our default data here since it depends on other stuff that
* has to happen first ...
*
* @return   boolean     true = proceed with install, false = an error occured
*
*/
function plugin_postinstall_nexproject($pi_name)
{
    global $_DB_dbms, $_CONF, $_DB_table_prefix, $_TABLES;
    require_once $_CONF['path'] . 'plugins/nexproject/nexproject.php';
    // fix nexproject block group ownership
    $blockAdminGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'");
    if ($blockAdminGroup > 0) {
        // set the block's permissions
        $A = array();
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        // ... and make it the last block on the right side
        $result = DB_query("SELECT MAX(blockorder) FROM {$_TABLES['blocks']} WHERE onleft = 0");
        list($order) = DB_fetchArray($result);
        $order += 10;
        DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$blockAdminGroup}, blockorder = {$order}, perm_owner = {$A['perm_owner']}, perm_group = {$A['perm_group']}, perm_members = {$A['perm_members']}, perm_anon = {$A['perm_anon']} WHERE (type = 'phpblock') AND (phpblockfn = 'phpblock_nexproject')");
    }
    $nexfile = true;
    if (!function_exists("fm_createCategory")) {
        //COM_errorLog ('The nexFile plugin is not installed.  Please install it before continuing', 1);
        //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=2&plugin='.$pi_name);
        //exit(0);
        $nexfile = false;
    }
    $forum = true;
    if (!function_exists("forum_addForum")) {
        //COM_errorLog ('The forum plugin is not installed.  Please install it before continuing', 1);
        //echo COM_refresh ($_CONF['site_admin_url'] . '/plugins.php?msg=4&plugin='.$pi_name);
        //exit(0);
        $forum = false;
    }
    //And now, install the lookup lists and add nxprj config values to house the nexlist items
    $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n    values (    'all','nexPro',    'Locations',    'List of locations', 1, 1, 2, 1);";
    $res = DB_query($sql);
    $locID = DB_insertId();
    $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n    values ('all','nexPro','Departments','List of Departments', 1, 1, 2, 1);";
    $res = DB_query($sql);
    $deptID = DB_insertId();
    $sql = "insert into {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n    values ('all','nexPro', 'Categories','List of Categories', 1, 1, 2, 1);";
    $res = DB_query($sql);
    $catID = DB_insertId();
    $sql = "INSERT INTO {$_TABLES['nexlist']} (plugin, category, name, description, listfields, edit_perms, view_perms, active)\r\n    VALUES ('all', 'nexPro', 'Objectives', 'List of Project Objectives', 1, 1, 2, 1);";
    $res = DB_query($sql);
    $objID = DB_insertId();
    /* create lookuplist Fields for list definitions */
    $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$locID}','Location' )";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$deptID}','Department' )";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$catID}','Department' )";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistfields']} (lid, fieldname) values('{$objID}','Objective' )";
    /* create lookuplist list records for each definition */
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 10, 'Toronto',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 20, 'Hong Kong',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 30, 'Brisbane',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 40, 'Tokyo',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 50, 'New York',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 60, 'San Fransisco',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$locID}', 70, 'London',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 10, 'Sales',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 20, 'Information Technology',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 30, 'Marketing',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 40, 'Finance',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 50, 'Operations',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 60, 'Legal',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$deptID}', 70, 'Revenue',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 10, 'Revenue',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 20, 'Safety',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 30, 'Environment',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 40, 'Training',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 50, 'Product Development',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 60, 'Branding',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 70, 'Investment',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) values ('{$catID}', 80, 'Capital Expenditure',1)";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 90, 'Business Growth', 1);";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 100, 'Product Development', 1);";
    $_PRJSQL[] = "insert into {$_TABLES['nexlistitems']} (lid, itemorder, value, active) VALUES ('{$objID}', 110, 'Objective 3', 1);";
    foreach ($_PRJSQL as $sql) {
        DB_query($sql);
        if (DB_error()) {
            $err = 1;
        }
    }
    $c = config::get_instance();
    $c->add('prj_list', NULL, 'fieldset', 0, 1, NULL, 0, true, 'nexproject');
    $c->add('nexlist_locations', $locID, 'text', 0, 1, 0, 150, true, 'nexproject');
    $c->add('nexlist_departments', $deptID, 'text', 0, 1, 0, 160, true, 'nexproject');
    $c->add('nexlist_category', $catID, 'text', 0, 1, 0, 170, true, 'nexproject');
    $c->add('nexlist_objective', $objID, 'text', 0, 1, 0, 180, true, 'nexproject');
    //we are assuming that nexfile and the forum are installed here.  We cannot get this far if they werent!
    //the first thing we do is create a new nexFile category which will be used as the base category ID to dump files into for projects
    if ($nexfile) {
        $arr = fm_createCategory(0, 'nexProject Category', 'This base category is used by the nexProject plugin to create document repositories for each project.', true);
        //config parms for this
        $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject');
        $c->add('nexfile_parent', $arr[0], 'text', 0, 2, 0, 190, true, 'nexproject');
    } else {
        //config parms for this
        $c->add('prj_file', NULL, 'fieldset', 0, 2, NULL, 0, true, 'nexproject');
        $c->add('nexfile_parent', 0, 'text', 0, 2, 0, 190, true, 'nexproject');
    }
    //and now, we create a new forum category and dump that into the config database
    if ($forum) {
        $sql = "INSERT INTO {$_TABLES['gf_categories']} (cat_order,cat_name,cat_dscp) values (0,'nexProject Category','This base category is used by the nexProject plugin to create forum repositories for each project.') ";
        DB_query($sql);
        $catid = DB_insertId();
        $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject');
        $c->add('forum_parent', $catid, 'text', 0, 3, 0, 200, true, 'nexproject');
    } else {
        $c->add('prj_forum', NULL, 'fieldset', 0, 3, NULL, 0, true, 'nexproject');
        $c->add('forum_parent', 0, 'text', 0, 3, 0, 200, true, 'nexproject');
    }
    return true;
}
Exemple #4
0
/**
* Displays the static page editor form
*
* @param    array   $A      Data to display
* @return   string          HTML for the static page editor
*
*/
function staticpageeditor_form($A)
{
    global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SP_CONF, $mode, $sp_id, $LANG21, $LANG_STATIC, $LANG_ACCESS, $LANG_ADMIN, $LANG01, $LANG24, $LANG_postmodes, $MESSAGE, $_IMAGE_TYPE, $_SCRIPTS;
    if (!empty($sp_id) && $mode == 'edit') {
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        if ($mode != 'clone') {
            $A['sp_inblock'] = $_SP_CONF['in_block'];
        }
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Static Page Admin'])) {
            $A['group_id'] = $_GROUPS['Static Page Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('staticpages.edit');
        }
        SEC_setDefaultPermissions($A, $_SP_CONF['default_permissions']);
        $access = 3;
        if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
            $A['advanced_editor_mode'] = 1;
        }
    }
    $retval = '';
    $sp_template = COM_newTemplate(CTL_plugin_templatePath('staticpages', 'admin'));
    if ($_CONF['advanced_editor'] && $_USER['advanced_editor']) {
        $sp_template->set_file('form', 'editor_advanced.thtml');
        // Shouldn't really have to check if anonymous user but who knows...
        if (COM_isAnonUser()) {
            $link_message = "";
        } else {
            $link_message = $LANG01[138];
        }
        $sp_template->set_var('noscript', COM_getNoScript(false, '', $link_message));
        // Setup Advanced Editor
        COM_setupAdvancedEditor('/staticpages/adveditor.js', 'staticpages.edit');
        $sp_template->set_var('lang_expandhelp', $LANG24[67]);
        $sp_template->set_var('lang_reducehelp', $LANG24[68]);
        $sp_template->set_var('lang_toolbar', $LANG24[70]);
        $sp_template->set_var('toolbar1', $LANG24[71]);
        $sp_template->set_var('toolbar2', $LANG24[72]);
        $sp_template->set_var('toolbar3', $LANG24[73]);
        $sp_template->set_var('toolbar4', $LANG24[74]);
        $sp_template->set_var('toolbar5', $LANG24[75]);
        $sp_template->set_var('lang_nojavascript', $LANG24[77]);
        $sp_template->set_var('lang_postmode', $LANG24[4]);
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $sp_template->set_var('show_adveditor', '');
            $sp_template->set_var('show_htmleditor', 'none');
        } else {
            $sp_template->set_var('show_adveditor', 'none');
            $sp_template->set_var('show_htmleditor', '');
        }
        $post_options = '<option value="html" selected="selected">' . $LANG_postmodes['html'] . '</option>';
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>';
        } else {
            $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>';
        }
        $sp_template->set_var('post_options', $post_options);
        $sp_template->set_var('change_editormode', 'onchange="change_editmode(this);"');
    } else {
        $sp_template->set_file('form', 'editor.thtml');
    }
    // Add JavaScript
    if ($_CONF['titletoid']) {
        $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js');
        $sp_template->set_var('titletoid', true);
    }
    $sp_template->set_var('lang_mode', $LANG24[3]);
    $sp_template->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $A['commentcode']));
    $sp_template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $sp_template->set_var('lang_owner', $LANG_ACCESS['owner']);
    $owner_name = COM_getDisplayName($A['owner_id']);
    $owner_username = DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}");
    $sp_template->set_var('owner_id', $A['owner_id']);
    $sp_template->set_var('owner', $owner_name);
    $sp_template->set_var('owner_name', $owner_name);
    $sp_template->set_var('owner_username', $owner_username);
    if ($A['owner_id'] > 1) {
        $profile_link = $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $A['owner_id'];
        $sp_template->set_var('start_owner_anchortag', '<a href="' . $profile_link . '">');
        $sp_template->set_var('end_owner_anchortag', '</a>');
        $sp_template->set_var('owner_link', COM_createLink($owner_name, $profile_link));
        $photo = '';
        if ($_CONF['allow_user_photo']) {
            $photo = DB_getItem($_TABLES['users'], 'photo', "uid = {$A['owner_id']}");
            if (!empty($photo)) {
                $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>';
                $sp_template->set_var('camera_icon', COM_createLink($camera_icon, $profile_link));
            }
        }
        if (empty($photo)) {
            $sp_template->set_var('camera_icon', '');
        }
    } else {
        $sp_template->set_var('start_owner_anchortag', '');
        $sp_template->set_var('end_owner_anchortag', '');
        $sp_template->set_var('owner_link', $owner_name);
    }
    $sp_template->set_var('lang_group', $LANG_ACCESS['group']);
    $sp_template->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $sp_template->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $sp_template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $sp_template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $sp_template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $sp_template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $token = SEC_createToken();
    $start_block = COM_startBlock($LANG_STATIC['staticpageeditor'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $start_block .= SEC_getTokenExpiryNotice($token);
    $sp_template->set_var('start_block_editor', $start_block);
    $sp_template->set_var('lang_save', $LANG_ADMIN['save']);
    $sp_template->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $sp_template->set_var('lang_preview', $LANG_ADMIN['preview']);
    if (SEC_hasRights('staticpages.delete') && $mode != 'clone' && !empty($A['sp_old_id'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $sp_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $sp_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    } else {
        $sp_template->set_var('delete_option', '');
    }
    $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
    $sp_template->set_var('username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $authorname = COM_getDisplayName($A['owner_id']);
    $sp_template->set_var('name', $authorname);
    $sp_template->set_var('author', $authorname);
    $sp_template->set_var('lang_url', $LANG_STATIC['url']);
    $sp_template->set_var('lang_id', $LANG_STATIC['id']);
    $sp_template->set_var('sp_uid', $A['owner_id']);
    $sp_template->set_var('sp_id', $A['sp_id']);
    $sp_template->set_var('sp_old_id', $A['sp_old_id']);
    $sp_template->set_var('example_url', COM_buildURL($_CONF['site_url'] . '/staticpages/index.php?page=' . $A['sp_id']));
    $sp_template->set_var('lang_centerblock', $LANG_STATIC['centerblock']);
    $sp_template->set_var('lang_centerblock_help', $LANG_ADMIN['help_url']);
    $sp_template->set_var('lang_centerblock_include', $LANG21[51]);
    $sp_template->set_var('lang_centerblock_desc', $LANG21[52]);
    $sp_template->set_var('centerblock_help', $A['sp_help']);
    $sp_template->set_var('lang_centerblock_msg', $LANG_STATIC['centerblock_msg']);
    if (isset($A['sp_centerblock']) && $A['sp_centerblock'] == 1) {
        $sp_template->set_var('centerblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('centerblock_checked', '');
    }
    $sp_template->set_var('lang_position', $LANG_STATIC['position']);
    $position = '<select name="sp_where">';
    $position .= '<option value="1"';
    if ($A['sp_where'] == 1) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_top'] . '</option>';
    $position .= '<option value="2"';
    if ($A['sp_where'] == 2) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_feat'] . '</option>';
    $position .= '<option value="3"';
    if ($A['sp_where'] == 3) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_bottom'] . '</option>';
    $position .= '<option value="0"';
    if ($A['sp_where'] == 0) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_entire'] . '</option>';
    $position .= '</select>';
    $sp_template->set_var('pos_selection', $position);
    if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP')) {
        if (!isset($A['sp_php'])) {
            $A['sp_php'] = 0;
        }
        $selection = '<select name="sp_php">' . LB;
        $selection .= '<option value="0"';
        if ($A['sp_php'] <= 0 || $A['sp_php'] > 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_none'] . '</option>' . LB;
        $selection .= '<option value="1"';
        if ($A['sp_php'] == 1) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_return'] . '</option>' . LB;
        $selection .= '<option value="2"';
        if ($A['sp_php'] == 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_free'] . '</option>' . LB;
        $selection .= '</select>';
        $sp_template->set_var('php_selector', $selection);
        $sp_template->set_var('php_warn', $LANG_STATIC['php_warn']);
    } else {
        $sp_template->set_var('php_selector', '');
        $sp_template->set_var('php_warn', $LANG_STATIC['php_not_activated']);
    }
    $sp_template->set_var('php_msg', $LANG_STATIC['php_msg']);
    // old variables (for the 1.3-type checkbox)
    $sp_template->set_var('php_checked', '');
    $sp_template->set_var('php_type', 'hidden');
    if (isset($A['sp_nf']) && $A['sp_nf'] == 1) {
        $sp_template->set_var('exit_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('exit_checked', '');
    }
    $sp_template->set_var('exit_msg', $LANG_STATIC['exit_msg']);
    $sp_template->set_var('exit_info', $LANG_STATIC['exit_info']);
    if ($A['sp_inblock'] == 1) {
        $sp_template->set_var('inblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('inblock_checked', '');
    }
    $sp_template->set_var('inblock_msg', $LANG_STATIC['inblock_msg']);
    $sp_template->set_var('inblock_info', $LANG_STATIC['inblock_info']);
    if ($A['draft_flag'] == 1) {
        $sp_template->set_var('draft_flag_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('draft_flag_checked', '');
    }
    $sp_template->set_var('lang_draft', $LANG_STATIC['draft']);
    $sp_template->set_var('lang_cache_time', $LANG_STATIC['cache_time']);
    $sp_template->set_var('lang_cache_time_desc', $LANG_STATIC['cache_time_desc']);
    $sp_template->set_var('cache_time', $A['cache_time']);
    $curtime = COM_getUserDateTimeFormat($A['unixdate']);
    $sp_template->set_var('lang_lastupdated', $LANG_STATIC['date']);
    $sp_template->set_var('sp_formateddate', $curtime[0]);
    $sp_template->set_var('sp_date', $curtime[1]);
    $sp_template->set_var('lang_title', $LANG_STATIC['title']);
    $sp_template->set_var('lang_page_title', $LANG_STATIC['page_title']);
    $title = '';
    $page_title = '';
    if (isset($A['sp_title'])) {
        $title = htmlspecialchars(stripslashes($A['sp_title']));
    }
    if (isset($A['sp_page_title'])) {
        $page_title = htmlspecialchars(stripslashes($A['sp_page_title']));
    }
    $sp_template->set_var('sp_title', $title);
    $sp_template->set_var('sp_page_title', $page_title);
    $sp_template->set_var('lang_topic', $LANG_STATIC['topic']);
    if ($mode != 'clone') {
        // want to use default topic selection if new staticpage so pass in blank id
        $topic_sp_id = $A['sp_id'];
        if (empty($sp_id) && $mode == 'edit') {
            // means new
            $topic_sp_id = '';
        }
        $sp_template->set_var('topic_selection', TOPIC_getTopicSelectionControl('staticpages', $topic_sp_id, true, false, true));
    } else {
        $sp_template->set_var('topic_selection', TOPIC_getTopicSelectionControl('staticpages', $A['clone_sp_id'], true, false, true));
    }
    $sp_template->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $sp_template->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $sp_template->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $sp_template->set_var('meta_keywords', $A['meta_keywords']);
    }
    if ($_CONF['meta_tags'] > 0 && $_SP_CONF['meta_tags'] > 0) {
        $sp_template->set_var('hide_meta', '');
    } else {
        $sp_template->set_var('hide_meta', ' style="display:none;"');
    }
    if ($A['template_flag'] == 1) {
        $sp_template->set_var('template_flag_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('template_flag_checked', '');
    }
    $sp_template->set_var('lang_template', $LANG_STATIC['template']);
    $sp_template->set_var('lang_template_flag_msg', $LANG_STATIC['template_msg']);
    $template_list = templatelist($A['template_id']);
    $template_none = '<option value=""';
    if ($A['template_id'] == "") {
        $template_none .= ' selected="selected"';
    }
    $template_none .= '>' . $LANG_STATIC['none'] . '</option>';
    $sp_template->set_var('use_template_selection', '<select name="template_id">' . $template_none . $template_list . '</select>');
    $sp_template->set_var('lang_use_template', $LANG_STATIC['use_template']);
    $sp_template->set_var('lang_use_template_msg', $LANG_STATIC['use_template_msg']);
    $sp_template->set_var('lang_addtomenu', $LANG_STATIC['addtomenu']);
    if (isset($A['sp_onmenu']) && $A['sp_onmenu'] == 1) {
        $sp_template->set_var('onmenu_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('onmenu_checked', '');
    }
    $sp_template->set_var('lang_label', $LANG_STATIC['label']);
    if (isset($A['sp_label'])) {
        $sp_template->set_var('sp_label', $A['sp_label']);
    } else {
        $sp_template->set_var('sp_label', '');
    }
    $sp_template->set_var('lang_pageformat', $LANG_STATIC['pageformat']);
    $sp_template->set_var('lang_blankpage', $LANG_STATIC['blankpage']);
    $sp_template->set_var('lang_noblocks', $LANG_STATIC['noblocks']);
    $sp_template->set_var('lang_leftblocks', $LANG_STATIC['leftblocks']);
    $sp_template->set_var('lang_leftrightblocks', $LANG_STATIC['leftrightblocks']);
    if (!isset($A['sp_format'])) {
        $A['sp_format'] = '';
    }
    if ($A['sp_format'] == 'noblocks') {
        $sp_template->set_var('noblock_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('noblock_selected', '');
    }
    if ($A['sp_format'] == 'leftblocks') {
        $sp_template->set_var('leftblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('leftblocks_selected', '');
    }
    if ($A['sp_format'] == 'blankpage') {
        $sp_template->set_var('blankpage_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('blankpage_selected', '');
    }
    if ($A['sp_format'] == 'allblocks' or empty($A['sp_format'])) {
        $sp_template->set_var('allblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('allblocks_selected', '');
    }
    $sp_template->set_var('lang_content', $LANG_STATIC['content']);
    $content = '';
    if (isset($A['sp_content'])) {
        $content = htmlspecialchars(stripslashes($A['sp_content']));
        $content = str_replace(array('{', '}'), array('&#123;', '&#125;'), $content);
    }
    $sp_template->set_var('sp_content', $content);
    $allowed = COM_allowedHTML('staticpages.edit', false, $_SP_CONF['filter_html']) . COM_allowedAutotags();
    $sp_template->set_var('lang_allowedhtml', $allowed);
    $sp_template->set_var('lang_allowed_html', $allowed);
    $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
    if (empty($A['sp_hits'])) {
        $sp_template->set_var('sp_hits', '0');
        $sp_template->set_var('sp_hits_formatted', '0');
    } else {
        $sp_template->set_var('sp_hits', $A['sp_hits']);
        $sp_template->set_var('sp_hits_formatted', COM_numberFormat($A['sp_hits']));
    }
    $sp_template->set_var('lang_comments', $LANG_STATIC['comments']);
    if ($A['commentcode'] == -1) {
        $sp_template->set_var('sp_comments', $LANG_ADMIN['na']);
    } else {
        $num_comments = DB_count($_TABLES['comments'], array('sid', 'type'), array(DB_escapeString($A['sp_id']), 'staticpages'));
        $sp_template->set_var('sp_comments', COM_numberFormat($num_comments));
    }
    $sp_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $sp_template->set_var('gltoken_name', CSRF_TOKEN);
    $sp_template->set_var('gltoken', $token);
    $sp_template->parse('output', 'form');
    $retval .= $sp_template->finish($sp_template->get_var('output'));
    return $retval;
}
Exemple #5
0
/**
* Show topic administration form
*
* @param    string  tid     ID of topic to edit
* @return   string          HTML for the topic editor
*
*/
function edittopic($tid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    $retval = '';
    if (empty($tid)) {
        // new topic - set defaults
        $A = array();
        $A['tid'] = '';
        $A['topic'] = '';
        $A['sortnum'] = 0;
        $A['limitnews'] = '';
        // leave empty!
        $A['is_default'] = 0;
        $A['archive_flag'] = 0;
    } else {
        $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='{$tid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            $retval .= COM_startBlock($LANG27[12], '', COM_getBlockTemplate('_msg_block', 'header'));
            $retval .= $LANG27[13];
            $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}.");
            return $retval;
        }
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    if (!is_array($A) || empty($A['owner_id'])) {
        $A['owner_id'] = $_USER['uid'];
        // this is the one instance where we default the group
        // most topics should belong to the Topic Admin group
        if (isset($_GROUPS['Topic Admin'])) {
            $A['group_id'] = $_GROUPS['Topic Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('topic.edit');
        }
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
        $access = 3;
    }
    $topic_templates = new Template($_CONF['path_layout'] . 'admin/topic');
    $topic_templates->set_file('editor', 'topiceditor.thtml');
    $topic_templates->set_var('xhtml', XHTML);
    $topic_templates->set_var('site_url', $_CONF['site_url']);
    $topic_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $topic_templates->set_var('layout_url', $_CONF['layout_url']);
    if (!empty($tid) && SEC_hasRights('topic.edit')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $topic_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $topic_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $topic_templates->set_var('warning_msg', $LANG27[6]);
    }
    $topic_templates->set_var('lang_topicid', $LANG27[2]);
    $topic_templates->set_var('topic_id', $A['tid']);
    $topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
    $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $topic_templates->set_var('owner_name', $ownername);
    $topic_templates->set_var('owner', $ownername);
    $topic_templates->set_var('owner_id', $A['owner_id']);
    $topic_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $topic_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    // show sort order only if they specified sortnum as the sort method
    if ($_CONF['sortmethod'] != 'alpha') {
        $topic_templates->set_var('lang_sortorder', $LANG27[10]);
        if ($A['sortnum'] == 0) {
            $A['sortnum'] = '';
        }
        $topic_templates->set_var('sort_order', '<input type="text" size="3" maxlength="3" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>');
    } else {
        $topic_templates->set_var('lang_sortorder', $LANG27[14]);
        $topic_templates->set_var('sort_order', $LANG27[15]);
    }
    $topic_templates->set_var('lang_storiesperpage', $LANG27[11]);
    if ($A['limitnews'] == 0) {
        $topic_templates->set_var('story_limit', '');
    } else {
        $topic_templates->set_var('story_limit', $A['limitnews']);
    }
    $topic_templates->set_var('default_limit', $_CONF['limitnews']);
    $topic_templates->set_var('lang_defaultis', $LANG27[16]);
    $topic_templates->set_var('lang_topicname', $LANG27[3]);
    $topic_templates->set_var('topic_name', stripslashes($A['topic']));
    if (empty($A['tid'])) {
        $A['imageurl'] = '/images/topics/';
    }
    $topic_templates->set_var('lang_topicimage', $LANG27[4]);
    $topic_templates->set_var('lang_uploadimage', $LANG27[27]);
    $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']);
    $topic_templates->set_var('lang_maxsize', $LANG27[28]);
    $topic_templates->set_var('max_url_length', 255);
    $topic_templates->set_var('image_url', $A['imageurl']);
    $topic_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $topic_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $topic_templates->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $topic_templates->set_var('meta_keywords', $A['meta_keywords']);
    }
    $topic_templates->set_var('lang_defaulttopic', $LANG27[22]);
    $topic_templates->set_var('lang_defaulttext', $LANG27[23]);
    if ($A['is_default'] == 1) {
        $topic_templates->set_var('default_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('default_checked', '');
    }
    $topic_templates->set_var('lang_archivetopic', $LANG27[25]);
    $topic_templates->set_var('lang_archivetext', $LANG27[26]);
    $topic_templates->set_var('archive_disabled', '');
    if ($A['archive_flag'] == 1) {
        $topic_templates->set_var('archive_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('archive_checked', '');
        // Only 1 topic can be the archive topic - so check if there already is one
        if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) {
            $topic_templates->set_var('archive_disabled', 'disabled');
        }
    }
    if (empty($tid)) {
        $num_stories = $LANG_ADMIN['na'];
    } else {
        $nresult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE tid = '" . addslashes($tid) . "'" . COM_getPermSql('AND'));
        $N = DB_fetchArray($nresult);
        $num_stories = COM_numberFormat($N['count']);
    }
    $topic_templates->set_var('lang_num_stories', $LANG27[30]);
    $topic_templates->set_var('num_stories', $num_stories);
    $topic_templates->set_var('gltoken_name', CSRF_TOKEN);
    $topic_templates->set_var('gltoken', $token);
    $topic_templates->parse('output', 'editor');
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #6
0
/**
* Shows the links editor
*
* @param  string  $mode   Used to see if we are moderating a link or simply editing one
* @param  string  $lid    ID of link to edit
* @global array core config vars
* @global array core group data
* @global array core table data
* @global array core user data
* @global array links plugin config vars
* @global array links plugin lang vars
* @global array core lang access vars
* @return string HTML for the link editor form
*
*/
function editlink($mode, $lid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    $retval = '';
    $link_templates = COM_newTemplate(CTL_plugin_templatePath('links', 'admin'));
    $link_templates->set_file('editor', 'linkeditor.thtml');
    $link_templates->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
    $link_templates->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
    $link_templates->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
    $link_templates->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
    $link_templates->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
    $link_templates->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
    $link_templates->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
    $link_templates->set_var('instructions', $LANG_LINKS_ADMIN[29]);
    if ($mode != 'editsubmission' and !empty($lid)) {
        $result = DB_query("SELECT * FROM {$_TABLES['links']} WHERE lid ='{$lid}'");
        if (DB_numRows($result) !== 1) {
            $msg = COM_showMessageText($LANG_LINKS_ADMIN[25], $LANG_LINKS_ADMIN[24]);
            return $msg;
        }
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            $retval .= COM_showMessageText($LANG_LINKS_ADMIN[17], $LANG_LINKS_ADMIN[16]);
            COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link {$lid}.");
            return $retval;
        }
    } else {
        if ($mode == 'editsubmission') {
            $result = DB_query("SELECT * FROM {$_TABLES['linksubmission']} WHERE lid = '{$lid}'");
            $A = DB_fetchArray($result);
        } else {
            $A['lid'] = COM_makesid();
            $A['cid'] = '';
            $A['url'] = '';
            $A['description'] = '';
            $A['title'] = '';
            $A['owner_id'] = $_USER['uid'];
        }
        $A['hits'] = 0;
        if (isset($_GROUPS['Links Admin'])) {
            $A['group_id'] = $_GROUPS['Links Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('links.edit');
        }
        SEC_setDefaultPermissions($A, $_LI_CONF['default_permissions']);
        $access = 3;
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG_LINKS_ADMIN[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    $link_templates->set_var('link_id', $A['lid']);
    if (!empty($lid) && SEC_hasRights('links.edit')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $link_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $link_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        if ($mode == 'editsubmission') {
            $link_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"' . XHTML . '>');
        }
    }
    $link_templates->set_var('lang_linktitle', $LANG_LINKS_ADMIN[3]);
    $link_templates->set_var('link_title', htmlspecialchars(stripslashes($A['title'])));
    $link_templates->set_var('lang_linkid', $LANG_LINKS_ADMIN[2]);
    $link_templates->set_var('lang_linkurl', $LANG_LINKS_ADMIN[4]);
    $link_templates->set_var('max_url_length', 255);
    $link_templates->set_var('link_url', $A['url']);
    $link_templates->set_var('lang_includehttp', $LANG_LINKS_ADMIN[6]);
    $link_templates->set_var('lang_category', $LANG_LINKS_ADMIN[5]);
    $othercategory = links_select_box(3, $A['cid']);
    $link_templates->set_var('category_options', $othercategory);
    $link_templates->set_var('lang_ifotherspecify', $LANG_LINKS_ADMIN[20]);
    $link_templates->set_var('category', $othercategory);
    $link_templates->set_var('lang_linkhits', $LANG_LINKS_ADMIN[8]);
    $link_templates->set_var('link_hits', $A['hits']);
    $link_templates->set_var('lang_linkdescription', $LANG_LINKS_ADMIN[9]);
    $link_templates->set_var('link_description', stripslashes($A['description']));
    $allowed = COM_allowedHTML('links.edit') . COM_allowedAutotags();
    $link_templates->set_var('lang_allowed_html', $allowed);
    $link_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $link_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    // user access info
    $link_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $link_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $link_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $link_templates->set_var('owner_name', $ownername);
    $link_templates->set_var('owner', $ownername);
    $link_templates->set_var('link_ownerid', $A['owner_id']);
    $link_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $link_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $link_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $link_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $link_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $link_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $link_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $link_templates->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']);
    $link_templates->set_var('gltoken_name', CSRF_TOKEN);
    $link_templates->set_var('gltoken', $token);
    $link_templates->parse('output', 'editor');
    $retval .= $link_templates->finish($link_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #7
0
/**
 * This function creates a map Form
 *
 * Creates a Form for a map using the supplied defaults (if specified).
 *
 * @param array $map array of values describing a map
 * @return string HTML string of map form
 */
function getUserMarkerForm($marker = array())
{
    global $_CONF, $_TABLES, $_MAPS_CONF, $LANG_MAPS_1, $LANG_configselects, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS;
    $display = COM_startBlock('<h1>' . $LANG_MAPS_1['marker_edit'] . ' ' . $marker['name'] . '</h1>');
    $map_options = MAPS_recurseMaps($marker['mid']);
    if ($map_options == '') {
        $display .= COM_startBlock($LANG_MAPS_1['error'], '', 'blockheader-message.thtml');
        $display .= $LANG_MAPS_1['maps_empty'];
        $display .= COM_endBlock('blockfooter-message.thtml');
    } else {
        $template = new Template($_CONF['path'] . 'plugins/maps/templates');
        $template->set_file(array('map' => 'marker_user_form.thtml'));
        $template->set_var('site_url', $_MAPS_CONF['site_url']);
        $template->set_var('xhtml', XHTML);
        $template->set_var('goog_api_key', $_MAPS_CONF['google_api_key']);
        $template->set_var('go', $LANG_MAPS_1['go']);
        $template->set_var('edit_marker_text', $LANG_MAPS_1['edit_marker_text']);
        if (isset($marker['mkid'])) {
            $template->set_var('default_address', $marker['address']);
        } else {
            $template->set_var('default_address', '1600 Amphitheatre Pky, Mountain View, CA');
        }
        $template->set_var('yes', $LANG_MAPS_1['yes']);
        $template->set_var('no', $LANG_MAPS_1['no']);
        $template->set_var('arrow', '<img src="' . $_MAPS_CONF['site_url'] . '/images/arrow.png" alt=""align="absmiddle">&nbsp;');
        //informations
        $template->set_var('informations', $LANG_MAPS_1['informations']);
        $template->set_var('name_label', $LANG_MAPS_1['marker_name_label']);
        $template->set_var('name', stripslashes($marker['name']));
        $template->set_var('address_label', $LANG_MAPS_1['address_label']);
        $template->set_var('address', stripslashes($marker['address']));
        $template->set_var('empty_for_geo', $LANG_MAPS_1['empty_for_geo']);
        $template->set_var('lat', $LANG_MAPS_1['lat']);
        $template->set_var('lat_value', $marker['lat']);
        $template->set_var('lng', $LANG_MAPS_1['lng']);
        $template->set_var('lng_value', $marker['lng']);
        $template->set_var('select_marker_map', $LANG_MAPS_1['select_marker_map']);
        $template->set_var('mid_label', $LANG_MAPS_1['name_label']);
        $template->set_var('mid', $marker['mid']);
        $template->set_var('map_options', $map_options);
        $template->set_var('created_label', $LANG_MAPS_1['marker_created']);
        $template->set_var('modified_label', $LANG_MAPS_1['modified']);
        $datecreated = COM_getUserDateTimeFormat($marker['created']);
        $datemodified = COM_getUserDateTimeFormat($marker['modified']);
        $template->set_var('created', $datecreated[0]);
        $template->set_var('modified', $datemodified[0]);
        $template->set_var('required_field', $LANG_MAPS_1['required_field']);
        //marker
        $template->set_var('marker_customisation', $LANG_MAPS_1['marker_customisation']);
        $template->set_var('mk_default', $LANG_MAPS_1['mk_default']);
        if ($marker['mk_default'] == 0) {
            $template->set_var('mk_default_yes', '');
            $template->set_var('mk_default_no', ' selected');
        } else {
            $template->set_var('mk_default_yes', ' selected');
            $template->set_var('mk_default_no', '');
        }
        //icon
        $sql = "SELECT * FROM {$_TABLES['maps_map_icons']} WHERE 1=1";
        $result = DB_query($sql, 0);
        $radio = '<p>' . $LANG_MAPS_1['choose_icon'] . '</p>';
        $marker['mk_icon'] == 0 ? $checked = ' checked="checked"' : ($checked = '');
        $radio .= '<input type="radio" name="mk_icon" value="0"' . $checked . '>' . $LANG_MAPS_1['no_icon'] . '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
        while ($icon = DB_fetchArray($result, false)) {
            $marker['mk_icon'] == $icon['icon_id'] ? $checked = ' checked="checked"' : ($checked = '');
            $radio .= '<input type="radio" name="mk_icon" value="' . $icon['icon_id'] . '"' . $checked . '> <img src="' . $_MAPS_CONF['images_icons_url'] . $icon['icon_image'] . '" alt="' . $icon['icon_image'] . '">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
        }
        $radio .= '<hr' . XHTML . '>';
        $template->set_var('icon', $radio);
        $template->set_var('primary_color_label', $LANG_MAPS_1['primary_color_label']);
        $template->set_var('primary_color', $marker['mk_pcolor']);
        $template->set_var('stroke_color_label', $LANG_MAPS_1['stroke_color_label']);
        $template->set_var('stroke_color', $marker['mk_scolor']);
        $template->set_var('label_label', $LANG_MAPS_1['label']);
        $template->set_var('label', $marker['mk_label']);
        $template->set_var('label_color_label', $LANG_MAPS_1['label_color']);
        if ($marker['mk_label_color'] == '') {
            $marker['label_color'] = $_MAPS_CONF['label_color'];
        }
        if ($marker['mk_label_color'] == 1) {
            $template->set_var('label_color_white', ' selected');
            $template->set_var('label_color_black', '');
        } else {
            $template->set_var('label_color_white', '');
            $template->set_var('label_color_black', ' selected');
        }
        $template->set_var('black', $LANG_MAPS_1['black']);
        $template->set_var('white', $LANG_MAPS_1['white']);
        //Genaral settings
        $template->set_var('general_settings', $LANG_MAPS_1['general_settings']);
        //payed
        $template->set_var('payed', $LANG_MAPS_1['payed']);
        if ($marker['payed'] == '') {
            $marker['payed'] = $_MAPS_CONF['payed'];
        }
        if ($marker['payed'] == 1) {
            $template->set_var('payed_yes', ' selected');
            $template->set_var('payed_no', '');
        } else {
            $template->set_var('payed_yes', '');
            $template->set_var('payed_no', ' selected');
        }
        //active
        $template->set_var('active', $LANG_MAPS_1['marker_active']);
        if ($marker['active'] == '') {
            $marker['active'] = $_MAPS_CONF['map_active'];
        }
        if ($marker['active'] == 1) {
            $template->set_var('active_yes', ' selected');
            $template->set_var('active_no', '');
        } else {
            $template->set_var('active_yes', '');
            $template->set_var('active_no', ' selected');
        }
        //hidden
        $template->set_var('hidden', $LANG_MAPS_1['marker_hidden']);
        if ($marker['hidden'] == '') {
            $marker['hidden'] = $_MAPS_CONF['map_hidden'];
        }
        if ($marker['hidden'] == 1) {
            $template->set_var('hidden_yes', ' selected');
            $template->set_var('hidden_no', '');
        } else {
            $template->set_var('hidden_yes', '');
            $template->set_var('hidden_no', ' selected');
        }
        //validity
        $template->set_var('validity', $marker['validity']);
        $template->set_var('marker_validity', $LANG_MAPS_1['marker_validity']);
        if ($marker['validity'] == '') {
            $marker['validity'] = $_MAPS_CONF['map_hidden'];
        }
        if ($marker['validity'] == 1) {
            $template->set_var('validity_yes', ' selected');
            $template->set_var('validity_no', '');
            $template->set_var('disabled', '');
        } else {
            $template->set_var('validity_yes', '');
            $template->set_var('validity_no', ' selected');
            $template->set_var('disabled', ' disabled');
        }
        $template->set_var('from_label', $LANG_MAPS_1['from']);
        if ($marker['validity_start'] != '') {
            $datefrom = date("m/d/Y", strtotime($marker['validity_start']));
            $template->set_var('from', $datefrom);
        } else {
            $datefrom = date("m/d/Y");
            $template->set_var('from', $datefrom);
        }
        $template->set_var('to_label', $LANG_MAPS_1['to']);
        if ($marker['validity_end'] != '') {
            $dateto = date("m/d/Y", strtotime($marker['validity_end']));
            $template->set_var('to', $dateto);
        } else {
            $dateto = date("m/d/Y");
            $template->set_var('to', $dateto);
        }
        //note
        $template->set_var('remark_label', $LANG_MAPS_1['remark']);
        $template->set_var('remark', stripslashes($marker['remark']));
        //Tab presentation
        $template->set_var('presentation_tab', $LANG_MAPS_1['presentation_tab']);
        $template->set_var('description_label', $LANG_MAPS_1['description_label']);
        $template->set_var('description', stripslashes($marker['description']));
        $template->set_var('street_label', $LANG_MAPS_1['street_label']);
        if ($_MAPS_CONF['street'] == 1) {
            $template->set_var('street', '<input type="text" name="street" value="' . stripslashes($marker['street']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('street', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('code_label', $LANG_MAPS_1['code_label']);
        if ($_MAPS_CONF['code'] == 1) {
            $template->set_var('code', '<input type="text" name="code" value="' . $marker['code'] . '" size="10" maxlength="10">');
        } else {
            $template->set_var('code', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('city_label', $LANG_MAPS_1['city_label']);
        if ($_MAPS_CONF['city'] == 1) {
            $template->set_var('city', '<input type="text" name="city" value="' . stripslashes($marker['city']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('city', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('state_label', $LANG_MAPS_1['state_label']);
        if ($_MAPS_CONF['state'] == 1) {
            $template->set_var('state', '<input type="text" name="state" value="' . stripslashes($marker['state']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('state', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('country_label', $LANG_MAPS_1['country_label']);
        if ($_MAPS_CONF['country'] == 1) {
            $template->set_var('country', '<input type="text" name="country" value="' . stripslashes($marker['country']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('country', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('tel_label', $LANG_MAPS_1['tel_label']);
        if ($_MAPS_CONF['tel'] == 1) {
            $template->set_var('tel', '<input type="text" name="tel" value="' . $marker['tel'] . '" size="20" maxlength="20">');
        } else {
            $template->set_var('tel', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('fax_label', $LANG_MAPS_1['fax_label']);
        if ($_MAPS_CONF['fax'] == 1) {
            $template->set_var('fax', '<input type="text" name="fax" value="' . $marker['fax'] . '" size="20" maxlength="20">');
        } else {
            $template->set_var('fax', $LANG_MAPS_1['not_use_see_config']);
        }
        $template->set_var('web_label', $LANG_MAPS_1['web_label']);
        if ($_MAPS_CONF['web'] == 1) {
            $template->set_var('web', '<input type="text" name="web" value="' . stripslashes($marker['web']) . '" size="80" maxlength="255">');
        } else {
            $template->set_var('web', $LANG_MAPS_1['not_use_see_config']);
        }
        //Tab ressources
        $template->set_var('ressources_tab', $LANG_MAPS_1['ressources_tab']);
        $template->set_var('max_char', $LANG_MAPS_1['max_char']);
        $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        $ressources = '';
        foreach ($arr as &$value) {
            if ($_MAPS_CONF['item_' . $value] == '') {
                $template->set_var('item_' . $value . '_label', '');
                $template->set_var('item_' . $value, '');
                $ressources .= '';
            } else {
                $template->set_var('item_' . $value . '_label', $_MAPS_CONF['item_' . $value]);
                $template->set_var('item_' . $value, $marker['item_' . $value]);
                $ressources .= '<p>' . $_MAPS_CONF['item_' . $value] . ' <input type"text" name="item_' . $value . '" size="80" maxlength="255" value="' . $marker['item_' . $value] . '"></p>';
            }
        }
        if ($ressources == '') {
            $ressources = $LANG_MAPS_1['empty_ressources'];
        }
        $template->set_var('ressources', $ressources);
        // Permissions
        if ($marker['perm_owner'] == '') {
            SEC_setDefaultPermissions($marker, $_MAPS_CONF['default_permissions']);
        }
        $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
        $template->set_var('lang_owner', $LANG_ACCESS['owner']);
        if ($marker['owner_id'] == '') {
            $marker['owner_id'] = $_USER['uid'];
        }
        $ownername = COM_getDisplayName($marker['owner_id']);
        $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$marker['owner_id']}"));
        $template->set_var('owner_name', $ownername);
        $template->set_var('owner', $ownername);
        $template->set_var('owner_id', $marker['owner_id']);
        if ($marker['group_id'] == '') {
            $marker['group_id'] = $_GROUPS['Maps Admin'];
        }
        $template->set_var('lang_group', $LANG_ACCESS['group']);
        //Todo make group = maps.admin
        $access = 3;
        $template->set_var('group_dropdown', SEC_getGroupDropdown($marker['group_id'], $access));
        $template->set_var('permissions_editor', SEC_getPermissionsHTML($marker['perm_owner'], $marker['perm_group'], $marker['perm_members'], $marker['perm_anon']));
        $template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
        $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
        $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
        $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
        //Form validation
        $template->set_var('submission', $marker['submission']);
        $template->set_var('save_button', $LANG_MAPS_1['save_button']);
        $template->set_var('delete_button', $LANG_MAPS_1['delete_button']);
        $template->set_var('ok_button', $LANG_MAPS_1['ok_button']);
        $template->set_var('mkid', '<input type="hidden" name="mkid" value="' . $marker['mkid'] . '" />');
        $display .= $template->parse('output', 'map');
    }
    $display .= COM_endBlock();
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $_SCRIPTS->setJavaScriptFile('maps_simplecolor', '/' . $_MAPS_CONF['maps_folder'] . '/js/simple-color.js');
    $js = LB . '<script  type="text/javascript" src= "https://maps.googleapis.com/maps/api/js?key=' . $_MAPS_CONF['google_api_key'] . '&sensor=false"> </script>
    <script type="text/javascript">
	jQuery(document).ready(
        function()
        {
            jQuery("#primary_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
            jQuery("#stroke_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
			$( "#from" ).datepicker();
		    $( "#to" ).datepicker();
        });
		
		function changeValidity()
		{
		  if (document.getElementById(\'validity\').value == 0){
			 $("#from").prop(\'disabled\', true);
			 $("#to").prop(\'disabled\', true);

		  }
		  else {
			$("#from").prop(\'disabled\', false);
			$("#to").prop(\'disabled\', false);
		  }
		}

		jQuery(function() {
			jQuery(\'#from\').datepicker({
				altFormat:\'m/d/Y\'
			});
			jQuery(\'#to\').datepicker({
				altFormat:\'m/d/Y\',
			});
		});
		
		
		var geocoder = new google.maps.Geocoder();
		var map;

		function initializeGMap() {
			
			var mapOptions = {
			  center: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
			  zoom: 10,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			
			map = new google.maps.Map(document.getElementById("map_canvas"),
				mapOptions);
				
			var marker = new google.maps.Marker({
			  map: map,
			  position: new google.maps.LatLng(' . $marker['lat'] . ', ' . $marker['lng'] . '),
			  title: "' . $marker['name'] . '",
			  draggable:true,
              animation: google.maps.Animation.DROP,
			});
			
			google.maps.event.addDomListener(marker, "dragend", function(evt) {
				document.getElementById(\'lat\').value = evt.latLng.lat().toFixed(6);
				document.getElementById(\'lng\').value = evt.latLng.lng().toFixed(6);
				//showInfoWindowHtml(marker);
			});
			
		}
		
		google.maps.event.addDomListener(window, \'load\', initializeGMap);
		
		function showInfoWindowHtml (marker) {
		  var latlng= marker.getLatLng();
		  var lat=latlng.lat();
		  var lng=latlng.lng();
		  //marker.openInfoWindowHtml(\'<p>{lat} \' + lat.toString() + \'</p><p>{lng} \' + lng.toString());
		  document.getElementById(\'lat\').value = lat;
		  document.getElementById(\'lng\').value = lng;
		}

		function codeAddress() {
		  var address = document.getElementById(\'geoaddress\').value;
		  geocoder.geocode( { \'address\': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
			  map.setCenter(results[0].geometry.location);
			  var marker = new google.maps.Marker({
				  map: map,
				  position: results[0].geometry.location
			  });
			  document.getElementById(\'lat\').value = results[0].geometry.location.lat(); 
              document.getElementById(\'lng\').value = results[0].geometry.location.lng(); 
			} else {
			  alert(\'Geocode was not successful for the following reason: \' + status);
			}
		  });
		}

		function limitText(limitField, limitCount, limitNum)
		{
			if (limitField.value.length > limitNum) {
				limitField.value = limitField.value.substring(0, limitNum);
			} else {
				limitCount.value = limitNum - limitField.value.length;
			}
		}

		function copyText()
		{
			var t1 = document.getElementById(\'geoaddress\').value;
			document.getElementById(\'address\').value = t1;
		}
		</script>' . LB . LB;
    $_SCRIPTS->setJavaScript($js, false);
    $_SCRIPTS->setJavaScriptFile('ui_core', '/javascript/jquery_ui/jquery.ui.core.min.js');
    $_SCRIPTS->setJavaScriptFile('datepicker', '/javascript/jquery_ui/jquery.ui.datepicker.min.js');
    return $display;
}
Exemple #8
0
function CMED_editMenuitem($mid, $mode = 'edit', $A = array())
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $_PLUGINS, $_CMED_CONF, $LANG_CMED_EDITOR, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    $retval = '';
    if ($mode == 'edit' || $mode == 'clone') {
        if (empty($A)) {
            $result = DB_query("SELECT * FROM {$_TABLES['menuitems']} WHERE mid ='{$mid}'");
            $A = DB_fetchArray($result);
        }
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access < 3 || CMED_hasMenuitemTopicAccess($A['tid']) < 3) {
            $retval .= COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG_CMED_EDITOR['message_access1'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit menuitem {$mid}.");
            return $retval;
        }
        $selpmid = CMED_makeSelBox($A['pmid']);
    }
    if ($mode == 'clone') {
        preg_match('/(.*)_clone_(.+)/', $A['mid'], $match);
        $label = empty($match[1]) ? $A['mid'] : $match[1];
        $A['mid'] = CMED_createMenuitemID($label . '_clone_');
        $A['type'] = 'custom';
        $access = 3;
    }
    if ($mode == 'create') {
        $A['mid'] = CMED_createMenuitemID();
        $A['pmid'] = '';
        $A['is_enabled'] = 1;
        $A['type'] = 'custom';
        $A['mode'] = 'fixation';
        $A['label'] = '';
        $A['label_var'] = '';
        $A['php_function'] = '';
        $A['tid'] = 'all';
        $A['url'] = '';
        $A['icon_url'] = '';
        $A['menuorder'] = 0;
        $A['pattern'] = '';
        $A['is_preg'] = 0;
        $A['class_name'] = '';
        $selpmid = CMED_makeSelBox();
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['CustomMenu Admin'])) {
            $A['group_id'] = $_GROUPS['CustomMenu Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('custommenu.admin');
        }
        SEC_setDefaultPermissions($A, $_CMED_CONF['default_permissions']);
        $access = 3;
    }
    $T = COM_newTemplate($_CMED_CONF['path_layout']);
    $T->set_file('editor', 'menueditor.thtml');
    $T->set_var('icon_url', plugin_geticon_custommenu());
    $retval .= COM_startBlock($LANG_CMED_EDITOR['custommenueditor'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $v = $mode == 'create' || $mode == 'clone' || $A['type'] == 'gldefault' || $A['type'] == 'plugin' && in_array($A['mid'], $_PLUGINS) ? UC_DISABLED : '';
    $T->set_var('delete_disabled', $v);
    foreach ($LANG_CMED_EDITOR as $key => $val) {
        $T->set_var('lang_' . $key, $val);
    }
    $v = ($mode == 'create' or $mode == 'clone') ? 'save' : 'update';
    $T->set_var('lang_save', $LANG_CMED_EDITOR[$v]);
    $T->set_var('val_title_fixation', stripslashes($A['label']));
    $T->set_var('val_title_variable', stripslashes($A['label_var']));
    $T->set_var('val_php_function', stripslashes($A['php_function']));
    $T->set_var('val_is_enabled', $A['is_enabled'] == 1 ? UC_CHECKED : '');
    $T->set_var('val_menuitemurl', $A['url']);
    $T->set_var('val_icon_url', $A['icon_url']);
    $T->set_var('val_mid', $A['mid']);
    $T->set_var('val_pmid', $A['pmid']);
    $T->set_var('selpmid', $selpmid);
    $T->set_var('val_old_mid', $A['mid']);
    $T->set_var('val_menuorder', $A['menuorder']);
    $T->set_var('val_type', $A['type']);
    $T->set_var('val_pattern', stripslashes($A['pattern']));
    $T->set_var('val_is_preg', $A['is_preg'] == 1 ? UC_CHECKED : '');
    $T->set_var('val_class_name', stripslashes($A['class_name']));
    $v = $A['type'] == 'gldefault' || $A['type'] == 'plugin' ? UC_READONLY : '';
    $T->set_var('mid_readonly', $v);
    $T->set_var($A['tid'] . '_selected', UC_SELECTED);
    $T->set_var('topic_options', COM_topicList('tid,topic', $A['tid'], 1, true));
    $T->set_var('lang_type', $LANG_CMED_EDITOR['type_' . $A['type']]);
    $T->set_var($A['type'] . '_selected', UC_SELECTED);
    $T->set_var('val_mode_' . $A['mode'], UC_SELECTED);
    // user access info
    $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $T->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $T->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $T->set_var('owner_name', $ownername);
    $T->set_var('owner', $ownername);
    $T->set_var('owner_id', $A['owner_id']);
    $T->set_var('lang_group', $LANG_ACCESS['group']);
    $T->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $T->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $T->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $T->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $T->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']);
    if (!defined(CSRF_TOKEN)) {
        define('CSRF_TOKEN', 'token');
    }
    $T->set_var('gltoken_name', CSRF_TOKEN);
    $T->set_var('gltoken', SEC_createToken());
    $T->parse('output', 'editor');
    $retval .= $T->finish($T->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #9
0
 /**
  * Load a Story object from the sid specified, returning a status result.
  * The result will either be a permission denied message, invalid SID
  * message, or a loaded ok message. If it's loaded ok, then we've got all
  * the exciting gubbins here.
  *
  * Only used from story admin and submit.php!
  *
  * @param $sid  string  Story Identifier, valid glFusion story id from the db.
  * @return Integer from a constant.
  */
 function loadFromDatabase($sid, $mode = 'edit')
 {
     global $_TABLES, $_CONF, $_USER, $_GROUPS;
     $dtPublish = new Date('now', $_USER['tzid']);
     $dtExpire = new Date('now', $_USER['tzid']);
     $dtCmtclose = new Date('now', $_USER['tzid']);
     $sid = DB_escapeString(COM_applyFilter($sid));
     if (!empty($sid) && ($mode == 'edit' || $mode == 'view' || $mode == 'clone')) {
         $sql = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, UNIX_TIMESTAMP(s.comment_expire) as cmt_expire_unix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '{$sid}')";
     } elseif (!empty($sid) && $mode == 'moderate') {
         $sql = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, ' . 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
     } elseif ($mode == 'edit') {
         $this->_sid = COM_makesid();
         $this->_old_sid = $this->_sid;
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 0;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         if (COM_isAnonUser()) {
             $this->_uid = 1;
         } else {
             $this->_uid = $_USER['uid'];
         }
         $this->_date = $dtPublish->toUnix();
         $this->_expire = $dtExpire->toUnix();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = $dtCmtclose->toUnix() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_title = '';
         $this->_introtext = '';
         $this->_bodytext = '';
         if (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_hits = 0;
         $this->_rating = 0.0;
         $this->_votes = 0;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         if ($_CONF['postmode'] != 'plaintext') {
             $this->_postmode = 'html';
         } else {
             $this->_postmode = $_CONF['postmode'];
         }
         $this->_statuscode = 0;
         $this->_featured = 0;
         if (COM_isAnonUser()) {
             $this->_owner_id = 1;
         } else {
             $this->_owner_id = $_USER['uid'];
         }
         if (isset($_GROUPS['Story Admin'])) {
             $this->_group_id = $_GROUPS['Story Admin'];
         } else {
             $this->_group_id = SEC_getFeatureGroup('story.edit');
         }
         $array = array();
         SEC_setDefaultPermissions($array, $_CONF['default_permissions_story']);
         $this->_perm_owner = $array['perm_owner'];
         $this->_perm_group = $array['perm_group'];
         $this->_perm_anon = $array['perm_anon'];
         $this->_perm_members = $array['perm_members'];
     } else {
         $this->loadFromArgsArray($_POST);
     }
     /* if we have SQL, load from it */
     if (!empty($sql)) {
         $result = DB_query($sql);
         if ($result) {
             $story = DB_fetchArray($result, false);
             if ($story == null) {
                 return STORY_INVALID_SID;
             }
             $this->loadFromArray($story);
             if (!isset($story['owner_id'])) {
                 $story['owner_id'] = 1;
             }
             if (SEC_hasRights('story.edit')) {
                 $this->_access = 3;
             } else {
                 $access = SEC_hasAccess($story['owner_id'], $story['group_id'], $story['perm_owner'], $story['perm_group'], $story['perm_members'], $story['perm_anon']);
                 $this->_access = min($access, SEC_hasTopicAccess($this->_tid));
             }
             if ($this->_access == 0) {
                 return STORY_PERMISSION_DENIED;
             } elseif ($this->_access == 2 && $mode != 'view') {
                 return STORY_EDIT_DENIED;
             } elseif ($this->_access == 2 && $mode == 'view' && ($this->_draft_flag == 1 || $this->_date > time())) {
                 return STORY_INVALID_SID;
             }
         } else {
             return STORY_INVALID_SID;
         }
     }
     if ($mode == 'moderate') {
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 1;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_featured = 0;
         $this->_expire = time();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '" . DB_escapeString($this->_tid) . "'") == 1) {
             $this->_frontpage = 0;
         } elseif (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         $this->_statuscode = 0;
         $this->_owner_id = $this->_uid;
     } elseif ($mode == 'clone') {
         $this->_sid = COM_makesid();
         $this->_old_sid = $this->_sid;
         $this->_originalSid = '';
         if (COM_isAnonUser()) {
             $this->_uid = 1;
         } else {
             $this->_uid = $_USER['uid'];
         }
         $this->_date = $dtPublish->toUnix();
         $this->_expire = $dtExpire->toUnix();
         //time();
         // if the original story uses comment expire, update the time
         if ($this->_comment_expire != 0) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         }
         // reset counters
         $this->_hits = 0;
         $this->_rating = 0.0;
         $this->_votes = 0;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         $this->_owner_id = $_USER['uid'];
     }
     $this->_sanitizeData();
     return STORY_LOADED_OK;
 }
Exemple #10
0
/**
* Shows the block editor
*
* This will show a block edit form.  If this is a Geeklog default block it will
* send it off to editdefaultblock.
*
* @param    string  $bid    ID of block to edit
* @return   string          HTML for block editor
*
*/
function editblock($bid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG01, $LANG21, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    $retval = '';
    if (!empty($bid)) {
        $sql['mysql'] = "SELECT * FROM {$_TABLES['blocks']} WHERE bid ='{$bid}'";
        $sql['mssql'] = "SELECT bid, is_enabled, name, type, title, tid, blockorder, cast(content as text) as content, rdfurl, ";
        $sql['mssql'] .= "rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id,group_id, ";
        $sql['mssql'] .= "perm_owner, perm_group, perm_members, perm_anon, allow_autotags FROM {$_TABLES['blocks']} WHERE bid ='{$bid}'";
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 2 || $access == 0 || hasBlockTopicAccess($A['tid']) < 3) {
            $retval .= COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG21[45] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit block {$bid}.");
            return $retval;
        }
        if ($A['type'] == 'gldefault') {
            $retval .= editdefaultblock($A, $access);
            return $retval;
        }
    } else {
        $A['bid'] = 0;
        $A['is_enabled'] = 1;
        $A['name'] = '';
        $A['type'] = 'normal';
        $A['title'] = '';
        $A['tid'] = 'All';
        $A['blockorder'] = 0;
        $A['content'] = '';
        $A['allow_autotags'] = 0;
        $A['rdfurl'] = '';
        $A['rdfupdated'] = '';
        $A['rdflimit'] = 0;
        $A['onleft'] = 0;
        $A['phpblockfn'] = '';
        $A['help'] = '';
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Block Admin'])) {
            $A['group_id'] = $_GROUPS['Block Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('block.edit');
        }
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        $access = 3;
    }
    $token = SEC_createToken();
    $block_templates = new Template($_CONF['path_layout'] . 'admin/block');
    $block_templates->set_file('editor', 'blockeditor.thtml');
    $block_templates->set_var('site_url', $_CONF['site_url']);
    $block_templates->set_var('xhtml', XHTML);
    $block_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $block_templates->set_var('layout_url', $_CONF['layout_url']);
    $block_start = COM_startBlock($LANG21[3], '', COM_getBlockTemplate('_admin_block', 'header'));
    $block_start .= LB . SEC_getTokenExpiryNotice($token);
    $block_templates->set_var('start_block_editor', $block_start);
    if (!empty($bid) && SEC_hasrights('block.delete')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $block_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $block_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    }
    $block_templates->set_var('block_bid', $A['bid']);
    // standard Admin strings
    $block_templates->set_var('lang_blocktitle', $LANG_ADMIN['title']);
    $block_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']);
    $block_templates->set_var('lang_blockhelpurl', $LANG_ADMIN['help_url']);
    $block_templates->set_var('lang_topic', $LANG_ADMIN['topic']);
    $block_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $block_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $block_templates->set_var('lang_blocktype', $LANG_ADMIN['type']);
    $block_templates->set_var('lang_allowed_html', $LANG01[123]);
    $block_templates->set_var('block_title', stripslashes($A['title']));
    $block_templates->set_var('lang_enabled', $LANG21[53]);
    if ($A['is_enabled'] == 1) {
        $block_templates->set_var('is_enabled', 'checked="checked"');
    } else {
        $block_templates->set_var('is_enabled', '');
    }
    $block_templates->set_var('block_help', $A['help']);
    $block_templates->set_var('lang_includehttp', $LANG21[51]);
    $block_templates->set_var('lang_explanation', $LANG21[52]);
    $block_templates->set_var('block_name', $A['name']);
    $block_templates->set_var('lang_blockname', $LANG21[48]);
    $block_templates->set_var('lang_nospaces', $LANG21[49]);
    $block_templates->set_var('lang_all', $LANG21[7]);
    $block_templates->set_var('lang_homeonly', $LANG21[43]);
    if ($A['tid'] == 'all') {
        $block_templates->set_var('all_selected', 'selected="selected"');
    } else {
        if ($A['tid'] == 'homeonly') {
            $block_templates->set_var('homeonly_selected', 'selected="selected"');
        }
    }
    $block_templates->set_var('topic_options', COM_topicList('tid,topic', $A['tid'], 1, true));
    $block_templates->set_var('lang_side', $LANG21[39]);
    $block_templates->set_var('lang_left', $LANG21[40]);
    $block_templates->set_var('lang_right', $LANG21[41]);
    if ($A['onleft'] == 1) {
        $block_templates->set_var('left_selected', 'selected="selected"');
    } else {
        if ($A['onleft'] == 0) {
            $block_templates->set_var('right_selected', 'selected="selected"');
        }
    }
    $block_templates->set_var('lang_blockorder', $LANG21[9]);
    $block_templates->set_var('block_order', $A['blockorder']);
    $block_templates->set_var('lang_normalblock', $LANG21[12]);
    $block_templates->set_var('lang_phpblock', $LANG21[27]);
    $block_templates->set_var('lang_portalblock', $LANG21[11]);
    if ($A['type'] == 'normal') {
        $block_templates->set_var('normal_selected', 'selected="selected"');
    } else {
        if ($A['type'] == 'phpblock') {
            $block_templates->set_var('php_selected', 'selected="selected"');
        } else {
            if ($A['type'] == 'portal') {
                $block_templates->set_var('portal_selected', 'selected="selected"');
            }
        }
    }
    $block_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $block_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $block_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = '{$A['owner_id']}'"));
    $block_templates->set_var('owner_name', $ownername);
    $block_templates->set_var('owner', $ownername);
    $block_templates->set_var('owner_id', $A['owner_id']);
    $block_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $block_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $block_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $block_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $block_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $block_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $block_templates->set_var('lang_phpblockoptions', $LANG21[28]);
    $block_templates->set_var('lang_blockfunction', $LANG21[29]);
    $block_templates->set_var('block_phpblockfn', $A['phpblockfn']);
    $block_templates->set_var('lang_phpblockwarning', $LANG21[30]);
    $block_templates->set_var('lang_portalblockoptions', $LANG21[13]);
    $block_templates->set_var('lang_rdfurl', $LANG21[14]);
    $block_templates->set_var('max_url_length', 255);
    $block_templates->set_var('block_rdfurl', $A['rdfurl']);
    $block_templates->set_var('lang_rdflimit', $LANG21[62]);
    $block_templates->set_var('block_rdflimit', $A['rdflimit']);
    $block_templates->set_var('lang_lastrdfupdate', $LANG21[15]);
    if ($A['rdfupdated'] == '0000-00-00 00:00:00') {
        $block_templates->set_var('block_rdfupdated', '');
    } else {
        $block_templates->set_var('block_rdfupdated', $A['rdfupdated']);
    }
    $block_templates->set_var('lang_normalblockoptions', $LANG21[16]);
    $block_templates->set_var('lang_blockcontent', $LANG21[17]);
    $block_templates->set_var('lang_autotags', $LANG21[66]);
    $block_templates->set_var('lang_use_autotags', $LANG21[67]);
    $block_templates->set_var('block_content', htmlspecialchars(stripslashes($A['content'])));
    if ($A['allow_autotags'] == 1) {
        $block_templates->set_var('allow_autotags', 'checked="checked"');
    } else {
        $block_templates->set_var('allow_autotags', '');
    }
    $block_templates->set_var('gltoken_name', CSRF_TOKEN);
    $block_templates->set_var('gltoken', $token);
    $block_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $block_templates->parse('output', 'editor');
    $retval .= $block_templates->finish($block_templates->get_var('output'));
    return $retval;
}
/**
 * This function creates a product Form
 *
 * Creates a Form for a product using the supplied defaults (if specified).
 *
 * @param array $product array of values describing a proudct
 * @return string HTML string of product form
 */
function PAYPAL_getProductForm($product = array(), $type = 'product')
{
    global $_CONF, $_PAY_CONF, $LANG_PAYPAL_1, $LANG_PAYPAL_ADMIN, $LANG_PAYPAL_PRO, $_TABLES, $LANG24, $LANG_ADMIN, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS;
    //PHP 5.4 set all $product[key]
    PAYPAL_setAllKeys($product, array('type', 'name', 'id', 'category', 'cat_id', 'short_description', 'description', 'item_id', 'price', 'price_ref', 'discount_a', 'discount_p', 'logged', 'hidden', 'active', 'show_in_blocks', 'customisable', 'product_type', 'file', 'weight', 'shipping_type', 'expiration', 'duration', 'duration_type', 'duration_recurrent', 'duration_type_recurrent', 'add_to_group', 'add_to_group_recurrent', 'perm_owner', 'owner_id', 'group_id', 'perm_group', 'perm_members', 'perm_anon'));
    //Validate product type
    if ($_REQUEST['type'] == '' && $product['type'] == '') {
        $type = 'product';
    }
    foreach ($_PAY_CONF['types'] as $item => $value) {
        $types[$item] = $item;
    }
    if (!in_array($type, $types)) {
        return $LANG_PAYPAL_1['wrong_type'];
    }
    //Display form
    $product['name'] == '' ? $display = COM_startBlock($LANG_PAYPAL_1['create_new_product']) : ($display = COM_startBlock($LANG_PAYPAL_1['edit_label'] . ' ' . $product['name']));
    $template = new Template($_CONF['path'] . 'plugins/paypal/templates');
    $template->set_file(array('product' => 'product_form.thtml'));
    $template->set_var('site_url', $_CONF['site_url']);
    $template->set_var('xhtml', XHTML);
    if ($_CONF['advanced_editor'] == 1) {
        $_SCRIPTS->setJavaScriptLibrary('jquery');
        $_SCRIPTS->setJavaScriptFile('ckeditor', '/editors/ckeditor/ckeditor.js');
        $ckeditor = '        var geeklogEditorName = "ckeditor";
        var geeklogAllowedHtml = [];
        jQuery(function() {
            CKEDITOR.replace( \'description\', {
             customConfig: \'' . $_CONF['site_url'] . '/editors/ckeditor/config.js\',
             toolbar: \'toolbar0\',
             height:500
            });
        });';
        $_SCRIPTS->setJavaScript($ckeditor, true);
    } else {
        $template->set_var('adveditor', '');
    }
    $product['product_type'] == '' ? $prod_type_ini = 2 : ($prod_type_ini = $product['product_type']);
    $js = 'jQuery(function () {
        var tabContainers = jQuery(\'div.tabs > div\');
        
        jQuery(\'div.tabs ul.tabNavigation a\').click(function () {
            tabContainers.hide().filter(this.hash).show();
            
            jQuery(\'div.tabs ul.tabNavigation a\').removeClass(\'selected\');
            jQuery(this).addClass(\'selected\');
            
            return false;
        }).filter(\':first\').click();
		
    });' . LB;
    $js .= "jQuery(document).ready(function() {\n\t\tjQuery('#load').hide();\n\t\t});\n\n\t\tjQuery(function() {\n\t\t\tjQuery(\".delete\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar pid = jQuery(this).attr(\"pid\");\n\t\t\t\tvar aid = jQuery(this).attr(\"aid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&pid=' + pid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#attributes_actions\").replaceWith(result);\n\t\t\t\t\t}   \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t\tjQuery(\".add\").click(function() {\n\t\t\t\tjQuery('#load').show();\n\t\t\t\tvar id = jQuery(this).attr(\"id\");\n\t\t\t\tvar pid = jQuery(this).attr(\"pid\");\n\t\t\t\tvar aid = jQuery(this).attr(\"aid\");\n\t\t\t\tvar action = jQuery(this).attr(\"class\");\n\t\t\t\tvar string = 'id='+ id + '&action=' + action + '&pid=' + pid;\n\t\t\t\t\t\n\t\t\t\tjQuery.ajax({\n\t\t\t\t\ttype: \"POST\",\n\t\t\t\t\turl: \"ajax.php\",\n\t\t\t\t\tdata: string,\n\t\t\t\t\tcache: false,\n\t\t\t\t\tasync:false,\n\t\t\t\t\tsuccess: function(result){\n\t\t\t\t\t\tjQuery(\"#attributes_actions\").replaceWith(result);\n\t\t\t\t\t}   \n\t\t\t\t});\n\t\t\t\tjQuery('#load').hide();\n\t\t\t\treturn false;\n\t\t\t});\n\t\t});\n\t" . LB;
    //Hide #attributes if product not customisable
    if ($product['customisable'] == '0' || $product['customisable'] == '') {
        $js .= LB . "jQuery(document).ready(function() {\n\t\t    jQuery('#attributes_actions').hide();\n\t\t});" . LB;
    }
    if ($prod_type_ini == 2) {
        $js .= LB . "jQuery(document).ready(function() {\n\t\t    jQuery('#type_download').hide();\n\t\t});" . LB;
    }
    $js .= "\n\tfunction PP_changeCustomisable(value)\n\t{\n\t  switch(value) {\n\t  case '0':\n\t\tdocument.getElementById('attributes_actions').style.display = 'none';\n\t\tbreak;\n\t  case '1':\n\t\tdocument.getElementById('attributes_actions').style.display = '';\n\t\tbreak;\n\t  }\n\t}\n\n\t" . LB;
    $js .= "\n\tfunction PP_changeProdType(value)\n\t{\n\t  switch(value) {\n\t  case '0':\n\t\tdocument.getElementById('type_download').style.display = 'none';\n\t\tdocument.getElementById('type_physical').style.display = '';\n\t\tbreak;\n\t  case '1':\n\t\tdocument.getElementById('type_download').style.display = '';\n\t\tdocument.getElementById('type_physical').style.display = 'none';\n\t\tbreak;\n\t  case '2':\n\t\tdocument.getElementById('type_download').style.display = 'none';\n\t\tdocument.getElementById('type_physical').style.display = 'none';\n\t\tbreak;\n\t  }\n\t}\n\n\t" . LB;
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $_SCRIPTS->setJavaScript($js, true);
    //Product type
    if ($product['type'] != '') {
        $template->set_var('product_type', '<input type="hidden" name="type" value="' . $product['type'] . '" />');
    } else {
        $template->set_var('product_type', '<input type="hidden" name="type" value="' . $type . '" />');
    }
    //Product infos
    $template->set_var('informations', $LANG_PAYPAL_1['product_informations']);
    if ($_REQUEST['type'] == 'subscription' || $product['type'] == 'subscription') {
        $template->set_var('informations', $LANG_PAYPAL_1['membership_informations']);
    }
    $template->set_var('name_label', $LANG_PAYPAL_1['name_label']);
    $template->set_var('category_label', $LANG_PAYPAL_1['category_label']);
    $template->set_var('currency', $_PAY_CONF['currency']);
    if (is_numeric($product['id'])) {
        $template->set_var('id', '<input type="hidden" name="id" value="' . $product['id'] . '" />');
    } else {
        $template->set_var('id', '');
    }
    $template->set_var('name', $product['name']);
    //catogory
    $template->set_var('category', $product['category']);
    //categorie
    $categories = '';
    $categories .= '<option value="0">' . $LANG_PAYPAL_ADMIN['choose_category'] . '</option>';
    $categories .= PAYPAL_adOptionList($_TABLES['paypal_categories'], 'cat_id,cat_name', $product['cat_id'], 'cat_name', 'enabled=1');
    $template->set_var('categories', $categories);
    //Descriptions
    $template->set_var('short_description_label', $LANG_PAYPAL_1['short_description_label']);
    $template->set_var('short_description', strip_tags($product['short_description']));
    $template->set_var('description_label', $LANG_PAYPAL_1['description_label']);
    $template->set_var('description', $product['description']);
    //item_id
    $template->set_var('item_id_label', $LANG_PAYPAL_1['item_id_label']);
    $template->set_var('item_id', $product['item_id']);
    //Price
    $template->set_var('price_label', $LANG_PAYPAL_1['price_label']);
    if (empty($product['price']) || !is_numeric($product['price'])) {
        $template->set_var('price', 0);
    } else {
        $template->set_var('price', number_format($product['price'], $_CONF['decimal_count']));
    }
    $template->set_var('price_edit', $LANG_PAYPAL_1['price_edit']);
    //Price_ref
    $template->set_var('price_ref_label', $LANG_PAYPAL_1['price_ref_label']);
    if (empty($product['price_ref'])) {
        $template->set_var('price_ref', 0);
    } else {
        $template->set_var('price_ref', number_format($product['price_ref'], $_CONF['decimal_count']));
    }
    $template->set_var('price_ref_edit', $LANG_PAYPAL_1['price_ref_edit']);
    //Discount
    $template->set_var('discount_legend', $LANG_PAYPAL_1['discount_legend']);
    $template->set_var('discount_label', $LANG_PAYPAL_1['discount_label']);
    $template->set_var('discount_a_label', $LANG_PAYPAL_1['discount_a_label']);
    $template->set_var('discount_p_label', $LANG_PAYPAL_1['discount_p_label']);
    if (empty($product['discount_a'])) {
        $template->set_var('discount_a', 0);
    } else {
        $template->set_var('discount_a', number_format($product['discount_a'], $_CONF['decimal_count']));
    }
    if (empty($product['discount_p'])) {
        $template->set_var('discount_p', 0);
    } else {
        $template->set_var('discount_p', number_format($product['discount_p'], $_CONF['decimal_count']));
    }
    //access & display
    $template->set_var('access_display', $LANG_PAYPAL_1['access_display']);
    //logged
    $template->set_var('logged_to_purchase', $LANG_PAYPAL_1['logged_to_purchase']);
    if ($type == 'subscription' || $product['type'] == 'subscription') {
        $template->set_var('logged_yes', ' selected');
        $template->set_var('logged_no', ' disabled="disabled"');
    } else {
        if ($product['logged'] == 1) {
            $template->set_var('logged_yes', ' selected');
            $template->set_var('logged_no', '');
        } else {
            $template->set_var('logged_yes', '');
            $template->set_var('logged_no', ' selected');
        }
    }
    //hidden
    $template->set_var('hidden', $LANG_PAYPAL_1['hidden_product']);
    if ($product['hidden'] == 1) {
        $template->set_var('hidden_yes', ' selected');
        $template->set_var('hidden_no', '');
    } else {
        $template->set_var('hidden_yes', '');
        $template->set_var('hidden_no', ' selected');
    }
    //active
    $template->set_var('active', $LANG_PAYPAL_1['active_product']);
    !isset($product['active']) ? $product['active'] = 1 : NULL;
    if ($product['active'] == 1) {
        $template->set_var('active_yes', ' selected');
        $template->set_var('active_no', '');
    } else {
        $template->set_var('active_yes', '');
        $template->set_var('active_no', ' selected');
    }
    //Show in blocks
    $template->set_var('show_in_blocks', $LANG_PAYPAL_1['show_in_blocks']);
    !isset($product['show_in_blocks']) ? $product['show_in_blocks'] = 1 : NULL;
    if ($product['show_in_blocks'] == 1) {
        $template->set_var('show_in_blocks_yes', ' selected');
        $template->set_var('show_in_blocks_no', '');
    } else {
        $template->set_var('show_in_blocks_yes', '');
        $template->set_var('show_in_blocks_no', ' selected');
    }
    //customisable
    $template->set_var('customisation', $LANG_PAYPAL_ADMIN['customisation']);
    $template->set_var('customisable', $LANG_PAYPAL_ADMIN['customisable']);
    if (isset($product['customisable']) && $product['customisable'] == 1) {
        $template->set_var('customisable_yes', ' selected');
        $template->set_var('customisable_no', '');
    } else {
        $template->set_var('customisable_yes', '');
        $template->set_var('customisable_no', ' selected');
    }
    if (function_exists('PAYPALPRO_displayAttributes') && $product['id'] != '') {
        $template->set_var('attributes', PAYPALPRO_displayAttributes($product['id']));
        $template->set_var('add_attributes', PAYPALPRO_displayAttributesToAdd($product['id']));
    } else {
        if (function_exists('PAYPALPRO_displayAttributes')) {
            $template->set_var('attributes', '');
            $template->set_var('add_attributes', $LANG_PAYPAL_PRO['add_attributes']);
        } else {
            $template->set_var('attributes', '<p>' . $LANG_PAYPAL_PRO['pro_feature'] . '</p>');
            $template->set_var('add_attributes', '');
        }
    }
    //images
    $template->set_var('lang_images', $LANG_PAYPAL_1['product_images']);
    $fileinputs = '';
    $saved_images = '';
    if ($_PAY_CONF['max_images_per_products'] > 0) {
        if ($product['id'] != '') {
            $icount = DB_count($_TABLES['paypal_images'], 'pi_pid', $product['id']);
            if ($icount > 0) {
                $result_products = DB_query("SELECT * FROM {$_TABLES['paypal_images']} WHERE pi_pid = '" . $product['id'] . "'");
                for ($z = 1; $z <= $icount; $z++) {
                    $I = DB_fetchArray($result_products);
                    $saved_images .= '<div><p>' . $z . ') ' . '<a class="lightbox" href="' . $_PAY_CONF['images_url'] . $I['pi_filename'] . '"><img align="top" class="lightbox" src="' . $_PAY_CONF['site_url'] . '/timthumb.php?src=' . $_PAY_CONF['images_url'] . $I['pi_filename'] . '&amp;w=75&amp;h=75&amp;zc=1&amp;q=100" alt="' . $I['pi_filename'] . '" /></a>' . '&nbsp;&nbsp;&nbsp;' . $LANG_ADMIN['delete'] . ': <input type="checkbox" name="delete[' . $I['pi_img_num'] . ']"' . XHTML . '><br' . XHTML . '></p></div>';
                }
            }
        }
        $newallowed = $_PAY_CONF['max_images_per_products'] - $icount;
        for ($z = $icount + 1; $z <= $_PAY_CONF['max_images_per_products']; $z++) {
            $fileinputs .= $z . ') <input type="file" dir="ltr" name="file' . $z . '"' . XHTML . '> ';
            if ($z < $_PAY_CONF['max_images_per_products']) {
                $fileinputs .= '<br' . XHTML . '>';
            }
        }
    }
    $template->set_var('saved_images', $saved_images);
    $template->set_var('image_form_elements', $fileinputs);
    //delivery info
    $type != 'product' ? $template->set_var('display_product', 'display:none;') : $template->set_var('display_product', '');
    $template->set_var('delivery_info_label', $LANG_PAYPAL_ADMIN['delivery_info_label']);
    $template->set_var('prod_type', $LANG_PAYPAL_ADMIN['prod_type']);
    $template->set_var('prod_type_ini', $product['product_type']);
    $template->set_var('customisable_ini', $product['customisable']);
    $template->set_block('product', 'ProdTypeRadio', 'ProdType');
    foreach ($LANG_PAYPAL_ADMIN['prod_types'] as $value => $text) {
        $template->set_var(array('type_val' => $value, 'type_txt' => $text, 'type_sel' => $product['product_type'] == $value ? 'checked="checked"' : ''));
        $template->parse('ProdType', 'ProdTypeRadio', true);
    }
    //files
    $template->set_var('filename_label', $LANG_PAYPAL_1['filename_label']);
    $files = '';
    $files_folder = @opendir($_PAY_CONF['download_path']);
    if (!$files_folder) {
        $template->set_var('select_file', $LANG_PAYPAL_1['no_download_folder']);
        $template->set_var('file_selection', '');
    } else {
        while ($file = readdir($files_folder)) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $sel = $file == $product['file'] ? ' selected="selected" ' : '';
            $files .= "<option value=\"{$file}\" {$sel}>{$file}</option>\n";
        }
        closedir($files_folder);
        $template->set_var('select_file', $LANG_PAYPAL_1['select_file']);
        $template->set_var('file_selection', $files);
    }
    $template->set_var('upload_new', $LANG_PAYPAL_1['upload_new']);
    $template->set_var('expiration_label', $LANG_PAYPAL_1['expiration_label']);
    //weight
    $template->set_var('weight_label', $LANG_PAYPAL_ADMIN['weight']);
    if ($product['weight'] == '') {
        $product['weight'] = '0.000';
    }
    $template->set_var('weight', $product['weight']);
    $template->set_var('per_item', $LANG_PAYPAL_ADMIN['per_item']);
    //shipping
    $template->set_var('shipping_type', $LANG_PAYPAL_ADMIN['shipping_type']);
    $template->set_var('shipping_type_ini', $product['shipping_type']);
    $shipping_options = '';
    if ($product['shipping_type'] == 0) {
        $selected0 = ' selected="selected"';
        $selected1 = '';
    } else {
        $selected1 = ' selected="selected"';
        $selected0 = '';
    }
    $shipping_options .= '<option value="0"' . $selected0 . '>' . $LANG_PAYPAL_ADMIN['shipping_options'][0] . '</option>';
    $shipping_options .= '<option value="1"' . $selected1 . '>' . $LANG_PAYPAL_ADMIN['shipping_options'][1] . '</option>';
    $template->set_var('shipping_options', $shipping_options);
    $template->set_var('yes', $LANG_PAYPAL_1['yes']);
    $template->set_var('no', $LANG_PAYPAL_1['no']);
    $template->set_var('save_button', $LANG_PAYPAL_1['save_button']);
    $template->set_var('delete_button', $LANG_PAYPAL_1['delete_button']);
    $template->set_var('ok_button', $LANG_PAYPAL_1['ok_button']);
    $template->set_var('required_field', $LANG_PAYPAL_1['required_field']);
    if ($product['product_type'] == 1) {
        $template->set_var('download_yes', ' selected');
        $template->set_var('download_no', '');
    } else {
        $template->set_var('download_yes', '');
        $template->set_var('download_no', ' selected');
    }
    $template->set_var('file', $product['file']);
    $template->set_var('expiration', $product['expiration']);
    //Subscription
    $type != 'subscription' ? $template->set_var('display_subscription', 'display:none;') : $template->set_var('display_subscription', '');
    $template->set_var('subscription_product_label', $LANG_PAYPAL_1['subscription_label']);
    $template->set_var('duration_label', $LANG_PAYPAL_1['duration_label']);
    $template->set_var('duration', $product['duration']);
    $product['duration_type'] == 'day' ? $template->set_var('sel_day', ' selected="selected"') : '';
    $template->set_var('day', $LANG_PAYPAL_1['day']);
    $product['duration_type'] == 'week' ? $template->set_var('sel_week', ' selected="selected"') : '';
    $template->set_var('week', $LANG_PAYPAL_1['week']);
    $product['duration_type'] == 'month' ? $template->set_var('sel_month', ' selected="selected"') : '';
    $template->set_var('month', $LANG_PAYPAL_1['month']);
    $product['duration_type'] == 'year' ? $template->set_var('sel_year', ' selected="selected"') : '';
    $template->set_var('year', $LANG_PAYPAL_1['year']);
    //Recurrent
    if ($type != 'recurrent') {
        $template->set_var('display_recurrent', 'display:none;');
        $template->set_var('add_to_group_label', $LANG_PAYPAL_1['recurrent_add_to_group']);
    } else {
        $template->set_var('display_recurrent', '');
    }
    $template->set_var('recurrent_product_label', $LANG_PAYPAL_1['recurrent_product_label']);
    $template->set_var('add_to_group_label', $LANG_PAYPAL_1['recurrent_add_to_group']);
    $template->set_var('period_label', $LANG_PAYPAL_1['period_label']);
    $template->set_var('billing_label', $LANG_PAYPAL_1['billing_label']);
    $template->set_var('billingamt', $product['billingamt']);
    $template->set_var('frequency_label', $LANG_PAYPAL_1['frequency_label']);
    $template->set_var('frequency_help', $LANG_PAYPAL_1['frequency_help']);
    $template->set_var('duration_recurrent', $product['duration']);
    $product['duration_type'] == 'Day' ? $template->set_var('sel_recurrent_day', ' selected="selected"') : '';
    $template->set_var('recurrent_day', $LANG_PAYPAL_1['recurrent_day']);
    $product['duration_type'] == 'Week' ? $template->set_var('sel_recurrent_week', ' selected="selected"') : '';
    $template->set_var('recurrent_week', $LANG_PAYPAL_1['recurrent_week']);
    $product['duration_type'] == 'SemiMonth' ? $template->set_var('sel_recurrent_semimonth', ' selected="selected"') : '';
    $template->set_var('recurrent_semimonth', $LANG_PAYPAL_1['recurrent_semimonth']);
    $product['duration_type'] == 'Month' ? $template->set_var('sel_recurrent_month', ' selected="selected"') : '';
    $template->set_var('recurrent_month', $LANG_PAYPAL_1['recurrent_month']);
    $product['duration_type'] == 'Year' ? $template->set_var('sel_recurrent_year', ' selected="selected"') : '';
    $template->set_var('recurrent_year', $LANG_PAYPAL_1['recurrent_year']);
    //Group select list
    $template->set_var('add_to_group_options', COM_optionList($_TABLES['groups'], 'grp_id,grp_name', $product['add_to_group'], 1));
    // Permissions
    if ($product['perm_owner'] == '') {
        SEC_setDefaultPermissions($product, $_PAY_CONF['default_permissions']);
    }
    $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $template->set_var('lang_owner', $LANG_ACCESS['owner']);
    if ($product['owner_id'] == '') {
        $product['owner_id'] = $_USER['uid'];
    }
    $ownername = COM_getDisplayName($product['owner_id']);
    $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$product['owner_id']}"));
    $template->set_var('owner_name', $ownername);
    $template->set_var('owner', $ownername);
    $template->set_var('owner_id', $product['owner_id']);
    if ($product['group_id'] == '') {
        $product['group_id'] = $_GROUPS['Paypal Admin'];
    }
    $template->set_var('lang_group', $LANG_ACCESS['group']);
    //Todo make group = paypal.admin
    $access = 3;
    $template->set_var('group_dropdown', SEC_getGroupDropdown($product['group_id'], $access));
    $template->set_var('permissions_editor', SEC_getPermissionsHTML($product['perm_owner'], $product['perm_group'], $product['perm_members'], $product['perm_anon']));
    $template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $display .= $template->parse('output', 'product');
    $display .= COM_endBlock();
    return $display;
}
Exemple #12
0
function fncSave($edt_flg, $navbarMenu, $menuno, $template)
{
    $pi_name = "databox";
    global $_CONF;
    global $LANG_DATABOX_ADMIN;
    global $_TABLES;
    global $_USER;
    global $_DATABOX_CONF;
    global $LANG_DATABOX_user_menu;
    $addition_def = DATABOX_getadditiondef();
    $retval = '';
    // clean 'em up
    $id = COM_applyFilter($_POST['id'], true);
    if ($id == 0) {
        $new_flg = true;
    } else {
        $new_flg = false;
    }
    $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
    $code = COM_applyFilter($_POST['code']);
    $code = addslashes(COM_checkHTML(COM_checkWords($code)));
    $title = COM_stripslashes($_POST['title']);
    $title = addslashes(COM_checkHTML(COM_checkWords($title)));
    $page_title = COM_applyFilter($_POST['page_title']);
    $page_title = addslashes(COM_checkHTML(COM_checkWords($page_title)));
    $description = $_POST['description'];
    //COM_applyFilter($_POST['description']);
    $description = addslashes(COM_checkHTML(COM_checkWords($description)));
    $language_id = COM_applyFilter($_POST['language_id']);
    $language_id = addslashes(COM_checkHTML(COM_checkWords($language_id)));
    $category = $_POST['category'];
    //@@@@@
    $additionfields = $_POST['afield'];
    $additionfields_old = $_POST['afield'];
    $additionfields_fnm = $_POST['afield_fnm'];
    $additionfields_del = $_POST['afield_del'];
    $additionfields_alt = $_POST['afield_alt'];
    $additionfields_date = array();
    $additionfields = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt);
    //            $hits =0;
    //            $comments=0;
    $old_mode = COM_applyFilter($_POST['old_mode']);
    $old_mode = addslashes(COM_checkHTML(COM_checkWords($old_mode)));
    //-----
    $type = 1;
    $uuid = $_USER['uid'];
    // CHECK はじめ
    $err = "";
    //id
    if ($id == 0) {
        //$err.=$LANG_DATABOX_ADMIN['err_uid']."<br/>".LB;
    } else {
        if (!is_numeric($id)) {
            $err .= $LANG_DATABOX_ADMIN['err_id'] . "<br/>" . LB;
        }
    }
    //タイトル必須
    if (empty($title)) {
        $err .= $LANG_DATABOX_ADMIN['err_title'] . "<br/>" . LB;
    }
    //文字数制限チェック
    if (mb_strlen($description, 'UTF-8') > $_DATABOX_CONF['maxlength_description']) {
        $err .= $LANG_DATABOX_ADMIN['description'] . $_DATABOX_CONF['maxlength_description'] . $LANG_DATABOX_ADMIN['err_maxlength'] . "<br/>" . LB;
    }
    //----追加項目チェック
    $err .= DATABOX_checkaddtiondatas($additionfields, $addition_def, $pi_name, $additionfields_fnm, $additionfields_del, $additionfields_alt);
    //errorのあるとき
    if ($err != "") {
        $retval['title'] = $LANG_DATABOX_ADMIN['piname'] . $LANG_DATABOX_ADMIN['edit'];
        $retval['display'] = fncEdit($id, $edt_flg, 3, $err, "edit", $fieldset_id, $template, $old_mode);
        return $retval;
    }
    // CHECK おわり
    //-----
    // 新規登録時
    if ($new_flg) {
        $w = DB_getItem($_TABLES['DATABOX_base'], "max(id)", "1=1");
        if ($w == "") {
            $w = 0;
        }
        $id = $w + 1;
    }
    $fields = LB . "id";
    $values = LB . "{$id}";
    if ($new_flg) {
        if ($_DATABOX_CONF['datacode']) {
            $code = "000000" . date(Ymdhis);
        }
        $created = COM_convertDate2Timestamp(date("Y-m-d"), date("H:i::00"));
        $modified = $created;
        $released = $created;
        $commentcode = $_DATABOX_CONF['commentcode'];
        $trackbackcode = $_CONF[trackback_code];
        $comment_expire = '0000-00-00 00:00:00';
        $expired = '0000-00-00 00:00:00';
        //
        $defaulttemplatesdirectory = null;
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        //---
        $meta_description = "";
        $meta_keywords = "";
        $owner_id = $_USER['uid'];
        $group_id = SEC_getFeatureGroup('databox.admin', $_USER['uid']);
        $array = array();
        SEC_setDefaultPermissions($array, $_DATABOX_CONF['default_permissions']);
        $perm_owner = $array['perm_owner'];
        $perm_group = $array['perm_group'];
        $perm_anon = $array['perm_anon'];
        $perm_members = $array['perm_members'];
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        $cache_time = $_DATABOX_CONF['default_cache_time'];
        //-----
        $fields .= ",defaulttemplatesdirectory";
        //
        $values .= ",'{$defaulttemplatesdirectory}'";
        $fields .= ",draft_flag";
        $values .= ",{$draft_flag}";
        $fields .= ",cache_time";
        $values .= ",{$cache_time}";
        $fields .= ",meta_description";
        //
        $values .= ",'{$meta_description}'";
        $fields .= ",meta_keywords";
        //
        $values .= ",'{$meta_keywords}'";
        $fields .= ",commentcode";
        //
        $values .= ",{$commentcode}";
        $fields .= ",trackbackcode";
        //
        $values .= ",{$trackbackcode}";
        $fields .= ",comment_expire";
        //
        if ($comment_expire == '0000-00-00 00:00:00') {
            $values .= ",'{$comment_expire}'";
        } else {
            $values .= ",FROM_UNIXTIME('{$comment_expire}')";
        }
        $fields .= ",language_id";
        //
        $values .= ",'{$language_id}'";
        $fields .= ",owner_id";
        $values .= ",{$owner_id}";
        $fields .= ",group_id";
        $values .= ",{$group_id}";
        $fields .= ",perm_owner";
        $values .= ",{$perm_owner}";
        $fields .= ",perm_group";
        $values .= ",{$perm_group}";
        $fields .= ",perm_members";
        $values .= ",{$perm_members}";
        $fields .= ",perm_anon";
        $values .= ",{$perm_anon}";
        $fields .= ",modified";
        $values .= ",FROM_UNIXTIME('{$modified}')";
        $fields .= ",created";
        $values .= ",FROM_UNIXTIME('{$created}')";
        $fields .= ",expired";
        if ($expired == '0000-00-00 00:00:00') {
            $values .= ",'{$expired}'";
        } else {
            $values .= ",FROM_UNIXTIME('{$expired}')";
        }
        $fields .= ",released";
        $values .= ",FROM_UNIXTIME('{$released}')";
        $hits = 0;
        $comments = 0;
        $fields .= ",code";
        $values .= ",'{$code}'";
        $fields .= ",title";
        //
        $values .= ",'{$title}'";
        $fields .= ",page_title";
        //
        $values .= ",'{$page_title}'";
        $fields .= ",description";
        //
        $values .= ",'{$description}'";
        //        $fields.=",hits";//
        //        $values.=",$hits";
        $fields .= ",comments";
        //
        $values .= ",{$comments}";
        $fields .= ",fieldset_id";
        //
        $values .= ",{$fieldset_id}";
        $fields .= ",uuid";
        $values .= ",{$uuid}";
        if ($edt_flg) {
            $return_page = $_CONF['site_url'] . "/" . THIS_SCRIPT;
            $return_page .= "?id=" . $id;
        } else {
            $return_page = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?msg=1';
        }
        DB_save($_TABLES['DATABOX_base'], $fields, $values);
    } else {
        $sql = "UPDATE {$_TABLES['DATABOX_base']} set ";
        $sql .= " title = '{$title}'";
        $sql .= " ,page_title = '{$page_title}'";
        $sql .= " ,description = '{$description}'";
        $sql .= " ,language_id = '{$language_id}'";
        $sql .= " ,modified = FROM_UNIXTIME('{$modified}')";
        $sql .= ",uuid='{$uuid}' WHERE id={$id}";
        DB_query($sql);
    }
    //カテゴリ
    //$rt=DATABOX_savedatas("category_id",$_TABLES['DATABOX_category'],$id,$category);
    $rt = DATABOX_savecategorydatas($id, $category);
    //追加項目
    if ($old_mode == "copy") {
        DATABOX_uploadaddtiondatas_cpy($additionfields, $addition_def, $pi_name, $id, $additionfields_fnm, $additionfields_del, $additionfields_old, $additionfields_alt);
    } else {
        DATABOX_uploadaddtiondatas($additionfields, $addition_def, $pi_name, $id, $additionfields_fnm, $additionfields_del, $additionfields_old, $additionfields_alt);
    }
    if ($new_flg) {
        $rt = DATABOX_saveaddtiondatas($id, $additionfields, $addition_def, $pi_name);
    } else {
        $rt = DATABOX_saveaddtiondatas_update($id, $additionfields, $addition_def, $pi_name);
    }
    $rt = fncsendmail('data', $id);
    $cacheInstance = 'databox__' . $id . '__';
    CACHE_remove_instance($cacheInstance);
    //exit;//@@@@@debug 用
    if ($_DATABOX_CONF['aftersave'] === 'no') {
        $retval['title'] = $LANG_DATABOX_ADMIN['piname'] . $LANG_DATABOX_ADMIN['edit'];
        $retval['display'] .= fncEdit($id, $edt_flg, 1, $err, "edit", $fieldset_id, $template);
        return $retval;
    } else {
        if ($_DATABOX_CONF['aftersave'] === 'list' or $_DATABOX_CONF['aftersave'] === 'admin') {
            $url = $_CONF['site_url'] . "/databox/mydata/data.php";
            $item_url = COM_buildURL($url);
            $target = 'item';
        } else {
            $url = $_CONF['site_url'] . "/databox/data.php";
            $url .= "?";
            //コード使用の時
            if ($_DATABOX_CONF['datacode']) {
                $url .= "code=" . $code;
                $url .= "&amp;m=code";
            } else {
                $url .= "id=" . $id;
                $url .= "&amp;m=id";
            }
            $item_url = COM_buildUrl($url);
            $target = $_DATABOX_CONF['aftersave_admin'];
        }
    }
    $return_page = PLG_afterSaveSwitch($target, $item_url, $pi_name, 1);
    echo $return_page;
    exit;
}
Exemple #13
0
function fncEdit($id, $edt_flg, $msg = '', $errmsg = "", $mode = "edit", $old_mode = "")
{
    $pi_name = "databox";
    global $_CONF;
    global $_TABLES;
    global $LANG_ADMIN;
    global $MESSAGE;
    global $LANG_ACCESS;
    global $_USER;
    global $_SCRIPTS;
    global $_DATABOX_CONF;
    global $LANG_DATABOX_ADMIN;
    global $LANG_DATABOX;
    $retval = '';
    $delflg = false;
    $addition_def = DATABOX_getadditiondef();
    //メッセージ表示
    if (!empty($msg)) {
        $retval .= COM_showMessage($msg, 'databox');
        $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']);
        $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 {
        if (empty($id)) {
            $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
            //"";
            $fieldset_name = DB_getItem($_TABLES['DATABOX_def_fieldset'], "name", "fieldset_id=" . $fieldset_id);
            $fieldset_name = COM_stripslashes($fieldset_name);
            $id = 0;
            $code = "";
            $title = "";
            $description = "";
            $defaulttemplatesdirectory = null;
            $hits = 0;
            $comments = 0;
            $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;
            $commentcode = $_DATABOX_CONF['commentcode'];
            $trackbackcode = $_CONF[trackback_code];
            $cache_time = $_DATABOX_CONF[default_cache_time];
            $meta_description = "";
            $meta_keywords = "";
            $language_id = "";
            $category = "";
            $additionfields = array();
            $additionfields_fnm = array();
            //@@@@@
            $additionfields_del = array();
            $additionfields_date = "";
            $additionfields = DATABOX_getadditiondatas(0, $pi_name);
            //
            $owner_id = $_USER['uid'];
            //@@@@@
            //$group_id =SEC_getFeatureGroup('databox.admin', $_USER['uid']);;
            $group_id = $_DATABOX_CONF['grp_id_default'];
            $array = array();
            SEC_setDefaultPermissions($array, $_DATABOX_CONF['default_permissions']);
            $perm_owner = $array['perm_owner'];
            $perm_group = $array['perm_group'];
            $perm_anon = $array['perm_anon'];
            $perm_members = $array['perm_members'];
            //
            $draft_flag = $_DATABOX_CONF['admin_draft_default'];
            //編集日付
            $modified_month = date('m');
            $modified_day = date('d');
            $modified_year = date('Y');
            $modified_hour = date('H');
            $modified_minute = date('i');
            //作成日付
            $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;
            $orderno = "";
            $uuid = 0;
            $udatetime = "";
            //"";
        } else {
            $sql = "SELECT " . LB;
            $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 " . LB;
            $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;
            $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']);
            $page_title = COM_stripslashes($A['page_title']);
            $description = COM_stripslashes($A['description']);
            $defaulttemplatesdirectory = COM_stripslashes($A['defaulttemplatesdirectory']);
            $eyechatchiimage = COM_stripslashes($A['eyechatchimage']);
            $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['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']);
            //編集日
            $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;
            }
        }
    }
    if ($mode === "copy") {
        $id = 0;
        //作成日付
        $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";
    }
    //template フォルダ
    $tmplfld = DATABOX_templatePath('admin', 'default', $pi_name);
    $templates = new Template($tmplfld);
    $templates->set_file(array('editor' => 'data_editor.thtml', 'row' => 'row.thtml', 'col' => "data_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 && $_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('maxlength_meta_description', $_DATABOX_CONF['maxlength_meta_description']);
    $templates->set_var('maxlength_meta_keywords', $_DATABOX_CONF['maxlength_meta_keywords']);
    $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_ref', $LANG_DATABOX_ADMIN['ref']);
    $templates->set_var('lang_view', $LANG_DATABOX_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', $_DATABOX_CONF['dateformat']);
    //ビューリンク@@@@@
    $url = $_CONF['site_url'] . "/databox/data.php";
    $url .= "?";
    if ($_DATABOX_CONF['datacode']) {
        $url .= "code=" . $A['code'];
        $url .= "&amp;m=code";
    } else {
        $url .= "id=" . $A['id'];
        $url .= "&amp;m=id";
    }
    $url = COM_buildUrl($url);
    $view = COM_createLink($LANG_DATABOX['view'], $url);
    $templates->set_var('view', $view);
    //
    $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']);
    //fieldset_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");
    } else {
        $templates->set_var('draft_flag', "");
    }
    //
    $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);
    $templates->set_var('lang_defaulttemplatesdirectory', $LANG_DATABOX_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_DATABOX_ADMIN['meta_description']);
    $templates->set_var('meta_description', $meta_description);
    //meta_keywords
    $templates->set_var('lang_meta_keywords', $LANG_DATABOX_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_DATABOX_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_DATABOX_ADMIN['hits']);
    $templates->set_var('hits', $hits);
    //comments
    $templates->set_var('lang_comments', $LANG_DATABOX_ADMIN['comments']);
    $templates->set_var('comments', $comments);
    //commentcode
    $templates->set_var('lang_commentcode', $LANG_DATABOX_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_DATABOX_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_DATABOX_ADMIN['cache_time']);
    $templates->set_var('lang_cache_time_desc', $LANG_DATABOX_ADMIN['cache_time_desc']);
    $templates->set_var('cache_time', $cache_time);
    //comment_expire
    $templates->set_var('lang_enabled', $LANG_DATABOX_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_DATABOX_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_DATABOX_ADMIN", "comment_expire");
    $templates->set_var('datetime_comment_expire', $datetime_comment_expire);
    //編集日
    $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_released', $LANG_DATABOX_ADMIN['released']);
    $w = COM_convertDate2Timestamp($released_year . "-" . $released_month . "-" . $released_day, $released_hour . ":" . $released_minute . "::00");
    $datetime_released = DATABOX_datetimeedit($w, "LANG_DATABOX_ADMIN", "released");
    $templates->set_var('datetime_released', $datetime_released);
    //公開終了日
    $templates->set_var('lang_expired', $LANG_DATABOX_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_DATABOX_ADMIN['expired']);
    $w = COM_convertDate2Timestamp($expired_year . "-" . $expired_month . "-" . $expired_day, $expired_hour . ":" . $expired_minute . "::00");
    $datetime_expired = DATABOX_datetimeedit($w, "LANG_DATABOX_ADMIN", "expired");
    $templates->set_var('datetime_expired', $datetime_expired);
    //順序
    $templates->set_var('lang_orderno', $LANG_DATABOX_ADMIN['orderno']);
    $templates->set_var('orderno', $orderno);
    //カテゴリ
    $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, 9999, $pi_name, $additionfields_fnm, $additionfields_del, $fieldset_id, $additionfields_date);
    //保存日時
    $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);
    //アクセス権
    $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
    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;
}
Exemple #14
0
function DLM_convertData()
{
    global $_PLUGINS, $_DLM_CONF, $_GROUPS, $_CONF, $_TABLES, $_USER, $_FM_TABLES, $_FM_CONF, $_LANG_CONV, $_SUCCESS;
    $retval = '';
    if (is_readable($_FM_CONF['filemgmt_FileStore'])) {
        $retval .= '<p>' . $_LANG_CONV['readable_fm_file_dir'] . $_FM_CONF['filemgmt_FileStore'] . '</p>' . LB;
    } else {
        $retval .= '<p>' . $_LANG_CONV['unreadable_fm_file_dir'] . $_FM_CONF['filemgmt_FileStore'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    if (is_writeable($_DLM_CONF['path_filestore'])) {
        $retval .= '<p>' . $_LANG_CONV['writeable_dm_file_dir'] . $_DLM_CONF['path_filestore'] . '</p>' . LB;
    } else {
        $retval .= '<p>' . $_LANG_CONV['unwriteable_dm_file_dir'] . $_DLM_CONF['path_filestore'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $sql = "SELECT COUNT(*) FROM {$_TABLES['downloadcategories']}";
    list($count) = DB_fetchArray(DB_query($sql));
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $retval .= '<p>' . $_LANG_CONV['num_dm_cat_data'] . $count . '</p>' . LB;
    if ($count > 0) {
        $retval .= '<p>' . $_LANG_CONV['del_dm_cat_data'] . '</p>' . LB;
        DB_query("DELETE FROM {$_TABLES['downloadcategories']}");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT COUNT(*) FROM {$_TABLES['downloads']}";
    list($count) = DB_fetchArray(DB_query($sql));
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $retval .= '<p>' . $_LANG_CONV['num_dm_info_data'] . $count . '</p>' . LB;
    if ($count > 0) {
        $retval .= '<p>' . $_LANG_CONV['del_dm_info_data'] . '</p>' . LB;
        DB_query("DELETE FROM {$_TABLES['downloads']}");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT COUNT(*) FROM {$_TABLES['downloadvotes']}";
    list($count) = DB_fetchArray(DB_query($sql));
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $retval .= '<p>' . $_LANG_CONV['num_dm_vote_data'] . $count . '</p>' . LB;
    if ($count > 0) {
        $retval .= '<p>' . $_LANG_CONV['del_dm_vote_data'] . '</p>' . LB;
        DB_query("DELETE FROM {$_TABLES['downloadvotes']}");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT COUNT(*) FROM {$_TABLES['downloadhistories']}";
    list($count) = DB_fetchArray(DB_query($sql));
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $retval .= '<p>' . $_LANG_CONV['num_dm_history_data'] . $count . '</p>' . LB;
    if ($count > 0) {
        $retval .= '<p>' . $_LANG_CONV['del_dm_history_data'] . '</p>' . LB;
        DB_query("DELETE FROM {$_TABLES['downloadhistories']}");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT COUNT(*) FROM {$_TABLES['downloadsubmission']}";
    list($count) = DB_fetchArray(DB_query($sql));
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $retval .= '<p>' . $_LANG_CONV['num_dm_submission_data'] . $count . '</p>' . LB;
    if ($count > 0) {
        $retval .= '<p>' . $_LANG_CONV['del_dm_submission_data'] . '</p>' . LB;
        DB_query("DELETE FROM {$_TABLES['downloadsubmission']}");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    if (!$_SUCCESS) {
        return $retval;
    }
    $owner_id = $_USER['uid'];
    if (isset($_GROUPS['Downloads Admin'])) {
        $group_id = $_GROUPS['Downloads Admin'];
    } else {
        $group_id = SEC_getFeatureGroup('downloads.edit');
    }
    SEC_setDefaultPermissions($P, $_DLM_CONF['default_permissions']);
    foreach ($P as $key => $val) {
        ${$key} = $val;
    }
    $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_cat']}";
    $result = DB_query($sql);
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    $corder = 0;
    while ($A = DB_fetchArray($result)) {
        foreach ($A as $key => $val) {
            ${$key} = $val;
        }
        if ($pid == 0) {
            $pid = ROOTID;
        }
        $corder += 10;
        $is_enabled = 1;
        if (!empty($imgurl)) {
            $imgurl = rawurldecode($imgurl);
            $catimg_src = $_FM_CONF['filemgmt_SnapCat'] . $imgurl;
            if (!is_readable($catimg_src)) {
                $retval .= '<p>' . $_LANG_CONV['unable_to_read_catimg'] . $catimg_src . '</p>' . LB;
                $_SUCCESS = false;
                return $retval;
            }
            $catimg_dest = $_DLM_CONF['path_snapcat'] . DLM_createSafeFileName(DLM_createCatImgFilename($imgurl));
            $_SUCCESS = DLM_copyFile_fm2dm($catimg_src, $catimg_dest);
            if (!$_SUCCESS) {
                $retval .= '<p>' . $_LANG_CONV['unable_to_conv_catimg'] . $catimg_src . '</p>' . LB;
                return $retval;
            }
        }
        DB_query("INSERT INTO {$_TABLES['downloadcategories']} " . "(cid, pid, title, imgurl, corder, is_enabled, owner_id, group_id, " . "perm_owner, perm_group, perm_members, perm_anon) " . "VALUES ('{$cid}', '{$pid}', '{$title}', '{$imgurl}', {$corder}, {$is_enabled}, {$owner_id}, {$group_id}, " . "{$perm_owner}, {$perm_group}, {$perm_members}, {$perm_anon})");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_filedetail']}";
    $result = DB_query($sql);
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    while ($A = DB_fetchArray($result)) {
        foreach ($A as $key => $val) {
            ${$key} = $val;
        }
        $project = '';
        $description = '';
        $detail = '';
        $postmode = 'plaintext';
        $commentcode = $comments == 1 ? 0 : -1;
        $is_released = $status;
        $is_listing = $status;
        $createddate = date('Y-m-d H:i:s', $date);
        $owner_id = $submitter;
        $secret_id = md5(uniqid());
        $mg_autotag = '';
        $tags = '';
        $url = rawurldecode($url);
        $src_url = $_FM_CONF['filemgmt_FileStore'] . $url;
        if (!is_readable($src_url)) {
            $retval .= '<p>' . $_LANG_CONV['unable_to_read_dlfile'] . $src_url . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
        $size = filesize($src_url);
        $md5 = md5_file($src_url);
        $dest_url = $_DLM_CONF['path_filestore'] . DLM_createSafeFileName($url, $secret_id);
        $_SUCCESS = DLM_copyFile_fm2dm($src_url, $dest_url);
        if (!$_SUCCESS) {
            $retval .= '<p>' . $_LANG_CONV['unable_to_conv_dlfile'] . $src_url . '</p>' . LB;
            return $retval;
        }
        if (!empty($logourl)) {
            $logourl = rawurldecode($logourl);
            $snap_src = $_FM_CONF['filemgmt_SnapStore'] . $logourl;
            if (!is_readable($snap_src)) {
                $retval .= '<p>' . $_LANG_CONV['unable_to_read_snapimg'] . $snap_src . '</p>' . LB;
                $_SUCCESS = false;
                return $retval;
            }
            $logourl = DLM_createSnapFilename($logourl, $_TABLES['downloads'], 'logourl');
            $snap_dest = $_DLM_CONF['path_snapstore'] . DLM_createSafeFileName($logourl);
            $_SUCCESS = DLM_copyFile_fm2dm($snap_src, $snap_dest);
            if (!$_SUCCESS) {
                $retval .= '<p>' . $_LANG_CONV['unable_to_conv_snapimg'] . $snap_src . '</p>' . LB;
                return $retval;
            }
            $_SUCCESS = DLM_makeThumbnail(DLM_createSafeFileName($logourl));
            if (!$_SUCCESS) {
                $retval .= '<p>' . $_LANG_CONV['unable_to_make_tn'] . $snap_src . '</p>' . LB;
                return $retval;
            }
        }
        DB_query("INSERT INTO {$_TABLES['downloads']} " . "(lid, cid, title, url, homepage, version, size, secret_id, md5, " . "project, description, detail, postmode, logourl, mg_autotag, tags, " . "date, hits, rating, votes, commentcode, is_released, is_listing, createddate, owner_id" . ") " . "VALUES ('{$lid}', '{$cid}', '{$title}', '{$url}', '{$homepage}', '{$version}', '{$size}', '{$secret_id}', '{$md5}', " . "'{$project}', '{$description}', '{$detail}', '{$postmode}', '{$logourl}', '{$mg_autotag}', '{$tags}', " . "{$date}, {$hits}, {$rating}, {$votes}, '{$commentcode}', {$is_released}, {$is_listing}, '{$createddate}', '{$owner_id}'" . ")");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_filedesc']}";
    $result = DB_query($sql);
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    while ($A = DB_fetchArray($result)) {
        foreach ($A as $key => $val) {
            ${$key} = $val;
        }
        $description = addslashes(stripslashes($description));
        $descri = '';
        $detail = '';
        // Search break page position
        $breakPosition = strpos($description, "\r\n\r\n");
        if ($breakPosition > 0 and $breakPosition < strlen($description)) {
            $descri = substr($description, 0, $breakPosition);
            $detail = substr($description, $breakPosition + 4, strlen($description) - $breakPosition - 4);
        } else {
            $breakPosition = strpos($description, "\n\n");
            if ($breakPosition > 0 and $breakPosition < strlen($description)) {
                $descri = substr($description, 0, $breakPosition);
                $detail = substr($description, $breakPosition + 2, strlen($description) - $breakPosition - 2);
            } else {
                $breakPosition = strpos($description, "\r\r");
                if ($breakPosition > 0 and $breakPosition < strlen($description)) {
                    $descri = substr($description, 0, $breakPosition);
                    $detail = substr($description, $breakPosition + 2, strlen($description) - $breakPosition - 2);
                } else {
                    $descri = $description;
                }
            }
        }
        DB_query("UPDATE {$_TABLES['downloads']} " . "SET description='{$descri}', detail='{$detail}' " . "WHERE lid='{$lid}'");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_votedata']}";
    $result = DB_query($sql);
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    while ($A = DB_fetchArray($result)) {
        foreach ($A as $key => $val) {
            ${$key} = $val;
        }
        DB_query("INSERT INTO {$_TABLES['downloadvotes']} " . "(ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) " . "VALUES ('{$ratingid}', '{$lid}', '{$ratinguser}', '{$rating}', '{$ratinghostname}', '{$ratingtimestamp}')");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    $sql = "SELECT * FROM {$_FM_TABLES['filemgmt_history']}";
    $result = DB_query($sql);
    if (DB_error()) {
        $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
        $_SUCCESS = false;
        return $retval;
    }
    while ($A = DB_fetchArray($result)) {
        foreach ($A as $key => $val) {
            ${$key} = $val;
        }
        DB_query("INSERT INTO {$_TABLES['downloadhistories']} " . "(uid, lid, remote_ip, date) " . "VALUES ('{$uid}', '{$lid}', '{$remote_ip}', '{$date}')");
        if (DB_error()) {
            $retval .= '<p>' . $_LANG_CONV['db_error'] . '</p>' . LB;
            $_SUCCESS = false;
            return $retval;
        }
    }
    return $retval;
}
Exemple #15
0
/**
* When the install went through, give the plugin a chance for any
* plugin-specific post-install fixes
*
* @return   boolean     true = proceed with install, false = an error occured
*
*/
function plugin_postinstall()
{
    global $_CONF, $_TABLES;
    // fix Polls block group ownership
    $blockAdminGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'");
    if ($blockAdminGroup > 0) {
        // set the block's permissions
        $A = array();
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        // ... and make it the last block on the right side
        $result = DB_query("SELECT MAX(blockorder) FROM {$_TABLES['blocks']} WHERE onleft = 0");
        list($order) = DB_fetchArray($result);
        $order += 10;
        DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$blockAdminGroup}, blockorder = {$order}, perm_owner = {$A['perm_owner']}, perm_group = {$A['perm_group']}, perm_members = {$A['perm_members']}, perm_anon = {$A['perm_anon']} WHERE (type = 'phpblock') AND (phpblockfn = 'phpblock_polls')");
        return true;
    }
    return false;
}
Exemple #16
0
 /**
  * Load a Story object from the sid specified, returning a status result.
  * The result will either be a permission denied message, invalid SID
  * message, or a loaded ok message. If it's loaded ok, then we've got all
  * the exciting gubbins here.
  * Only used from story admin and submit.php!
  *
  * @param  string $sid  Story Identifier, valid geeklog story id from the db.
  * @param  string $mode 'edit'|'view'|'clone'|'editsubmission'
  * @return int          from a constant.
  */
 public function loadFromDatabase($sid, $mode = 'edit')
 {
     global $_TABLES, $_CONF, $_USER, $topic;
     $sid = DB_escapeString(COM_applyFilter($sid));
     $sql = array();
     if (!empty($sid) && ($mode === 'edit' || $mode === 'view' || $mode === 'clone')) {
         if (empty($topic)) {
             $topic_sql = ' AND ta.tdefault = 1';
         } else {
             $topic_sql = " AND ta.tid = '{$topic}'";
         }
         /* Original
            $sql['mysql'] = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) AS expireunix, UNIX_TIMESTAMP(s.comment_expire) AS cmt_expire_unix, "
                . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '$sid')";
            */
         $sql['mysql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) AS expireunix, UNIX_TIMESTAMP(s.comment_expire) AS cmt_expire_unix, u.username, u.fullname, u.photo, u.email, t.tid, t.topic, t.imageurl\n                FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta\n                WHERE ta.type = 'article' AND ta.id = sid {$topic_sql} AND (s.uid = u.uid) AND (ta.tid = t.tid) AND (sid = '{$sid}')";
         $sql['pgsql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) as expireunix, UNIX_TIMESTAMP(s.comment_expire) as cmt_expire_unix, u.username, u.fullname, u.photo, u.email, t.tid, t.topic, t.imageurl\n                FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta\n                WHERE ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1 AND (s.uid = u.uid) AND (ta.tid = t.tid) AND (sid = '{$sid}')";
     } elseif (!empty($sid) && $mode === 'editsubmission') {
         /* Original
            $sql['mysql'] = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
                . 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
            $sql['pgsql'] = 'SELECT  s.*, UNIX_TIMESTAMP(s.date) AS unixdate, '
                . 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
            */
         $sql['mysql'] = "SELECT s.*, UNIX_TIMESTAMP(s.date) AS unixdate, u.username, u.fullname, u.photo, u.email, t.tid, t.topic, t.imageurl, t.group_id, t.perm_owner, t.perm_group, t.perm_members, t.perm_anon\n                FROM {$_TABLES['storysubmission']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta\n                WHERE (s.uid = u.uid) AND  (ta.tid = t.tid) AND (sid = '{$sid}')\n                AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1";
         $sql['pgsql'] = "SELECT  s.*, UNIX_TIMESTAMP(s.date) AS unixdate, u.username, u.fullname, u.photo, u.email, t.tid, t.topic, t.imageurl, t.group_id, t.perm_owner, t.perm_group, t.perm_members, t.perm_anon\n                FROM {$_TABLES['storysubmission']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t, {$_TABLES['topic_assignments']} AS ta\n                WHERE (s.uid = u.uid) AND  (ta.tid = t.tid) AND (sid = '{$sid}')\n                AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1";
     } elseif ($mode === 'edit') {
         $this->_sid = COM_makesid();
         $this->_old_sid = $this->_sid;
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 0;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         if (isset($_CONF['default_cache_time_article'])) {
             $this->_cache_time = $_CONF['default_cache_time_article'];
         } else {
             $this->_cache_time = 0;
         }
         if (COM_isAnonUser()) {
             $this->_uid = 1;
         } else {
             $this->_uid = $_USER['uid'];
         }
         $this->_date = $this->_expire = time();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_title = '';
         $this->_page_title = '';
         $this->_meta_description = '';
         $this->_meta_keywords = '';
         $this->_introtext = '';
         $this->_bodytext = '';
         if (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_text_version = GLTEXT_LATEST_VERSION;
         $this->_hits = 0;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         if ($_CONF['advanced_editor'] && $_USER['advanced_editor'] && $_CONF['postmode'] !== 'plaintext' && $_CONF['postmode'] !== 'wikitext') {
             $this->_advanced_editor_mode = 1;
             $this->_postmode = 'adveditor';
         } else {
             $this->_postmode = $_CONF['postmode'];
             $this->_advanced_editor_mode = 0;
         }
         $this->_statuscode = 0;
         $this->_featured = 0;
         $this->_cache_time = $_CONF['default_cache_time_article'];
         if (COM_isAnonUser()) {
             $this->_owner_id = 1;
         } else {
             $this->_owner_id = $_USER['uid'];
         }
         if (isset($_GROUPS['Story Admin'])) {
             $this->_group_id = $_GROUPS['Story Admin'];
         } else {
             $this->_group_id = SEC_getFeatureGroup('story.edit');
         }
         $array = array();
         SEC_setDefaultPermissions($array, $_CONF['default_permissions_story']);
         $this->_perm_owner = $array['perm_owner'];
         $this->_perm_group = $array['perm_group'];
         $this->_perm_anon = $array['perm_anon'];
         $this->_perm_members = $array['perm_members'];
     } else {
         $this->loadFromArgsArray($_POST);
     }
     // if we have SQL, load from it
     if (!empty($sql)) {
         $result = DB_query($sql);
         if ($result) {
             $story = DB_fetchArray($result, false);
             if ($story == null) {
                 return STORY_INVALID_SID;
             }
             $this->loadFromArray($story);
             /**
              * The above SQL also got the story owner's username etc. from
              * the DB. If the user doing the cloning is different from the
              * original author, we need to fix those here.
              */
             if ($mode === 'clone' && $this->_uid != $_USER['uid']) {
                 $this->_uid = $_USER['uid'];
                 $story['owner_id'] = $this->_uid;
                 $uResult = DB_query("SELECT username, fullname, photo, email FROM {$_TABLES['users']} WHERE uid = {$_USER['uid']}");
                 list($this->_username, $this->_fullname, $this->_photo, $this->_email) = DB_fetchArray($uResult);
             }
             if (!isset($story['owner_id'])) {
                 $story['owner_id'] = 1;
             }
             $access = SEC_hasAccess($story['owner_id'], $story['group_id'], $story['perm_owner'], $story['perm_group'], $story['perm_members'], $story['perm_anon']);
             //$this->_access = min($access, SEC_hasTopicAccess($this->_tid));
             //$this->_access = min($access, TOPIC_hasMultiTopicAccess('article', $sid));
             if ($mode !== 'view') {
                 // When editing an article they need access to all topics article is assigned to plus edit access to article itself
                 $this->_access = min($access, TOPIC_hasMultiTopicAccess('article', $sid));
             } else {
                 // When viewing a article we only care about if it has access to the current topic and article
                 $this->_access = min($access, TOPIC_hasMultiTopicAccess('article', $sid, $topic));
             }
             if ($this->_access == 0) {
                 return STORY_PERMISSION_DENIED;
             } elseif ($this->_access == 2 && $mode !== 'view') {
                 return STORY_EDIT_DENIED;
             } elseif ($this->_access == 2 && $mode == 'view' && ($this->_draft_flag == 1 || $this->_date > time())) {
                 return STORY_INVALID_SID;
             }
         } else {
             return STORY_INVALID_SID;
         }
     }
     if ($mode === 'editsubmission') {
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 1;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_featured = 0;
         $this->_cache_time = $_CONF['default_cache_time_article'];
         $this->_expire = time();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         if (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_text_version = GLTEXT_LATEST_VERSION;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         $this->_statuscode = 0;
         $this->_owner_id = $this->_uid;
     } elseif ($mode === 'clone') {
         // new story, new sid ...
         $this->_sid = COM_makeSid();
         $this->_old_sid = $this->_sid;
         // assign ownership to current user
         if (COM_isAnonUser()) {
             $this->_uid = 1;
         } else {
             $this->_uid = $_USER['uid'];
         }
         $this->_owner_id = $this->_uid;
         // use current date + time
         $this->_date = $this->_expire = time();
         // if the original story uses comment expire, update the time
         if ($this->_comment_expire != 0) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         }
         // reset counters
         $this->_hits = 0;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
     }
     $this->sanitizeData();
     return STORY_LOADED_OK;
 }
Exemple #17
0
/**
* Shows the links editor
*
* @param  string  $action   'edit' or 'moderate'
* @param  string  $lid    ID of link to edit
* @global array core config vars
* @global array core group data
* @global array core table data
* @global array core user data
* @global array links plugin config vars
* @global array links plugin lang vars
* @global array core lang access vars
* @return string HTML for the link editor form
*
*/
function LINK_edit($action, $lid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    USES_lib_admin();
    $retval = '';
    switch ($action) {
        case 'edit':
            $blocktitle = $LANG_LINKS_ADMIN[1];
            // Link Editor
            $saveoption = $LANG_ADMIN['save'];
            // Save
            break;
        case 'moderate':
            $blocktitle = $LANG_LINKS_ADMIN[65];
            // Moderate Link
            $saveoption = $LANG_ADMIN['moderate'];
            // Save & Approve
            break;
    }
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/links/index.php', 'text' => $LANG_LINKS_ADMIN[53]), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $link_templates = new Template($_CONF['path'] . 'plugins/links/templates/admin/');
    $link_templates->set_file('editor', 'linkeditor.thtml');
    $link_templates->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
    $link_templates->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
    $link_templates->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
    $link_templates->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
    $link_templates->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
    $link_templates->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
    $link_templates->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
    $link_templates->set_var('instructions', $LANG_LINKS_ADMIN[29]);
    if ($action != 'moderate' and !empty($lid)) {
        $result = DB_query("SELECT * FROM {$_TABLES['links']} WHERE lid ='{$lid}'");
        if (DB_numRows($result) !== 1) {
            $msg = COM_startBlock($LANG_LINKS_ADMIN[24], '', COM_getBlockTemplate('_msg_block', 'header'));
            $msg .= $LANG_LINKS_ADMIN[25];
            $msg .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            return $msg;
        }
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            $retval .= COM_startBlock($LANG_LINKS_ADMIN[16], '', COM_getBlockTemplate('_msg_block', 'header'));
            $retval .= $LANG_LINKS_ADMIN[17];
            $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link {$lid}.");
            return $retval;
        }
    } else {
        if ($action == 'moderate') {
            $result = DB_query("SELECT * FROM {$_TABLES['linksubmission']} WHERE lid = '{$lid}'");
            $A = DB_fetchArray($result);
        } else {
            $A['lid'] = COM_makesid();
            $A['cid'] = '';
            $A['url'] = '';
            $A['description'] = '';
            $A['title'] = '';
            $A['owner_id'] = $_USER['uid'];
        }
        $A['hits'] = 0;
        if (isset($_GROUPS['Links Admin'])) {
            $A['group_id'] = $_GROUPS['Links Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('links.edit');
        }
        SEC_setDefaultPermissions($A, $_LI_CONF['default_permissions']);
        $access = 3;
    }
    $retval .= COM_startBlock($blocktitle, '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_LINKS_ADMIN[66], plugin_geticon_links());
    $link_templates->set_var('link_id', $A['lid']);
    if (!empty($lid) && SEC_hasRights('links.edit')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $link_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $link_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $link_templates->set_var('delete_confirm_msg', $MESSAGE[76]);
        if ($action == 'moderate') {
            $link_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission">');
        }
    }
    $link_templates->set_var('lang_linktitle', $LANG_LINKS_ADMIN[3]);
    $link_templates->set_var('link_title', htmlspecialchars($A['title']));
    $link_templates->set_var('lang_linkid', $LANG_LINKS_ADMIN[2]);
    $link_templates->set_var('lang_linkurl', $LANG_LINKS_ADMIN[4]);
    $link_templates->set_var('max_url_length', 255);
    $link_templates->set_var('link_url', $A['url']);
    $link_templates->set_var('lang_includehttp', $LANG_LINKS_ADMIN[6]);
    $link_templates->set_var('lang_category', $LANG_LINKS_ADMIN[5]);
    $othercategory = links_select_box(3, $A['cid']);
    $link_templates->set_var('category_options', $othercategory);
    $link_templates->set_var('lang_ifotherspecify', $LANG_LINKS_ADMIN[20]);
    $link_templates->set_var('category', $othercategory);
    $link_templates->set_var('lang_linkhits', $LANG_LINKS_ADMIN[8]);
    $link_templates->set_var('link_hits', $A['hits']);
    $link_templates->set_var('lang_linkdescription', $LANG_LINKS_ADMIN[9]);
    $link_templates->set_var('link_description', $A['description']);
    $link_templates->set_var('lang_save', $saveoption);
    $link_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    // user access info
    $link_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $link_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $link_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $link_templates->set_var('owner_name', $ownername);
    $link_templates->set_var('owner', $ownername);
    $link_templates->set_var('link_ownerid', $A['owner_id']);
    $link_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $link_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $link_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $link_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $link_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $link_templates->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']);
    $link_templates->set_var('gltoken_name', CSRF_TOKEN);
    $link_templates->set_var('gltoken', SEC_createToken());
    $link_templates->parse('output', 'editor');
    $retval .= $link_templates->finish($link_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #18
0
/**
* Show topic administration form
*
* @param    string  tid     ID of topic to edit
* @param    array   $T      An array of topic fields (optional)
* @return   string          HTML for the topic editor
*
*/
function TOPIC_edit($tid = '', $T = array(), $msg = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_IMAGE_TYPE;
    USES_lib_admin();
    $retval = '';
    $topicEdit = 0;
    $assoc_stories_published = 0;
    $assoc_stories_draft = 0;
    $assoc_images = 0;
    $assoc_comments = 0;
    $assoc_trackbacks = 0;
    if (!empty($tid)) {
        $topicEdit = 1;
        // existing topic - pull fields from DB
        $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='" . DB_escapeString($tid) . "'");
        $A = DB_fetchArray($result);
        $access = SEC_inGroup('Topic Admin') ? 3 : SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            $retval .= COM_showMessageText($LANG27[13], $LANG27[12], true);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}.");
            return $retval;
        }
        // ok let's see what is associated with this topic
        $result2 = DB_query("SELECT bid FROM {$_TABLES['blocks']} WHERE tid = '{$tid}'");
        $assoc_blocks = DB_numRows($result2);
        $result2 = DB_query("SELECT fid FROM {$_TABLES['syndication']} WHERE topic = '{$tid}'");
        $assoc_feeds = DB_numRows($result2);
        $result2 = DB_query("SELECT sid FROM {$_TABLES['storysubmission']} WHERE tid = '{$tid}'");
        $assoc_stories_submitted = DB_numRows($result2);
        $result2 = DB_query("SELECT sid, draft_flag FROM {$_TABLES['stories']} WHERE tid = '{$tid}'");
        $total_assoc_stories = DB_numRows($result2);
        if ($total_assoc_stories > 0) {
            for ($i = 0; $i < $total_assoc_stories; $i++) {
                $S = DB_fetchArray($result2);
                if ($S['draft_flag'] == 0) {
                    $assoc_stories_published += 1;
                } else {
                    $assoc_stories_draft += 1;
                }
                $result3 = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE ai_sid = '{$S['sid']}'");
                $assoc_images += DB_numRows($result3);
                $result3 = DB_query("SELECT cid FROM {$_TABLES['comments']} WHERE sid = '{$S['sid']}' AND type = 'article'");
                $assoc_comments += DB_numRows($result3);
                $result3 = DB_query("SELECT cid FROM {$_TABLES['trackback']} WHERE sid = '{$S['sid']}' AND type = 'article'");
                $assoc_trackbacks += DB_numRows($result3);
            }
        }
    } else {
        // new topic - retain field values if any in case of failed validation
        $A = array();
        $A['tid'] = isset($T['tid']) ? $T['tid'] : '';
        $A['topic'] = isset($T['topic']) ? $T['topic'] : '';
        $A['sortnum'] = isset($T['sortnum']) ? $T['sortnum'] : 0;
        $A['limitnews'] = isset($T['limitnews']) ? $T['limitnews'] : '';
        // leave empty!
        $A['is_default'] = isset($T['is_default']) && $T['is_default'] == 'on' ? 1 : 0;
        $A['archive_flag'] = isset($T['archive_flag']) && $T['archive_flag'] == 'on' ? 1 : 0;
        $A['sort_by'] = isset($T['sort_by']) ? $T['sort_by'] : 0;
        $A['sort_dir'] = isset($T['sort_dir']) && $T['sort_dir'] == 'ASC' ? 'ASC' : 'DESC';
        $A['owner_id'] = isset($T['owner_id']) ? $T['owner_id'] : '';
        $A['group_id'] = isset($T['group_id']) ? $T['group_id'] : '';
        $A['imageurl'] = isset($T['imageurl']) ? $T['imageurl'] : '';
        $assoc_stories_submitted = 0;
        $assoc_blocks = 0;
        $assoc_feeds = 0;
        if ($A['sortnum'] != '') {
            $tidSortNumber = DB_getItem($_TABLES['topics'], 'sortnum', 'tid="' . DB_escapeString($A['sortnum']) . '"');
            $newSortNum = $tidSortNumber;
        } else {
            $newSortNum = 0;
        }
        $A['sortnum'] = $newSortNum;
        // an empty owner_id signifies this is a new block, set to current user
        // this will also set the default values for group_id as well as the
        // default values for topic permissions
        if (empty($A['owner_id'])) {
            $A['owner_id'] = $_USER['uid'];
            // this is the one instance where we default the group
            // most topics should belong to the Topic Admin group
            if (isset($_GROUPS['Topic Admin'])) {
                $A['group_id'] = $_GROUPS['Topic Admin'];
            } else {
                $A['group_id'] = SEC_getFeatureGroup('topic.edit');
            }
            SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
        } else {
            if (isset($T['perm_owner'])) {
                $A['perm_owner'] = SEC_getPermissionValue($T['perm_owner']);
                $A['perm_group'] = SEC_getPermissionValue($T['perm_group']);
                $A['perm_members'] = SEC_getPermissionValue($T['perm_members']);
                $A['perm_anon'] = SEC_getPermissionValue($T['perm_anon']);
            } else {
                SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
            }
        }
        $access = 3;
    }
    // display the topic editor
    $topic_templates = new Template($_CONF['path_layout'] . 'admin/topic');
    $topic_templates->set_file('editor', 'topiceditor.thtml');
    // generate input for topic id
    if (!empty($topicEdit) && SEC_hasRights('topic.edit')) {
        $tid_input = $tid . '<input type="hidden" size="20" maxlength="128" name="tid" value="' . $tid . '"' . XHTML . '>';
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return doubleconfirm(\'' . $LANG27[40] . '\',\'' . $LANG27[6] . '\');"';
        $topic_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $topic_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $topic_templates->clear_var('lang_donotusespaces');
    } else {
        $tid_input = '<input class="required alphanumeric" type="text" size="20" maxlength="128" name="tid" id="tid" value="' . $tid . '"' . XHTML . '>';
        $topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
    }
    $topic_templates->set_var('tid_input', $tid_input);
    $topic_templates->set_var('lang_topicid', $LANG27[2]);
    $topic_templates->set_var('topic_id', $A['tid']);
    $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $topic_templates->set_var('owner_name', $ownername);
    $topic_templates->set_var('owner', $ownername);
    $topic_templates->set_var('owner_id', $A['owner_id']);
    $topic_templates->set_var('owner_dropdown', COM_buildOwnerList('owner_id', $A['owner_id']));
    $topic_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $topic_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $sort_select = '<select id="sortnum" name="sortnum">' . LB;
    $sort_select .= '<option value="0">' . 'First Position' . '</option>' . LB;
    $result = DB_query("SELECT tid,topic,sortnum FROM {$_TABLES['topics']} ORDER BY sortnum ASC");
    if ($topicEdit == 1) {
        $testvar = 10;
    } else {
        $testvar = 0;
    }
    $order = 10;
    while ($row = DB_fetchArray($result)) {
        if ($row['tid'] != $tid) {
            $test_sortnum = $order + $testvar;
            $sort_select .= '<option value="' . $row['tid'] . '"' . ($A['sortnum'] == $test_sortnum ? ' selected="selected"' : '') . '>' . $row['topic'] . ' (' . $row['tid'] . ')' . '</option>' . LB;
        }
        $order += 10;
    }
    $sort_select .= '</select>' . LB;
    // show sort order only if they specified sortnum as the sort method
    if ($_CONF['sortmethod'] != 'alpha') {
        $topic_templates->set_var('lang_sortorder', $LANG27[41]);
        if ($A['sortnum'] == 0) {
            $A['sortnum'] = '';
        }
        $topic_templates->set_var('sort_order', $sort_select);
    } else {
        $topic_templates->set_var('lang_sortorder', $LANG27[14]);
        $topic_templates->set_var('sort_order', $LANG27[15]);
    }
    $topic_templates->set_var('lang_storiesperpage', $LANG27[11]);
    if ($A['limitnews'] == 0) {
        $topic_templates->set_var('story_limit', '');
    } else {
        $topic_templates->set_var('story_limit', $A['limitnews']);
    }
    $topic_templates->set_var('default_limit', $_CONF['limitnews']);
    $topic_templates->set_var('lang_defaultis', $LANG27[16]);
    $topic_templates->set_var('lang_topicname', $LANG27[3]);
    $topic_templates->set_var('topic_name', htmlentities($A['topic']));
    if (empty($A['tid'])) {
        $A['imageurl'] = '/images/topics/';
    }
    $topic_templates->set_var('lang_topicimage', $LANG27[4]);
    $topic_templates->set_var('lang_uploadimage', $LANG27[27]);
    $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']);
    $topic_templates->set_var('lang_maxsize', $LANG27[28]);
    $topic_templates->set_var('max_url_length', 255);
    $topic_templates->set_var('image_url', $A['imageurl']);
    if (@getimagesize($_CONF['path_html'] . $A['imageurl']) !== false) {
        $topic_templates->set_var('topicimage', $_CONF['site_url'] . $A['imageurl']);
    }
    $topic_templates->set_var('lang_defaulttopic', $LANG27[22]);
    $topic_templates->set_var('lang_defaulttext', $LANG27[23]);
    if ($A['is_default'] == 1) {
        $topic_templates->set_var('default_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('default_checked', '');
    }
    $topic_templates->set_var('lang_sort_story_by', $LANG27[35]);
    $topic_templates->set_var('lang_sort_story_dir', $LANG27[36]);
    $sortSelect = '<select name="sort_by" id="sort_by">' . LB;
    $sortSelect .= '<option value="0"' . ($A['sort_by'] == 0 ? ' selected="selected"' : '') . '>' . $LANG27[30] . '</option>' . LB;
    $sortSelect .= '<option value="1"' . ($A['sort_by'] == 1 ? ' selected="selected"' : '') . '>' . $LANG27[31] . '</option>' . LB;
    $sortSelect .= '<option value="2"' . ($A['sort_by'] == 2 ? ' selected="selected"' : '') . '>' . $LANG27[32] . '</option>' . LB;
    $sortSelect .= '</select>' . LB;
    $topic_templates->set_var('story_sort_select', $sortSelect);
    $sort_dir = '<select name="sort_dir" id="sort_dir">' . LB;
    $sort_dir .= '<option value="ASC"' . ($A['sort_dir'] == 'ASC' ? ' selected="selected"' : '') . '>' . $LANG27[33] . '</option>' . LB;
    $sort_dir .= '<option value="DESC"' . ($A['sort_dir'] == 'DESC' ? ' selected="selected"' : '') . '>' . $LANG27[34] . '</option>' . LB;
    $sort_dir .= '</select>';
    $topic_templates->set_var('story_sort_dir', $sort_dir);
    $topic_templates->set_var('lang_archivetopic', $LANG27[25]);
    $topic_templates->set_var('lang_archivetext', $LANG27[26]);
    $topic_templates->set_var('archive_disabled', '');
    if ($A['archive_flag'] == 1) {
        $topic_templates->set_var('archive_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('archive_checked', '');
        // Only 1 topic can be the archive topic - so check if there already is one
        if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) {
            $topic_templates->set_var('archive_disabled', 'disabled');
        }
    }
    $assoc_stories = ($assoc_stories_published > 0 or $assoc_stories_draft > 0 or $assoc_stories_submitted > 0 or $assoc_images > 0 or $assoc_comments > 0 or $assoc_trackbacks > 0);
    if ($assoc_blocks > 0 or $assoc_feeds > 0 or $assoc_stories) {
        $topic_templates->set_var('lang_assoc_objects', $LANG27[43]);
        if ($assoc_stories_published > 0) {
            $topic_templates->set_var('lang_assoc_stories_published', $LANG27[44]);
            $topic_templates->set_var('assoc_stories_published', $assoc_stories_published);
            $topic_templates->set_var('published_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php'));
        }
        if ($assoc_stories_draft > 0) {
            $topic_templates->set_var('lang_assoc_stories_draft', $LANG27[45]);
            $topic_templates->set_var('assoc_stories_draft', $assoc_stories_draft);
            $topic_templates->set_var('draft_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php'));
        }
        if ($assoc_stories_submitted > 0) {
            $topic_templates->set_var('lang_assoc_stories_submitted', $LANG27[46]);
            $topic_templates->set_var('assoc_stories_submitted', $assoc_stories_submitted);
            $topic_templates->set_var('moderation_link', COM_createLink($LANG27[53], $_CONF['site_admin_url'] . '/moderation.php'));
        }
        if ($assoc_images > 0) {
            $topic_templates->set_var('lang_assoc_images', $LANG27[47]);
            $topic_templates->set_var('assoc_images', $assoc_images);
        }
        if ($assoc_comments > 0) {
            $topic_templates->set_var('lang_assoc_comments', $LANG27[48]);
            $topic_templates->set_var('assoc_comments', $assoc_comments);
        }
        if ($assoc_trackbacks > 0) {
            $topic_templates->set_var('lang_assoc_trackbacks', $LANG27[49]);
            $topic_templates->set_var('assoc_trackbacks', $assoc_trackbacks);
        }
        if ($assoc_blocks > 0) {
            $topic_templates->set_var('lang_assoc_blocks', $LANG27[50]);
            $topic_templates->set_var('assoc_blocks', $assoc_blocks);
            $topic_templates->set_var('block_admin_link', COM_createLink($LANG27[54], $_CONF['site_admin_url'] . '/block.php'));
        }
        if ($assoc_feeds > 0) {
            $topic_templates->set_var('lang_assoc_feeds', $LANG27[51]);
            $topic_templates->set_var('assoc_feeds', $assoc_feeds);
            $topic_templates->set_var('syndication_admin_link', COM_createLink($LANG27[55], $_CONF['site_admin_url'] . '/syndication.php'));
        }
    }
    $topic_templates->set_var('gltoken_name', CSRF_TOKEN);
    $topic_templates->set_var('gltoken', SEC_createToken());
    $topic_templates->parse('output', 'editor');
    if ($msg != '') {
        $retval .= COM_showMessageText($msg);
    }
    $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/topic.php', 'text' => $LANG_ADMIN['topic_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= ADMIN_createMenu($menu_arr, $LANG27[57], $_CONF['layout_url'] . '/images/icons/topic.' . $_IMAGE_TYPE);
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #19
0
/**
* When the install went through, give the plugin a chance for any
* plugin-specific post-install fixes
*
* @return   boolean     true = proceed with install, false = an error occured
*
*/
function plugin_postinstall_calendar()
{
    global $_CONF, $_TABLES, $LANG_CAL_1;
    require_once $_CONF['path'] . 'plugins/calendar/functions.inc';
    // fix Upcoming Events block group ownership
    $blockAdminGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'");
    if ($blockAdminGroup > 0) {
        // set the block's permissions
        $A = array();
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        // set the block's title in the current language, while we're at it
        $title = 'Upcoming Events';
        // ... and make it the last block on the left side
        $result = DB_query("SELECT MAX(blockorder) FROM {$_TABLES['blocks']} WHERE onleft = 1");
        list($order) = DB_fetchArray($result);
        $order += 10;
        DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$blockAdminGroup}, title = '{$title}', blockorder = {$order}, perm_owner = {$A['perm_owner']}, perm_group = {$A['perm_group']}, perm_members = {$A['perm_members']}, perm_anon = {$A['perm_anon']} WHERE (type = 'phpblock') AND (phpblockfn = 'phpblock_calendar')");
        return true;
    }
    return false;
}
Exemple #20
0
/**
* Displays the Auto Tag Editor
*
* @tag          string      tag to edit
* @mode         string      Mode
*
*/
function autotagseditor($tag, $mode = '')
{
    global $_TABLES, $_USER, $_GROUPS, $_AUTO_CONF;
    if (!empty($tag) && $mode == 'edit') {
        $query = DB_query("SELECT * FROM {$_TABLES['autotags']} WHERE tag = '{$tag}'");
        $A = DB_fetchArray($query);
        $A['old_tag'] = $A['tag'];
    } elseif ($mode == 'edit') {
        $A['tag'] = '';
        $A['old_tag'] = '';
        $A['is_enabled'] = '0';
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Autotags Admin'])) {
            $A['group_id'] = $_GROUPS['Autotags Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('autotags.edit');
        }
        SEC_setDefaultPermissions($A, $_AUTO_CONF['default_autotag_permissions']);
    } else {
        $A = $_POST;
        $A['tag'] = COM_applyFilter($A['tag']);
    }
    return form($A);
}
Exemple #21
0
/**
* Shows the block editor
*
* This will show a block edit form.  If this is a Geeklog default block it will
* send it off to editdefaultblock.
*
* @param    string  $bid    ID of block to edit
* @return   string          HTML for block editor
*
*/
function editblock($bid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG01, $LANG21, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS;
    $retval = '';
    if (!empty($bid)) {
        $sql['mysql'] = "SELECT * FROM {$_TABLES['blocks']} WHERE bid ='{$bid}'";
        $sql['mssql'] = "SELECT bid, is_enabled, name, type, title, blockorder, cast(content as text) as content, rdfurl, ";
        $sql['mssql'] .= "rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id,group_id, ";
        $sql['mssql'] .= "perm_owner, perm_group, perm_members, perm_anon, allow_autotags, cache_time FROM {$_TABLES['blocks']} WHERE bid ='{$bid}'";
        $sql['pgsql'] = "SELECT * FROM {$_TABLES['blocks']} WHERE bid ='{$bid}'";
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 2 || $access == 0 || TOPIC_hasMultiTopicAccess('block', $bid) < 3) {
            $retval .= COM_showMessageText($LANG21[45], $LANG_ACCESS['accessdenied']);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit block {$bid}.");
            return $retval;
        }
        if ($A['type'] == 'gldefault') {
            $retval .= editdefaultblock($A, $access);
            return $retval;
        }
    } else {
        $A['bid'] = 0;
        $A['is_enabled'] = 1;
        $A['name'] = '';
        $A['type'] = 'normal';
        $A['title'] = '';
        $A['tid'] = '';
        $A['blockorder'] = 0;
        $A['cache_time'] = $_CONF['default_cache_time_block'];
        $A['content'] = '';
        $A['allow_autotags'] = 0;
        $A['rdfurl'] = '';
        $A['rdfupdated'] = '';
        $A['rdflimit'] = 0;
        $A['onleft'] = 0;
        $A['phpblockfn'] = '';
        $A['help'] = '';
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Block Admin'])) {
            $A['group_id'] = $_GROUPS['Block Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('block.edit');
        }
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        $access = 3;
        if ($_POST['mode'] == $LANG_ADMIN['save'] && !empty($LANG_ADMIN['save'])) {
            overridePostdata($A);
        }
    }
    $token = SEC_createToken();
    $block_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/block');
    $block_templates->set_file('editor', 'blockeditor.thtml');
    $block_start = COM_startBlock($LANG21[3], '', COM_getBlockTemplate('_admin_block', 'header'));
    $block_start .= LB . SEC_getTokenExpiryNotice($token);
    $block_templates->set_var('start_block_editor', $block_start);
    if (!empty($bid) && SEC_hasrights('block.delete')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $block_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $block_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $block_templates->set_var('allow_delete', true);
        $block_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $block_templates->set_var('confirm_message', $MESSAGE[76]);
    }
    $block_templates->set_var('block_bid', $A['bid']);
    // standard Admin strings
    $block_templates->set_var('lang_blocktitle', $LANG_ADMIN['title']);
    $block_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']);
    $block_templates->set_var('lang_blockhelpurl', $LANG_ADMIN['help_url']);
    $block_templates->set_var('lang_topic', $LANG_ADMIN['topic']);
    $block_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $block_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $block_templates->set_var('lang_blocktype', $LANG_ADMIN['type']);
    $block_templates->set_var('lang_allowed_html', $LANG01[123]);
    $block_templates->set_var('block_title', stripslashes($A['title']));
    $block_templates->set_var('lang_enabled', $LANG21[53]);
    if ($A['is_enabled'] == 1) {
        $block_templates->set_var('is_enabled', 'checked="checked"');
    } else {
        $block_templates->set_var('is_enabled', '');
    }
    $block_templates->set_var('block_help', $A['help']);
    $block_templates->set_var('lang_includehttp', $LANG21[51]);
    $block_templates->set_var('lang_explanation', $LANG21[52]);
    $block_templates->set_var('block_name', $A['name']);
    $block_templates->set_var('lang_blockname', $LANG21[48]);
    $block_templates->set_var('lang_nospaces', $LANG21[49]);
    $block_templates->set_var('topic_selection', TOPIC_getTopicSelectionControl('block', $A['bid'], true, true));
    $block_templates->set_var('lang_side', $LANG21[39]);
    $block_templates->set_var('lang_left', $LANG21[40]);
    $block_templates->set_var('lang_right', $LANG21[41]);
    if ($A['onleft'] == 1) {
        $block_templates->set_var('left_selected', 'selected="selected"');
    } elseif ($A['onleft'] == 0) {
        $block_templates->set_var('right_selected', 'selected="selected"');
    }
    $block_templates->set_var('lang_blockorder', $LANG21[9]);
    $block_templates->set_var('block_order', $A['blockorder']);
    $block_templates->set_var('lang_normalblock', $LANG21[12]);
    $block_templates->set_var('lang_phpblock', $LANG21[27]);
    $block_templates->set_var('lang_portalblock', $LANG21[11]);
    if ($A['type'] == 'normal') {
        $block_templates->set_var('normal_selected', 'selected="selected"');
    } elseif ($A['type'] == 'phpblock') {
        $block_templates->set_var('php_selected', 'selected="selected"');
    } elseif ($A['type'] == 'portal') {
        $block_templates->set_var('portal_selected', 'selected="selected"');
    }
    $block_templates->set_var('lang_cachetime', $LANG21['cache_time']);
    $block_templates->set_var('lang_cachetime_desc', $LANG21['cache_time_desc']);
    $block_templates->set_var('cache_time', $A['cache_time']);
    $block_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $block_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $block_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = '{$A['owner_id']}'"));
    $block_templates->set_var('owner_name', $ownername);
    $block_templates->set_var('owner', $ownername);
    $block_templates->set_var('owner_id', $A['owner_id']);
    $block_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $block_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $block_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $block_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $block_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $block_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $block_templates->set_var('lang_phpblockoptions', $LANG21[28]);
    $block_templates->set_var('lang_blockfunction', $LANG21[29]);
    $block_templates->set_var('block_phpblockfn', $A['phpblockfn']);
    $block_templates->set_var('lang_phpblockwarning', $LANG21[30]);
    $block_templates->set_var('lang_portalblockoptions', $LANG21[13]);
    $block_templates->set_var('lang_rdfurl', $LANG21[14]);
    $block_templates->set_var('max_url_length', 255);
    $block_templates->set_var('block_rdfurl', $A['rdfurl']);
    $block_templates->set_var('lang_rdflimit', $LANG21[62]);
    $block_templates->set_var('block_rdflimit', $A['rdflimit']);
    $block_templates->set_var('lang_lastrdfupdate', $LANG21[15]);
    if ($A['rdfupdated'] == '0000-00-00 00:00:00') {
        $block_templates->set_var('block_rdfupdated', '');
    } else {
        $block_templates->set_var('block_rdfupdated', $A['rdfupdated']);
    }
    $block_templates->set_var('lang_normalblockoptions', $LANG21[16]);
    $block_templates->set_var('lang_blockcontent', $LANG21[17]);
    $block_templates->set_var('lang_autotags', $LANG21[66]);
    $block_templates->set_var('lang_use_autotags', $LANG21[67]);
    $content = htmlspecialchars(stripslashes($A['content']));
    $content = str_replace(array('{', '}'), array('&#123;', '&#125;'), $content);
    $block_templates->set_var('block_content', $content);
    if ($A['allow_autotags'] == 1) {
        $block_templates->set_var('allow_autotags', 'checked="checked"');
    } else {
        $block_templates->set_var('allow_autotags', '');
    }
    $block_templates->set_var('gltoken_name', CSRF_TOKEN);
    $block_templates->set_var('gltoken', $token);
    $block_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $block_templates->parse('output', 'editor');
    $retval .= $block_templates->finish($block_templates->get_var('output'));
    // Shows/Hides relevant block options dynamically
    $_SCRIPTS->setJavaScript("\njQuery(function () {\n    var \$ = jQuery;\n    \$('#admin-blockeditor-type').on('change', function () {\n        var fs, i, fieldsets = ['normal', 'phpblock', 'portal'];\n\n        for (i = 0; i < 3; i++) {\n            if (this.value === fieldsets[i]) {\n                \$('#fs-' + fieldsets[i] + '-options').show();\n            } else {\n                \$('#fs-' + fieldsets[i] + '-options').hide();\n            }\n        }\n    })\n    .trigger('change');\n});", true, true);
    return $retval;
}
Exemple #22
0
/**
* Shows event editor
*
* @param    string  $action action we are performing: 'edit', 'clone' or 'moderate'
* @param    array   $A      array holding the event's details
* @param    string  $msg    an optional error message to display
* @return   string          HTML for event editor or error message
*
*/
function CALENDAR_edit($action, $A, $msg = '')
{
    global $_CONF, $_USER, $_GROUPS, $_TABLES, $_USER, $_CA_CONF, $LANG_CAL_1, $LANG_CAL_ADMIN, $LANG10, $LANG12, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE;
    USES_lib_admin();
    $retval = '';
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/calendar/index.php', 'text' => $LANG_CAL_ADMIN[40]), array('url' => $_CONF['site_admin_url'] . '/moderation.php', 'text' => $LANG_ADMIN['submissions']), array('url' => $_CONF['site_admin_url'] . '/plugins/calendar/index.php?batchadmin=x', 'text' => $LANG_CAL_ADMIN[38]), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    switch ($action) {
        case 'edit':
        case 'clone':
            $blocktitle = $LANG_CAL_ADMIN[1];
            // Event Editor
            $saveoption = $LANG_ADMIN['save'];
            // Save
            break;
        case 'moderate':
            $blocktitle = $LANG_CAL_ADMIN[37];
            // Moderate Event
            $saveoption = $LANG_ADMIN['moderate'];
            // Save & Approve
            break;
    }
    if (!empty($msg)) {
        $retval .= COM_showMessageText($msg, $LANG_CAL_ADMIN[2], true);
    }
    $event_templates = new Template($_CONF['path'] . 'plugins/calendar/templates/admin');
    $event_templates->set_file('editor', 'eventeditor.thtml');
    $event_templates->set_var('lang_allowed_html', COM_allowedHTML(SEC_getUserPermissions(), false, 'calendar', 'description'));
    $event_templates->set_var('lang_postmode', $LANG_CAL_ADMIN[3]);
    if (!isset($A['perm_owner'])) {
        $A['perm_owner'][0] = "0";
    }
    if (!isset($A['perm_group'])) {
        $A['perm_group'][0] = "0";
    }
    if (!isset($A['perm_members'])) {
        $A['perm_members'][0] = "0";
    }
    if (!isset($A['perm_anon'])) {
        $A['perm_anon'][0] = "0";
    }
    if ($action != 'moderate' and !empty($A['eid'])) {
        // Get what level of access user has to this object
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            // Uh, oh!  User doesn't have access to this object
            $retval .= COM_showMessageText($LANG_CAL_ADMIN[17], $LANG_ACCESS['accessdenied'], true);
            COM_accessLog("User {$_USER['username']} tried to illegally submit or edit event {$eid}.");
            return $retval;
        }
    } else {
        if (!isset($A['owner_id']) || $A['owner_id'] == '') {
            $A['owner_id'] = $_USER['uid'];
        }
        if (isset($_GROUPS['Calendar Admin'])) {
            $A['group_id'] = $_GROUPS['Calendar Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('calendar.edit');
        }
        SEC_setDefaultPermissions($A, $_CA_CONF['default_permissions']);
        $access = 3;
    }
    if ($action == 'moderate') {
        $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'], 'code,name', 'plaintext'));
    } else {
        if (!isset($A['postmode'])) {
            $A['postmode'] = $_CONF['postmode'];
        }
        $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'], 'code,name', $A['postmode']));
    }
    $retval .= COM_startBlock($blocktitle, '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_CAL_ADMIN[41], plugin_geticon_calendar());
    if (!empty($A['eid'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s/>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $event_templates->set_var('lang_delete_confirm', $MESSAGE[76]);
        $event_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $event_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        if ($action == 'moderate') {
            $event_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"/>');
        }
    } else {
        // new event
        $A['eid'] = COM_makesid();
        $A['status'] = 1;
        $A['title'] = '';
        $A['description'] = '';
        $A['url'] = '';
        $A['hits'] = 0;
        // in case a start date/time has been passed from the calendar,
        // pick it up for the end date/time
        if (empty($A['dateend'])) {
            $A['dateend'] = $A['datestart'];
        }
        if (empty($A['timeend'])) {
            $A['timeend'] = $A['timestart'];
        }
        $A['event_type'] = '';
        $A['location'] = '';
        $A['address1'] = '';
        $A['address2'] = '';
        $A['city'] = '';
        $A['state'] = '';
        $A['zipcode'] = '';
        $A['allday'] = 0;
    }
    $event_templates->set_var('event_id', $A['eid']);
    $event_templates->set_var('lang_eventtitle', $LANG_ADMIN['title']);
    $A['title'] = str_replace('{', '&#123;', $A['title']);
    $A['title'] = str_replace('}', '&#125;', $A['title']);
    $A['title'] = str_replace('"', '&quot;', $A['title']);
    $event_templates->set_var('event_title', $A['title']);
    $event_templates->set_var('lang_eventtype', $LANG_CAL_1[37]);
    $event_templates->set_var('lang_editeventtypes', $LANG12[50]);
    $event_templates->set_var('type_options', CALENDAR_eventTypeList($A['event_type']));
    $event_templates->set_var('status_checked', $A['status'] == 1 ? ' checked="checked"' : '');
    $event_templates->set_var('lang_eventurl', $LANG_CAL_ADMIN[4]);
    $event_templates->set_var('max_url_length', 255);
    $event_templates->set_var('event_url', $A['url']);
    $event_templates->set_var('lang_includehttp', $LANG_CAL_ADMIN[9]);
    $event_templates->set_var('lang_eventstartdate', $LANG_CAL_ADMIN[5]);
    //$event_templates->set_var('event_startdate', $A['datestart']);
    $event_templates->set_var('lang_starttime', $LANG_CAL_1[30]);
    // Combine date/time for easier manipulation
    $A['datestart'] = trim($A['datestart'] . ' ' . $A['timestart']);
    if (empty($A['datestart'])) {
        $start_stamp = time();
    } else {
        $start_stamp = strtotime($A['datestart']);
    }
    $A['dateend'] = trim($A['dateend'] . ' ' . $A['timeend']);
    if (empty($A['dateend'])) {
        $end_stamp = time();
    } else {
        $end_stamp = strtotime($A['dateend']);
    }
    $start_month = date('m', $start_stamp);
    $start_day = date('d', $start_stamp);
    $start_year = date('Y', $start_stamp);
    $end_month = date('m', $end_stamp);
    $end_day = date('d', $end_stamp);
    $end_year = date('Y', $end_stamp);
    $start_hour = date('H', $start_stamp);
    $start_minute = intval(date('i', $start_stamp) / 15) * 15;
    if ($start_hour >= 12) {
        $startampm = 'pm';
    } else {
        $startampm = 'am';
    }
    $start_hour_24 = $start_hour % 24;
    if ($start_hour > 12) {
        $start_hour = $start_hour - 12;
    } else {
        if ($start_hour == 0) {
            $start_hour = 12;
        }
    }
    $end_hour = date('H', $end_stamp);
    $end_minute = intval(date('i', $end_stamp) / 15) * 15;
    if ($end_hour >= 12) {
        $endampm = 'pm';
    } else {
        $endampm = 'am';
    }
    $end_hour_24 = $end_hour % 24;
    if ($end_hour > 12) {
        $end_hour = $end_hour - 12;
    } else {
        if ($end_hour == 0) {
            $end_hour = 12;
        }
    }
    $month_options = COM_getMonthFormOptions($start_month);
    $event_templates->set_var('startmonth_options', $month_options);
    $month_options = COM_getMonthFormOptions($end_month);
    $event_templates->set_var('endmonth_options', $month_options);
    $day_options = COM_getDayFormOptions($start_day);
    $event_templates->set_var('startday_options', $day_options);
    $day_options = COM_getDayFormOptions($end_day);
    $event_templates->set_var('endday_options', $day_options);
    $year_options = COM_getYearFormOptions($start_year);
    $event_templates->set_var('startyear_options', $year_options);
    $year_options = COM_getYearFormOptions($end_year);
    $event_templates->set_var('endyear_options', $year_options);
    if (isset($_CA_CONF['hour_mode']) && $_CA_CONF['hour_mode'] == 24) {
        $hour_options = COM_getHourFormOptions($start_hour_24, 24);
        $event_templates->set_var('starthour_options', $hour_options);
        $hour_options = COM_getHourFormOptions($end_hour_24, 24);
        $event_templates->set_var('endhour_options', $hour_options);
        $event_templates->set_var('hour_mode', 24);
    } else {
        $hour_options = COM_getHourFormOptions($start_hour);
        $event_templates->set_var('starthour_options', $hour_options);
        $hour_options = COM_getHourFormOptions($end_hour);
        $event_templates->set_var('endhour_options', $hour_options);
        $event_templates->set_var('hour_mode', 12);
    }
    $event_templates->set_var('startampm_selection', CALENDAR_getAmPmFormSelection('start_ampm', $startampm, 'update_ampm()'));
    $event_templates->set_var('endampm_selection', CALENDAR_getAmPmFormSelection('end_ampm', $endampm));
    $event_templates->set_var('startminute_options', COM_getMinuteFormOptions($start_minute, 15));
    $event_templates->set_var('endminute_options', COM_getMinuteFormOptions($end_minute, 15));
    $event_templates->set_var('lang_enddate', $LANG12[13]);
    $event_templates->set_var('lang_eventenddate', $LANG_CAL_ADMIN[6]);
    $event_templates->set_var('event_enddate', $A['dateend']);
    $event_templates->set_var('lang_enddate', $LANG12[13]);
    $event_templates->set_var('lang_endtime', $LANG_CAL_1[29]);
    $event_templates->set_var('lang_alldayevent', $LANG_CAL_1[31]);
    if ($A['allday'] == 1) {
        $event_templates->set_var('allday_checked', 'checked="checked"');
    }
    $event_templates->set_var('lang_location', $LANG12[51]);
    $event_templates->set_var('event_location', $A['location']);
    $event_templates->set_var('lang_addressline1', $LANG12[44]);
    $event_templates->set_var('event_address1', $A['address1']);
    $event_templates->set_var('lang_addressline2', $LANG12[45]);
    $event_templates->set_var('event_address2', $A['address2']);
    $event_templates->set_var('lang_city', $LANG12[46]);
    $event_templates->set_var('event_city', $A['city']);
    $event_templates->set_var('lang_state', $LANG12[47]);
    $event_templates->set_var('state_options', '');
    $event_templates->set_var('event_state', $A['state']);
    $event_templates->set_var('lang_zipcode', $LANG12[48]);
    $event_templates->set_var('event_zipcode', $A['zipcode']);
    $event_templates->set_var('lang_eventlocation', $LANG_CAL_ADMIN[7]);
    $event_templates->set_var('event_location', $A['location']);
    $event_templates->set_var('lang_eventdescription', $LANG_CAL_ADMIN[8]);
    $event_templates->set_var('event_description', $A['description']);
    $event_templates->set_var('lang_hits', $LANG10[30]);
    $event_templates->set_var('hits', COM_numberFormat($A['hits']));
    $event_templates->set_var('lang_save', $saveoption);
    $event_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    // user access info
    $event_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $event_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $event_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $event_templates->set_var('owner_name', $ownername);
    $event_templates->set_var('owner', $ownername);
    $event_templates->set_var('owner_id', $A['owner_id']);
    $event_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $event_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $event_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $event_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $event_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $event_templates->set_var('gltoken_name', CSRF_TOKEN);
    $event_templates->set_var('gltoken', SEC_createToken());
    $event_templates->parse('output', 'editor');
    $retval .= $event_templates->finish($event_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #23
0
/**
* Displays the static page form
*
* @param    array   $A      Data to display
* @param    string  $error  Error message to display
*
*/
function PAGE_form($A, $error = false)
{
    global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SP_CONF, $action, $sp_id, $LANG21, $LANG_STATIC, $LANG_ACCESS, $LANG_ADMIN, $LANG24, $LANG_postmodes, $MESSAGE;
    USES_lib_admin();
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/staticpages/index.php', 'text' => $LANG_STATIC['page_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $template_path = staticpages_templatePath('admin');
    if (!empty($sp_id) && ($action == 'edit' || $action == 'clone')) {
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['staticpages Admin'])) {
            $A['group_id'] = $_GROUPS['staticpages Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('staticpages.edit');
        }
        SEC_setDefaultPermissions($A, $_SP_CONF['default_permissions']);
        $access = 3;
    }
    $retval = '';
    if (empty($A['owner_id'])) {
        $error = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header'));
        $error .= $LANG_STATIC['deny_msg'];
        $error .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
    }
    if ($error) {
        $retval .= $error . '<br/><br/>';
    } else {
        $sp_template = new Template($template_path);
        $sp_template->set_file('form', 'editor.thtml');
        $sp_template->set_var('lang_mode', $LANG24[3]);
        $sp_template->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $A['commentcode']));
        $ownername = COM_getDisplayName($A['owner_id']);
        $sp_template->set_var(array('sp_search_checked' => $A['sp_search'] == 1 ? ' checked="checked"' : '', 'sp_status_checked' => $A['sp_status'] == 1 ? ' checked="checked"' : '', 'lang_accessrights' => $LANG_ACCESS['accessrights'], 'lang_owner' => $LANG_ACCESS['owner'], 'owner_username' => DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"), 'owner_name' => $ownername, 'owner' => $ownername, 'owner_id' => $A['owner_id'], 'lang_group' => $LANG_ACCESS['group'], 'group_dropdown' => SEC_getGroupDropdown($A['group_id'], $access), 'permissions_editor' => SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']), 'lang_permissions' => $LANG_ACCESS['permissions'], 'lang_perm_key' => $LANG_ACCESS['permissionskey'], 'permissions_msg' => $LANG_ACCESS['permmsg'], 'start_block_editor' => COM_startBlock($LANG_STATIC['staticpages'] . ' :: ' . $LANG_STATIC['staticpageeditor'], '', COM_getBlockTemplate('_admin_block', 'header')), 'lang_save' => $LANG_ADMIN['save'], 'lang_cancel' => $LANG_ADMIN['cancel'], 'lang_preview' => $LANG_ADMIN['preview'], 'lang_editor' => $LANG_STATIC['staticpageeditor'], 'lang_attributes' => $LANG_STATIC['attributes']));
        if (SEC_hasRights('staticpages.delete') && $action != 'clone' && !empty($A['sp_old_id'])) {
            $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s/>';
            $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
            $sp_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
            $sp_template->set_var('delete_button', true);
            $sp_template->set_var('lang_delete_confirm', $MESSAGE[76]);
            $sp_template->set_var('lang_delete', $LANG_ADMIN['delete']);
            $sp_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        } else {
            $sp_template->set_var('delete_option', '');
        }
        $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
        $sp_template->set_var('username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['sp_uid']}"));
        $authorname = COM_getDisplayName($A['sp_uid']);
        $sp_template->set_var('name', $authorname);
        $sp_template->set_var('author', $authorname);
        $sp_template->set_var('lang_url', $LANG_STATIC['url']);
        $sp_template->set_var('lang_id', $LANG_STATIC['id']);
        $sp_template->set_var('sp_uid', $A['sp_uid']);
        $sp_template->set_var('sp_id', $A['sp_id']);
        $sp_template->set_var('sp_old_id', $A['sp_old_id']);
        $sp_template->set_var('example_url', COM_buildURL($_CONF['site_url'] . '/page.php?page=' . $A['sp_id']));
        $sp_template->set_var('lang_centerblock', $LANG_STATIC['centerblock']);
        $sp_template->set_var('lang_centerblock_help', $LANG_ADMIN['help_url']);
        $sp_template->set_var('lang_centerblock_include', $LANG21[51]);
        $sp_template->set_var('lang_centerblock_desc', $LANG21[52]);
        $sp_template->set_var('centerblock_help', $A['sp_help']);
        $sp_template->set_var('lang_centerblock_msg', $LANG_STATIC['centerblock_msg']);
        if (isset($A['sp_centerblock']) && $A['sp_centerblock'] == 1) {
            $sp_template->set_var('centerblock_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('centerblock_checked', '');
        }
        $sp_template->set_var('lang_topic', $LANG_STATIC['topic']);
        $sp_template->set_var('lang_position', $LANG_STATIC['position']);
        $current_topic = '';
        if (isset($A['sp_tid'])) {
            $current_topic = $A['sp_tid'];
        }
        if (empty($current_topic)) {
            $current_topic = 'none';
        }
        $topics = COM_topicList('tid,topic', $current_topic, 1, true);
        $alltopics = '<option value="all"';
        if ($current_topic == 'all') {
            $alltopics .= ' selected="selected"';
        }
        $alltopics .= '>' . $LANG_STATIC['all_topics'] . '</option>' . LB;
        $allnhp = '<option value="allnhp"';
        if ($current_topic == 'allnhp') {
            $allnhp .= ' selected="selected"';
        }
        $allnhp .= '>' . $LANG_STATIC['allnhp_topics'] . '</option>' . LB;
        $notopic = '<option value="none"';
        if ($current_topic == 'none') {
            $notopic .= ' selected="selected"';
        }
        $notopic .= '>' . $LANG_STATIC['no_topic'] . '</option>' . LB;
        $sp_template->set_var('topic_selection', '<select name="sp_tid">' . $alltopics . $allnhp . $notopic . $topics . '</select>');
        $position = '<select name="sp_where">';
        $position .= '<option value="1"';
        if ($A['sp_where'] == 1) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_top'] . '</option>';
        $position .= '<option value="2"';
        if ($A['sp_where'] == 2) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_feat'] . '</option>';
        $position .= '<option value="3"';
        if ($A['sp_where'] == 3) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_bottom'] . '</option>';
        $position .= '<option value="0"';
        if ($A['sp_where'] == 0) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_entire'] . '</option>';
        $position .= '<option value="4"';
        if ($A['sp_where'] == 4) {
            $position .= ' selected="selected"';
        }
        $position .= '>' . $LANG_STATIC['position_nonews'] . '</option>';
        $position .= '</select>';
        $sp_template->set_var('pos_selection', $position);
        if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP')) {
            if (!isset($A['sp_php'])) {
                $A['sp_php'] = 0;
            }
            $selection = '<select name="sp_php">' . LB;
            $selection .= '<option value="0"';
            if ($A['sp_php'] <= 0 || $A['sp_php'] > 2) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_none'] . '</option>' . LB;
            $selection .= '<option value="1"';
            if ($A['sp_php'] == 1) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_return'] . '</option>' . LB;
            $selection .= '<option value="2"';
            if ($A['sp_php'] == 2) {
                $selection .= ' selected="selected"';
            }
            $selection .= '>' . $LANG_STATIC['select_php_free'] . '</option>' . LB;
            $selection .= '</select>';
            $sp_template->set_var('php_selector', $selection);
            $sp_template->set_var('php_warn', $LANG_STATIC['php_warn']);
        } else {
            $sp_template->set_var('php_selector', '');
            $sp_template->set_var('php_warn', $LANG_STATIC['php_not_activated']);
        }
        $sp_template->set_var('php_msg', $LANG_STATIC['php_msg']);
        // old variables (for the 1.3-type checkbox)
        $sp_template->set_var('php_checked', '');
        $sp_template->set_var('php_type', 'hidden');
        if (isset($A['sp_nf']) && $A['sp_nf'] == 1) {
            $sp_template->set_var('exit_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('exit_checked', '');
        }
        $sp_template->set_var('exit_msg', $LANG_STATIC['exit_msg']);
        $sp_template->set_var('exit_info', $LANG_STATIC['exit_info']);
        if (isset($A['sp_inblock']) && $A['sp_inblock'] == 1) {
            $sp_template->set_var('inblock_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('inblock_checked', '');
        }
        $sp_template->set_var('inblock_msg', $LANG_STATIC['inblock_msg']);
        $sp_template->set_var('inblock_info', $LANG_STATIC['inblock_info']);
        $curtime = COM_getUserDateTimeFormat($A['unixdate']);
        $sp_template->set_var('lang_lastupdated', $LANG_STATIC['date']);
        $sp_template->set_var('sp_formateddate', $curtime[0]);
        $sp_template->set_var('sp_date', $curtime[1]);
        $sp_template->set_var('lang_title', $LANG_STATIC['title']);
        $title = '';
        if (isset($A['sp_title'])) {
            $title = htmlspecialchars($A['sp_title']);
        }
        $sp_template->set_var('sp_title', $title);
        $sp_template->set_var('lang_addtomenu', $LANG_STATIC['addtomenu']);
        if (isset($A['sp_onmenu']) && $A['sp_onmenu'] == 1) {
            $sp_template->set_var('onmenu_checked', 'checked="checked"');
        } else {
            $sp_template->set_var('onmenu_checked', '');
        }
        $sp_template->set_var('lang_label', $LANG_STATIC['label']);
        if (isset($A['sp_label'])) {
            $sp_template->set_var('sp_label', $A['sp_label']);
        } else {
            $sp_template->set_var('sp_label', '');
        }
        $sp_template->set_var('lang_pageformat', $LANG_STATIC['pageformat']);
        $sp_template->set_var('lang_blankpage', $LANG_STATIC['blankpage']);
        $sp_template->set_var('lang_noblocks', $LANG_STATIC['noblocks']);
        $sp_template->set_var('lang_leftblocks', $LANG_STATIC['leftblocks']);
        $sp_template->set_var('lang_rightblocks', $LANG_STATIC['rightblocks']);
        $sp_template->set_var('lang_leftrightblocks', $LANG_STATIC['leftrightblocks']);
        if (!isset($A['sp_format'])) {
            $A['sp_format'] = '';
        }
        if ($A['sp_format'] == 'noblocks') {
            $sp_template->set_var('noblock_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('noblock_selected', '');
        }
        if ($A['sp_format'] == 'leftblocks') {
            $sp_template->set_var('leftblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('leftblocks_selected', '');
        }
        if ($A['sp_format'] == 'rightblocks') {
            $sp_template->set_var('rightblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('rightblocks_selected', '');
        }
        if ($A['sp_format'] == 'blankpage') {
            $sp_template->set_var('blankpage_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('blankpage_selected', '');
        }
        if ($A['sp_format'] == 'allblocks' or empty($A['sp_format'])) {
            $sp_template->set_var('allblocks_selected', 'selected="selected"');
        } else {
            $sp_template->set_var('allblocks_selected', '');
        }
        $sp_template->set_var('lang_content', $LANG_STATIC['content']);
        $content = '';
        if (isset($A['sp_content'])) {
            $content = htmlspecialchars($A['sp_content']);
        }
        $sp_template->set_var('sp_content', $content);
        if ($_SP_CONF['filter_html'] == 1) {
            $sp_template->set_var('lang_allowedhtml', COM_allowedHTML(SEC_getUserPermissions(), false, 'staticpages', 'page'));
        } else {
            $sp_template->set_var('lang_allowedhtml', $LANG_STATIC['all_html_allowed']);
        }
        $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
        if (empty($A['sp_hits'])) {
            $sp_template->set_var('sp_hits', '0');
            $sp_template->set_var('sp_hits_formatted', '0');
        } else {
            $sp_template->set_var('sp_hits', $A['sp_hits']);
            $sp_template->set_var('sp_hits_formatted', COM_numberFormat($A['sp_hits']));
        }
        $sp_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
        $sp_template->set_var('owner_dropdown', COM_buildOwnerList('owner_id', $A['owner_id']));
        $sp_template->set_var('writtenby_dropdown', COM_buildOwnerList('sp_uid', $A['sp_uid']));
        $sp_template->set_var('gltoken_name', CSRF_TOKEN);
        $sp_template->set_var('gltoken', SEC_createToken());
        $sp_template->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG_STATIC['instructions_edit'], plugin_geticon_staticpages()));
        PLG_templateSetVars('sp_editor', $sp_template);
        $retval .= $sp_template->parse('output', 'form');
    }
    return $retval;
}
Exemple #24
0
/**
* Displays the static page editor form
*
* @param    array   $A  Data to display
* @return   string      HTML for the static page editor
*
*/
function staticpageeditor_form($A, $error = false)
{
    global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SP_CONF, $mode, $sp_id, $LANG21, $LANG_STATIC, $LANG_ACCESS, $LANG_ADMIN, $LANG24, $LANG_postmodes, $MESSAGE;
    $template_path = staticpages_templatePath('admin');
    if (!empty($sp_id) && $mode == 'edit') {
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        if ($mode != 'clone') {
            $A['sp_inblock'] = $_SP_CONF['in_block'];
        }
        $A['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Static Page Admin'])) {
            $A['group_id'] = $_GROUPS['Static Page Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('staticpages.edit');
        }
        SEC_setDefaultPermissions($A, $_SP_CONF['default_permissions']);
        $access = 3;
        if (isset($_CONF['advanced_editor']) && $_CONF['advanced_editor'] == 1 && file_exists($template_path . '/editor_advanced.thtml')) {
            $A['advanced_editor_mode'] = 1;
        }
    }
    $retval = '';
    $sp_template = new Template($template_path);
    if (isset($_CONF['advanced_editor']) && $_CONF['advanced_editor'] == 1 && file_exists($template_path . '/editor_advanced.thtml')) {
        $sp_template->set_file('form', 'editor_advanced.thtml');
        $sp_template->set_var('lang_expandhelp', $LANG24[67]);
        $sp_template->set_var('lang_reducehelp', $LANG24[68]);
        $sp_template->set_var('lang_toolbar', $LANG24[70]);
        $sp_template->set_var('toolbar1', $LANG24[71]);
        $sp_template->set_var('toolbar2', $LANG24[72]);
        $sp_template->set_var('toolbar3', $LANG24[73]);
        $sp_template->set_var('toolbar4', $LANG24[74]);
        $sp_template->set_var('toolbar5', $LANG24[75]);
        $sp_template->set_var('lang_nojavascript', $LANG24[77]);
        $sp_template->set_var('lang_postmode', $LANG24[4]);
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $sp_template->set_var('show_adveditor', '');
            $sp_template->set_var('show_htmleditor', 'none');
        } else {
            $sp_template->set_var('show_adveditor', 'none');
            $sp_template->set_var('show_htmleditor', '');
        }
        $post_options = '<option value="html" selected="selected">' . $LANG_postmodes['html'] . '</option>';
        if (isset($A['postmode']) && $A['postmode'] == 'adveditor') {
            $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>';
        } else {
            $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>';
        }
        $sp_template->set_var('post_options', $post_options);
        $sp_template->set_var('change_editormode', 'onchange="change_editmode(this);"');
    } else {
        $sp_template->set_file('form', 'editor.thtml');
    }
    $sp_template->set_var('layout_url', $_CONF['layout_url']);
    $sp_template->set_var('lang_mode', $LANG24[3]);
    $sp_template->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $A['commentcode']));
    $sp_template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $sp_template->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $sp_template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $sp_template->set_var('owner_name', $ownername);
    $sp_template->set_var('owner', $ownername);
    $sp_template->set_var('owner_id', $A['owner_id']);
    $sp_template->set_var('lang_group', $LANG_ACCESS['group']);
    $sp_template->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $sp_template->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $sp_template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $sp_template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $sp_template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $sp_template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $sp_template->set_var('site_url', $_CONF['site_url']);
    $sp_template->set_var('site_admin_url', $_CONF['site_admin_url']);
    $token = SEC_createToken();
    $start_block = COM_startBlock($LANG_STATIC['staticpageeditor'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $start_block .= SEC_getTokenExpiryNotice($token);
    $sp_template->set_var('start_block_editor', $start_block);
    $sp_template->set_var('lang_save', $LANG_ADMIN['save']);
    $sp_template->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $sp_template->set_var('lang_preview', $LANG_ADMIN['preview']);
    if (SEC_hasRights('staticpages.delete') && $mode != 'clone' && !empty($A['sp_old_id'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $sp_template->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $sp_template->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    } else {
        $sp_template->set_var('delete_option', '');
    }
    $sp_template->set_var('lang_writtenby', $LANG_STATIC['writtenby']);
    $sp_template->set_var('username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['sp_uid']}"));
    $authorname = COM_getDisplayName($A['sp_uid']);
    $sp_template->set_var('name', $authorname);
    $sp_template->set_var('author', $authorname);
    $sp_template->set_var('lang_url', $LANG_STATIC['url']);
    $sp_template->set_var('lang_id', $LANG_STATIC['id']);
    $sp_template->set_var('sp_uid', $A['sp_uid']);
    $sp_template->set_var('sp_id', $A['sp_id']);
    $sp_template->set_var('sp_old_id', $A['sp_old_id']);
    $sp_template->set_var('example_url', COM_buildURL($_CONF['site_url'] . '/staticpages/index.php?page=' . $A['sp_id']));
    $sp_template->set_var('lang_centerblock', $LANG_STATIC['centerblock']);
    $sp_template->set_var('lang_centerblock_help', $LANG_ADMIN['help_url']);
    $sp_template->set_var('lang_centerblock_include', $LANG21[51]);
    $sp_template->set_var('lang_centerblock_desc', $LANG21[52]);
    $sp_template->set_var('centerblock_help', $A['sp_help']);
    $sp_template->set_var('lang_centerblock_msg', $LANG_STATIC['centerblock_msg']);
    if (isset($A['sp_centerblock']) && $A['sp_centerblock'] == 1) {
        $sp_template->set_var('centerblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('centerblock_checked', '');
    }
    $sp_template->set_var('lang_topic', $LANG_STATIC['topic']);
    $sp_template->set_var('lang_position', $LANG_STATIC['position']);
    $current_topic = '';
    if (isset($A['sp_tid'])) {
        $current_topic = $A['sp_tid'];
    }
    if (empty($current_topic)) {
        $current_topic = 'none';
    }
    $topics = COM_topicList('tid,topic', $current_topic, 1, true);
    $alltopics = '<option value="all"';
    if ($current_topic == 'all') {
        $alltopics .= ' selected="selected"';
    }
    $alltopics .= '>' . $LANG_STATIC['all_topics'] . '</option>' . LB;
    $notopic = '<option value="none"';
    if ($current_topic == 'none') {
        $notopic .= ' selected="selected"';
    }
    $notopic .= '>' . $LANG_STATIC['no_topic'] . '</option>' . LB;
    $sp_template->set_var('topic_selection', '<select name="sp_tid">' . $alltopics . $notopic . $topics . '</select>');
    $position = '<select name="sp_where">';
    $position .= '<option value="1"';
    if ($A['sp_where'] == 1) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_top'] . '</option>';
    $position .= '<option value="2"';
    if ($A['sp_where'] == 2) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_feat'] . '</option>';
    $position .= '<option value="3"';
    if ($A['sp_where'] == 3) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_bottom'] . '</option>';
    $position .= '<option value="0"';
    if ($A['sp_where'] == 0) {
        $position .= ' selected="selected"';
    }
    $position .= '>' . $LANG_STATIC['position_entire'] . '</option>';
    $position .= '</select>';
    $sp_template->set_var('pos_selection', $position);
    if ($_SP_CONF['allow_php'] == 1 && SEC_hasRights('staticpages.PHP')) {
        if (!isset($A['sp_php'])) {
            $A['sp_php'] = 0;
        }
        $selection = '<select name="sp_php">' . LB;
        $selection .= '<option value="0"';
        if ($A['sp_php'] <= 0 || $A['sp_php'] > 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_none'] . '</option>' . LB;
        $selection .= '<option value="1"';
        if ($A['sp_php'] == 1) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_return'] . '</option>' . LB;
        $selection .= '<option value="2"';
        if ($A['sp_php'] == 2) {
            $selection .= ' selected="selected"';
        }
        $selection .= '>' . $LANG_STATIC['select_php_free'] . '</option>' . LB;
        $selection .= '</select>';
        $sp_template->set_var('php_selector', $selection);
        $sp_template->set_var('php_warn', $LANG_STATIC['php_warn']);
    } else {
        $sp_template->set_var('php_selector', '');
        $sp_template->set_var('php_warn', $LANG_STATIC['php_not_activated']);
    }
    $sp_template->set_var('php_msg', $LANG_STATIC['php_msg']);
    // old variables (for the 1.3-type checkbox)
    $sp_template->set_var('php_checked', '');
    $sp_template->set_var('php_type', 'hidden');
    if (isset($A['sp_nf']) && $A['sp_nf'] == 1) {
        $sp_template->set_var('exit_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('exit_checked', '');
    }
    $sp_template->set_var('exit_msg', $LANG_STATIC['exit_msg']);
    $sp_template->set_var('exit_info', $LANG_STATIC['exit_info']);
    if ($A['sp_inblock'] == 1) {
        $sp_template->set_var('inblock_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('inblock_checked', '');
    }
    $sp_template->set_var('inblock_msg', $LANG_STATIC['inblock_msg']);
    $sp_template->set_var('inblock_info', $LANG_STATIC['inblock_info']);
    $curtime = COM_getUserDateTimeFormat($A['unixdate']);
    $sp_template->set_var('lang_lastupdated', $LANG_STATIC['date']);
    $sp_template->set_var('sp_formateddate', $curtime[0]);
    $sp_template->set_var('sp_date', $curtime[1]);
    $sp_template->set_var('lang_title', $LANG_STATIC['title']);
    $title = '';
    if (isset($A['sp_title'])) {
        $title = htmlspecialchars(stripslashes($A['sp_title']));
    }
    $sp_template->set_var('sp_title', $title);
    $sp_template->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $sp_template->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $sp_template->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $sp_template->set_var('meta_keywords', $A['meta_keywords']);
    }
    $sp_template->set_var('lang_addtomenu', $LANG_STATIC['addtomenu']);
    if (isset($A['sp_onmenu']) && $A['sp_onmenu'] == 1) {
        $sp_template->set_var('onmenu_checked', 'checked="checked"');
    } else {
        $sp_template->set_var('onmenu_checked', '');
    }
    $sp_template->set_var('lang_label', $LANG_STATIC['label']);
    if (isset($A['sp_label'])) {
        $sp_template->set_var('sp_label', $A['sp_label']);
    } else {
        $sp_template->set_var('sp_label', '');
    }
    $sp_template->set_var('lang_pageformat', $LANG_STATIC['pageformat']);
    $sp_template->set_var('lang_blankpage', $LANG_STATIC['blankpage']);
    $sp_template->set_var('lang_noblocks', $LANG_STATIC['noblocks']);
    $sp_template->set_var('lang_leftblocks', $LANG_STATIC['leftblocks']);
    $sp_template->set_var('lang_leftrightblocks', $LANG_STATIC['leftrightblocks']);
    if (!isset($A['sp_format'])) {
        $A['sp_format'] = '';
    }
    if ($A['sp_format'] == 'noblocks') {
        $sp_template->set_var('noblock_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('noblock_selected', '');
    }
    if ($A['sp_format'] == 'leftblocks') {
        $sp_template->set_var('leftblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('leftblocks_selected', '');
    }
    if ($A['sp_format'] == 'blankpage') {
        $sp_template->set_var('blankpage_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('blankpage_selected', '');
    }
    if ($A['sp_format'] == 'allblocks' or empty($A['sp_format'])) {
        $sp_template->set_var('allblocks_selected', 'selected="selected"');
    } else {
        $sp_template->set_var('allblocks_selected', '');
    }
    $sp_template->set_var('lang_content', $LANG_STATIC['content']);
    $content = '';
    if (isset($A['sp_content'])) {
        $content = htmlspecialchars(stripslashes($A['sp_content']));
        $content = str_replace(array('{', '}'), array('&#123;', '&#125;'), $content);
    }
    $sp_template->set_var('sp_content', $content);
    if ($_SP_CONF['filter_html'] == 1) {
        $allowed = COM_allowedHTML('staticpages.edit');
        $sp_template->set_var('lang_allowedhtml', $allowed);
        $sp_template->set_var('lang_allowed_html', $allowed);
    } else {
        $sp_template->set_var('lang_allowedhtml', $LANG_STATIC['all_html_allowed']);
        $allowed = '<span class="warningsmall">' . $LANG_STATIC['all_html_allowed'] . ',</span>' . LB . '<div dir="ltr" class="warningsmall">';
        $autotags = array_keys(PLG_collectTags());
        $allowed .= '[' . implode(':], [', $autotags) . ':]';
        $allowed .= '</div>';
        $sp_template->set_var('lang_allowed_html', $allowed);
    }
    $sp_template->set_var('lang_hits', $LANG_STATIC['hits']);
    if (empty($A['sp_hits'])) {
        $sp_template->set_var('sp_hits', '0');
        $sp_template->set_var('sp_hits_formatted', '0');
    } else {
        $sp_template->set_var('sp_hits', $A['sp_hits']);
        $sp_template->set_var('sp_hits_formatted', COM_numberFormat($A['sp_hits']));
    }
    $sp_template->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    $sp_template->set_var('xhtml', XHTML);
    $sp_template->set_var('gltoken_name', CSRF_TOKEN);
    $sp_template->set_var('gltoken', $token);
    $sp_template->parse('output', 'form');
    $retval .= $sp_template->finish($sp_template->get_var('output'));
    return $retval;
}
Exemple #25
0
/**
* Shows poll editor
*
* Diplays the poll editor form
*
* @param    string  $pid    ID of poll to edit
* @return   string          HTML for poll editor form
*
*/
function editpoll($pid = '')
{
    global $_CONF, $_PO_CONF, $_GROUPS, $_TABLES, $_USER, $LANG25, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $LANG_POLLS;
    $retval = '';
    if (!empty($pid)) {
        $topic = DB_query("SELECT * FROM {$_TABLES['polltopics']} WHERE pid='{$pid}'");
        $T = DB_fetchArray($topic);
        // Get permissions for poll
        $access = SEC_hasAccess($T['owner_id'], $T['group_id'], $T['perm_owner'], $T['perm_group'], $T['perm_members'], $T['perm_anon']);
        if ($access == 0 or $access == 2) {
            // User doesn't have access...bail
            $retval .= COM_startBlock($LANG25[21], '', COM_getBlockTemplate('_msg_block', 'header'));
            $retval .= $LANG25[22];
            $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
            COM_accessLog("User {$_USER['username']} tried to illegally submit or edit poll {$pid}.");
            return $retval;
        }
    }
    // writing the menu on top
    require_once $_CONF['path_system'] . 'lib-admin.php';
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/polls/index.php', 'text' => $LANG_ADMIN['list_all']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG25[5], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG_POLLS['editinstructions'], plugin_geticon_polls());
    $retval .= SEC_getTokenExpiryNotice($token);
    $poll_templates = new Template($_CONF['path'] . 'plugins/polls/templates/admin/');
    $poll_templates->set_file(array('editor' => 'polleditor.thtml', 'question' => 'pollquestions.thtml', 'answer' => 'pollansweroption.thtml'));
    $poll_templates->set_var('xhtml', XHTML);
    $poll_templates->set_var('site_url', $_CONF['site_url']);
    $poll_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
    $poll_templates->set_var('layout_url', $_CONF['layout_url']);
    if (!empty($pid) and $access == 3 and !empty($T['owner_id'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $poll_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $poll_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    } else {
        $T['pid'] = COM_makeSid();
        $T['topic'] = '';
        $T['meta_description'] = '';
        $T['meta_keywords'] = '';
        $T['voters'] = 0;
        $T['display'] = 1;
        $T['is_open'] = 1;
        $T['hideresults'] = 0;
        $T['owner_id'] = $_USER['uid'];
        if (isset($_GROUPS['Polls Admin'])) {
            $T['group_id'] = $_GROUPS['Polls Admin'];
        } else {
            $T['group_id'] = SEC_getFeatureGroup('polls.edit');
        }
        SEC_setDefaultPermissions($T, $_PO_CONF['default_permissions']);
        $T['statuscode'] = 0;
        $T['commentcode'] = $_CONF['comment_code'];
        $access = 3;
    }
    $poll_templates->set_var('lang_pollid', $LANG25[6]);
    $poll_templates->set_var('poll_id', $T['pid']);
    $poll_templates->set_var('lang_donotusespaces', $LANG25[7]);
    $poll_templates->set_var('lang_topic', $LANG25[9]);
    $poll_templates->set_var('poll_topic', htmlspecialchars($T['topic']));
    $poll_templates->set_var('lang_mode', $LANG25[1]);
    $poll_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $poll_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($T['meta_description'])) {
        $poll_templates->set_var('meta_description', $T['meta_description']);
    }
    if (!empty($T['meta_keywords'])) {
        $poll_templates->set_var('meta_keywords', $T['meta_keywords']);
    }
    $poll_templates->set_var('status_options', COM_optionList($_TABLES['statuscodes'], 'code,name', $T['statuscode']));
    $poll_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $T['commentcode']));
    $poll_templates->set_var('lang_appearsonhomepage', $LANG25[8]);
    $poll_templates->set_var('lang_openforvoting', $LANG25[33]);
    $poll_templates->set_var('lang_hideresults', $LANG25[37]);
    $poll_templates->set_var('poll_hideresults_explain', $LANG25[38]);
    $poll_templates->set_var('poll_topic_info', $LANG25[39]);
    if ($T['display'] == 1) {
        $poll_templates->set_var('poll_display', 'checked="checked"');
    }
    if ($T['is_open'] == 1) {
        $poll_templates->set_var('poll_open', 'checked="checked"');
    }
    if ($T['hideresults'] == 1) {
        $poll_templates->set_var('poll_hideresults', 'checked="checked"');
    }
    // user access info
    $poll_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $poll_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($T['owner_id']);
    $poll_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$T['owner_id']}"));
    $poll_templates->set_var('owner_name', $ownername);
    $poll_templates->set_var('owner', $ownername);
    $poll_templates->set_var('owner_id', $T['owner_id']);
    $poll_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $poll_templates->set_var('group_dropdown', SEC_getGroupDropdown($T['group_id'], $access));
    $poll_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $poll_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $poll_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $poll_templates->set_var('permissions_editor', SEC_getPermissionsHTML($T['perm_owner'], $T['perm_group'], $T['perm_members'], $T['perm_anon']));
    $poll_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $poll_templates->set_var('lang_answersvotes', $LANG25[10]);
    $poll_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $poll_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    // repeat for several questions
    $question_sql = "SELECT question,qid " . "FROM {$_TABLES['pollquestions']} WHERE pid='{$pid}' ORDER BY qid;";
    $questions = DB_query($question_sql);
    include $_CONF['path_system'] . 'classes/navbar.class.php';
    $navbar = new navbar();
    for ($j = 0; $j < $_PO_CONF['maxquestions']; $j++) {
        $display_id = $j + 1;
        if ($j > 0) {
            $poll_templates->set_var('style', 'style="display:none;"');
        } else {
            $poll_templates->set_var('style', '');
        }
        $navbar->add_menuitem($LANG25[31] . " {$display_id}", "showhidePollsEditorDiv(\"{$j}\",{$j},{$_PO_CONF['maxquestions']});return false;", true);
        $Q = DB_fetchArray($questions);
        $poll_templates->set_var('question_text', $Q['question']);
        $poll_templates->set_var('question_id', $j);
        $poll_templates->set_var('lang_question', $LANG25[31] . " {$display_id}");
        $poll_templates->set_var('lang_saveaddnew', $LANG25[32]);
        // answers
        $answer_sql = "SELECT answer,aid,votes,remark " . "FROM {$_TABLES['pollanswers']} WHERE qid='{$j}' AND pid='{$pid}' ORDER BY aid";
        $answers = DB_query($answer_sql);
        for ($i = 0; $i < $_PO_CONF['maxanswers']; $i++) {
            if (isset($answers)) {
                $A = DB_fetchArray($answers);
                $poll_templates->set_var('answer_text', htmlspecialchars($A['answer']));
                $poll_templates->set_var('answer_votes', $A['votes']);
                $poll_templates->set_var('remark_text', $A['remark']);
            } else {
                $poll_templates->set_var('answer_text', '');
                $poll_templates->set_var('answer_votes', '');
                $poll_templates->set_var('remark_text', '');
            }
            $poll_templates->parse('answer_option', 'answer', true);
        }
        $poll_templates->parse('question_list', 'question', true);
        $poll_templates->clear_var('answer_option');
    }
    $navbar->set_selected($LANG25[31] . " 1");
    $poll_templates->set_var('navbar', $navbar->generate());
    $poll_templates->set_var('gltoken_name', CSRF_TOKEN);
    $poll_templates->set_var('gltoken', $token);
    $poll_templates->parse('output', 'editor');
    $retval .= $poll_templates->finish($poll_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #26
0
/**
* Shows event editor
*
* @param    string  $mode   Indicates if this is a submission or a regular entry
* @param    array   $A      array holding the event's details
* @param    string  $msg    an optional error message to display
* @return   string          HTML for event editor or error message
*
*/
function CALENDAR_editEvent($mode, $A, $msg = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $_CA_CONF, $LANG_CAL_1, $LANG_CAL_ADMIN, $LANG10, $LANG12, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS;
    // Loads jQuery UI datepicker and timepicker-addon
    $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider');
    $_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');
    // Add JavaScript
    $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.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.options.stepMinute = 15;" . "  geeklog.datetimepicker.set('start', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "  geeklog.datetimepicker.set('end', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE);
    $retval = '';
    if (!empty($msg)) {
        $retval .= COM_showMessageText($msg, $LANG_CAL_ADMIN[2]);
    }
    $event_templates = COM_newTemplate(CTL_plugin_templatePath('calendar', 'admin'));
    $event_templates->set_file('editor', 'eventeditor.thtml');
    $allowed = '';
    foreach (array('plaintext', 'html') as $pm) {
        $allowed .= COM_allowedHTML('calendar.edit', false, 1, $pm);
    }
    $allowed .= COM_allowedAutotags();
    $event_templates->set_var('lang_allowed_html', $allowed);
    $event_templates->set_var('lang_postmode', $LANG_CAL_ADMIN[3]);
    if ($mode != 'editsubmission' and !empty($A['eid'])) {
        // Get what level of access user has to this object
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            // Uh, oh!  User doesn't have access to this object
            $retval .= COM_showMessageText($LANG_CAL_ADMIN[17], $LANG_ACCESS['accessdenied']);
            COM_accessLog("User {$_USER['username']} tried to illegally submit or edit event {$eid}.");
            return $retval;
        }
    } else {
        if (empty($A['owner_id'])) {
            $A['owner_id'] = $_USER['uid'];
        }
        if (isset($_GROUPS['Calendar Admin'])) {
            $A['group_id'] = $_GROUPS['Calendar Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('calendar.edit');
        }
        SEC_setDefaultPermissions($A, $_CA_CONF['default_permissions']);
        $access = 3;
    }
    if ($mode == 'editsubmission') {
        $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'], 'code,name', 'plaintext'));
    } else {
        if (!isset($A['postmode'])) {
            $A['postmode'] = $_CONF['postmode'];
        }
        $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'], 'code,name', $A['postmode']));
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG_CAL_ADMIN[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    if (!empty($A['eid'])) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $event_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $event_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $event_templates->set_var('allow_delete', true);
        $event_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $event_templates->set_var('confirm_message', $MESSAGE[76]);
        if ($mode == 'editsubmission') {
            $event_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"' . XHTML . '>');
        }
    } else {
        // new event
        $A['eid'] = COM_makesid();
        $A['title'] = '';
        $A['description'] = '';
        $A['url'] = '';
        $A['hits'] = 0;
        // in case a start date/time has been passed from the calendar,
        // pick it up for the end date/time
        if (empty($A['dateend'])) {
            $A['dateend'] = $A['datestart'];
        }
        if (empty($A['timeend'])) {
            $A['timeend'] = $A['timestart'];
        }
        $A['event_type'] = '';
        $A['location'] = '';
        $A['address1'] = '';
        $A['address2'] = '';
        $A['city'] = '';
        $A['state'] = '';
        $A['zipcode'] = '';
        $A['allday'] = 0;
    }
    $event_templates->set_var('lang_eventid', $LANG_CAL_ADMIN[34]);
    $event_templates->set_var('event_id', $A['eid']);
    $event_templates->set_var('lang_eventtitle', $LANG_ADMIN['title']);
    $A['title'] = str_replace('{', '&#123;', $A['title']);
    $A['title'] = str_replace('}', '&#125;', $A['title']);
    $A['title'] = str_replace('"', '&quot;', $A['title']);
    $event_templates->set_var('event_title', stripslashes($A['title']));
    $event_templates->set_var('lang_eventtype', $LANG_CAL_1[37]);
    $event_templates->set_var('lang_editeventtypes', $LANG12[50]);
    $event_templates->set_var('type_options', CALENDAR_eventTypeList($A['event_type']));
    $event_templates->set_var('lang_eventurl', $LANG_CAL_ADMIN[4]);
    $event_templates->set_var('max_url_length', 255);
    $event_templates->set_var('event_url', $A['url']);
    $event_templates->set_var('lang_includehttp', $LANG_CAL_ADMIN[9]);
    $event_templates->set_var('lang_eventstartdate', $LANG_CAL_ADMIN[5]);
    //$event_templates->set_var('event_startdate', $A['datestart']);
    $event_templates->set_var('lang_starttime', $LANG_CAL_1[30]);
    // Combine date/time for easier manipulation
    $A['datestart'] = trim($A['datestart'] . ' ' . $A['timestart']);
    if (empty($A['datestart'])) {
        $start_stamp = time();
    } else {
        $start_stamp = strtotime($A['datestart']);
    }
    $A['dateend'] = trim($A['dateend'] . ' ' . $A['timeend']);
    if (empty($A['dateend'])) {
        $end_stamp = time();
    } else {
        $end_stamp = strtotime($A['dateend']);
    }
    $start_month = date('m', $start_stamp);
    $start_day = date('d', $start_stamp);
    $start_year = date('Y', $start_stamp);
    $end_month = date('m', $end_stamp);
    $end_day = date('d', $end_stamp);
    $end_year = date('Y', $end_stamp);
    $start_hour = date('H', $start_stamp);
    $start_minute = intval(date('i', $start_stamp) / 15) * 15;
    if ($start_hour >= 12) {
        $startampm = 'pm';
    } else {
        $startampm = 'am';
    }
    $start_hour_24 = $start_hour % 24;
    if ($start_hour > 12) {
        $start_hour = $start_hour - 12;
    } else {
        if ($start_hour == 0) {
            $start_hour = 12;
        }
    }
    $end_hour = date('H', $end_stamp);
    $end_minute = intval(date('i', $end_stamp) / 15) * 15;
    if ($end_hour >= 12) {
        $endampm = 'pm';
    } else {
        $endampm = 'am';
    }
    $end_hour_24 = $end_hour % 24;
    if ($end_hour > 12) {
        $end_hour = $end_hour - 12;
    } else {
        if ($end_hour == 0) {
            $end_hour = 12;
        }
    }
    $month_options = COM_getMonthFormOptions($start_month);
    $event_templates->set_var('startmonth_options', $month_options);
    $month_options = COM_getMonthFormOptions($end_month);
    $event_templates->set_var('endmonth_options', $month_options);
    $day_options = COM_getDayFormOptions($start_day);
    $event_templates->set_var('startday_options', $day_options);
    $day_options = COM_getDayFormOptions($end_day);
    $event_templates->set_var('endday_options', $day_options);
    $year_options = COM_getYearFormOptions($start_year);
    $event_templates->set_var('startyear_options', $year_options);
    $year_options = COM_getYearFormOptions($end_year);
    $event_templates->set_var('endyear_options', $year_options);
    if (isset($_CA_CONF['hour_mode']) && $_CA_CONF['hour_mode'] == 24) {
        $hour_options = COM_getHourFormOptions($start_hour_24, 24);
        $event_templates->set_var('starthour_options', $hour_options);
        $hour_options = COM_getHourFormOptions($end_hour_24, 24);
        $event_templates->set_var('endhour_options', $hour_options);
        $event_templates->set_var('hour_mode', 24);
    } else {
        $hour_options = COM_getHourFormOptions($start_hour);
        $event_templates->set_var('starthour_options', $hour_options);
        $hour_options = COM_getHourFormOptions($end_hour);
        $event_templates->set_var('endhour_options', $hour_options);
        $event_templates->set_var('hour_mode', 12);
    }
    $event_templates->set_var('startampm_selection', COM_getAmPmFormSelection('start_ampm', $startampm));
    $event_templates->set_var('endampm_selection', COM_getAmPmFormSelection('end_ampm', $endampm));
    $event_templates->set_var('startminute_options', COM_getMinuteFormOptions($start_minute, 15));
    $event_templates->set_var('endminute_options', COM_getMinuteFormOptions($end_minute, 15));
    $event_templates->set_var('lang_enddate', $LANG12[13]);
    $event_templates->set_var('lang_eventenddate', $LANG_CAL_ADMIN[6]);
    $event_templates->set_var('event_enddate', $A['dateend']);
    $event_templates->set_var('lang_enddate', $LANG12[13]);
    $event_templates->set_var('lang_endtime', $LANG_CAL_1[29]);
    $event_templates->set_var('lang_alldayevent', $LANG_CAL_1[31]);
    if ($A['allday'] == 1) {
        $event_templates->set_var('allday_checked', 'checked="checked"');
    }
    $event_templates->set_var('lang_location', $LANG12[51]);
    $event_templates->set_var('event_location', stripslashes($A['location']));
    $event_templates->set_var('lang_addressline1', $LANG12[44]);
    $event_templates->set_var('event_address1', stripslashes($A['address1']));
    $event_templates->set_var('lang_addressline2', $LANG12[45]);
    $event_templates->set_var('event_address2', stripslashes($A['address2']));
    $event_templates->set_var('lang_city', $LANG12[46]);
    $event_templates->set_var('event_city', stripslashes($A['city']));
    $event_templates->set_var('lang_state', $LANG12[47]);
    $event_templates->set_var('state_options', '');
    $event_templates->set_var('event_state', stripslashes($A['state']));
    $event_templates->set_var('lang_zipcode', $LANG12[48]);
    $event_templates->set_var('event_zipcode', $A['zipcode']);
    $event_templates->set_var('lang_eventlocation', $LANG_CAL_ADMIN[7]);
    $event_templates->set_var('event_location', stripslashes($A['location']));
    $event_templates->set_var('lang_eventdescription', $LANG_CAL_ADMIN[8]);
    $event_templates->set_var('event_description', stripslashes($A['description']));
    $event_templates->set_var('lang_hits', $LANG10[30]);
    $event_templates->set_var('hits', COM_numberFormat($A['hits']));
    $event_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $event_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    // user access info
    $event_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $event_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $event_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $event_templates->set_var('owner_name', $ownername);
    $event_templates->set_var('owner', $ownername);
    $event_templates->set_var('owner_id', $A['owner_id']);
    $event_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $event_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $event_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $event_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $event_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $event_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $event_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $event_templates->set_var('gltoken_name', CSRF_TOKEN);
    $event_templates->set_var('gltoken', $token);
    $event_templates->parse('output', 'editor');
    $retval .= $event_templates->finish($event_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #27
0
function links_edit_category($cid, $pid)
{
    global $_CONF, $_TABLES, $_USER, $MESSAGE, $LANG_LINKS_ADMIN, $LANG_ADMIN, $LANG_ACCESS, $_LI_CONF;
    $retval = '';
    $cid = addslashes($cid);
    if (!empty($pid)) {
        // have parent id, so making a new subcategory
        // get parent access rights
        $result = DB_query("SELECT group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='" . addslashes($pid) . "'");
        $A = DB_fetchArray($result);
        $A['owner_id'] = $_USER['uid'];
        $A['pid'] = $pid;
    } elseif (!empty($cid)) {
        // have category id, so editing a category
        $sql = "SELECT * FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'" . COM_getPermSQL('AND');
        $result = DB_query($sql);
        $A = DB_fetchArray($result);
    } else {
        // nothing, so making a new top-level category
        // get default access rights
        $A['group_id'] = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name='Links Admin'");
        SEC_setDefaultPermissions($A, $_LI_CONF['category_permissions']);
        $A['owner_id'] = $_USER['uid'];
        $A['pid'] = $_LI_CONF['root'];
    }
    $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    if ($access < 3) {
        return COM_showMessage(6, 'links');
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG_LINKS_ADMIN[56], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    $T = new Template($_CONF['path'] . 'plugins/links/templates/admin');
    $T->set_file(array('page' => 'categoryeditor.thtml'));
    $T->set_var('xhtml', XHTML);
    $T->set_var('site_url', $_CONF['site_url']);
    $T->set_var('site_admin_url', $_CONF['site_admin_url']);
    $T->set_var('layout_url', $_CONF['layout_url']);
    $T->set_var('lang_pagetitle', $LANG_LINKS_ADMIN[28]);
    $T->set_var('lang_link_list', $LANG_LINKS_ADMIN[53]);
    $T->set_var('lang_new_link', $LANG_LINKS_ADMIN[51]);
    $T->set_var('lang_validate_links', $LANG_LINKS_ADMIN[26]);
    $T->set_var('lang_list_categories', $LANG_LINKS_ADMIN[50]);
    $T->set_var('lang_new_category', $LANG_LINKS_ADMIN[52]);
    $T->set_var('lang_admin_home', $LANG_ADMIN['admin_home']);
    $T->set_var('instructions', $LANG_LINKS_ADMIN[29]);
    $T->set_var('lang_category', $LANG_LINKS_ADMIN[30]);
    $T->set_var('lang_cid', $LANG_LINKS_ADMIN[32]);
    $T->set_var('lang_description', $LANG_LINKS_ADMIN[31]);
    $T->set_var('lang_topic', $LANG_LINKS_ADMIN[33]);
    $T->set_var('lang_parent', $LANG_LINKS_ADMIN[34]);
    $T->set_var('lang_save', $LANG_ADMIN['save']);
    if (!empty($cid)) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $T->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $T->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
    } else {
        $T->set_var('delete_option', '');
    }
    $T->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    if (!empty($cid)) {
        $T->set_var('cid_value', $A['cid']);
        $T->set_var('old_cid_value', $A['cid']);
        $T->set_var('category_options', links_select_box(3, $A['pid']));
        $T->set_var('category_value', $A['category']);
        $T->set_var('description_value', $A['description']);
    } else {
        $A['cid'] = COM_makeSid();
        $T->set_var('cid_value', $A['cid']);
        $T->set_var('old_cid_value', '');
        $T->set_var('category_options', links_select_box(3, $A['pid']));
        $T->set_var('category_value', '');
        $T->set_var('description_value', '');
    }
    if (!isset($A['tid'])) {
        $A['tid'] = 'all';
    }
    $topics = COM_topicList('tid,topic', $A['tid'], 1, true);
    $T->set_var('topic_list', $topics);
    $alltopics = '<option value="all"';
    if ($A['tid'] == 'all') {
        $alltopics .= ' selected="selected"';
    }
    $alltopics .= '>' . $LANG_LINKS_ADMIN[35] . '</option>' . LB;
    $T->set_var('topic_selection', '<select name="tid">' . $alltopics . $topics . '</select>');
    if (empty($cid)) {
        $num_links = $LANG_ADMIN['na'];
    } else {
        $nresult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$cid}'" . COM_getPermSQL('AND'));
        $N = DB_fetchArray($nresult);
        $num_links = COM_numberFormat($N['count']);
    }
    $T->set_var('lang_num_links', $LANG_LINKS_ADMIN[61]);
    $T->set_var('num_links', $num_links);
    // user access info
    $T->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $T->set_var('lang_owner', $LANG_ACCESS['owner']);
    $T->set_var('owner_name', COM_getDisplayName($A['owner_id']));
    $T->set_var('cat_ownerid', $A['owner_id']);
    $T->set_var('lang_group', $LANG_ACCESS['group']);
    $T->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $T->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $T->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']);
    $T->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $T->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $T->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $T->set_var('lang_lockmsg', $LANG_ACCESS['permmsg']);
    $T->set_var('gltoken_name', CSRF_TOKEN);
    $T->set_var('gltoken', $token);
    $T->parse('output', 'page');
    $retval .= $T->finish($T->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #28
0
 /**
  * Load a Story object from the sid specified, returning a status result.
  * The result will either be a permission denied message, invalid SID
  * message, or a loaded ok message. If it's loaded ok, then we've got all
  * the exciting gubbins here.
  *
  * Only used from story admin and submit.php!
  *
  * @param $sid  string  Story Identifier, valid geeklog story id from the db.
  * @return Integer from a constant.
  */
 function loadFromDatabase($sid, $mode = 'edit')
 {
     global $_TABLES, $_CONF, $_USER;
     $sid = addslashes(COM_applyFilter($sid));
     if (!empty($sid) && ($mode == 'edit' || $mode == 'view')) {
         $sql = array();
         $sql['mysql'] = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) AS expireunix, UNIX_TIMESTAMP(s.comment_expire) AS cmt_expire_unix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '{$sid}')";
         $sql['mssql'] = "SELECT STRAIGHT_JOIN s.sid, s.uid, s.draft_flag, s.tid, s.date, s.title, CAST(s.introtext AS text) AS introtext, CAST(s.bodytext AS text) AS bodytext, s.hits, s.numemails, s.comments, s.trackbacks, s.related, s.featured, s.show_topic_icon, s.commentcode, s.trackbackcode, s.statuscode, s.expire, s.postmode, s.frontpage, s.owner_id, s.group_id, s.perm_owner, s.perm_group, s.perm_members, s.perm_anon, s.advanced_editor_mode, " . " UNIX_TIMESTAMP(s.date) AS unixdate, UNIX_TIMESTAMP(s.expire) AS expireunix, UNIX_TIMESTAMP(s.comment_expire) AS cmt_expire_unix, " . "u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, {$_TABLES['topics']} AS t " . "WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND (sid = '{$sid}')";
     } elseif (!empty($sid) && $mode == 'editsubmission') {
         $sql = 'SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, ' . 'u.username, u.fullname, u.photo, u.email, t.topic, t.imageurl, t.group_id, ' . 't.perm_owner, t.perm_group, t.perm_members, t.perm_anon ' . 'FROM ' . $_TABLES['storysubmission'] . ' AS s, ' . $_TABLES['users'] . ' AS u, ' . $_TABLES['topics'] . ' AS t WHERE (s.uid = u.uid) AND' . ' (s.tid = t.tid) AND (sid = \'' . $sid . '\')';
     } elseif ($mode == 'edit') {
         $this->_sid = COM_makesid();
         $this->_old_sid = $this->_sid;
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 0;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         if (COM_isAnonUser()) {
             $this->_uid = 1;
         } else {
             $this->_uid = $_USER['uid'];
         }
         $this->_date = time();
         $this->_expire = time();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_title = '';
         $this->_meta_description = '';
         $this->_meta_keywords = '';
         $this->_introtext = '';
         $this->_bodytext = '';
         if (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_hits = 0;
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         if (isset($_CONF['advanced_editor']) && $_CONF['advanced_editor'] && $_CONF['postmode'] != 'plaintext') {
             $this->_advanced_editor_mode = 1;
             $this->_postmode = 'adveditor';
         } else {
             $this->_postmode = $_CONF['postmode'];
             $this->_advanced_editor_mode = 0;
         }
         $this->_statuscode = 0;
         $this->_featured = 0;
         if (COM_isAnonUser()) {
             $this->_owner_id = 1;
         } else {
             $this->_owner_id = $_USER['uid'];
         }
         if (isset($_GROUPS['Story Admin'])) {
             $this->_group_id = $_GROUPS['Story Admin'];
         } else {
             $this->_group_id = SEC_getFeatureGroup('story.edit');
         }
         $array = array();
         SEC_setDefaultPermissions($array, $_CONF['default_permissions_story']);
         $this->_perm_owner = $array['perm_owner'];
         $this->_perm_group = $array['perm_group'];
         $this->_perm_anon = $array['perm_anon'];
         $this->_perm_members = $array['perm_members'];
     } else {
         $this->loadFromArgsArray($_POST);
     }
     /* if we have SQL, load from it */
     if (!empty($sql)) {
         $result = DB_query($sql);
         if ($result) {
             $story = DB_fetchArray($result, false);
             if ($story == null) {
                 return STORY_INVALID_SID;
             }
             $this->loadFromArray($story);
             if (!isset($story['owner_id'])) {
                 $story['owner_id'] = 1;
             }
             $access = SEC_hasAccess($story['owner_id'], $story['group_id'], $story['perm_owner'], $story['perm_group'], $story['perm_members'], $story['perm_anon']);
             $this->_access = min($access, SEC_hasTopicAccess($this->_tid));
             if ($this->_access == 0) {
                 return STORY_PERMISSION_DENIED;
             } elseif ($this->_access == 2 && $mode != 'view') {
                 return STORY_EDIT_DENIED;
             } elseif ($this->_access == 2 && $mode == 'view' && ($this->_draft_flag == 1 || $this->_date > time())) {
                 return STORY_INVALID_SID;
             }
         } else {
             return STORY_INVALID_SID;
         }
     }
     if ($mode == 'editsubmission') {
         if (isset($_CONF['draft_flag'])) {
             $this->_draft_flag = $_CONF['draft_flag'];
         } else {
             $this->_draft_flag = 1;
         }
         if (isset($_CONF['show_topic_icon'])) {
             $this->_show_topic_icon = $_CONF['show_topic_icon'];
         } else {
             $this->_show_topic_icon = 1;
         }
         $this->_commentcode = $_CONF['comment_code'];
         $this->_trackbackcode = $_CONF['trackback_code'];
         $this->_featured = 0;
         $this->_expire = time();
         if ($_CONF['article_comment_close_enabled']) {
             $this->_comment_expire = time() + $_CONF['article_comment_close_days'] * 86400;
         } else {
             $this->_comment_expire = 0;
         }
         if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$this->_tid}'") == 1) {
             $this->_frontpage = 0;
         } elseif (isset($_CONF['frontpage'])) {
             $this->_frontpage = $_CONF['frontpage'];
         } else {
             $this->_frontpage = 1;
         }
         $this->_comments = 0;
         $this->_trackbacks = 0;
         $this->_numemails = 0;
         $this->_statuscode = 0;
         $this->_owner_id = $this->_uid;
     }
     $this->_sanitizeData();
     return STORY_LOADED_OK;
 }
Exemple #29
0
/**
 * Show topic administration form
 *
 * @param    string  tid     ID of topic to edit
 * @return   string          HTML for the topic editor
 */
function edittopic($tid = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG04, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS;
    $retval = '';
    if (empty($tid)) {
        // new topic - set defaults
        $A = array('tid' => '', 'topic' => '', 'sortnum' => 0, 'parent_id' => TOPIC_ROOT, 'inherit' => 1, 'hidden' => 0, 'limitnews' => '', 'is_default' => 0, 'archive_flag' => 0);
    } else {
        $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='{$tid}'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 || $access == 2) {
            $retval .= COM_showMessageText($LANG27[13], $LANG27[12]);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}.");
            return $retval;
        }
    }
    $token = SEC_createToken();
    $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= SEC_getTokenExpiryNotice($token);
    if (!is_array($A) || empty($A['owner_id'])) {
        $A['owner_id'] = $_USER['uid'];
        // this is the one instance where we default the group
        // most topics should belong to the Topic Admin group
        if (isset($_GROUPS['Topic Admin'])) {
            $A['group_id'] = $_GROUPS['Topic Admin'];
        } else {
            $A['group_id'] = SEC_getFeatureGroup('topic.edit');
        }
        SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
        $access = 3;
    }
    $topic_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/topic');
    $topic_templates->set_file('editor', 'topiceditor.thtml');
    if (!empty($tid) && SEC_hasRights('topic.edit')) {
        $delButton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>';
        $jsConfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $topic_templates->set_var('delete_option', sprintf($delButton, $jsConfirm));
        $topic_templates->set_var('delete_option_no_confirmation', sprintf($delButton, ''));
        $topic_templates->set_var('allow_delete', true);
        $topic_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $topic_templates->set_var('confirm_message', $MESSAGE[76]);
        $topic_templates->set_var('warning_msg', $LANG27[6]);
    }
    if ($_CONF['titletoid'] && empty($tid)) {
        $_SCRIPTS->setJavaScriptFile('title_2_id', '/javascript/title_2_id.js');
        $topic_templates->set_var('titletoid', true);
    }
    $topic_templates->set_var('lang_topicid', $LANG27[2]);
    $topic_templates->set_var('topic_id', $A['tid']);
    $topic_templates->set_var('lang_parent_id', $LANG27[32]);
    $topic_templates->set_var('parent_id_options', TOPIC_getTopicListSelect($A['parent_id'], 1, false, $A['tid'], true));
    $topic_templates->set_var('lang_inherit', $LANG27[33]);
    $topic_templates->set_var('lang_inherit_info', $LANG27[34]);
    if ($A['inherit'] == 1) {
        $topic_templates->set_var('inherit_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('inherit_checked', '');
    }
    $topic_templates->set_var('lang_hidden', $LANG27[35]);
    $topic_templates->set_var('lang_hidden_info', $LANG27[36]);
    if ($A['hidden'] == 1) {
        $topic_templates->set_var('hidden_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('hidden_checked', '');
    }
    $topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
    $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $topic_templates->set_var('owner_name', $ownername);
    $topic_templates->set_var('owner', $ownername);
    $topic_templates->set_var('owner_id', $A['owner_id']);
    $topic_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $topic_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    // show sort order only if they specified sortnum as the sort method
    if ($_CONF['sortmethod'] !== 'alpha') {
        $topic_templates->set_var('lang_sortorder', $LANG27[10]);
        if ($A['sortnum'] == 0) {
            $A['sortnum'] = '';
        }
        $topic_templates->set_var('sort_order', '<input type="text" size="5" maxlength="5" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>');
    } else {
        $topic_templates->set_var('lang_sortorder', $LANG27[14]);
        $topic_templates->set_var('sort_order', $LANG27[15] . '<input type="hidden" name="sortnum" value="' . $A['sortnum'] . '"' . XHTML . '>');
    }
    $topic_templates->set_var('lang_storiesperpage', $LANG27[11]);
    if ($A['limitnews'] == 0) {
        $topic_templates->set_var('story_limit', '');
    } else {
        $topic_templates->set_var('story_limit', $A['limitnews']);
    }
    $topic_templates->set_var('default_limit', $_CONF['limitnews']);
    $topic_templates->set_var('lang_defaultis', $LANG27[16]);
    $topic_templates->set_var('lang_topicname', $LANG27[3]);
    $topic_templates->set_var('topic_name', htmlspecialchars(stripslashes($A['topic']), ENT_QUOTES, COM_getEncodingt()));
    if (empty($A['tid'])) {
        $A['imageurl'] = '/images/topics/';
    }
    $topic_templates->set_var('lang_topicimage', $LANG27[4]);
    $topic_templates->set_var('lang_uploadimage', $LANG27[27]);
    $topic_templates->set_var('lang_maxsize', $LANG27[28]);
    $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']);
    $topic_templates->set_var('max_url_length', 255);
    $topic_templates->set_var('image_url', $A['imageurl']);
    if (empty($_CONF['image_lib'])) {
        $scaling = $LANG04[162];
    } else {
        $scaling = $LANG04[161];
    }
    $topic_templates->set_var('icon_max_dimensions', sprintf($LANG04[160], $_CONF['max_topicicon_width'], $_CONF['max_topicicon_height'], $_CONF['max_topicicon_size'], $scaling));
    $topic_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
    $topic_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
    if (!empty($A['meta_description'])) {
        $topic_templates->set_var('meta_description', $A['meta_description']);
    }
    if (!empty($A['meta_keywords'])) {
        $topic_templates->set_var('meta_keywords', $A['meta_keywords']);
    }
    if ($_CONF['meta_tags'] > 0) {
        $topic_templates->set_var('hide_meta', '');
    } else {
        $topic_templates->set_var('hide_meta', ' style="display:none;"');
    }
    $topic_templates->set_var('lang_defaulttopic', $LANG27[22]);
    $topic_templates->set_var('lang_defaulttext', $LANG27[23]);
    if ($A['is_default'] == 1) {
        $topic_templates->set_var('default_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('default_checked', '');
    }
    $topic_templates->set_var('lang_archivetopic', $LANG27[25]);
    $topic_templates->set_var('lang_archivetext', $LANG27[26]);
    $topic_templates->set_var('archive_disabled', '');
    if ($A['archive_flag'] == 1) {
        $topic_templates->set_var('archive_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('archive_checked', '');
        // Only 1 topic can be the archive topic - so check if there already is one
        if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) {
            $topic_templates->set_var('archive_disabled', 'disabled');
        }
    }
    if (empty($tid)) {
        $num_stories = $LANG_ADMIN['na'];
    } else {
        $nResult = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'article' AND ta.id = sid AND ta.tid = '" . DB_escapeString($tid) . "'" . COM_getPermSql('AND'));
        $N = DB_fetchArray($nResult);
        $num_stories = COM_numberFormat($N['count']);
    }
    $topic_templates->set_var('lang_num_stories', $LANG27[30]);
    $topic_templates->set_var('num_stories', $num_stories);
    $topic_templates->set_var('gltoken_name', CSRF_TOKEN);
    $topic_templates->set_var('gltoken', $token);
    $topic_templates->parse('output', 'editor');
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Exemple #30
0
/**
 * This function creates a map Form
 *
 * Creates a Form for a map using the supplied defaults (if specified).
 *
 * @param array $map array of values describing a map
 * @return string HTML string of map form
 */
function getMapForm($map = array())
{
    global $_CONF, $_TABLES, $_MAPS_CONF, $LANG_MAPS_1, $LANG_configselects, $LANG_ACCESS, $_USER, $_GROUPS, $_SCRIPTS;
    $_SCRIPTS->setJavaScriptLibrary('jquery');
    $js = 'jQuery(function () {
        var tabContainers = jQuery(\'div.tabs > div\');
        
        jQuery(\'div.tabs ul.tabNavigation a\').click(function () {
            tabContainers.hide().filter(this.hash).show();
            
            jQuery(\'div.tabs ul.tabNavigation a\').removeClass(\'selected\');
            jQuery(this).addClass(\'selected\');
            
            return false;
        }).filter(\':first\').click();
		
		jQuery(".delete").click(function() {
			jQuery("#load").show();
			var id = jQuery(this).attr("id");
			var mid = jQuery(this).attr("mid");
			var oid = jQuery(this).attr("oid");
			var action = jQuery(this).attr("class");
			var string = \'id=\'+ id + \'&action=\' + action + \'&mid=\' + mid;
				
			jQuery.ajax({
				type: "POST",
				url: "ajax.php",
				data: string,
				cache: false,
				async:false,
				success: function(result){
					jQuery("#overlays_actions").replaceWith(result);
				}   
			});
			jQuery("#load").hide();
			return false;
		});
		
		jQuery(".add").click(function() {
			jQuery("#load").show();
			var id = jQuery(this).attr("id");
			var mid = jQuery(this).attr("mid");
			var oid = jQuery(this).attr("oid");
			var action = jQuery(this).attr("class");
			var string = \'id=\'+ id + \'&action=\' + action + \'&mid=\' + mid;
				
			jQuery.ajax({
				type: "POST",
				url: "ajax.php",
				data: string,
				cache: false,
				async:false,
				success: function(result){
					jQuery("#overlays_actions").replaceWith(result);
				}   
			});
			jQuery("#load").hide();
			return false;
		});
		
    });' . LB;
    if ($_CONF['advanced_editor'] == true) {
        $js_ad = '// Setup editor path for FCKeditor JS Functions
		geeklogEditorBasePath = "' . $_CONF['site_url'] . '/fckeditor/" ;
		window.onload = function() {
			var map_header = new FCKeditor( \'mapheader\' ) ;
			map_header.Config[\'CustomConfigurationsPath\'] = geeklogEditorBaseUrl + \'/fckeditor/myconfig.js\';
			map_header.BasePath = geeklogEditorBasePath;
			map_header.ToolbarSet = \'editor-toolbar2\';
			map_header.Height = 300 ;
			map_header.ReplaceTextarea() ;
			
			var map_footer = new FCKeditor( \'mapfooter\' ) ;
			map_footer.Config[\'CustomConfigurationsPath\'] = geeklogEditorBaseUrl + \'/fckeditor/myconfig.js\';
			map_footer.BasePath = geeklogEditorBasePath;
			map_footer.ToolbarSet = \'editor-toolbar2\';
			map_footer.Height = 300 ;
			map_footer.ReplaceTextarea() ;
		};';
        $_SCRIPTS->setJavaScript($js_ad, true, true);
    }
    $js .= '      jQuery(document).ready(
        function()
        {
            jQuery("#primary_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
            jQuery("#stroke_color").simpleColor({
				cellWidth: 9,
				cellHeight: 9,
				border: \'1px solid #333333\',
				displayColorCode: true
		    });
			
			jQuery("#load").hide();
		});
	';
    $_SCRIPTS->setJavaScript('<script type="text/javascript" src="' . $_CONF['site_url'] . '/fckeditor/fckeditor.js"></script>', false);
    $_SCRIPTS->setJavaScript($js, true);
    $_SCRIPTS->setJavaScriptFile('maps_simplecolor', '/' . $_MAPS_CONF['maps_folder'] . '/js/simple-color.js');
    $display = COM_startBlock($LANG_MAPS_1['map_edit'] . ' ' . $map['name']);
    $template = COM_newTemplate($_CONF['path'] . 'plugins/maps/templates');
    $template->set_file(array('map' => 'map_form.thtml'));
    $template->set_var('site_admin_url', $_CONF['site_admin_url']);
    $template->set_var('arrow', '<img src="' . $_CONF['site_url'] . '/maps/images/arrow.png" alt=""align="absmiddle">&nbsp;');
    $template->set_var('map_tab', $LANG_MAPS_1['map_tab']);
    $template->set_var('overlays_tab', $LANG_MAPS_1['overlays_tab']);
    //informations
    $template->set_var('informations', $LANG_MAPS_1['informations']);
    $template->set_var('name_label', $LANG_MAPS_1['name_label']);
    $template->set_var('name', stripslashes($map['name']));
    $template->set_var('address_label', $LANG_MAPS_1['address_label']);
    $template->set_var('geo', $map['geo']);
    $template->set_var('description_label', $LANG_MAPS_1['description_label']);
    $template->set_var('description', stripslashes($map['description']));
    $template->set_var('required_field', $LANG_MAPS_1['required_field']);
    $template->set_var('created_label', $LANG_MAPS_1['map_created']);
    $template->set_var('modified_label', $LANG_MAPS_1['modified']);
    $datecreated = COM_getUserDateTimeFormat($map['created']);
    $datemodified = COM_getUserDateTimeFormat($map['modified']);
    $template->set_var('created', $datecreated[0]);
    $template->set_var('modified', $datemodified[0]);
    //Genaral settings
    $template->set_var('general_settings', $LANG_MAPS_1['general_settings']);
    $template->set_var('map_width', $LANG_MAPS_1['map_width']);
    if ($map['width'] == '') {
        $map['width'] = $_MAPS_CONF['map_width'];
    }
    $template->set_var('width', $map['width']);
    $template->set_var('map_height', $LANG_MAPS_1['map_height']);
    if ($map['height'] == '') {
        $map['height'] = $_MAPS_CONF['map_height'];
    }
    $template->set_var('height', $map['height']);
    $template->set_var('map_zoom', $LANG_MAPS_1['map_zoom']);
    if ($map['zoom'] == '') {
        $map['zoom'] = $_MAPS_CONF['map_zoom'];
    }
    $template->set_var('zoom', $map['zoom']);
    $template->set_var('map_type', $LANG_MAPS_1['map_type']);
    $map_type = $LANG_configselects['maps']["20"];
    $options = '';
    foreach ($map_type as $i => $value) {
        $options .= '<option value="' . $value . '"';
        if ($value == $map['type']) {
            $options .= ' selected="selected"';
        }
        $options .= '>' . $i . '</option>' . LB;
    }
    $template->set_var('options', $options);
    $template->set_var('yes', $LANG_MAPS_1['yes']);
    $template->set_var('no', $LANG_MAPS_1['no']);
    $template->set_var('active', $LANG_MAPS_1['active']);
    if ($map['active'] == '') {
        $map['active'] = $_MAPS_CONF['map_active'];
    }
    if ($map['active'] == 1) {
        $template->set_var('active_yes', ' selected');
        $template->set_var('active_no', '');
    } else {
        $template->set_var('active_yes', '');
        $template->set_var('active_no', ' selected');
    }
    $template->set_var('hidden', $LANG_MAPS_1['hidden']);
    if ($map['hidden'] == '') {
        $map['hidden'] = $_MAPS_CONF['map_hidden'];
    }
    if ($map['hidden'] == 1) {
        $template->set_var('hidden_yes', ' selected');
        $template->set_var('hidden_no', '');
    } else {
        $template->set_var('hidden_yes', '');
        $template->set_var('hidden_no', ' selected');
    }
    $template->set_var('free_marker', $LANG_MAPS_1['free_marker']);
    if ($map['free_marker'] == '') {
        $map['free_marker'] = $_MAPS_CONF['free_markers'];
    }
    if ($map['free_marker'] == 1) {
        $template->set_var('free_marker_yes', ' selected');
        $template->set_var('free_marker_no', '');
    } else {
        $template->set_var('free_marker_yes', '');
        $template->set_var('free_marker_no', ' selected');
    }
    $template->set_var('paid_marker', $LANG_MAPS_1['paid_marker']);
    if ($map['paid_marker'] == '') {
        $map['paid_marker'] = $_MAPS_CONF['paid_markers'];
    }
    if ($map['paid_marker'] == 1) {
        $template->set_var('paid_marker_yes', ' selected');
        $template->set_var('paid_marker_no', '');
    } else {
        $template->set_var('paid_marker_yes', '');
        $template->set_var('paid_marker_no', ' selected');
    }
    //marker
    $template->set_var('mk_default', $LANG_MAPS_1['mk_default']);
    if ($map['mmk_default'] == '1') {
        $template->set_var('mk_default_yes', 'selected="selected"');
        $template->set_var('mk_default_no', '');
    } else {
        $template->set_var('mk_default_yes', '');
        $template->set_var('mk_default_no', 'selected="selected"');
    }
    //icon
    $sql = "SELECT * FROM {$_TABLES['maps_map_icons']} WHERE 1=1";
    $result = DB_query($sql, 0);
    $radio = '<p>' . $LANG_MAPS_1['choose_icon'] . '</p>';
    $map['mk_icon'] == 0 ? $checked = ' checked="checked"' : ($checked = '');
    $radio .= '<input type="radio" name="mk_icon" value="0"' . $checked . '>' . $LANG_MAPS_1['no_icon'] . '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
    while ($icon = DB_fetchArray($result, false)) {
        $map['mk_icon'] == $icon['icon_id'] ? $checked = ' checked="checked"' : ($checked = '');
        $radio .= '<input type="radio" name="mk_icon" value="' . $icon['icon_id'] . '"' . $checked . '> <img src="' . $_MAPS_CONF['images_icons_url'] . $icon['icon_image'] . '" alt="' . $icon['icon_image'] . '">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;';
    }
    $radio .= '<hr' . XHTML . '>';
    $template->set_var('icon', $radio);
    $template->set_var('marker_label', $LANG_MAPS_1['marker_label']);
    $template->set_var('primary_color_label', $LANG_MAPS_1['primary_color_label']);
    $template->set_var('primary_color', $map['primary_color']);
    $template->set_var('stroke_color_label', $LANG_MAPS_1['stroke_color_label']);
    $template->set_var('stroke_color', $map['stroke_color']);
    $template->set_var('label_label', $LANG_MAPS_1['label']);
    $template->set_var('label', $map['label']);
    $template->set_var('label_color_label', $LANG_MAPS_1['label_color']);
    if ($map['label_color'] == '') {
        $map['label_color'] = $_MAPS_CONF['label_color'];
    }
    if ($map['label_color'] == 1) {
        $template->set_var('label_color_white', ' selected');
        $template->set_var('label_color_black', '');
    } else {
        $template->set_var('label_color_white', '');
        $template->set_var('label_color_black', ' selected');
    }
    $template->set_var('black', $LANG_MAPS_1['black']);
    $template->set_var('white', $LANG_MAPS_1['white']);
    //header and footer
    $template->set_var('header_footer', $LANG_MAPS_1['header_footer']);
    if ($map['header'] == '') {
        $map['header'] = '&nbsp;';
    }
    if ($map['footer'] == '') {
        $map['footer'] = '<p>&nbsp;</p>';
    }
    $template->set_var('map_header_label', $LANG_MAPS_1['map_header_label']);
    $template->set_var('map_header', $map['header']);
    $template->set_var('map_footer_label', $LANG_MAPS_1['map_footer_label']);
    $template->set_var('map_footer', $map['footer']);
    // Permissions
    if ($map['perm_owner'] == '') {
        SEC_setDefaultPermissions($map, $_MAPS_CONF['default_permissions']);
    }
    $template->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $template->set_var('lang_owner', $LANG_ACCESS['owner']);
    if ($map['owner_id'] == '') {
        $map['owner_id'] = $_USER['uid'];
    }
    $ownername = COM_getDisplayName($map['owner_id']);
    //Select owner
    $result = DB_query("SELECT * FROM {$_TABLES['users']}");
    $nRows = DB_numRows($result);
    $owner_select = '<select name="owner_id">';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        if ($row['uid'] == 1) {
            continue;
        }
        $owner_select .= '<option value="' . $row['uid'] . '"' . ($map['owner_id'] == $row['uid'] ? 'selected="selected"' : '') . '>' . COM_getDisplayName($row['uid']) . ' | ' . $row['uid'] . '</option>';
    }
    $owner_select .= '</select>';
    $template->set_var('owner_select', $owner_select);
    $template->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$map['owner_id']}"));
    $template->set_var('owner_name', $ownername);
    $template->set_var('owner', $ownername);
    $template->set_var('owner_id', $map['owner_id']);
    if ($map['group_id'] == '') {
        $map['group_id'] = $_GROUPS['Maps Admin'];
    }
    $template->set_var('lang_group', $LANG_ACCESS['group']);
    $access = 3;
    $template->set_var('group_dropdown', SEC_getGroupDropdown($map['group_id'], $access));
    $template->set_var('permissions_editor', SEC_getPermissionsHTML($map['perm_owner'], $map['perm_group'], $map['perm_members'], $map['perm_anon']));
    $template->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $template->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $template->set_var('permissions_msg', $LANG_ACCESS['permmsg']);
    $template->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    //Form validation
    $template->set_var('save_button', $LANG_MAPS_1['save_button']);
    $template->set_var('delete_button', $LANG_MAPS_1['delete_button']);
    $template->set_var('ok_button', $LANG_MAPS_1['ok_button']);
    if (is_numeric($map['mid'])) {
        $template->set_var('mid', '<input type="hidden" name="mid" value="' . $map['mid'] . '" />');
    } else {
        $template->set_var('mid', '');
    }
    //overlays
    if ($map['mid'] != '') {
        $template->set_var('overlays', MAPS_displayOverlays($map['mid']));
        $template->set_var('add_overlay', MAPS_displayOverlaysToAdd($map['mid']));
    } else {
        $template->set_var('overlays', '');
        $template->set_var('add_overlay', '<p>' . $LANG_MAPS_1['add_overlay'] . '</p>');
    }
    $display .= $template->parse('output', 'map');
    $display .= COM_endBlock();
    return $display;
}