Author Topic: Conditional User Group template tags  (Read 86636 times)

0 Members and 1 Guest are viewing this topic.

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Conditional User Group template tags
« on: March 10, 2005, 01:14:39 PM »
Hi everybody

4images knows 4 types of users:

user logged out  ('GUEST', -1);
registered user, but not activatet  ('USER_AWAITING', 1);
user logged in ('USER', 2);
administrator ('ADMIN', 9);

with the following tags it is possible to define the layout of pages:
Code: [Select]
{if user_loggedout}
{endif user_loggedout}

{if user_loggedin}
{endif user_loggedin}

 {if is_admin}
{endif is_admin}

My homepage is addressed to customers and to photographers. Each of them has other needs (customer: shop cart, e-card, … / photographer: upload, control-center…).

That’s why I need a new “userlevel” for photographers.

I’d like to design the pages with new tags
Code: [Select]
{if photograph_loggedout}
{endif photograph _loggedout}

Two register-forms and two login-forms should be available. One for the customer and one for the photographer. In the database it should be stored, if a user is “registered” / “logged in” as a customer or as a photographer. And of course should functions like "e-Mail convermation after upload a picture" still be available.

I have already createt new templates for {user_box2}: user_loginform2.html and user_logininfo2.html.

I have installed the following MOD’s:


I hope, somebody can help me! This MOD is very important for me.

Thank you!

Serge
« Last Edit: March 16, 2005, 06:00:55 PM by Chris »

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: One Login for customer and one login for photographers
« Reply #1 on: March 16, 2005, 12:34:14 PM »
Do you talk about usergroups or userlevels? Since you installed the "Default usergroup after registration"-Mod, i guess you have two usergroups, "normal" users and photographers and assign differnet permissions to the groups. Right?

If you just want a {tag} for your templates to show special content for different groups, its quite simple:

Step 1: Open includes/page_header.php and search for

Code: [Select]
if ($user_info['user_level'] >= USER) {
add the following code above

Code: [Select]
$usergroups = array();
AND add the following code below

Code: [Select]
  $current_time = time();
  $sql = "SELECT group_id 
          FROM ".GROUP_MATCH_TABLE."
          WHERE user_id = ".$user_info['user_id']."
          AND groupmatch_startdate <= $current_time
          AND (groupmatch_enddate > $current_time OR groupmatch_enddate = 0)";
  $result = $site_db->query($sql);

  while ($row = $site_db->fetch_array($result)) {
    $usergroups[$row['group_id']] = true;
  }

Step 2: To create the the {tag} for the templates, search for

Code: [Select]
//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------

and add the following code above

Code: [Select]
$site_template->register_vars(array(
  "is_in_group_photographer" => (isset($usergroups[USERGROUP_ID])) ? 1 : 0
));

Replace USERGROUP_ID with the ID of the group photographer. See the picture below how to find out the group ID:



In this case (usergroup ID is 1), the last part should look like this:

Code: [Select]
$site_template->register_vars(array(
  "is_in_group_photographer" => (isset($usergroups[1])) ? 1 : 0
));

Now you can use the following in your templates

Code: [Select]
{if is_in_group_photographer}
  This text is for photographers only
{endif is_in_group_photographer}

If you want to create tags for other usergroups, just repeat Step 2 and change the USERGROUP_ID.
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #2 on: March 17, 2005, 07:45:10 AM »
Hi Jan

That is exactly what I'm looking for.
Unfortunately it doesn't work.
The text between the tags doesn't appear..

This is a part of my template:
Code: [Select]
{images_menu_kunde}

<!-- /* Titel */ -->
       <br>
   <h1>Wandergalerien</span> <hr size="1" />  </h1>
       <br>
 
 {if is_in_group_customer}
ich bin ein kunde
{endif is_in_group_customer}

{if is_in_group_photographer}
ich bin ein Fotograf
{endif is_in_group_photographer}

This is my header_page.php

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: page_header.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.1                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/


if (!defined('ROOT_PATH')) {
  die("Security violation");
}

// Cache Templates
/*$template_list = 'header,footer,category_dropdown_form,user_logininfo,user_loginform,user_loginform2';
if (isset($templates_used) && $templates_used != "") {
  $template_list = $template_list.",".$templates_used;
}
$site_template->cache_templates($template_list);*/

//-----------------------------------------------------
//--- Register Global Vars ----------------------------
//-----------------------------------------------------
$total_images 0;
$total_categories 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;

$cache_id create_cache_id(
  'cat.data.auth_and_info',
  array($user_info[$user_table_fields['user_id']])
);

if (!
$data get_cache_file($cache_idnull)) {
  if (!empty($cat_cache)) {
    foreach ($cat_cache as $key => $val) {
      if (check_permission("auth_viewcat"$key)) {
        $total_categories++;
        if (isset($val['num_images'])) {
          $total_images += $val['num_images'];
        }
        else {
          $cat_cache[$key]['num_images'] = 0;
        }
        $auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
      }
      else {
        $auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
      }
    }
  }

  $data = array();

  $data['total_images'] = $total_images;
  $data['total_categories'] = $total_categories;
  $data['auth_viewcat']['IN'] = $auth_cat_sql['auth_viewcat']['IN'];
  $data['auth_viewcat']['NOTIN'] = $auth_cat_sql['auth_viewcat']['NOTIN'];

  save_cache_file($cache_idserialize($data));

} else {
  $data unserialize($data);

  $total_images $data['total_images'];
  $total_categories $data['total_categories'];
  $auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
  $auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];
}

$site_template->register_vars(array(
  "media_url" => MEDIA_PATH,
  "thumb_url" => THUMB_PATH,
  "icon_url" => ICON_PATH,
  "template_url" => TEMPLATE_PATH,
  "template_image_url" => TEMPLATE_PATH."/images",
  "template_lang_image_url" => TEMPLATE_PATH."/images_".$config['language_dir'],
  "site_name" => $config['site_name'],
  "site_email" => $config['site_email'],
  "self" => $site_sess->url($self_url),
  "self_full" => $site_sess->url($script_url."/".$self_url),
  "script_version" => SCRIPT_VERSION,
  "cp_link" => ($user_info['user_level'] != ADMIN) ? "" "\n<p align=\"center\">[<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php")."\">Control Panel</a>]</p>\n",
  "total_categories" => $total_categories,
  "total_images" => $total_images,
  "url_new_images" => $site_sess->url(ROOT_PATH."search.php?search_new_images=1"),
  "url_top_images" => $site_sess->url(ROOT_PATH."top.php"),
  "url_top_cat_images" => $site_sess->url(ROOT_PATH."top.php".(($cat_id && preg_match("/categories.php/"$self_url)) ? "?".URL_CAT_ID."=".$cat_id "")),
  "url_register" => (!empty($url_register)) ? $site_sess->url($url_register) : $site_sess->url(ROOT_PATH."register.php"),
  "url_search" => $site_sess->url(ROOT_PATH."search.php"),
  "url_lightbox" => $site_sess->url(ROOT_PATH."lightbox.php"),
  "url_warenkorb" => $site_sess->url(ROOT_PATH."warenkorb.php"), 
  "url_control_panel" => (!empty($url_control_panel)) ? $site_sess->url($url_control_panel) : $site_sess->url(ROOT_PATH."member.php?action=editprofile"),
  "url_categories" => $site_sess->url(ROOT_PATH."categories.php"),
  "url_home" => $site_sess->url(ROOT_PATH."index.php"),
  "url_login" => (!empty($url_login)) ? $site_sess->url($url_login) : $site_sess->url(ROOT_PATH."login.php"),
  "url_logout" => (!empty($url_logout)) ? $site_sess->url($url_logout) : $site_sess->url(ROOT_PATH."logout.php"),
  "url_member" => (!empty($url_member)) ? $site_sess->url($url_member) : $site_sess->url(ROOT_PATH."member.php"),
  "url_upload" => (!empty($url_upload)) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH."member.php?action=uploadform"),
  "url_lost_password" => (!empty($url_lost_password)) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH."member.php?action=lostpassword")
));

if (!empty(
$additional_urls)) {
  $register_array = array();
  foreach ($additional_urls as $key => $val) {
    $register_array[$key] = $site_sess->url($val);
  }
  $site_template->register_vars($register_array);
}

// Replace Globals in $lang
$lang $site_template->parse_array($lang);

$site_template->register_vars(array(
  "lang_site_stats" => $lang['site_stats'],
  "lang_registered_user" => $lang['registered_user'],
  "lang_random_image" => $lang['random_image'],
  "lang_categories" => $lang['categories'],
  "lang_sub_categories" => $lang['sub_categories'],
  "lang_new_images" => $lang['new_images'],
  "lang_top_images" => $lang['top_images'],
  "lang_search" => $lang['search'],
  "lang_advanced_search" => $lang['advanced_search'],
  "lang_lightbox" => $lang['lightbox'],
  "lang_warenkorb" => $lang['warenkorb'],  
  
"lang_register" => $lang['register'],
  "lang_control_panel" => $lang['control_panel'],
  "lang_login" => $lang['login'],
  "lang_auto_login" => $lang['lang_auto_login'],
  "lang_logout" => $lang['logout'],
  "lang_lost_password" => $lang['lost_password'],
  "lang_user_name" => $lang['user_name'],
  "lang_password" => $lang['password'],
  "lang_go" => $lang['go'],
  "lang_images_per_page" => $lang['images_per_page'],
  "charset" => $lang['charset'],
  "direction" => $lang['direction']
));

//-----------------------------------------------------
//--- Category Dropdown -------------------------------
//-----------------------------------------------------

if (!$cache_enable) {
    $category_dropdown_selfjump get_category_dropdown($cat_id1);
} else {
  $cache_id create_cache_id(
    'cat.data.dropdown_selfjump',
    array(
      $user_info[$user_table_fields['user_id']],
      $config['template_dir'],
      $config['language_dir']
    )
  );

  if (!$category_dropdown_selfjump get_cache_file($cache_id)) {
    // Always append session id if cache is enabled
    $old_session_mode $site_sess->mode;
    $site_sess->mode 'get';

    // Set $cat_id to 0 to ensure that no category is selected
    $category_dropdown_selfjump get_category_dropdown(01);

    $site_sess->mode $old_session_mode;

    save_cache_file($cache_id$category_dropdown_selfjump);
  }
}

$site_template->register_vars("category_dropdown_selfjump"$category_dropdown_selfjump);
unset(
$category_dropdown_selfjump);

// -------------------------------------
if (!$cache_enable) {
    $category_dropdown_form $site_template->parse_template("category_dropdown_form");
} else {
  $cache_id create_cache_id(
    'cat.data.dropdown_form',
    array(
      $user_info[$user_table_fields['user_id']],
      // $cat_id, // uncomment if the current category should be selected, will increase the number of cache files
      $config['template_dir'],
      $config['language_dir']
    )
  );

  if (!$category_dropdown_form get_cache_file($cache_id)) {
    // Always append session id if cache is enabled
    $old_session_mode $site_sess->mode;
    $site_sess->mode 'get';

    $category_dropdown_form $site_template->parse_template("category_dropdown_form");

    $site_sess->mode $old_session_mode;

    save_cache_file($cache_id$category_dropdown_form);
  }
}

$site_template->register_vars("category_dropdown_form"$category_dropdown_form);
unset(
$category_dropdown_form);

//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" get_random_image();
$site_template->register_vars("random_image"$random_image);
unset(
$random_image);

//-----------------------------------------------------
//--- Shop System -------------------------------------
//-----------------------------------------------------
function FormatPrice ($nPrice

   //--- Format Zahlen  ------------------------
   $nPrice number_format($nPrice"2"".""'"); 
   return $nPrice

$kunde $user_info['user_id']; 




//-----------------------------------------------------
//--- Set Paging Vars ---------------------------------
//-----------------------------------------------------
if (isset($HTTP_POST_VARS['setperpage'])) {
  $setperpage intval($HTTP_POST_VARS['setperpage']);
  if ($setperpage) {
    $site_sess->set_session_var("perpage"$setperpage);
    $session_info['perpage'] = $setperpage;
  }
}

if (isset(
$session_info['perpage'])) {
  $perpage $session_info['perpage'];
}
else {
  $perpage ceil($config['default_image_rows'] * $config['image_cells']);
}

//-----------------------------------------------------
//--- Set Perpage Dropdown ----------------------------
//-----------------------------------------------------
$setperpage_dropdown "\n<select name=\"setperpage\" class=\"setperpageselect\">\n";
for(
$i 1$i <= $config['custom_row_steps']; $i++) {
  $setvalue $config['image_cells'] * $i;
  $setperpage_dropdown .= "<option value=\"".$setvalue."\"";
    if ($setvalue == $perpage) {
    $setperpage_dropdown .= " selected=\"selected\"";
  }
  $setperpage_dropdown .= ">";
  $setperpage_dropdown .= $setvalue;
  $setperpage_dropdown .= "</option>\n";
}
$setperpage_dropdown .= "</select>\n";
if (
$cat_id != 0) {
  $setperpage_dropdown .= "<input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\" />\n";
}
if (isset(
$show_result) && $show_result == 1) {
  $setperpage_dropdown .= "<input type=\"hidden\" name=\"show_result\" value=\"1\" />\n";
}
$site_template->register_vars("setperpage_dropdown"$setperpage_dropdown);
$setperpage_dropdown_form $site_template->parse_template("setperpage_dropdown_form");
$site_template->register_vars("setperpage_dropdown_form"$setperpage_dropdown_form);

$site_template->un_register_vars("setperpage_dropdown");
unset(
$setperpage_dropdown);
unset(
$setperpage_dropdown_form);

//----------------------------------------------------- 
//--- Add & Delete from Lists ------------------------- 
//----------------------------------------------------- 
if ($action == "addtolightbox" && $id) { 
  if ($user_info['user_level'] >= GUEST) { 
    $msg_color = (add_to_lightbox($id)) ? 0
    $msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error']; 
  
  else { 
    $msg $lang['lightbox_register']; 
  

if (
$action == "removefromlightbox" && $id) { 
  if ($user_info['user_level'] >= GUEST) { 
    $msg_color = (remove_from_lightbox($id)) ? 0
    $msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error']; 
  
  else { 
    $msg $lang['lightbox_register']; 
  

if (
$action == "clearlightbox") { 
  if ($user_info['user_level'] >= GUEST) { 
    $msg_color = (clear_lightbox()) ? 0
    $msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error']; 
  
  else { 
    $msg $lang['lightbox_register']; 
  
}


if (
$action == "addtowarenkorb" && $id) { 

//---17.03.05---Layout gemäss Usergroup----
  $usergroups = array();
//--Ende---17.03.05---Layout gemäss Usergroup----  

  if ($user_info['user_level'] >= USER) { 
    $msg = (add_to_warenkorb($id)) ? $lang['warenkorb_add_success'] : $lang['warenkorb_add_error']; 

//---17.03.05---Layout gemäss Usergroup----    
   $current_time time();
  $sql "SELECT group_id  
          FROM "
.GROUP_MATCH_TABLE."
          WHERE user_id = "
.$user_info['user_id'].
          AND groupmatch_startdate <= 
$current_time 
          AND (groupmatch_enddate > 
$current_time OR groupmatch_enddate = 0)";
  $result $site_db->query($sql);

  while ($row $site_db->fetch_array($result)) {
    $usergroups[$row['group_id']] = true;
  }
 
//--Ende---17.03.05---Layout gemäss Usergroup----  
  
  
  

  else { 
    $msg $lang['warenkorb_register']; 
  

if (
$action == "removefromwarenkorb" && $id) { 
  if ($user_info['user_level'] >= USER) { 
    $msg = (remove_from_warenkorb($id)) ? $lang['warenkorb_remove_success'] : $lang['warenkorb_remove_error']; 
  
  else { 
    $msg $lang['warenkorb_register']; 
  


if (
$action == "anzahlverkleinernwarenkorb" && $id) { 
  if ($user_info['user_level'] >= USER) { 
    $msg = (anzahl_verkleinern_warenkorb($id)) ? $lang['anzahl_verkleinern_success'] : $lang['warenkorb_remove_error']; 
  
  else { 
    $msg $lang['warenkorb_register']; 
  


if (
$action == "clearwarenkorb") { 
  if ($user_info['user_level'] >= USER) { 
    $msg = (clear_warenkorb()) ? $lang['warenkorb_delete_success'] : $lang['warenkorb_delete_error']; 
  
  else { 
    $msg $lang['warenkorb_register']; 
  





//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list explode(" "$session_info['rated_imgs']);
    }
    if (!in_array($id$split_list) && !in_array($id$cookie_rated)) {
      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs"$session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire time() + 60 60 24 4;
      setcookie($cookie_name.'rated'serialize($cookie_rated), $cookie_expireCOOKIE_PATHCOOKIE_DOMAINCOOKIE_SECURE);
      update_image_rating($id$rating);
      $msg $lang['voting_success'];
    }
    else {
      $msg $lang['already_voted'];
    }
  }
  else {
    $msg $lang['voting_error'];
  }
}


//--- Warenkorb Summen --------- 
$sql "SELECT sum( w.image_quantity * i.price_1+i.price_2 ) AS total_price 
FROM "
.WARENKORB_TABLE." w, ".IMAGES_TABLE." i 
WHERE image_active = 1 
AND w.user_id = "
.$kunde.
AND i.image_id = w.warenkorb_image_id"

$result $site_db->query_firstrow($sql); 
$total_sum $result['total_price']; 
$porto $config['porto']; 
$bearbeitung $config['bearbeitung']; 
$sum_porto_bear_t = ($total_sum $porto $bearbeitung); 
$sum_porto_bear FormatPrice ($sum_porto_bear_t); 
$total_sum FormatPrice ($total_sum); 
$porto FormatPrice ($config['porto']); 
$bearbeitung FormatPrice ($config['bearbeitung']); 
$sql "SELECT sum( w.image_quantity) AS total_images_sum 
FROM "
.WARENKORB_TABLE." w, ".IMAGES_TABLE." i 
WHERE image_active = 1 
AND w.user_id = "
.$kunde.
AND i.image_id = w.warenkorb_image_id"

$result $site_db->query_firstrow($sql); 
$total_images_sum $result['total_images_sum']; 
$site_template->register_vars(array( 
"total_sum" => $total_sum
"total_images_sum" => $total_images_sum
"bearbeitung" => $bearbeitung
"sum_porto_bear" => $sum_porto_bear
"porto" => $porto 
)); 





//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  $site_template->register_vars("lang_loggedin_msg"preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU"$user_info['user_name'], $lang['lang_loggedin_msg']));
  $user_box $site_template->parse_template("user_logininfo");
  $site_template->register_vars(array(
    "user_box" => $user_box,
    
  
"lang_warenkorb" => $lang['warenkorb'], 
  "bestellung" => $bestellung
  "total_images_sum" => $total_images_sum
  "total_sum" => $total_sum


    
    
    
"user_loggedin" => 1,
    "user_loggedout" => 0,
    "is_admin" => ($user_info['user_level'] == ADMIN) ? 0
  
));
  $site_template->un_register_vars("user_logininfo");
  unset($user_box);
}
else {
  $user_box $site_template->parse_template("user_loginform");
  $site_template->register_vars(array(
    "user_box" => $user_box,
    "user_loggedin" => 0,
    "user_loggedout" => 1,
    "is_admin" => 0
  
));
  $site_template->un_register_vars("user_loginform");
  unset($user_box);
}




//-----------------------------------------------------
//--- User Box 2 ----Fotograf -------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  $site_template->register_vars("lang_loggedin_msg"preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU"$user_info['user_name'], $lang['lang_loggedin_msg']));
  $user_box2 $site_template->parse_template("user_logininfo2");
  $site_template->register_vars(array(
    "user_box2" => $user_box2,
    
  
"lang_warenkorb" => $lang['warenkorb'], 
  "bestellung" => $bestellung
  "total_images_sum" => $total_images_sum
  "total_sum" => $total_sum


    
    
 
//--   "user_loggedin" => 1,
    "user_fotograf" => 2,
    "user_loggedout" => 0,
    "is_admin" => ($user_info['user_level'] == ADMIN) ? 0
  
));
  $site_template->un_register_vars("user_logininfo2");
  unset($user_box2);
}
else {
  $user_box2 $site_template->parse_template("user_loginform2");
  $site_template->register_vars(array(
    "user_box2" => $user_box2,
 
//--    "user_loggedin" => 0,
    "user_fotograf" => 2,
    "user_loggedout" => 1,
    "is_admin" => 0
  
));
  $site_template->un_register_vars("user_loginform2");
  unset($user_box2);
}

//-----------17.03.05--Layout gemäss Usergroup ----------------
$site_template->register_vars(array(
  "is_in_group_photographer" => (isset($usergroups[1])) ? 0
));

$site_template->register_vars(array(
  "is_in_group_photographer" => (isset($usergroups[1])) ? 0
));

$site_template->register_vars(array(
  "is_in_group_customer" => (isset($usergroups[2])) ? 0
));
//------Ende-----17.03.05--Layout gemäss Usergroup ----------------

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  $header $site_template->parse_template("header");
  $footer $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  
));
  unset($header);
  unset($footer);
}


$menu_fotograf = (file_exists(TEMPLATE_PATH."/images_menu_fotograf.html")) ? $site_template->parse_template("images_menu_fotograf") : ""
$site_template->register_vars("images_menu_fotograf"$menu_fotograf);

$menu_kunde = (file_exists(TEMPLATE_PATH."/images_menu_kunde.html")) ? $site_template->parse_template("images_menu_kunde") : ""
$site_template->register_vars("images_menu_kunde"$menu_kunde);


$footer_kunde = (file_exists(TEMPLATE_PATH."/images_footer_kunde.html")) ? $site_template->parse_template("images_footer_kunde") : ""
$site_template->register_vars("images_footer_kunde"$footer_kunde);
?>

Thank you for your help!

Serge

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Conditional User Group template tags
« Reply #3 on: March 17, 2005, 08:14:24 AM »
and did u add in your address url query: action=addtowarenkorb ?
for example details.php?image_id=12&action=addtowarenkorb
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #4 on: March 17, 2005, 08:22:29 AM »
Sorry... I don't understand your question...  :oops:

I couldn't find "action=addtowarenkorb " in my html-/php-files.
So... what is the problem with this missing code?

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #5 on: March 17, 2005, 12:50:22 PM »
I think we are very close to a good solution... who can help me?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: Conditional User Group template tags
« Reply #6 on: March 17, 2005, 05:37:11 PM »
You put

Code: [Select]
  $current_time = time();
  $sql = "SELECT group_id 
          FROM ".GROUP_MATCH_TABLE."
          WHERE user_id = ".$user_info['user_id']."
          AND groupmatch_startdate <= $current_time
          AND (groupmatch_enddate > $current_time OR groupmatch_enddate = 0)";
  $result = $site_db->query($sql);

  while ($row = $site_db->fetch_array($result)) {
    $usergroups[$row['group_id']] = true;
  }

after
Code: [Select]
if ($action == "addtowarenkorb" && $id) {

which isn't the right place. Check my instructions above agin.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #7 on: March 17, 2005, 07:38:14 PM »
and I had to put the code befor and after

Code: [Select]
if ($user_info['user_level'] >= USER) {for several times. This code exists more than once.

But now it works!

Two more questions:

Code: [Select]
{if is_admin}and
Code: [Select]
{endif is_admin}doesn't work anymore, if this code is between
Code: [Select]
{if is_in_group_photographer}and
Code: [Select]
{endif is_in_group_photographer}what can I do, that all tags are interpreted?

Is it possible to combine two different tags?
let's say, something can be seen by a guest and by a logged in photographer, but not for a customer.
how can I define that?

Thank you for helping me!

Serge


Offline inkhead

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Re: Conditional User Group template tags
« Reply #8 on: March 17, 2005, 07:59:12 PM »
This is a great mod. perfect v@no.

Now can we get the forum fixed so it doesn't do those iframe scroll boxes hehehe.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Conditional User Group template tags
« Reply #9 on: March 18, 2005, 12:16:44 AM »
This is a great mod. perfect v@no.
nothing to do with me ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: Conditional User Group template tags
« Reply #10 on: March 18, 2005, 02:12:55 AM »
It's good to see Jan back in the forums posting code  :wink:

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: Conditional User Group template tags
« Reply #11 on: March 18, 2005, 09:43:25 AM »
Two more questions:

Code: [Select]
{if is_admin}
and

Code: [Select]
{endif is_admin}
doesn't work anymore, if this code is between

Code: [Select]
{if is_in_group_photographer}
and
Code: [Select]
{endif is_in_group_photographer}what can I do, that all tags are interpreted?

Obviusly this is because the admin isn't in group "photographer".

Is it possible to combine two different tags?
let's say, something can be seen by a guest and by a logged in photographer, but not for a customer.
how can I define that?

This is only possible if you use PHP code directly in your templates. You can use all {tags} directly as PHP variables ($tags). For example:

Code: [Select]
{user_box}
will output the same as

Code: [Select]
<?php echo $user_box?>
In your case, use something like:

Code: [Select]
<?php
if ($user_loggedout || $is_in_group_photographer) {
?>

 ...this text is for guests and photographers
<?php
}
?>

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #12 on: March 20, 2005, 12:22:02 AM »
Thank you Jan! You have helped me a lot!

Now I have implemented two radio-buttons in the register_form.html.

Code: [Select]
<tr>
<td class="row2"><b>Usergruppe</b></td>
<td class="row2">
<input checked type="radio" name="usergruppe" value="Kunde"/> Kunde
<input type="radio" name="usergruppe" value="Fotograf"/>Fotograf</td>
</tr>

So the user has to chose one of the usergroupes "Customer" or "Photographer" befor he can register.

This information should be stored in the database. I have installed the MOD "default usergroup". This MOD wouldn't be used anymore, if the user has to chose the groupe at the moment of registration.

What do I have to do for storing this information in my database?
And how can I display the name of the usergroup which the user belongs to (e.g. in the control center)??

Thank you for your help. I appreciate this service!
Serge

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Re: Conditional User Group template tags
« Reply #13 on: March 21, 2005, 10:02:25 AM »
Did you checked this: http://www.4homepages.de/forum/index.php?topic=747.msg3277#msg3277
This is explained for image fields. Do the same for users and add the column to the 4images_users table.

Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: Conditional User Group template tags
« Reply #14 on: March 21, 2005, 10:38:04 AM »
but the field usergroup already exists somwere in the database. So I don't need a new field. The user should be able to define the existing field "usergroup". So I don't have to link the user to a usergroup. And the user should also be able to change the usergroup in the control center (onliy between usergroup "Customer" and "Photographer".

Or do I missunderstand something?


 

Post your comments here