Exemplo n.º 1
0
function cot_generate_sbrtags($item_data, $tag_prefix = '', $admin_rights = null, $pagepath_home = false)
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_sbr, $db_sbr_stages, $sys;
    static $extp_first = null, $extp_main = null;
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('sbrtags.first');
        $extp_main = cot_getextplugins('sbrtags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($item_data)) {
        $sql = $db->query("SELECT * FROM {$db_sbr} WHERE sbr_id = '" . (int) $item_data . "' LIMIT 1");
        $item_data = $sql->fetch();
    }
    if ($item_data['sbr_id'] > 0 && !empty($item_data['sbr_title'])) {
        if (is_null($admin_rights)) {
            $admin_rights = cot_auth('plug', 'sbr', 'A');
        }
        $patharray[] = array(cot_url('sbr'), $L['sbr']);
        $patharray[] = array(cot_url('sbr', 'id=' . $item_data['sbr_id']), $item_data['sbr_title']);
        $itempath = cot_breadcrumbs($patharray, $pagepath_home, true);
        $temp_array = array('ID' => $item_data['sbr_id'], 'STATUS' => $item_data['sbr_status'], 'LOCALSTATUS' => $L['sbr_status_' . $item_data['sbr_status']], 'LABELSTATUS' => $R['sbr_labels'][$item_data['sbr_status']], 'URL' => cot_url('sbr', 'id=' . $item_data['sbr_id']), 'TITLE' => $itempath, 'SHORTTITLE' => $item_data['sbr_title'], 'CREATEDATE' => date('d.m.Y H:i', $item_data['sbr_create']), 'CREATEDATE_STAMP' => $item_data['sbr_create'], 'BEGINDATE' => date('d.m.Y H:i', $item_data['sbr_begin']), 'BEGINDATE_STAMP' => $item_data['sbr_begin'], 'DONEDATE' => date('d.m.Y H:i', $item_data['sbr_done']), 'DONEDATE_STAMP' => $item_data['sbr_done'], 'COST' => $item_data['sbr_cost'], 'TAX' => $item_data['sbr_tax'], 'TOTAL' => $item_data['sbr_cost'] + $item_data['sbr_tax'], 'USER_IS_ADMIN' => $admin_rights || $usr['id'] == $item_data['item_userid']);
        if ($admin_rights || $usr['id'] == $item_data['sbr_employer']) {
            $temp_array['ADMIN_EDIT'] = cot_rc_link(cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']), $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']);
        }
        // Extrafields
        if (isset($cot_extrafields[$db_sbr])) {
            foreach ($cot_extrafields[$db_sbr] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['sbr_' . $exfld['field_name'] . '_title']) ? $L['sbr_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('sbr', $exfld, $item_data['item_' . $exfld['field_name']]);
            }
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
    } else {
        $temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
    }
    $return_array = array();
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Exemplo n.º 2
0
$alloffers_count = $db->query("SELECT COUNT(*) FROM {$db_projects_offers} WHERE offer_pid=" . $id)->fetchColumn();
$t_o->assign(array("ALLOFFERS_COUNT" => $alloffers_count));
/* === Hook === */
$extp1 = cot_getextplugins('projects.offers.choise.first');
$extp2 = cot_getextplugins('projects.offers.choise');
$extp3 = cot_getextplugins('projects.offers.posts.loop');
$extp4 = cot_getextplugins('projects.offers.loop');
/* ===== */
while ($offer = $sql->fetch()) {
    $t_o->assign(cot_generate_usertags($offer, 'OFFER_ROW_OWNER_'));
    $t_o->assign(array("OFFER_ROW_DATE" => cot_date('d.m.Y H:i', $offer['offer_date']), "OFFER_ROW_DATE_STAMP" => $offer['offer_date'], "OFFER_ROW_TEXT" => cot_parse($offer['offer_text']), "OFFER_ROW_COSTMIN" => number_format($offer['offer_cost_min'], '0', '.', ' '), "OFFER_ROW_COSTMAX" => number_format($offer['offer_cost_max'], '0', '.', ' '), "OFFER_ROW_TIMEMIN" => $offer['offer_time_min'], "OFFER_ROW_TIMEMAX" => $offer['offer_time_max'], "OFFER_ROW_TIMETYPE" => $L['offers_timetype'][$offer['offer_time_type']], "OFFER_ROW_HIDDEN" => $offer['offer_hidden'], "OFFER_ROW_CHOISE" => $offer['offer_choise']));
    // Extrafields
    if (isset($cot_extrafields[$db_projects_offers])) {
        foreach ($cot_extrafields[$db_projects_offers] as $exfld) {
            $uname = mb_strtoupper($exfld['field_name']);
            $t_o->assign(array('OFFER_ROW_' . $uname . '_TITLE' => isset($L['offers_' . $exfld['field_name'] . '_title']) ? $L['offers_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'OFFER_ROW_' . $uname => cot_build_extrafields_data('offers', $exfld, $offer['item_' . $exfld['field_name']])));
        }
    }
    $choise_enabled = true;
    /* === Hook - Part1 : Include === */
    foreach ($extp1 as $pl) {
        include $pl;
    }
    /* ===== */
    if ($usr['id'] == $item['item_userid'] && $choise_enabled) {
        $t_o->assign(array("OFFER_ROW_SETPERFORMER" => cot_url('projects', 'id=' . $id . '&a=setperformer&userid=' . $offer['user_id'] . '&' . cot_xg()), "OFFER_ROW_REFUSE" => cot_url('projects', 'id=' . $id . '&a=refuse&userid=' . $offer['user_id'] . '&' . cot_xg())));
        /* === Hook - Part2 : Include === */
        foreach ($extp2 as $pl) {
            include $pl;
        }
        /* ===== */
Exemplo n.º 3
0
/**
 * Returns all product tags for coTemplate
 *
 * @param mixed $item_data product Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights product Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_markettags($item_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_market, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('markettags.first');
        $extp_main = cot_getextplugins('markettags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($item_data)) {
        $sql = $db->query("SELECT * FROM {$db_market} WHERE item_id = '" . (int) $item_data . "' LIMIT 1");
        $item_data = $sql->fetch();
    }
    if ($item_data['item_id'] > 0 && !empty($item_data['item_title'])) {
        if (is_null($admin_rights)) {
            $admin_rights = cot_auth('market', $item_data['item_cat'], 'A');
        }
        $item_data['item_pageurl'] = empty($item_data['item_alias']) ? cot_url('market', 'c=' . $item_data['item_cat'] . '&id=' . $item_data['item_id']) : cot_url('market', 'c=' . $item_data['item_cat'] . '&al=' . $item_data['item_alias']);
        $catpatharray[] = array(cot_url('market'), $L['market']);
        $itempatharray[] = array($item_data['item_pageurl'], $item_data['item_title']);
        $patharray = array_merge($catpatharray, cot_structure_buildpath('market', $item_data['item_cat']), $itempatharray);
        $itempath = cot_breadcrumbs($patharray, $pagepath_home, true);
        $patharray = array_merge($catpatharray, cot_structure_buildpath('market', $item_data['item_cat']));
        $catpath = cot_breadcrumbs($patharray, $pagepath_home, true);
        $text = cot_parse($item_data['item_text'], $cfg['market']['markup'], $item_data['item_parser']);
        $text_cut = (int) $textlength > 0 ? cot_string_truncate($text, $textlength) : $text;
        $item_data['item_status'] = cot_market_status($item_data['item_state']);
        $temp_array = array('ID' => $item_data['item_id'], 'ALIAS' => $item_data['item_alias'], 'STATE' => $item_data['item_state'], 'STATUS' => $item_data['item_status'], 'LOCALSTATUS' => $L['market_status_' . $item_data['item_status']], 'URL' => $item_data['item_pageurl'], 'USER_PRDURL' => cot_url('users', 'm=details&id=' . $item_data['item_userid'] . '&u=' . $item_data['user_name'] . '&tab=market'), 'TITLE' => $itempath, 'SHORTTITLE' => $item_data['item_title'], 'CAT' => $item_data['item_cat'], 'CATTITLE' => htmlspecialchars($structure['market'][$item_data['item_cat']]['title']), 'CATURL' => cot_url('market', 'c=' . $item_data['item_cat']), 'CATPATH' => $catpath, 'TEXT' => $text, 'SHORTTEXT' => $text_cut, 'COST' => number_format($item_data['item_cost'], '0', '.', ' '), 'DATE' => cot_date('datetime_medium', $item_data['item_date']), 'DATE_STAMP' => $item_data['item_date'], 'SHOW_URL' => $item_data['item_pageurl'], 'COUNT' => $item_data['item_count'], 'USER_IS_ADMIN' => $admin_rights || $usr['id'] == $item_data['item_userid']);
        if ($admin_rights || $usr['id'] == $item_data['item_userid']) {
            $temp_array['ADMIN_EDIT'] = cot_rc_link(cot_url('market', 'm=edit&id=' . $item_data['item_id']), $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = cot_url('market', 'm=edit&id=' . $item_data['item_id']);
            $temp_array['HIDEPRODUCT_URL'] = cot_url('market', 'm=edit&id=' . $item_data['item_id'] . ($item_data['item_state'] == 1 ? '&a=public' : '&a=hide'));
            $temp_array['HIDEPRODUCT_TITLE'] = $item_data['item_state'] == 1 ? $L['Publish'] : $L['Hide'];
        }
        // Extrafields
        if (isset($cot_extrafields[$db_market])) {
            foreach ($cot_extrafields[$db_market] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['market_' . $exfld['field_name'] . '_title']) ? $L['market_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('market', $exfld, $item_data['item_' . $exfld['field_name']]);
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['market'][$item_data['item_cat']][$exfld['field_name']]);
            }
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
    } else {
        $temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
    }
    $return_array = array();
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Exemplo n.º 4
0
/**
 * Returns all page tags for coTemplate
 *
 * @param mixed $page_data Page Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights Page Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_pages, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    static $pag_auth = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('pagetags.first');
        $extp_main = cot_getextplugins('pagetags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($page_data)) {
        $sql = $db->query("SELECT * FROM {$db_pages} WHERE page_id = '" . (int) $page_data . "' LIMIT 1");
        $page_data = $sql->fetch();
    }
    if ($page_data['page_id'] > 0 && !empty($page_data['page_title'])) {
        if (is_null($admin_rights)) {
            if (!isset($pag_auth[$page_data['page_cat']])) {
                $pag_auth[$page_data['page_cat']] = cot_auth('page', $page_data['page_cat'], 'RWA1');
            }
            $admin_rights = (bool) $pag_auth[$page_data['page_cat']][2];
        }
        $pagepath = cot_structure_buildpath('page', $page_data['page_cat']);
        $catpath = cot_breadcrumbs($pagepath, $pagepath_home);
        $page_data['page_pageurl'] = empty($page_data['page_alias']) ? cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id']) : cot_url('page', 'c=' . $page_data['page_cat'] . '&al=' . $page_data['page_alias']);
        $page_link[] = array($page_data['page_pageurl'], $page_data['page_title']);
        $page_data['page_fulltitle'] = cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home);
        if (!empty($page_data['page_url']) && $page_data['page_file']) {
            $dotpos = mb_strrpos($page_data['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($page_data['page_url'], $dotpos, 5));
            $page_data['page_fileicon'] = cot_rc('page_icon_file_path', array('type' => $type));
            if (!file_exists($page_data['page_fileicon'])) {
                $page_data['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $page_data['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $page_data['page_fileicon']));
        } else {
            $page_data['page_fileicon'] = '';
        }
        $date_format = 'datetime_medium';
        $text = cot_parse($page_data['page_text'], $cfg['page']['markup'], $page_data['page_parser']);
        $text_cut = cot_cut_more($text);
        if ($textlength > 0 && mb_strlen($text_cut) > $textlength) {
            $text_cut = cot_string_truncate($text_cut, $textlength);
        }
        $cutted = mb_strlen($text) > mb_strlen($text_cut) ? true : false;
        $cat_url = cot_url('page', 'c=' . $page_data['page_cat']);
        $validate_url = cot_url('admin', "m=page&a=validate&id={$page_data['page_id']}&x={$sys['xk']}");
        $unvalidate_url = cot_url('admin', "m=page&a=unvalidate&id={$page_data['page_id']}&x={$sys['xk']}");
        $edit_url = cot_url('page', "m=edit&id={$page_data['page_id']}");
        $delete_url = cot_url('page', "m=edit&a=update&delete=1&id={$page_data['page_id']}&x={$sys['xk']}");
        $page_data['page_status'] = cot_page_status($page_data['page_state'], $page_data['page_begin'], $page_data['page_expire']);
        $temp_array = array('URL' => $page_data['page_pageurl'], 'ID' => $page_data['page_id'], 'TITLE' => $page_data['page_fulltitle'], 'ALIAS' => $page_data['page_alias'], 'STATE' => $page_data['page_state'], 'STATUS' => $page_data['page_status'], 'LOCALSTATUS' => $L['page_status_' . $page_data['page_status']], 'SHORTTITLE' => htmlspecialchars($page_data['page_title'], ENT_COMPAT, 'UTF-8', false), 'CAT' => $page_data['page_cat'], 'CATURL' => $cat_url, 'CATTITLE' => htmlspecialchars($structure['page'][$page_data['page_cat']]['title']), 'CATPATH' => $catpath, 'CATPATH_SHORT' => cot_rc_link($cat_url, htmlspecialchars($structure['page'][$page_data['page_cat']]['title'])), 'CATDESC' => htmlspecialchars($structure['page'][$page_data['page_cat']]['desc']), 'CATICON' => $structure['page'][$page_data['page_cat']]['icon'], 'KEYWORDS' => htmlspecialchars($page_data['page_keywords']), 'DESC' => htmlspecialchars($page_data['page_desc']), 'TEXT' => $text, 'TEXT_CUT' => $text_cut, 'TEXT_IS_CUT' => $cutted, 'DESC_OR_TEXT' => !empty($page_data['page_desc']) ? htmlspecialchars($page_data['page_desc']) : $text, 'MORE' => $cutted ? cot_rc('list_more', array('page_url' => $page_data['page_pageurl'])) : '', 'AUTHOR' => htmlspecialchars($page_data['page_author']), 'OWNERID' => $page_data['page_ownerid'], 'OWNERNAME' => htmlspecialchars($page_data['user_name']), 'DATE' => cot_date($date_format, $page_data['page_date']), 'BEGIN' => cot_date($date_format, $page_data['page_begin']), 'EXPIRE' => cot_date($date_format, $page_data['page_expire']), 'UPDATED' => cot_date($date_format, $page_data['page_updated']), 'DATE_STAMP' => $page_data['page_date'], 'BEGIN_STAMP' => $page_data['page_begin'], 'EXPIRE_STAMP' => $page_data['page_expire'], 'UPDATED_STAMP' => $page_data['page_updated'], 'FILE' => $cot_yesno[$page_data['page_file']], 'FILE_URL' => empty($page_data['page_url']) ? '' : cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id'] . '&a=dl'), 'FILE_SIZE' => $page_data['page_size'] / 1024, 'FILE_SIZE_BYTES' => $page_data['page_size'], 'FILE_SIZE_READABLE' => cot_build_filesize($page_data['page_size'], 1), 'FILE_ICON' => $page_data['page_fileicon'], 'FILE_COUNT' => $page_data['page_filecount'], 'FILE_COUNTTIMES' => cot_declension($page_data['page_filecount'], $Ls['Times']), 'FILE_NAME' => basename($page_data['page_url']), 'COUNT' => $page_data['page_count'], 'ADMIN' => $admin_rights ? cot_rc('list_row_admin', array('unvalidate_url' => $unvalidate_url, 'edit_url' => $edit_url)) : '', 'NOTAVAILABLE' => $page_data['page_begin'] > $sys['now'] ? $L['page_notavailable'] . cot_build_timegap($sys['now'], $pag['page_begin']) : '');
        // Admin tags
        if ($admin_rights) {
            $validate_confirm_url = cot_confirm_url($validate_url, 'page', 'page_confirm_validate');
            $unvalidate_confirm_url = cot_confirm_url($unvalidate_url, 'page', 'page_confirm_unvalidate');
            $delete_confirm_url = cot_confirm_url($delete_url, 'page', 'page_confirm_delete');
            $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            $temp_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ? cot_rc_link($validate_confirm_url, $L['Validate'], 'class="confirmLink"') : cot_rc_link($unvalidate_confirm_url, $L['Putinvalidationqueue'], 'class="confirmLink"');
            $temp_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ? $validate_confirm_url : $unvalidate_confirm_url;
            $temp_array['ADMIN_DELETE'] = cot_rc_link($delete_confirm_url, $L['Delete'], 'class="confirmLink"');
            $temp_array['ADMIN_DELETE_URL'] = $delete_confirm_url;
        } else {
            if ($usr['id'] == $page_data['page_ownerid']) {
                $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
                $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            }
        }
        if (cot_auth('page', 'any', 'W')) {
            $clone_url = cot_url('page', "m=add&c={$page_data['page_cat']}&clone={$page_data['page_id']}");
            $temp_array['ADMIN_CLONE'] = cot_rc_link($clone_url, $L['page_clone']);
            $temp_array['ADMIN_CLONE_URL'] = $clone_url;
        }
        // Extrafields
        if (isset($cot_extrafields[$db_pages])) {
            foreach ($cot_extrafields[$db_pages] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('page', $exfld, $page_data['page_' . $exfld['field_name']], $page_data['page_parser']);
                $temp_array[$tag . '_VALUE'] = $page_data['page_' . $exfld['field_name']];
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['page'][$page_data['page_cat']][$exfld['field_name']]);
                $temp_array['CAT_' . $tag . '_VALUE'] = $structure['page'][$page_data['page_cat']][$exfld['field_name']];
            }
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
    } else {
        $temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
    }
    $return_array = array();
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Exemplo n.º 5
0
/**
 * Generates comments display for a given item
 *
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param bool $force_admin Enforces user to be administrator of comments for this item.
 *	E.g. to moderate his wall even if he is not a moderator
 * @return string Rendered HTML output for comments
 * @global CotDB $db
 */
function cot_comments_display($ext_name, $code, $cat = '', $force_admin = false)
{
    global $db, $db_com, $db_users, $cfg, $usr, $L, $sys, $R, $env, $pg, $cot_extrafields, $cache, $structure;
    // Check permissions and enablement
    list($auth_read, $auth_write, $auth_admin) = cot_auth('plug', 'comments');
    if ($auth_read && $auth_write && $force_admin) {
        $auth_admin = true;
        $_SESSION['cot_comments_force_admin'][$ext_name][$code] = true;
    }
    $enabled = cot_comments_enabled($ext_name, $cat, $code);
    if (!$auth_read || !$enabled && !$auth_admin) {
        return '';
    }
    $comments_join_columns = $comments_join_tables = $comments_join_where = '';
    // Get the URL and parameters
    $link_area = $env['ext'];
    $link_params = $_GET;
    if (defined('COT_PLUG')) {
        $link_area = 'plug';
        $link_params['e'] = $env['ext'];
    }
    if (isset($_GET['rwr'])) {
        unset($link_params['rwr'], $link_params['e']);
    }
    $cot_com_back = array($link_area, $link_params);
    $_SESSION['cot_com_back'][$ext_name][$cat][$code] = $cot_com_back;
    $d_var = 'dcm';
    list($pg, $d, $durl) = cot_import_pagenav($d_var, $cfg['plugin']['comments']['maxcommentsperpage']);
    $d = empty($d) ? 0 : (int) $d;
    if ($auth_write && $enabled) {
        require_once cot_incfile('forms');
    }
    $t = new XTemplate(cot_tplfile('comments', 'plug'));
    /* == Hook == */
    foreach (cot_getextplugins('comments.main') as $pl) {
        include $pl;
    }
    /* ===== */
    $editor = cot::$cfg['plugin']['comments']['markup'] ? 'input_textarea_minieditor' : '';
    $t->assign(array('COMMENTS_CODE' => $code, 'COMMENTS_FORM_SEND' => cot_url('plug', "e=comments&a=send&area={$ext_name}&cat={$cat}&item={$code}"), 'COMMENTS_FORM_AUTHOR' => $usr['id'] > 0 ? $usr['name'] : cot_inputbox('text', 'rname'), 'COMMENTS_FORM_AUTHORID' => $usr['id'], 'COMMENTS_FORM_TEXT' => $auth_write && $enabled ? cot_textarea('rtext', $rtext, 7, 120, '', $editor) . cot_inputbox('hidden', 'cb', base64_encode(serialize($cot_com_back))) : '', 'COMMENTS_DISPLAY' => $cfg['plugin']['comments']['expand_comments'] ? '' : 'none'));
    if ($auth_write && $enabled) {
        // Extra fields
        if (!empty(cot::$extrafields[cot::$db->com])) {
            foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                $uname = strtoupper($exfld['field_name']);
                $exfld_val = cot_build_extrafields('rcomments' . $exfld['field_name'], $exfld, $rcomments[$exfld['field_name']]);
                $exfld_title = cot_extrafield_title($exfld, 'comments_');
                $t->assign(array('COMMENTS_FORM_' . $uname => $exfld_val, 'COMMENTS_FORM_' . $uname . '_TITLE' => $exfld_title, 'COMMENTS_FORM_EXTRAFLD' => $exfld_val, 'COMMENTS_FORM_EXTRAFLD_TITLE' => $exfld_title));
                $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.EXTRAFLD');
            }
        }
        $allowed_time = cot_build_timegap($sys['now'] - $cfg['plugin']['comments']['time'] * 60, $sys['now']);
        $com_hint = cot_rc('com_edithint', array('time' => $allowed_time));
        /* == Hook == */
        foreach (cot_getextplugins('comments.newcomment.tags') as $pl) {
            include $pl;
        }
        /* ===== */
        $usr['id'] == 0 && $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.GUEST');
        if ($usr['id'] == 0 && cot_check_messages() && $cache) {
            if ($ext_name == 'page' && $cfg['cache_page']) {
                $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$cat]['path']));
                $cfg['cache_page'] = false;
            }
        }
        cot_display_messages($t, 'COMMENTS.COMMENTS_NEWCOMMENT');
        $t->assign('COMMENTS_FORM_HINT', $com_hint);
        $t->parse('COMMENTS.COMMENTS_NEWCOMMENT');
    } else {
        $warning = $enabled ? $L['com_regonly'] : $L['com_closed'];
        $t->assign('COMMENTS_CLOSED', $warning);
        $t->parse('COMMENTS.COMMENTS_CLOSED');
    }
    $order = $cfg['plugin']['comments']['order'] == 'Chronological' ? 'ASC' : 'DESC';
    $comments_order = "com_id {$order}";
    /* == Hook == */
    foreach (cot_getextplugins('comments.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT c.*, u.* {$comments_join_columns}\n\t\tFROM {$db_com} AS c LEFT JOIN {$db_users} AS u ON u.user_id = c.com_authorid {$comments_join_tables}\n\t\tWHERE com_area = ? AND com_code = ? {$comments_join_where} ORDER BY {$comments_order} LIMIT ?, ?", array($ext_name, $code, (int) $d, (int) $cfg['plugin']['comments']['maxcommentsperpage']));
    if ($sql->rowCount() > 0 && $enabled) {
        $i = $d;
        $kk = 0;
        $totalitems = cot_comments_count($ext_name, $code);
        /* === Hook - Part1 : Set === */
        $extp = cot_getextplugins('comments.loop');
        /* ===== */
        foreach ($sql->fetchAll() as $row) {
            $i++;
            $kk++;
            $com_admin = $auth_admin ? cot_rc('comments_code_admin', array('ipsearch' => cot_build_ipsearch($row['com_authorip']), 'delete_url' => cot_confirm_url(cot_url('plug', 'e=comments&a=delete&cat=' . $cat . '&id=' . $row['com_id'] . '&' . cot_xg()), 'comments', 'comments_confirm_delete'))) : '';
            $com_text = cot_parse($row['com_text'], $cfg['plugin']['comments']['markup']);
            $time_limit = $sys['now'] < $row['com_date'] + $cfg['plugin']['comments']['time'] * 60 ? TRUE : FALSE;
            $usr['isowner_com'] = $time_limit && ($usr['id'] > 0 && $row['com_authorid'] == $usr['id'] || $usr['id'] == 0 && !empty($_SESSION['cot_comments_edit'][$row['com_id']]) && $usr['ip'] == $row['com_authorip']);
            $com_gup = $sys['now'] - ($row['com_date'] + $cfg['plugin']['comments']['time'] * 60);
            $allowed_time = $usr['isowner_com'] && !$usr['isadmin'] ? ' - ' . cot_build_timegap($sys['now'] + $com_gup, $sys['now']) . $L['plu_comgup'] : '';
            $com_edit = $auth_admin || $usr['isowner_com'] ? cot_rc('comments_code_edit', array('edit_url' => cot_url('plug', 'e=comments&m=edit&cat=' . $cat . '&id=' . $row['com_id']), 'allowed_time' => $allowed_time)) : '';
            if ($row['com_area'] == 'page') {
                if ($usr['id'] == 0 && $usr['isowner_com'] && $cfg['cache_page']) {
                    $cfg['cache_page'] = $cfg['cache_index'] = false;
                }
            }
            $t->assign(array('COMMENTS_ROW_ID' => $row['com_id'], 'COMMENTS_ROW_ORDER' => $cfg['plugin']['comments']['order'] == 'Recent' ? $totalitems - $i + 1 : $i, 'COMMENTS_ROW_URL' => cot_url($link_area, $link_params, '#c' . $row['com_id']), 'COMMENTS_ROW_AUTHOR' => cot_build_user($row['com_authorid'], htmlspecialchars($row['com_author'])), 'COMMENTS_ROW_AUTHORID' => $row['com_authorid'], 'COMMENTS_ROW_TEXT' => $com_text, 'COMMENTS_ROW_DATE' => cot_date('datetime_medium', $row['com_date']), 'COMMENTS_ROW_DATE_STAMP' => $row['com_date'], 'COMMENTS_ROW_ADMIN' => $com_admin, 'COMMENTS_ROW_EDIT' => $com_edit, 'COMMENTS_ROW_ODDEVEN' => cot_build_oddeven($kk), 'COMMENTS_ROW_NUM' => $kk));
            // Extrafields
            if (!empty(cot::$extrafields[cot::$db->com])) {
                foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                    $tag = mb_strtoupper($exfld['field_name']);
                    $exfld_title = cot_extrafield_title($exfld, 'comments_');
                    $t->assign(array('COMMENTS_ROW_' . $tag . '_TITLE' => $exfld_title, 'COMMENTS_ROW_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'COMMENTS_ROW_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
                }
            }
            $t->assign(cot_generate_usertags($row, 'COMMENTS_ROW_AUTHOR_', htmlspecialchars($row['com_author'])));
            /* === Hook - Part2 : Include === */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('COMMENTS.COMMENTS_ROW');
        }
        $pagenav = cot_pagenav($link_area, $link_params, $d, $totalitems, $cfg['plugin']['comments']['maxcommentsperpage'], $d_var, '#comments', $cfg['jquery'] && $cfg['ajax_enabled'], 'comments', 'plug', "e=comments&area={$ext_name}&cat={$cat}&item={$code}");
        $t->assign(array('COMMENTS_PAGES_INFO' => cot_rc('comments_code_pages_info', array('totalitems' => $totalitems, 'onpage' => $i - $d)), 'COMMENTS_PAGES_TOTALITEMS' => $totalitems, 'COMMENTS_PAGES_PAGESPREV' => $pagenav['prev'], 'COMMENTS_PAGES_PAGNAV' => $pagenav['main'], 'COMMENTS_PAGES_PAGESNEXT' => $pagenav['next']));
        $t->parse('COMMENTS.PAGNAVIGATOR');
    } elseif (!$sql->rowCount() && $enabled) {
        $t->assign(array('COMMENTS_EMPTYTEXT' => $L['com_nocommentsyet']));
        $t->parse('COMMENTS.COMMENTS_EMPTY');
    }
    /* == Hook == */
    foreach (cot_getextplugins('comments.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('COMMENTS');
    $res_display = $t->text('COMMENTS');
    return $res_display;
}
Exemplo n.º 6
0
/**
 * Returns all user tags for XTemplate
 *
 * @param mixed $user_data User Info Array
 * @param string $tag_prefix Prefix for tags
 * @param string $emptyname Name text if user is not exist
 * @param bool $allgroups Build info about all user groups
 * @param bool $cacheitem Cache tags
 * @return array
 * @global CotDB $db
 */
function cot_generate_usertags($user_data, $tag_prefix = '', $emptyname = '', $allgroups = false, $cacheitem = true)
{
    global $db, $cot_extrafields, $cot_groups, $cfg, $L, $user_cache, $db_users;
    static $extp_first = null, $extp_main = null;
    $return_array = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('usertags.first');
        $extp_main = cot_getextplugins('usertags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    $user_id = is_array($user_data) ? (int) $user_data['user_id'] : (is_numeric($user_data) ? (int) $user_data : 0);
    if (isset($user_cache[$user_id])) {
        $temp_array = $user_cache[$user_id];
    } else {
        if (!is_array($user_data) && $user_id > 0) {
            $sql = $db->query("SELECT * FROM {$db_users} WHERE user_id = {$user_id} LIMIT 1");
            $user_data = $sql->fetch();
        } else {
            if (!is_array($user_data)) {
                $user_data = array();
            }
        }
        if (is_array($user_data) && $user_data['user_id'] > 0 && !empty($user_data['user_name'])) {
            $user_data['user_birthdate'] = cot_date2stamp($user_data['user_birthdate']);
            $user_data['user_text'] = cot_parse($user_data['user_text'], $cfg['users']['usertextimg']);
            $temp_array = array('ID' => $user_data['user_id'], 'NAME' => cot_build_user($user_data['user_id'], htmlspecialchars($user_data['user_name'])), 'NICKNAME' => htmlspecialchars($user_data['user_name']), 'DETAILSLINK' => cot_url('users', 'm=details&id=' . $user_data['user_id'] . '&u=' . htmlspecialchars($user_data['user_name'])), 'DETAILSLINKSHORT' => cot_url('users', 'm=details&id=' . $user_data['user_id']), 'FULL_NAME' => htmlspecialchars(cot_user_full_name($user_data)), 'TITLE' => $cot_groups[$user_data['user_maingrp']]['title'], 'MAINGRP' => cot_build_group($user_data['user_maingrp']), 'MAINGRPID' => $user_data['user_maingrp'], 'MAINGRPNAME' => $cot_groups[$user_data['user_maingrp']]['name'], 'MAINGRPTITLE' => cot_build_group($user_data['user_maingrp'], true), 'MAINGRPSTARS' => cot_build_stars($cot_groups[$user_data['user_maingrp']]['level']), 'MAINGRPICON' => cot_build_groupicon($cot_groups[$user_data['user_maingrp']]['icon']), 'COUNTRY' => cot_build_country($user_data['user_country']), 'COUNTRYFLAG' => cot_build_flag($user_data['user_country']), 'TEXT' => $user_data['user_text'], 'EMAIL' => cot_build_email($user_data['user_email'], $user_data['user_hideemail']), 'THEME' => $user_data['user_theme'], 'SCHEME' => $user_data['user_scheme'], 'LANG' => $user_data['user_lang'], 'GENDER' => $user_data['user_gender'] == '' || $user_data['user_gender'] == 'U' ? '' : $L['Gender_' . $user_data['user_gender']], 'BIRTHDATE' => is_null($user_data['user_birthdate']) ? '' : cot_date('date_full', $user_data['user_birthdate']), 'BIRTHDATE_STAMP' => is_null($user_data['user_birthdate']) ? '' : $user_data['user_birthdate'], 'AGE' => is_null($user_data['user_birthdate']) ? '' : cot_build_age($user_data['user_birthdate']), 'TIMEZONE' => cot_build_timezone(cot_timezone_offset($user_data['user_timezone'], false, false)) . ' ' . str_replace('_', ' ', $user_data['user_timezone']), 'REGDATE' => cot_date('datetime_medium', $user_data['user_regdate']), 'REGDATE_STAMP' => $user_data['user_regdate'], 'LASTLOG' => cot_date('datetime_medium', $user_data['user_lastlog']), 'LASTLOG_STAMP' => $user_data['user_lastlog'], 'LOGCOUNT' => $user_data['user_logcount'], 'POSTCOUNT' => $user_data['user_postcount'], 'LASTIP' => $user_data['user_lastip']);
            if ($allgroups) {
                $temp_array['GROUPS'] = cot_build_groupsms($user_data['user_id'], FALSE, $user_data['user_maingrp']);
            }
            // Extra fields
            if (isset($cot_extrafields[$db_users])) {
                foreach ($cot_extrafields[$db_users] as $exfld) {
                    $temp_array[strtoupper($exfld['field_name'])] = cot_build_extrafields_data('user', $exfld, $user_data['user_' . $exfld['field_name']]);
                    $temp_array[strtoupper($exfld['field_name']) . '_TITLE'] = isset($L['user_' . $exfld['field_name'] . '_title']) ? $L['user_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                    $temp_array[strtoupper($exfld['field_name']) . '_VALUE'] = $user_data['user_' . $exfld['field_name']];
                }
            }
        } else {
            $temp_array = array('ID' => 0, 'NAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'NICKNAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'FULL_NAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'MAINGRP' => cot_build_group(1), 'MAINGRPID' => 1, 'MAINGRPSTARS' => '', 'MAINGRPICON' => cot_build_groupicon($cot_groups[1]['icon']), 'COUNTRY' => cot_build_country(''), 'COUNTRYFLAG' => cot_build_flag(''), 'TEXT' => '', 'EMAIL' => '', 'GENDER' => '', 'BIRTHDATE' => '', 'BIRTHDATE_STAMP' => '', 'AGE' => '', 'REGDATE' => '', 'REGDATE_STAMP' => '', 'POSTCOUNT' => '', 'LASTIP' => '');
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
        if (is_array($user_data) && isset($user_data['user_id'])) {
            $cacheitem && ($user_cache[$user_data['user_id']] = $temp_array);
        }
    }
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Exemplo n.º 7
0
foreach ($subcat as $x) {
    $kk++;
    $cat_childs = cot_structure_children('page', $x);
    $sub_count = 0;
    foreach ($cat_childs as $cat_child) {
        $sub_count += (int) $structure['page'][$cat_child]['count'];
    }
    $sub_url_path = $list_url_path;
    $sub_url_path['c'] = $x;
    $t->assign(array('LIST_ROWCAT_ID' => $structure['page'][$x]['id'], 'LIST_ROWCAT_URL' => cot_url('page', $sub_url_path), 'LIST_ROWCAT_TITLE' => $structure['page'][$x]['title'], 'LIST_ROWCAT_DESC' => $structure['page'][$x]['desc'], 'LIST_ROWCAT_ICON' => $structure['page'][$x]['icon'], 'LIST_ROWCAT_COUNT' => $sub_count, 'LIST_ROWCAT_ODDEVEN' => cot_build_oddeven($kk), 'LIST_ROWCAT_NUM' => $kk));
    // Extra fields for structure
    if (!empty(cot::$extrafields[cot::$db->structure])) {
        foreach (cot::$extrafields[cot::$db->structure] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'structure_');
            $t->assign(array('LIST_ROWCAT_' . $uname . '_TITLE' => $exfld_title, 'LIST_ROWCAT_' . $uname => cot_build_extrafields_data('structure', $exfld, cot::$structure['page'][$x][$exfld['field_name']]), 'LIST_ROWCAT_' . $uname . '_VALUE' => cot::$structure['page'][$x][$exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.LIST_ROWCAT');
}
$pagenav_cat = cot_pagenav('page', $list_url_path + array('d' => $durl), $dc, count($allsub), cot::$cfg['page']['maxlistsperpage'], 'dc');
$t->assign(array('LISTCAT_PAGEPREV' => $pagenav_cat['prev'], 'LISTCAT_PAGENEXT' => $pagenav_cat['next'], 'LISTCAT_PAGNAV' => $pagenav_cat['main']));
$jj = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.list.loop');
/* ===== */
Exemplo n.º 8
0
    }
    if ($row['ft_postcount'] > $cfg['forums']['maxpostsperpage'] && !$row['ft_movedto']) {
        $pn_q = $row['ft_movedto'] > 0 ? $row['ft_movedto'] : $row['ft_id'];
        $pn = cot_pagenav('forums', 'm=posts&q=' . $pn_q, 0, $row['ft_postcount'], $cfg['forums']['maxpostsperpage'], 'd');
        $row['ft_pages'] = cot_rc('forums_code_topic_pages', array('main' => $pn['main'], 'first' => $pn['first'], 'last' => $pn['last']));
    }
    $row['ft_icon_type_ex'] = $row['ft_icon_type'];
    if ($row['ft_user_posted']) {
        $row['ft_icon_type_ex'] .= '_posted';
    }
    $t->assign(array('FORUMS_TOPICS_ROW_ID' => $row['ft_id'], 'FORUMS_TOPICS_ROW_STATE' => $row['ft_state'], 'FORUMS_TOPICS_ROW_ICON' => $row['ft_icon'], 'FORUMS_TOPICS_ROW_ICON_TYPE' => $row['ft_icon_type'], 'FORUMS_TOPICS_ROW_ICON_TYPE_EX' => $row['ft_icon_type_ex'], 'FORUMS_TOPICS_ROW_TITLE' => htmlspecialchars($row['ft_title']), 'FORUMS_TOPICS_ROW_DESC' => htmlspecialchars($row['ft_desc']), 'FORUMS_TOPICS_ROW_CREATIONDATE' => cot_date('datetime_short', $row['ft_creationdate']), 'FORUMS_TOPICS_ROW_CREATIONDATE_STAMP' => $row['ft_creationdate'], 'FORUMS_TOPICS_ROW_UPDATEDURL' => $row['ft_lastposturl'], 'FORUMS_TOPICS_ROW_UPDATED' => $row['ft_lastpostlink'], 'FORUMS_TOPICS_ROW_UPDATED_STAMP' => $row['ft_updated'], 'FORUMS_TOPICS_ROW_MOVED' => $row['ft_movedto'] > 0 ? 1 : 0, 'FORUMS_TOPICS_ROW_TIMEAGO' => cot_build_timegap($row['ft_updated']), 'FORUMS_TOPICS_ROW_POSTCOUNT' => $row['ft_postcount'], 'FORUMS_TOPICS_ROW_REPLYCOUNT' => $row['ft_replycount'], 'FORUMS_TOPICS_ROW_VIEWCOUNT' => $row['ft_viewcount'], 'FORUMS_TOPICS_ROW_FIRSTPOSTER' => cot_build_user($row['ft_firstposterid'], htmlspecialchars($row['ft_firstpostername'])), 'FORUMS_TOPICS_ROW_LASTPOSTER' => $row['ft_lastpostername'], 'FORUMS_TOPICS_ROW_USER_POSTED' => (int) $row['ft_user_posted'], 'FORUMS_TOPICS_ROW_URL' => $row['ft_url'], 'FORUMS_TOPICS_ROW_PREVIEW' => $row['ft_preview'] . '...', 'FORUMS_TOPICS_ROW_PAGES' => $row['ft_pages'], 'FORUMS_TOPICS_ROW_MAXPAGES' => $row['ft_maxpages'], 'FORUMS_TOPICS_ROW_ODDEVEN' => cot_build_oddeven($ft_num), 'FORUMS_TOPICS_ROW_NUM' => $ft_num, 'FORUMS_TOPICS_ROW' => $row));
    if (!empty(cot::$extrafields[cot::$db->forum_topics])) {
        foreach (cot::$extrafields[cot::$db->forum_topics] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'forums_topic_');
            $t->assign(array('FORUMS_TOPICS_ROW_' . $tag . '_TITLE' => $exfld_title, 'FORUMS_TOPICS_ROW_' . $tag => cot_build_extrafields_data('forums', $exfld, $row['ft_' . $exfld['field_name']], cot::$cfg['forums']['markup'] && cot::$cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_TOPICS_ROW_' . $tag . '_VALUE' => $row['ft_' . $exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.FORUMS_TOPICS_ROW');
}
$pagenav = cot_pagenav('forums', "m=topics&s={$s}&ord={$o}&w={$w}", $d, $totaltopics, cot::$cfg['forums']['maxtopicsperpage']);
$toptitle = cot_breadcrumbs(cot_forums_buildpath($s), $cfg['homebreadcrumb']);
$toptitle .= $usr['isadmin'] ? cot::$R['forums_code_admin_mark'] : '';
$jumpbox[cot_url('forums')] = cot::$L['Forums'];
foreach ($structure['forums'] as $key => $val) {
    if (cot_auth('forums', $key, 'R')) {
Exemplo n.º 9
0
    if (!cot_error_found()) {
        $rcontact['contact_authorid'] = (int) $usr['id'];
        $rcontact['contact_date'] = (int) $sys['now'];
        $rcontact['contact_val'] = 0;
        if (in_array($cfg['plugin']['contact']['save'], array('db', 'both'))) {
            $db->insert($db_contact, $rcontact);
        }
        $semail = !empty($cfg['plugin']['contact']['email']) ? $cfg['plugin']['contact']['email'] : $cfg['adminemail'];
        if (cot_check_email($semail) && in_array($cfg['plugin']['contact']['save'], array('email', 'both'))) {
            $headers = "From: \"" . $rcontact['contact_author'] . "\" <" . $rcontact['contact_email'] . ">\n";
            $context = array('sitetitle' => $cfg["maintitle"], 'siteurl' => $cfg['mainurl'], 'author' => $rcontact['contact_author'], 'email' => $rcontact['contact_email'], 'subject' => $rcontact['contact_subject'], 'text' => $rcontact['contact_text']);
            $rextras = '';
            if (!empty(cot::$extrafields[cot::$db->contact])) {
                foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
                    $exfld_title = cot_extrafield_title($exfld, 'contact_');
                    $ex_body = cot_build_extrafields_data('contact', $exfld, $rcontact['contact_' . $exfld['field_name']]);
                    $rextras .= "\n" . $exfld_title . ": " . $ex_body;
                    $context['extra' . $exfld['field_name']] = $ex_body;
                    $context['extra' . $exfld['field_name'] . '_title'] = $exfld_title;
                    $context['extra' . $exfld['field_name'] . '_value'] = $rcontact['contact_' . $exfld['field_name']];
                }
            }
            $context['extra'] = $rextras;
            $rtextm = cot_rc(empty(cot::$cfg['plugin']['contact']['template']) ? cot::$R['contact_message'] : cot::$cfg['plugin']['contact']['template'], $context);
            cot_mail($semail, $rcontact['contact_subject'], $rtextm, $headers);
        }
        $sent = true;
        cot_message('contact_message_sent');
        cot_extrafield_movefiles();
    }
}
Exemplo n.º 10
0
    $rowt['ft_icon'] .= '_new';
    $rowt['ft_postisnew'] = TRUE;
}
if ($rowt['ft_postcount'] >= $cfg['forums']['hottopictrigger'] && !$rowt['ft_state'] && !$rowt['ft_sticky']) {
    $rowt['ft_icon'] = $rowt['ft_postisnew'] ? 'posts_new_hot' : 'posts_hot';
} else {
    $rowt['ft_icon'] .= $rowt['ft_sticky'] ? '_sticky' : '';
    $rowt['ft_icon'] .= $rowt['ft_state'] ? '_locked' : '';
}
$rowt['ft_icon_type'] = $rowt['ft_icon'];
$rowt['ft_icon'] = cot_rc('forums_icon_topic', array('icon' => $rowt['ft_icon']));
$rowt['ft_icon_type_ex'] = $rowt['ft_icon_type'];
if ($rowt['ft_user_posted']) {
    $rowt['ft_icon_type_ex'] .= '_posted';
}
$t->assign(array('FORUMS_POSTS_ICON' => $rowt['ft_icon'], 'FORUMS_POSTS_ICON_TYPE' => $rowt['ft_icon_type'], 'FORUMS_POSTS_ICON_TYPE_EX' => $rowt['ft_icon_type_ex']));
foreach ($cot_extrafields[$db_forum_topics] as $exfld) {
    $tag = mb_strtoupper($exfld['field_name']);
    $t->assign(array('FORUMS_POSTS_TOPIC_' . $tag . '_TITLE' => isset($L['forums_topics_' . $exfld['field_name'] . '_title']) ? $L['forums_topics_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'FORUMS_POSTS_TOPIC_' . $tag => cot_build_extrafields_data('forums', $exfld, $rowt['ft_' . $exfld['field_name']], $cfg['forums']['markup'] && $cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_POSTS_TOPIC_' . $tag . '_VALUE' => $rowt['ft_' . $exfld['field_name']]));
}
/* === Hook  === */
foreach (cot_getextplugins('forums.posts.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse('MAIN');
$t->out('MAIN');
require_once $cfg['system_dir'] . '/footer.php';
if ($cache && $usr['id'] === 0 && $cfg['cache_forums']) {
    $cache->page->write();
}
Exemplo n.º 11
0
        case 'polls':
            $row['com_url'] = cot_url('polls', 'id=' . $row['com_value'] . "&comments=1", '#c' . $row['com_id']);
            break;
        case 'e_shop':
            $row['com_url'] = cot_url('plug', 'e=e_shop&sh=product&productID=' . $row['com_value'], '#c' . $row['com_id']);
            break;
        default:
            $row['com_url'] = '';
            break;
    }
    $t->assign(array('ADMIN_COMMENTS_ITEM_DEL_URL' => cot_url('admin', 'm=other&p=comments&a=delete&id=' . $row['com_id'] . '&' . cot_xg()), 'ADMIN_COMMENTS_ITEM_ID' => $row['com_id'], 'ADMIN_COMMENTS_CODE' => $row['com_code'], 'ADMIN_COMMENTS_AREA' => $row['com_area'], 'ADMIN_COMMENTS_AUTHOR' => $row['com_author'], 'ADMIN_COMMENTS_DATE' => cot_date('datetime_medium', $row['com_date']), 'ADMIN_COMMENTS_DATE_STAMP' => $row['com_date'], 'ADMIN_COMMENTS_TEXT' => $row['com_text'], 'ADMIN_COMMENTS_URL' => $row['com_url'], 'ADMIN_COMMENTS_ODDEVEN' => cot_build_oddeven($ii)));
    if (!empty(cot::$extrafields[cot::$db->com])) {
        foreach (cot::$extrafields[cot::$db->com] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'comments_');
            $t->assign(array('ADMIN_COMMENTS_' . $tag . '_TITLE' => $exfld_title, 'ADMIN_COMMENTS_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'ADMIN_COMMENTS_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.ADMIN_COMMENTS_ROW');
    $ii++;
}
$t->assign(array('ADMIN_COMMENTS_CONFIG_URL' => cot_url('admin', 'm=config&n=edit&o=plug&p=comments'), 'ADMIN_COMMENTS_ADMINWARNINGS' => $adminwarnings, 'ADMIN_COMMENTS_PAGINATION_PREV' => $pagenav['prev'], 'ADMIN_COMMENTS_PAGNAV' => $pagenav['main'], 'ADMIN_COMMENTS_PAGINATION_NEXT' => $pagenav['next'], 'ADMIN_COMMENTS_TOTALITEMS' => $totalitems, 'ADMIN_COMMENTS_COUNTER_ROW' => $ii));
/* === Hook  === */
foreach (cot_getextplugins('admin.comments.tags') as $pl) {
    include $pl;
}
Exemplo n.º 12
0
 public function editAction()
 {
     global $structure, $cot_extrafields, $db_structure;
     $id = cot_import('id', 'G', 'INT');
     // id Объявления
     $c = cot_import('c', 'G', 'TXT');
     $act = cot_import('act', 'G', 'ALP');
     if (empty($act)) {
         $act = cot_import('act', 'P', 'ALP');
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.first') as $pl) {
         include $pl;
     }
     /* ===== */
     // Права на любую категорию доски объявлений
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', 'any');
     cot_block(cot::$usr['auth_write']);
     if (!$c || !isset($structure['advboard'][$c])) {
         cot_die_message(404, TRUE);
     }
     $category = $structure['advboard'][$c];
     $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     $category['code'] = $c;
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $published = 0;
     if (!$id) {
         $advert = new advboard_model_Advert();
         $advert->category = $c;
         $advert->user = cot::$usr['id'];
     } else {
         $advert = advboard_model_Advert::getById($id);
         if (!$advert) {
             cot_die_message(404, TRUE);
         }
         if (!cot::$usr['isadmin']) {
             if ($advert->user != cot::$usr['id']) {
                 cot_die_message(404, TRUE);
             }
         }
         if ($c != $advert->category && isset($structure['advboard'][$advert->category])) {
             $tmp = array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id);
             if (!empty($act)) {
                 $tmp['act'] = $act;
             }
             cot_redirect(cot_url('advboard', array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id), '', true));
         }
         if ($act == 'clone') {
             $id = null;
             $advert = clone $advert;
             // Установить статус и пользователя нового объекта
             $advert->user = cot::$usr['id'];
             $advert->state = advboard_model_Advert::DRAFT;
         }
         $published = $advert->state < 2 ? 1 : 0;
     }
     //Проверим права на категорию:
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin'], cot::$usr['auth_upload']) = cot_auth('advboard', $c, 'RWA1');
     if ($structure['advboard'][$c]['locked'] && !cot::$usr['isadmin']) {
         cot_die_message(602, TRUE);
     } elseif ($advert->id == 0) {
         // Если у пользователя нет прав на подачу объявления, то ищем категорию куда он может подать оьбъявление
         if (!cot::$usr['auth_write']) {
             foreach ($structure['advboard'] as $catCode => $catRow) {
                 $auth_write = cot_auth('advboard', $catCode, 'W');
                 if ($auth_write) {
                     cot_redirect(cot_url('advboard', array('c' => $catCode, 'a' => 'edit'), '', true));
                 }
             }
         }
         cot_block(cot::$usr['auth_write']);
     }
     // Владелец объявления
     $user = array();
     if ($advert->user > 0) {
         $user = cot_user_data($advert->user);
     }
     $periodItems = adv_periodItems($c);
     // Сохранение
     if ($act == 'save') {
         unset($_POST['id'], $_POST['user']);
         cot_shield_protect();
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.first') as $pl) {
             include $pl;
         }
         /* ===== */
         // импортировать даты
         $begin = (int) cot_import_date('begin');
         $expire = (int) cot_import_date('expire');
         if ($begin == 0) {
             $begin = !empty($advert->begin) ? $advert->begin : cot::$sys['now'];
         }
         // Пересчитать период публикации объявления
         if ($expire == 0 && cot::$cfg['advboard']['cat_' . $c]['maxPeriod'] > 0) {
             $period = cot_import('period', 'P', 'INT');
             $maxPeriod = max($periodItems);
             if (empty($period)) {
                 $period = $maxPeriod;
             }
             if (!cot::$usr['isadmin'] && $period > $maxPeriod) {
                 $period = $maxPeriod;
             }
             if ($period > 0) {
                 $expire = $begin + $period * 86400;
             }
         }
         if ($category['config']['title_require']) {
             $advert->setValidator('title', 'required');
         }
         // Валидатор 'allowemptytext'
         if (!$category['config']['allowemptytext']) {
             $advert->setValidator('text', 'required');
         }
         if ($category['config']['phone_require']) {
             // проверить надичие заполненного поля в профиле пользователя - владельца
             if (empty($user['user_phone'])) {
                 $advert->setValidator('phone', 'required');
             }
         }
         if ($category['config']['city_require']) {
             // Проверить наличие заполненного города (id или названия) в профиле владельца
             if (empty($user['user_city_name']) && empty($user['user_city'])) {
                 if (cot_plugin_active('regioncity')) {
                     $advert->setValidator('city', function ($value) {
                         $value = (int) $value;
                         if ($value == 0) {
                             return cot::$L['field_required'] . ': ' . advboard_model_Advert::fieldLabel('city');
                         }
                         return true;
                     });
                 } else {
                     $advert->setValidator('city_name', 'required');
                 }
             }
         }
         if (cot::$usr['id'] == 0) {
             $advert->setValidator('person', 'required');
             // Email
             $email = cot_import('email', 'P', 'TXT');
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 if ($email == '') {
                     cot_error(cot::$L['advboard_err_noemail'], 'email');
                 }
             }
             if ($email != '') {
                 $tmp = advert_checkEmail($email);
                 if ($tmp !== true) {
                     cot_error($tmp, 'email');
                 }
             }
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $verify = cot_import('verify', 'P', 'TXT');
                 if (!cot_captcha_validate($verify)) {
                     cot_error(cot::$L['captcha_verification_failed'], 'verify');
                 }
             }
         }
         $advert->setData($_POST);
         $advert->begin = $begin;
         $advert->expire = $expire;
         if (!cot::$usr['isadmin']) {
             if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky']) {
                 $advert->sticky = 0;
             }
             if (cot::$usr['id'] == 0) {
                 $advert->sticky = 0;
             }
             // гости не дают срочных объявлений
         }
         $advert->category = $c;
         if (empty($advert->user) || !cot::$usr['isadmin']) {
             $advert->user = cot::$usr['id'];
         }
         $published = cot_import('published', 'P', 'BOL');
         if (!$published) {
             $advert->state = advboard_model_Advert::DRAFT;
         } elseif (cot::$usr['isadmin'] || cot_auth('advboard', $c, '2')) {
             $advert->state = advboard_model_Advert::PUBLISHED;
         } else {
             $advert->state = advboard_model_Advert::AWAITING_MODERATION;
         }
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.validate') as $pl) {
             include $pl;
         }
         /* ===== */
         // There is some errors
         if (!$advert->validate() || cot_error_found()) {
             $urlParams = array('c' => $c, 'a' => 'edit');
             if ($advert->id > 0) {
                 $urlParams['id'] = $advert->id;
             }
             cot_redirect(cot_url('advboard', $urlParams, '', true));
         }
         if (empty($advert->sort)) {
             $advert->sort = cot::$sys['now'];
         }
         $isNew = $advert->id == 0;
         // Сохранение
         if ($advert->save()) {
             // Для незарега запомним id страницы для чтого, чтобы он мог ее отредактировать в пределах сесии
             if ($isNew) {
                 if (cot::$usr['id'] == 0) {
                     if (empty($_SESSION['advboard'])) {
                         $_SESSION['advboard'] = array();
                     }
                     if (!in_array($id, $_SESSION['advboard'])) {
                         $_SESSION['advboard'][] = $advert->id;
                     }
                 }
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_created']);
                 }
             } else {
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_updated']);
                 }
             }
             if ($advert->state == advboard_model_Advert::AWAITING_MODERATION) {
                 cot_message(cot::$L['advboard_awaiting_moderation']);
             } elseif ($advert->state == advboard_model_Advert::DRAFT) {
                 cot_message(cot::$L['Saved']);
             }
             $redirectUrl = $advert->getUrl(true);
             /* === Hook === */
             foreach (cot_getextplugins('advboard.save.done') as $pl) {
                 include $pl;
             }
             /* ===== */
             // Редирект на станицу объявления
             cot_redirect($redirectUrl);
         }
     }
     $crumbs = cot_structure_buildpath('advboard', $c);
     if (cot::$cfg['advboard']['firstCrumb']) {
         array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
     }
     if (!$id) {
         $crumbs[] = $title = cot::$L['advboard_add_new'];
         cot::$out['subtitle'] = $title;
     } else {
         $crumbs[] = array($advert->url, $advert->title);
         $crumbs[] = cot::$L['Edit'];
         $title = cot::$L['advboard_advert'] . ' #' . $advert->id;
         if (!empty($advert->title)) {
             $title = $advert->title;
         }
         $title .= ': ' . cot::$L['Edit'];
         if (!empty(cot::$out['subtitle'])) {
             $title .= ' - ' . cot::$out['subtitle'];
         }
         cot::$out['subtitle'] = $title;
     }
     // Elemets placeholders
     $placeHolder_Person = '';
     $placeHolder_Phone = '';
     $placeHolder_Email = '';
     $placeHolder_City = '';
     //if($advboard->user == cot::$usr['id'] && cot::$usr['id'] > 0) {
     if (!empty($user)) {
         // Контакное лицо
         $placeHolder_Person = cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $placeHolder_Phone = $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $placeHolder_Email = $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $placeHolder_City = $user['user_city_name'];
         }
     }
     // 'input_textarea_editor', 'input_textarea_medieditor', 'input_textarea_minieditor', ''
     $editor = 'input_textarea_editor';
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $minYear = date('Y');
     $maxYear = $minYear + 30;
     $price = $advert->rawValue('price');
     if ($price <= 0) {
         $price = '';
     }
     $formElements = array('hidden' => array('element' => cot_inputbox('hidden', 'act', 'save')), 'category' => array('element' => cot_selectbox_structure('advboard', $advert->category, 'category'), 'label' => advboard_model_Advert::fieldLabel('category')), 'price' => array('element' => cot_inputbox('text', 'price', $price), 'label' => advboard_model_Advert::fieldLabel('price'), 'hint' => cot::$L['advboard_price_hint']), 'title' => array('element' => cot_inputbox('text', 'title', $advert->rawValue('title')), 'required' => true, 'label' => advboard_model_Advert::fieldLabel('title')), 'description' => array('element' => cot_inputbox('text', 'description', $advert->rawValue('description')), 'label' => advboard_model_Advert::fieldLabel('description')), 'text' => array('element' => cot_textarea('text', $advert->rawValue('text'), 5, 120, '', $editor), 'label' => advboard_model_Advert::fieldLabel('text')), 'person' => array('element' => cot_inputbox('text', 'person', $advert->rawValue('person'), array('class' => 'form-control', 'placeholder' => $placeHolder_Person)), 'label' => advboard_model_Advert::fieldLabel('person'), 'required' => cot::$usr['id'] == 0), 'email' => array('element' => cot_inputbox('text', 'email', $advert->rawValue('email'), array('class' => 'form-control', 'placeholder' => $placeHolder_Email)), 'label' => advboard_model_Advert::fieldLabel('email')), 'city' => array('element' => cot_inputbox('text', 'city_name', $advert->rawValue('city_name'), array('class' => 'form-control', 'placeholder' => $placeHolder_City)), 'label' => advboard_model_Advert::fieldLabel('city_name'), 'required' => $category['config']['city_require']), 'phone' => array('element' => cot_inputbox('text', 'phone', $advert->rawValue('phone'), array('class' => 'form-control', 'placeholder' => $placeHolder_Phone)), 'label' => advboard_model_Advert::fieldLabel('phone'), 'required' => $category['config']['phone_require']), 'sticky' => array('element' => cot_checkbox($advert->sticky, 'sticky', advboard_model_Advert::fieldLabel('sticky')), 'label' => advboard_model_Advert::fieldLabel('sticky')), 'published' => array('element' => cot_checkbox($published, 'published', cot::$L['advboard_published'] . '?'), 'label' => cot::$L['advboard_published'] . '?'), 'begin' => array('element' => cot_selectbox_date($advert->begin, 'long', 'begin', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('begin')), 'expire' => array('element' => cot_selectbox_date($advert->expire, 'long', 'expire', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('expire')), 'sort' => array('element' => cot_selectbox_date($advert->sort, 'long', 'sort', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('sort')), 'period' => array('element' => cot_selectbox('', 'period', $periodItems, array(), false), 'label' => cot::$L['advboard_period']));
     if (!empty($cot_extrafields[cot::$db->advboard])) {
         // Extra fields for ads
         foreach ($cot_extrafields[cot::$db->advboard] as $exfld) {
             $fName = $exfld['field_name'];
             $formElements[$fName] = array('element' => cot_build_extrafields($fName, $exfld, $advert->rawValue($fName)));
             if ($exfld['field_type'] !== 'checkbox') {
                 $formElements[$fName]['label'] = isset(cot::$L['advboard_' . $exfld['field_name'] . '_title']) ? cot::$L['advboard_' . $exfld['field_name'] . '_title'] : advboard_model_Advert::fieldLabel($fName);
             }
         }
     }
     if (cot_plugin_active('regioncity')) {
         $formElements['city']['element'] = rec_select2_city('city', $advert->rawValue('city'), true, array('class' => 'form-control', 'placeholder' => $placeHolder_City));
     }
     if ($category['config']['city_require']) {
         $formElements['city']['required'] = true;
     }
     if ($category['config']['phone_require']) {
         $formElements['phone']['required'] = true;
     }
     // Hints
     if (!empty($user)) {
         // Контакное лицо
         $formElements['person']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $formElements['phone']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $formElements['email']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $formElements['city']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_city_name'];
         }
     }
     if (!cot::$usr['isadmin']) {
         unset($formElements['begin']);
         unset($formElements['expire']);
         unset($formElements['sort']);
         if (cot::$usr['id'] == 0) {
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 $formElements['email']['required'] = true;
             }
             // Гости не дают срочных объявлений
             unset($formElements['sticky']);
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $formElements['verify'] = array('element' => cot_inputbox('text', 'verify'), 'img' => cot_captcha_generate(), 'label' => cot::$L['advboard_captcha'], 'required' => true);
             }
         }
         if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky'] && isset($formElements['sticky'])) {
             unset($formElements['sticky']);
         }
     } else {
         // Администратор напрямую указывает дату окончания публикации
         unset($formElements['period']);
     }
     $actionParams = array('a' => 'edit', 'c' => $advert->category);
     if ($advert->id > 0) {
         $actionParams['id'] = $advert->id;
     }
     $view = new View();
     $view->breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     $view->page_title = $title;
     $view->category = $category;
     $view->advert = $advert;
     $view->user = $user;
     $view->formElements = $formElements;
     $view->formAction = cot_url('advboard', $actionParams);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render(array('advboard', 'edit', $structure['advboard'][$c]['tpl']));
 }
Exemplo n.º 13
0
/**
 * Returns all section tags for coTemplate
 *
 * @param string $cat Forums structure cat code
 * @param string $tag_prefix Prefix for tags
 * @param array $stat Category statistics
 *
 * @return array
 */
function cot_generate_sectiontags($cat, $tag_prefix = '', $stat = NULL)
{
    global $cfg, $structure, $cot_extrafields, $usr, $sys, $L, $db_structure;
    $stat['fs_lt_date'] = !empty($stat['fs_lt_date']) ? $stat['fs_lt_date'] : 0;
    $stat['fs_lt_posterid'] = !empty($stat['fs_lt_posterid']) ? $stat['fs_lt_posterid'] : 0;
    $usr['lastvisit'] = !empty($usr['lastvisit']) ? $usr['lastvisit'] : 0;
    $new_elems = $usr['id'] > 0 && $stat['fs_lt_date'] > $usr['lastvisit'] && $stat['fs_lt_posterid'] != $usr['id'];
    $sections = array($tag_prefix . 'CAT' => $cat, $tag_prefix . 'LOCKED' => $structure['forums'][$cat]['locked'], $tag_prefix . 'TITLE' => $structure['forums'][$cat]['title'], $tag_prefix . 'DESC' => cot_parse_autourls($structure['forums'][$cat]['desc']) . ($structure['forums'][$cat]['locked'] ? ' ' . $L['Locked'] : ''), $tag_prefix . 'ICON' => empty($structure['forums'][$cat]['icon']) ? '' : cot_rc('img_structure_cat', array('icon' => $structure['forums'][$cat]['icon'], 'title' => htmlspecialchars($structure['forums'][$cat]['title']), 'desc' => htmlspecialchars($structure['forums'][$cat]['desc']))), $tag_prefix . 'URL' => cot_url('forums', 'm=topics&s=' . $cat), $tag_prefix . 'SECTIONSURL' => cot_url('forums', 'c=' . $cat), $tag_prefix . 'NEWPOSTS' => $new_elems, $tag_prefix . 'CAT_DEFSTATE' => htmlspecialchars($cfg['forums']['cat_' . $cat]['defstate']));
    if (is_array($stat)) {
        if ($stat['fs_lt_date'] > 0) {
            $sections += array($tag_prefix . 'LASTPOSTDATE' => cot_date('datetime_short', $stat['fs_lt_date']), $tag_prefix . 'LASTPOSTER' => cot_build_user($stat['fs_lt_posterid'], htmlspecialchars($stat['fs_lt_postername'])), $tag_prefix . 'LASTPOST' => cot_rc_link($new_elems ? cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=unread', '#unread') : cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=last', '#bottom'), cot_cutstring($stat['fs_lt_title'], 32)), $tag_prefix . 'LASTPOST_URL' => $new_elems ? cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=unread', '#unread') : cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=last', '#bottom'), $tag_prefix . 'TIMEAGO' => cot_build_timegap($stat['fs_lt_date'], $sys['now']));
        }
        $sections += array($tag_prefix . 'TOPICCOUNT' => $stat['topiccount'], $tag_prefix . 'LASTPOSTDATE_STAMP' => $stat['fs_lt_date'], $tag_prefix . 'POSTCOUNT' => $stat['postcount'], $tag_prefix . 'VIEWCOUNT' => $stat['viewcount'], $tag_prefix . 'VIEWCOUNT_SHORT' => $stat['viewcount'] > 9999 ? floor($stat['viewcount'] / 1000) . 'k' : $stat['viewcount']);
    }
    if (!is_array($stat) || !$stat['fs_lt_date']) {
        $sections[$tag_prefix . 'LASTPOSTDATE'] = '';
        $sections[$tag_prefix . 'LASTPOSTER'] = '';
        $sections[$tag_prefix . 'LASTPOST'] = '';
        $sections[$tag_prefix . 'TIMEAGO'] = '';
        $sections[$tag_prefix . 'TOPICCOUNT'] = 0;
        $sections[$tag_prefix . 'POSTCOUNT'] = 0;
        $sections[$tag_prefix . 'VIEWCOUNT'] = 0;
        $sections[$tag_prefix . 'VIEWCOUNT_SHORT'] = 0;
    }
    foreach ($cot_extrafields[$db_structure] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $sections[$tag_prefix . $uname . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
        $sections[$tag_prefix . $uname] = cot_build_extrafields_data('structure', $exfld, $structure['forums'][$cat][$exfld['field_name']]);
        $sections[$tag_prefix . $uname . '_VALUE'] = $structure['forums'][$cat][$exfld['field_name']];
    }
    return $sections;
}
Exemplo n.º 14
0
            break;
        case 'polls':
            $row['com_url'] = cot_url('polls', 'id=' . $row['com_value'] . "&comments=1", '#c' . $row['com_id']);
            break;
        case 'e_shop':
            $row['com_url'] = cot_url('plug', 'e=e_shop&sh=product&productID=' . $row['com_value'], '#c' . $row['com_id']);
            break;
        default:
            $row['com_url'] = '';
            break;
    }
    $t->assign(array('ADMIN_COMMENTS_ITEM_DEL_URL' => cot_url('admin', 'm=other&p=comments&a=delete&id=' . $row['com_id'] . '&' . cot_xg()), 'ADMIN_COMMENTS_ITEM_ID' => $row['com_id'], 'ADMIN_COMMENTS_CODE' => $row['com_code'], 'ADMIN_COMMENTS_AREA' => $row['com_area'], 'ADMIN_COMMENTS_AUTHOR' => $row['com_author'], 'ADMIN_COMMENTS_DATE' => cot_date('datetime_medium', $row['com_date']), 'ADMIN_COMMENTS_DATE_STAMP' => $row['com_date'], 'ADMIN_COMMENTS_TEXT' => $row['com_text'], 'ADMIN_COMMENTS_URL' => $row['com_url'], 'ADMIN_COMMENTS_ODDEVEN' => cot_build_oddeven($ii)));
    if (isset($cot_extrafields[$db_com])) {
        foreach ($cot_extrafields[$db_com] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $t->assign(array('ADMIN_COMMENTS_' . $tag . '_TITLE' => isset($L['comments_' . $exfld['field_name'] . '_title']) ? $L['comments_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'ADMIN_COMMENTS_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'ADMIN_COMMENTS_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.ADMIN_COMMENTS_ROW');
    $ii++;
}
$t->assign(array('ADMIN_COMMENTS_CONFIG_URL' => cot_url('admin', 'm=config&n=edit&o=plug&p=comments'), 'ADMIN_COMMENTS_ADMINWARNINGS' => $adminwarnings, 'ADMIN_COMMENTS_PAGINATION_PREV' => $pagenav['prev'], 'ADMIN_COMMENTS_PAGNAV' => $pagenav['main'], 'ADMIN_COMMENTS_PAGINATION_NEXT' => $pagenav['next'], 'ADMIN_COMMENTS_TOTALITEMS' => $totalitems, 'ADMIN_COMMENTS_COUNTER_ROW' => $ii));
/* === Hook  === */
foreach (cot_getextplugins('admin.comments.tags') as $pl) {
    include $pl;
}
Exemplo n.º 15
0
    $admin_tags_join_fields = ", f.*";
    $admin_tags_join_tables = " LEFT JOIN {$db_forum_posts} AS f\n\t\tON t.tag_area = 'forums' AND t.tag_item = f.fp_id";
}
$totalitems = $db->query("SELECT distinct(tag) FROM {$db_tag_references} AS t WHERE 1 " . $admin_tags_join_where)->rowCount();
//$totalitems = $db->countRows($db_tags);
$pagenav = cot_pagenav('admin', 'm=other&p=tags&sorttype=' . $sorttype . '&sortway=' . $sortway . '&filter=' . $filter, $d, $totalitems, $cfg['maxrowsperpage'], 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$sql = $db->query("SELECT t.*,COUNT(*) AS tag_cnt, GROUP_CONCAT(t.tag_area,':',t.tag_item SEPARATOR ',') AS tag_grp {$admin_tags_join_fields}\n\tFROM {$db_tag_references} AS t {$admin_tags_join_tables}\n\tWHERE 1 {$admin_tags_join_where}\n\tGROUP BY t.tag\n\tORDER BY {$admin_tags_join_sorttype} {$sortway} LIMIT {$d}, " . $cfg['maxrowsperpage']);
$ii = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('admin.tags.loop');
/* ===== */
foreach ($sql->fetchAll() as $row) {
    if (isset($cot_extrafields[$db_tag_references])) {
        foreach ($cot_extrafields[$db_tag_references] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $tt->assign(array('ADMIN_TAGS_' . $tag . '_TITLE' => isset($L['tags_' . $exfld['field_name'] . '_title']) ? $L['tags_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'ADMIN_TAGS_' . $tag => cot_build_extrafields_data('tags', $exfld, $row['tag_' . $exfld['field_name']]), 'ADMIN_TAGS_' . $tag . '_VALUE' => $row['tag_' . $exfld['field_name']]));
        }
    }
    if (!empty($row['tag_grp'])) {
        $item_mas = array();
        $items = explode(',', $row['tag_grp']);
        foreach ($items as $val) {
            $item = explode(':', $val);
            $item_mas[$item[0]][] = $item[1];
        }
        foreach ($item_mas as $k => $v) {
            if ($k == 'pages') {
                foreach ($v as $kk => $vv) {
                    $row_item = cot_generate_pagetags($vv, 'ADMIN_TAGS_ITEM_', 200);
                    if ($row_item['ADMIN_TAGS_ITEM_TITLE'] == 'Удалено') {
                    } else {
Exemplo n.º 16
0
    if (!empty(cot::$extrafields[cot::$db->contact])) {
        foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields_data('contact', $exfld, $row['contact_' . $exfld['field_name']]);
            $exfld_title = cot_extrafield_title($exfld, 'contact_');
            $tuman->assign(array('CONTACT_' . $tag . '_TITLE' => $exfld_title, 'CONTACT_' . $tag => $exfld_val, 'CONTACT_' . $tag . '_VALUE' => $row['contact_' . $exfld['field_name']], 'CONTACT_EXTRAFLD_TITLE' => $exfld_title, 'CONTACT_EXTRAFLD' => $exfld['field_type'] == 'file' ? cot_rc_link($cfg['extrafield_files_dir'] . '/' . $exfld_val, $exfld_val) : $exfld_val, 'CONTACT_EXTRAFLD_VALUE' => $row['contact_' . $exfld['field_name']]));
            $tuman->parse('MAIN.DATA.EXTRAFLD');
        }
    }
    $tuman->parse('MAIN.DATA');
}
$sql->closeCursor();
if ($a == '' && !empty($id)) {
    $row = $db->query("SELECT * FROM " . cot::$db->contact . " WHERE contact_id = {$id}")->fetch();
    $tuman->assign(array('CONTACT_DATE' => cot_date('date_full', $row['contact_date']), 'CONTACT_DATE_STAMP' => $row['contact_date'], 'CONTACT_USER' => $row['contact_authorid'] > 0 ? cot_build_user($row['contact_authorid'], $row['contact_author']) : $row['contact_author'], 'CONTACT_EMAIL' => $row['contact_email'], 'CONTACT_ID' => $row['contact_id'], 'CONTACT_DELLINK' => cot_url('admin', 'm=other&p=contact&a=del&id=' . $row['contact_id']), 'CONTACT_VAL' => $row['contact_val'] == 1 ? 'unval' : 'val', 'CONTACT_VALLINK' => cot_url('admin', 'm=other&p=contact&a=' . $val . '&id=' . $row['contact_id']), 'CONTACT_READLINK' => cot_url('admin', 'm=other&p=contact&a=val&id=' . $row['contact_id']), 'CONTACT_UNREADLINK' => cot_url('admin', 'm=other&p=contact&a=unval&id=' . $row['contact_id']), 'CONTACT_SUBJECT' => $row['contact_subject'], 'CONTACT_TEXT' => $row['contact_text'], 'CONTACT_REPLY' => $row['contact_reply'], 'CONTACT_FORM_SEND' => cot_url("admin", 'm=other&p=contact&a=send&id=' . $row['contact_id']), 'CONTACT_FORM_TEXT' => cot_textarea('rtext', $rtext, 8, 64)));
    // Extrafields
    if (!empty(cot::$extrafields[cot::$db->contact])) {
        foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields_data('contact', $exfld, $row['contact_' . $exfld['field_name']]);
            $exfld_title = cot_extrafield_title($exfld, 'contact_');
            $tuman->assign(array('CONTACT_' . $tag . '_TITLE' => $exfld_title, 'CONTACT_' . $tag => $exfld_val, 'CONTACT_' . $tag . '_VALUE' => $row['contact_' . $exfld['field_name']], 'CONTACT_EXTRAFLD_TITLE' => $exfld_title, 'CONTACT_EXTRAFLD' => $exfld['field_type'] == 'file' ? cot_rc_link($cfg['extrafield_files_dir'] . '/' . $exfld_val, $exfld_val) : $exfld_val, 'CONTACT_EXTRAFLD_VALUE' => $row['contact_' . $exfld['field_name']]));
            $tuman->parse('MAIN.VIEW.EXTRAFLD');
        }
    }
    $tuman->parse('MAIN.VIEW');
}
cot_display_messages($tuman);
$tuman->assign(array('CONTACT_PAGINATION' => $pagnav['main'], 'CONTACT_PREV' => $pagenav['prev'], 'CONTACT_NEXT' => $pagenav['next']));
$tuman->parse('MAIN');
$plugin_body .= $tuman->text('MAIN');
Exemplo n.º 17
0
$extp = cot_getextplugins('page.list.rowcat.loop');
/* ===== */
foreach ($subcat as $x) {
    $kk++;
    $cat_childs = cot_structure_children('page', $x);
    $sub_count = 0;
    foreach ($cat_childs as $cat_child) {
        $sub_count += (int) $structure['page'][$cat_child]['count'];
    }
    $sub_url_path = $list_url_path;
    $sub_url_path['c'] = $x;
    $t->assign(array('LIST_ROWCAT_ID' => $structure['page'][$x]['id'], 'LIST_ROWCAT_URL' => cot_url('page', $sub_url_path), 'LIST_ROWCAT_TITLE' => $structure['page'][$x]['title'], 'LIST_ROWCAT_DESC' => $structure['page'][$x]['desc'], 'LIST_ROWCAT_ICON' => $structure['page'][$x]['icon'], 'LIST_ROWCAT_COUNT' => $sub_count, 'LIST_ROWCAT_ODDEVEN' => cot_build_oddeven($kk), 'LIST_ROWCAT_NUM' => $kk));
    // Extra fields for structure
    foreach ($cot_extrafields[$db_structure] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $t->assign(array('LIST_ROWCAT_' . $uname . '_TITLE' => isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'LIST_ROWCAT_' . $uname => cot_build_extrafields_data('structure', $exfld, $structure['page'][$x][$exfld['field_name']]), 'LIST_ROWCAT_' . $uname . '_VALUE' => $structure['page'][$x][$exfld['field_name']]));
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.LIST_ROWCAT');
}
$pagenav_cat = cot_pagenav('page', $list_url_path + array('d' => $durl), $dc, count($allsub), $cfg['page']['maxlistsperpage'], 'dc');
$t->assign(array('LISTCAT_PAGEPREV' => $pagenav_cat['prev'], 'LISTCAT_PAGENEXT' => $pagenav_cat['next'], 'LISTCAT_PAGNAV' => $pagenav_cat['main']));
$jj = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.list.loop');
/* ===== */
$sqllist_rowset = $sqllist->fetchAll();
function cot_usercategories_tree($chosen = '', $parent = '', $template = '', $level = 0)
{
    global $structure, $cfg, $gm, $group, $cot_extrafields, $db_structure;
    global $i18n_notmain, $i18n_locale, $i18n_read;
    $urlparams = array('gm' => $gm, 'group' => $group);
    /* === Hook === */
    foreach (cot_getextplugins('usercategories.tree.first') as $pl) {
        include $pl;
    }
    /* ===== */
    if (empty($structure['usercategories'])) {
        return false;
    }
    if (!is_array($chosen)) {
        $chosen = explode(',', $chosen);
    }
    if (empty($parent)) {
        $i18n_enabled = $i18n_read;
        $children = array();
        foreach ($structure['usercategories'] as $i => $x) {
            if (mb_substr_count($structure['usercategories'][$i]['path'], ".") == 0) {
                $children[] = $i;
            }
        }
    } else {
        $i18n_enabled = $i18n_read && cot_i18n_enabled($parent);
        $children = $structure['usercategories'][$parent]['subcats'];
    }
    if (count($children) == 0) {
        return false;
    }
    $t1 = new XTemplate(cot_tplfile(array('usercategories', 'cattree', $template), 'plug'));
    /* === Hook === */
    foreach (cot_getextplugins('usercategories.tree.main') as $pl) {
        include $pl;
    }
    /* ===== */
    $level++;
    if ($parent) {
        $t1->assign(array("CAT_TITLE" => htmlspecialchars($structure['usercategories'][$parent]['title']), "CAT_DESC" => $structure['usercategories'][$parent]['desc'], "CAT_COUNT" => $structure['usercategories'][$parent]['count'], "CAT_ICON" => $structure['usercategories'][$parent]['icon']));
    }
    $t1->assign(array("CAT_URL" => cot_url("users", $urlparams + array('cat' => $parent)), "CAT_LEVEL" => $level));
    $jj = 0;
    /* === Hook - Part1 : Set === */
    $extp = cot_getextplugins('usercategories.tree.loop');
    /* ===== */
    foreach ($children as $row) {
        $jj++;
        $subcats = $structure['usercategories'][$row]['subcats'];
        $urlparams['cat'] = $row;
        if (is_array($subcats)) {
            $parent_selected = is_array($chosen) ? (bool) count(array_intersect($subcats, $chosen)) : in_array($chosen, $subcats);
        } else {
            $parent_selected = false;
        }
        $t1->assign(array("CAT_ROW_CAT" => $row, "CAT_ROW_TITLE" => htmlspecialchars($structure['usercategories'][$row]['title']), "CAT_ROW_DESC" => $structure['usercategories'][$row]['desc'], "CAT_ROW_COUNT" => $structure['usercategories'][$row]['count'], "CAT_ROW_ICON" => $structure['usercategories'][$row]['icon'], "CAT_ROW_URL" => cot_url("users", $urlparams), "CAT_ROW_SELECTED" => is_array($chosen) && in_array($row, $chosen) || !is_array($chosen) && $row == $chosen || $parent_selected ? 1 : 0, "CAT_ROW_SUBCAT" => count($subcats) > 0 ? cot_usercategories_tree($chosen, $row, $template, $level) : '', "CAT_ROW_ODDEVEN" => cot_build_oddeven($jj), "CAT_ROW_JJ" => $jj));
        // Extra fields for structure
        foreach ($cot_extrafields[$db_structure] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $t1->assign(array('ROW_' . $uname . '_TITLE' => isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'ROW_' . $uname => cot_build_extrafields_data('structure', $exfld, $structure['usercategories'][$row][$exfld['field_name']]), 'ROW_' . $uname . '_VALUE' => $structure['usercategories'][$row][$exfld['field_name']]));
        }
        if ($i18n_enabled && $i18n_notmain) {
            $x_i18n = cot_i18n_get_cat($row, $i18n_locale);
            if ($x_i18n) {
                if (!$cfg['plugin']['i18n']['omitmain'] || $i18n_locale != $cfg['defaultlang']) {
                    $urlparams['l'] = $i18n_locale;
                }
                $t1->assign(array('CAT_ROW_URL' => cot_url('users', $urlparams), 'CAT_ROW_TITLE' => $x_i18n['title'], 'CAT_ROW_DESC' => $x_i18n['desc']));
            }
        }
        /* === Hook - Part2 : Include === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $t1->parse("MAIN.CAT_ROW");
    }
    if ($jj == 0) {
        return false;
    }
    $t1->parse("MAIN");
    return $t1->text("MAIN");
}