4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: TIMT on March 10, 2005, 01:14:39 PM

Title: Conditional User Group template tags
Post by: TIMT 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
Title: Re: One Login for customer and one login for photographers
Post by: Jan 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:

(http://www.4homepages.de/forumdl/find_usergroup_id.gif)

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.
Title: Re: Conditional User Group template tags
Post by: TIMT 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
Title: Re: Conditional User Group template tags
Post by: V@no 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
Title: Re: Conditional User Group template tags
Post by: TIMT 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?
Title: Re: Conditional User Group template tags
Post by: TIMT on March 17, 2005, 12:50:22 PM
I think we are very close to a good solution... who can help me?
Title: Re: Conditional User Group template tags
Post by: Jan 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
Title: Re: Conditional User Group template tags
Post by: TIMT 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

Title: Re: Conditional User Group template tags
Post by: inkhead 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.
Title: Re: Conditional User Group template tags
Post by: V@no on March 18, 2005, 12:16:44 AM
This is a great mod. perfect v@no.
nothing to do with me ;)
Title: Re: Conditional User Group template tags
Post by: Chris on March 18, 2005, 02:12:55 AM
It's good to see Jan back in the forums posting code  :wink:
Title: Re: Conditional User Group template tags
Post by: Jan 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
Title: Re: Conditional User Group template tags
Post by: TIMT 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
Title: Re: Conditional User Group template tags
Post by: Jan 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
Title: Re: Conditional User Group template tags
Post by: TIMT 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?

Title: Re: Conditional User Group template tags
Post by: Jan on March 21, 2005, 11:04:00 AM
I don't have the "default usergroup" mod available at the moment. Can you post the code from register.php.

Jan
Title: Re: Conditional User Group template tags
Post by: TIMT on March 21, 2005, 12:17:21 PM
I have posted the MOD: http://www.4homepages.de/forum/index.php?topic=6945.new#new

After implementation of my request, this MOD wouln't be used anymore. The user would chose his usergroup at the time of registration and can anytime change the usergoup in the control center.

The name of the usergroupe is also displayed in the userinfo, next to the username.

And here is my register.php

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: register.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.                              *
 *                                                                        *
 *************************************************************************/

$main_template 'register';

define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

if (
$action == "") {
  $action "signup";
}

if (
$user_info['user_level'] != GUEST && $action != "activate") {
  show_error_page($lang['already_registered']);
}
$content "";


//-----------------------------------------------------
//--- Signup ------------------------------------------
//-----------------------------------------------------
if ($action == "signup") {
  $site_template->register_vars(array(
    "lang_agreement" => $lang['agreement'],
    "lang_agreement_terms" => $lang['agreement_terms'],
    "lang_agree" => $lang['agree'],
    "lang_agree_not" => $lang['agree_not']
  ));
  $content $site_template->parse_template("register_signup");
}

//-----------------------------------------------------
//--- Add New User ------------------------------------
//-----------------------------------------------------
if ($action == "register") {
  if (!isset($HTTP_POST_VARS['user_name'])) {
    if ($config['activation_time'] != 0) {
      $expiry time() - 60 60 24 $config['activation_time'];
      $sql "DELETE FROM ".USERS_TABLE.
              WHERE ("
.get_user_table_field("""user_lastaction")." < $expiry) AND ".get_user_table_field("""user_level")." = ".USER_AWAITING;
      $site_db->query($sql);
    }
  }
  $user_name = (isset($HTTP_POST_VARS['user_name'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])) : "";
  $user_name ereg_replace("( ){2,}"" "$user_name);
  $user_password = (isset($HTTP_POST_VARS['user_password'])) ? trim($HTTP_POST_VARS['user_password']) : "";
  $user_email = (isset($HTTP_POST_VARS['user_email'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_email'])) : "";
  $user_showemail = (isset($HTTP_POST_VARS['user_showemail'])) ? intval($HTTP_POST_VARS['user_showemail']) : 1;
  $user_allowemails = (isset($HTTP_POST_VARS['user_allowemails'])) ? intval($HTTP_POST_VARS['user_allowemails']) : 1;
  $user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;
  $user_homepage = (isset($HTTP_POST_VARS['user_homepage'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_homepage'])) : "";
  $user_icq = (isset($HTTP_POST_VARS['user_icq'])) ? ((intval(trim($HTTP_POST_VARS['user_icq']))) ? intval(trim($HTTP_POST_VARS['user_icq'])) : "") : "";

  $error 0;
  if (isset($HTTP_POST_VARS['user_name'])) {
    if ($user_name != "") {
      $sql "SELECT ".get_user_table_field("""user_name").
              FROM "
.USERS_TABLE.
              WHERE "
.get_user_table_field("""user_name")." = '".strtolower($user_name)."'";
      if ($site_db->not_empty($sql)) {
        $msg .= (($msg != "") ? "<br />" "").$lang['username_exists'];
        $error 1;
      }
    }
    else {
      $msg .= (($msg != "") ? "<br />" "").$field_error preg_replace("/".$site_template->start."field_name".$site_template->end."/siU"str_replace(":"""$lang['user_name']), $lang['field_required']);
      $error 1;
    }

    if ($user_password == "") {
      $msg .= (($msg != "") ? "<br />" "").$field_error preg_replace("/".$site_template->start."field_name".$site_template->end."/siU"str_replace(":"""$lang['password']), $lang['field_required']);
      $error 1;
    }

    if ($user_email != "") {
      if (check_email($user_email)) {
        $sql "SELECT ".get_user_table_field("""user_email").
                FROM "
.USERS_TABLE.
                WHERE "
.get_user_table_field("""user_email")." = '".strtolower($user_email)."'";
        if ($site_db->not_empty($sql)) {
          $msg .= (($msg != "") ? "<br />" "").$lang['email_exists'];
          $error 1;
        }
      }
      else {
        $msg .= (($msg != "") ? "<br />" "").$lang['invalid_email_format'];
        $error 1;
      }
    }
    else {
      $msg .= (($msg != "") ? "<br />" "").$field_error preg_replace("/".$site_template->start."field_name".$site_template->end."/siU"str_replace(":"""$lang['email']), $lang['field_required']);
      $error 1;
    }

    if (!empty($additional_user_fields)) {
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && intval($val[2]) == && trim($HTTP_POST_VARS[$key]) == "") {
          $error 1;
          $field_error preg_replace("/".$site_template->start."field_name".$site_template->end."/siU"str_replace(":"""$val[0]), $lang['field_required']);
          $msg .= (($msg != "") ? "<br />" "").$field_error;
        }
      }
    }
  // end if
  else {
    $error 1;
  }

  if (!$error) {
    $additional_field_sql "";
    $additional_value_sql "";
    if (!empty($additional_user_fields)) {
      $table_fields $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_field_sql .= ", $key";
          $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }
    $activationkey get_random_key(USERS_TABLEget_user_table_field(""$user_table_fields['user_activationkey']));
    $user_id $site_db->get_next_id($user_table_fields['user_id'], USERS_TABLE);

    $current_time time();
    $user_level = ($config['account_activation'] == 0) ? USER USER_AWAITING;
    $sql "INSERT INTO ".USERS_TABLE."
            ("
.get_user_table_field("""user_id").get_user_table_field(", ""user_level").get_user_table_field(", ""user_name").get_user_table_field(", ""user_password").get_user_table_field(", ""user_email").get_user_table_field(", ""user_showemail").get_user_table_field(", ""user_allowemails").get_user_table_field(", ""user_invisible").get_user_table_field(", ""user_joindate").get_user_table_field(", ""user_activationkey").get_user_table_field(", ""user_lastaction").get_user_table_field(", ""user_lastvisit").get_user_table_field(", ""user_comments").get_user_table_field(", ""user_homepage").get_user_table_field(", ""user_icq").$additional_field_sql.") 
            VALUES
            (
$user_id$user_level, '$user_name', '".md5($user_password)."', '$user_email', $user_showemail$user_allowemails$user_invisible$current_time, '$activationkey', $current_time$current_time, 0, '$user_homepage', '$user_icq'".$additional_value_sql.")";
    $result $site_db->query($sql);

    if ($result) {
      $activation_url $script_url."/register.php?action=activate&activationkey=".$activationkey;

      include(ROOT_PATH.'includes/email.php');
      $site_email = new Email();
      $site_email->set_to($user_email);
      $site_email->set_subject($lang['register_success_emailsubject']);
      $site_email->register_vars(array(
        "activation_url" => $activation_url,
        "user_name" => $user_name,
        "user_password" => $user_password,
        "site_name" => $config['site_name']
      ));
      
      
switch($config['account_activation']) {
      case 2:
        $email_template "register_activation_admin";
        $msg $lang['register_success_admin'];
        break;
      case 1:
        if ($config['language_dir_default'] != $config['language_dir']) {
          $activation_url .= "&l=".$config['language_dir'];
        }
        $email_template "register_activation";
        $msg $lang['register_success'];
        break;
      case 0:
      default:
        $email_template "register_activation_none";
        $msg $lang['register_success_none'];
        break;
      }

      $site_email->set_body($email_template$config['language_dir']);
      $site_email->send_email();
      if ($config['account_activation'] == 2) {
        $site_email->reset();
        $site_email->set_to($config['site_email']);
        $site_email->set_subject($lang['admin_activation_emailsubject']);
        $user_details_url $script_url."/admin/index.php?goto=".urlencode("users.php?action=edituser&user_id=".$user_id."&activation=1");
        $site_email->register_vars("user_details_url"$user_details_url);
        $site_email->set_body("admin_activation"$config['language_dir_default']);
        $site_email->send_email();
      }
    }
    else {
      $msg $lang['general_error'];
    }
  }

  if ($error) {
    if ($user_showemail == 1) {
      $user_showemail_yes " checked=\"checked\"";
      $user_showemail_no "";
    }
    else {
      $user_showemail_yes "";
      $user_showemail_no " checked=\"checked\"";
    }
    if ($user_allowemails == 1) {
      $user_allowemails_yes " checked=\"checked\"";
      $user_allowemails_no "";
    }
    else {
      $user_allowemails_yes "";
      $user_allowemails_no " checked=\"checked\"";
    }
    if ($user_invisible == 1) {
      $user_invisible_yes " checked=\"checked\"";
      $user_invisible_no "";
    }
    else {
      $user_invisible_yes "";
      $user_invisible_no " checked=\"checked\"";
    }
    $site_template->register_vars(array(
      "user_name" => htmlspecialchars(stripslashes($user_name)),
      "user_email" => htmlspecialchars(stripslashes($user_email)),
      "user_homepage" => htmlspecialchars(stripslashes($user_homepage)),
      "user_icq" => $user_icq,
      "user_showemail_yes" => $user_showemail_yes,
      "user_showemail_no" => $user_showemail_no,
      "user_allowemails_yes" => $user_allowemails_yes,
      "user_allowemails_no" => $user_allowemails_no,
      "user_invisible_yes" => $user_invisible_yes,
      "user_invisible_no" => $user_invisible_no,
      "lang_user_name" => $lang['user_name'],
      "lang_password" => $lang['password'],
      "lang_email" => $lang['email'],
      "lang_register_msg" => $lang['register_msg'],
      "lang_submit" => $lang['submit'],
      "lang_reset" => $lang['reset'],
      "lang_email" => $lang['email'],
      "lang_show_email" => $lang['show_email'],
      "lang_allow_emails" => $lang['allow_emails'],
      "lang_invisible" => $lang['invisible'],
      "lang_optional_infos" => $lang['optional_infos'],
      "lang_homepage" => $lang['homepage'],
      "lang_icq" => $lang['icq'],
      "lang_yes" => $lang['yes'],
      "lang_no" => $lang['no']
    ));
    
    
if (!empty($additional_user_fields)) {
      $additional_field_array = array();
      foreach ($additional_user_fields as $key => $val) {
        if ($val[1] == "radio") {
          $value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : 1;
          if ($value == 1) {
            $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
            $additional_field_array[$key.'_no'] = "";
          }
          else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }
        else {
          $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : "";
        }
        $additional_field_array[$key] = $value;
        $additional_field_array['lang_'.$key] = $val[0];
      }
      if (!empty($additional_field_array)) {
        $site_template->register_vars($additional_field_array);
      }
    }

    $content $site_template->parse_template("register_form");
  }
}

if (
$action == "activate") {
  if ($config['activation_time'] != 0) {
    $expiry time() - 60 60 24 $config['activation_time'];
    $sql "DELETE FROM ".USERS_TABLE.
            WHERE ("
.get_user_table_field("""user_lastaction")." < $expiry) AND ".get_user_table_field("""user_level")." = ".USER_AWAITING;
    $site_db->query($sql);
  }
  if (!isset($HTTP_GET_VARS['activationkey'])){
    $msg $lang['missing_activationkey'];
  }
  else {
    if ($config['account_activation'] == && $user_info['user_level'] != ADMIN) {
      show_error_page($lang['no_permission']);
      exit;
    }
    $activationkey trim($HTTP_GET_VARS['activationkey']);


$sql "SELECT ".get_user_table_field("""user_id").get_user_table_field(", ""user_name").get_user_table_field(", ""user_email").get_user_table_field(", ""user_activationkey")."                
            
            
            FROM "
.USERS_TABLE.
            WHERE "
.get_user_table_field("""user_activationkey")." = '$activationkey'";
    $row $site_db->query_firstrow($sql);
    if (!$row) {
      $msg $lang['invalid_activationkey'];
    }
    else {
      $sql "UPDATE ".USERS_TABLE.
              SET "
.get_user_table_field("""user_level")." = ".USER.
              WHERE "
.get_user_table_field("""user_activationkey")." = '$activationkey'";
      $site_db->query($sql);
      $msg $lang['activation_success'];

    
$group_id 
1

$sql "INSERT INTO ".GROUP_MATCH_TABLE.
        (group_id, user_id, groupmatch_startdate, groupmatch_enddate) 
        VALUES 
        (
$group_id, ".$row[$user_table_fields['user_id']].", ".time().", 0)"
$site_db->query($sql);

     
      

      
if ($config['account_activation'] == 2) {
        include(ROOT_PATH.'includes/email.php');
        $site_email = new Email();
        $site_email->set_to($row[$user_table_fields['user_email']]);
        $site_email->set_subject($lang['activation_success_emailsubject']);
        $site_email->register_vars(array(
          "user_name" => $row[$user_table_fields['user_name']],
          "site_name" => $config['site_name']
        ));
        $site_email->set_body("activation_success"$config['language_dir']);
        $site_email->send_email();
      }
    }
  }
}

//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['register']."</span>";

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,
  "lang_register" => $lang['register']
));
$site_template->print_template($site_template->parse_template($main_template));
include(
ROOT_PATH.'includes/page_footer.php');
?>

Title: Re: Conditional User Group template tags
Post by: Jan on March 21, 2005, 02:14:51 PM
Search in register.php for
Code: [Select]
if ($result) {
and add after

Code: [Select]
if (isset($HTTP_POST_VARS['usergruppe'])) {
    $user_id = $site_db->get_insert_id();
   
    if ($HTTP_POST_VARS['usergruppe'] == 'Fotograf') {
        $group_id = [put id of group photographer here];
    } else {
        $group_id = [put id of group customer here];
    }

    $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
            (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
            VALUES
            ($group_id, ".$user_id.", ".time().", 0)";
    $site_db->query($sql);
}

Then the user will be added to the selected usergroup.

Jan


Title: Re: Conditional User Group template tags
Post by: TIMT on March 21, 2005, 06:56:20 PM
Super Jan  :D

Now I have implemented the following code in member_editprofile.html

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

The radio button of the usergroup, which the user belongs to, should be active. That means, the database must be read befor displaying the radio buttons.
A change of the usergroup, which can be done by the user, should be stored in the database.

What code and where do I have to implement?


Thanks!
Title: Re: Conditional User Group template tags
Post by: Jan on March 22, 2005, 09:33:28 AM
Search in member.php for
Code: [Select]
  if ($user_invisible == 1) {
    $user_invisible_yes = " checked=\"checked\"";
    $user_invisible_no = "";
  }
  else {
    $user_invisible_yes = "";
    $user_invisible_no = " checked=\"checked\"";
  }

and add this below
Code: [Select]
  $group_id = [put id of group photographer here];
  if (isset($usergroup[$group_id])) {
    $user_is_photographer_yes = " checked=\"checked\"";
    $user_is_photographer_no = "";
  }
  else {
    $user_is_photographer_yes = "";
    $user_is_photographer_no = " checked=\"checked\"";
  }

Search for

Code: [Select]
    "user_invisible_yes" => $user_invisible_yes,
    "user_invisible_no" => $user_invisible_no,

and this below

Code: [Select]
    "user_is_photographer_yes" => $user_is_photographer_yes,
    "user_is_photographer_no" => $user_is_photographer_no,

Then use in the template
Code: [Select]
         <tr>
            <td class="row1"><b>Usergruppe</b></td>
            <td class="row1">
            <input checked type="radio" name="usergruppe" value="Kunde"{user_is_photographer_no} /> Kunde
            <input type="radio" name="usergruppe" value="Fotograf"/{user_is_photographer_yes} />Fotograf</td>
          </tr>

To have the usergroups updated correctly, search for
Code: [Select]
$msg = $lang['update_profile_success'];
and add this above

Code: [Select]

    if ($HTTP_POST_VARS['usergruppe'] == 'Fotograf') {
        $add_group_id = [put id of group photographer here];
        $del_group_id = [put id of group customer here];
    } else {
        $add_group_id = [put id of group customer here];
        $del_group_id = [put id of group photographer here];
    }

    if (!isset($usergroup[$add_group_id])) {

      $sql = "DELETE FROM ".GROUP_MATCH_TABLE."
              WHERE group_id = $del_group_id AND user_id = ".$user_info['user_id'];
      $site_db->query($sql);

      $sql = "INSERT INTO ".GROUP_MATCH_TABLE."
              (group_id, user_id, groupmatch_startdate, groupmatch_enddate)
               VALUES
              ($add_group_id, ".$user_info['user_id'].", ".time().", 0)";
      $site_db->query($sql);
    }
Title: Re: Conditional User Group template tags
Post by: TIMT on March 22, 2005, 01:06:42 PM
Hi Jan

As usual... very good instructions and high quality.

Now it should also be possible for a customer to change his usergroup. In the template warenkorb_kunde.html I have implemented the following code:

Code: [Select]
<td class="row2">
   <input checked type="radio" name="usergruppe" value="Kunde"{user_is_photographer_no} /> Kunde
   <input type="radio" name="usergruppe" value="Fotograf"/{user_is_photographer_yes} />Fotograf
  </td>

The template is used by warenkorb_kunde.php

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: warenkorb.php                                         *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7                                                  *
 *                                                                        *
 *    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.                              *
 *                                                                        *
 *************************************************************************/

$templates_used 'warenkorb_kunde,thumbnail_bit';
$main_template 'warenkorb_kunde';


define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

if (
$user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
  show_error_page($lang['warenkorb_register']);
}

$kunde_info = array();
$neuer_kunde = array();
$kunden_update = array();

if (
$user_id != GUEST) {
      $sql "SELECT *
              FROM 4images_kunden
              WHERE kunde_id = "
.$user_info['user_id'];
      $kunde_info $site_db->query_firstrow($sql);


  $sql "SELECT COUNT(*) as check_kunde
   FROM 4images_kunden
   WHERE kunde_id = "
.$user_info['user_id'];

   $check $site_db->query_firstrow($sql);
      $check_kunde $check['check_kunde'];
    if ($check_kunde 1)
    {

      $sql "INSERT INTO 4images_kunden( kunde_id, kunde_anrede, kunde_nachname, kunde_vorname, kunde_firma, kunde_plz, kunde_str, kunde_ort, kunde_telefon, kunde_telefax, liefer_anrede, liefer_nachname, liefer_vorname, liefer_firma, liefer_plz, liefer_str, liefer_ort, liefer_telefon, liefer_telefax, kunde_zahlungsart, kunde_bemerkung, kunde_bank, kunde_kontonr, kunde_blz, bestellung  )
      VALUES ( "
.$user_info['user_id'].", 'kunde_anrede', kunde_nachname, kunde_vorname, kunde_firma, kunde_plz, kunde_str, kunde_ort, kunde_telefon, kunde_telefax, liefer_anrede, liefer_nachname, liefer_vorname, liefer_firma, liefer_plz, liefer_str, liefer_ort, liefer_telefon, liefer_telefax, kunde_zahlungsart, kunde_bemerkung, kunde_bank, kunde_kontonr, kunde_blz, 1 ) ";
$result $site_db->query($sql);
}


}

$site_template->register_vars(array(
"kunde_id" => $kunde_info['kunde_id'],
"kunde_nachname" => $kunde_info['kunde_nachname'],
"kunde_vorname" => $kunde_info['kunde_vorname'],
"kunde_firma" => $kunde_info['kunde_firma'],
"kunde_plz" => $kunde_info['kunde_plz'],
"kunde_str" => $kunde_info['kunde_str'],
"kunde_ort" => $kunde_info['kunde_ort'],
"kunde_telefon" => $kunde_info['kunde_telefon'],
"kunde_telefax" => $kunde_info['kunde_telefax'],
"liefer_anrede" => $kunde_info['liefer_anrede'],
"liefer_nachname" => $kunde_info['liefer_nachname'],
"liefer_vorname" => $kunde_info['liefer_vorname'],
"liefer_firma" => $kunde_info['liefer_firma'],
"liefer_plz" => $kunde_info['liefer_plz'],
"liefer_str" => $kunde_info['liefer_str'],
"liefer_ort" => $kunde_info['liefer_ort'],
"liefer_telefon" => $kunde_info['liefer_telefon'],
"liefer_telefax" => $kunde_info['liefer_telefax'],
"kunde_bemerkung" => $kunde_info['kunde_bemerkung'],
"kunde_zahlungsart" => $kunde_info['kunde_zahlungsart'],
"kunde_bank" => $kunde_info['kunde_bank'],
"kunde_kontonr" => $kunde_info['kunde_kontonr'],
"kunde_blz" => $kunde_info['kunde_blz']

));

$site_template->print_template($site_template->parse_template($main_template));
include(
ROOT_PATH.'includes/page_footer.php');
?>



What do I have to implement, that the customer can change his usergroup from customer to photographer?

Thanks again, I really appreciate your help!    :D
Title: Re: Conditional User Group template tags
Post by: Jan on March 22, 2005, 02:55:41 PM
Just apply the code from my last posting to warenkorb_kunde.php and warenkorb_kunde.html.
Title: Re: Conditional User Group template tags
Post by: TIMT on March 25, 2005, 09:48:22 PM
Thank you Jan!

Great support!

Serge  :D
Title: Re: Conditional User Group template tags
Post by: TIMT on March 26, 2005, 03:08:37 PM
Hi Jan

Is it possible to user
Code: [Select]
{if user_loggedin} and
Code: [Select]
{endif user_loggedin}in the description of a picture, which I enter in the ACP?
It is mentioned, that I can use HTML-Code.
What do I have to do, that I can use this tags?

Thank you for helping me!
Serge
Title: Re: Conditional User Group template tags
Post by: Jan on March 29, 2005, 10:44:38 AM
This isn't possible without heavily change a lot of code.

Jan
Title: Re: Conditional User Group template tags
Post by: V@no on March 29, 2005, 09:14:38 PM
1) allowing HTML code in description of your pictures is a big security issue unless u dont allow your visitors upload
2) if HTML is enabled for description try add something like this instead of {if user_loggedin} :
Code: [Select]
<?php
global $user_info;
if (
$user_info['user_level'] > GUEST)
{
?>

and instead of {endif user_loggedin}:
Code: [Select]
<?php
}
?>
make sure that <?php and ?> are on separate line and nothing else should be on the sime line.

P.S. with this method php execution must be enabled in constants.php
Title: Re: Conditional User Group template tags
Post by: TIMT on March 29, 2005, 10:19:00 PM
Hi V@no

Why is it a sercurity risk to use HTML code in the description of pictures? Is it possible to user HTML code in the upload form?

In one category I show the product which are for sell. The description of the product is entered in the descirption picture. One of the product is a postcard, which shows one of a picture, made by the customer. That's, why I'd like to show the link for uploading pictures, but only for logged in users. A logged in user can upload a picture an buy postcards with this picture on it.

So I'd like to use HTML code only for my "pictures" or let's say for my "products" I wanna sell. Users, which can upload pictures don't have to use HTML code.

Do I have to  replace something in the code? Instead of interpreting the code, it shows me the code, unless the first line.


The following is displayed on the details:
global $user_info;
if ($user_info['user_level'] > GUEST)
{
?>

  Upload Foto (Sie können das Foto auch nach der Bestellung hochladen.)

}
?>

Thanks
Serge

PS:
Code: [Select]
define('EXEC_PHP_CODE', 1);should be ok, shouldn't it?
Title: Re: Conditional User Group template tags
Post by: TIMT on March 31, 2005, 09:16:45 AM
Hi V@no

Hope you can help me!

Thank you again.
Serge
Title: Re: Conditional User Group template tags
Post by: Jan on April 05, 2005, 04:53:35 PM
V@no is wrong  :mrgreen:
It isn't possible to use PHP code in description field, sry.
Title: Re: Conditional User Group template tags
Post by: V@no on April 06, 2005, 01:37:07 AM
V@no is wrong :mrgreen:
It isn't possible to use PHP code in description field, sry.
that's a good news! :D
/me now trying figure out how php code not being executed from description...
Title: Re: Conditional User Group template tags
Post by: IcEcReaM on April 06, 2006, 12:33:56 AM
but i think anyway it can be  a risk to allow html code in descriptions.
there are enough malicious javascript code you can use there
Title: Re: Conditional User Group template tags
Post by: V@no on April 06, 2006, 02:17:52 AM
but i think anyway it can be a risk to allow html code in descriptions.
there are enough malicious javascript code you can use there
In v1.7.2 the HTML security was giving very serious thoughts and all possible security breach html tags are filtered out now. but you never know, these hackers are very clever...
Title: Re: Conditional User Group template tags
Post by: IcEcReaM on April 06, 2006, 02:37:01 AM
ohh, i didn't noticed that this was changed too.

but why to open an possible risk, when it's not really needed.

most things can be done also with bccode..^^
Title: Re: Conditional User Group template tags
Post by: lenina on August 06, 2006, 09:32:16 PM
Hello, I used this code in my website since I need to restrict the use of the Lightbox to just a certain usergroup, however the tags aren't working, the Lightbox references do not appear for anyone

this is my page_header.php code:

Code: [Select]
REMOVED
The group is called Ark Citizens and the usergroup ID is 14, I tried changing the "Ark Citizen" title to just "citizen" to see if it did the trick, but didn't work :-?
Any help would be greatly appreciated
Title: Re: Conditional User Group template tags
Post by: live@ct on December 24, 2006, 02:47:09 AM
I install this mod but its not working
The content that I like to hide for a specific group of user its hide but it didnt show for any group

It can be possible to use this, but a personalize db_field
for example I create a field user_group in the users table
and in the db_field_definitions I create a dropdown field

Producer has the number 5
Normal User has the number 3
Visual Art has number 7

I like to show content depend of the number of the user_group field
using the if endif conditions

is it possible, im trying but I didnt make something that works

thanks and sorry for my poor englis :P
Title: Re: Conditional User Group template tags
Post by: binuj01 on March 20, 2007, 12:30:24 PM
There are 3 occurences of the below

if ($user_info['user_level'] >= USER) {


Which is the right one ?

Thanks
Binu
Title: Re: Conditional User Group template tags
Post by: Sun Zaza on November 11, 2007, 06:30:16 PM
Hi guys,

The code works perfect on details, categorie...., but NOT on user_logininfo.html template.

On the  user_logininfo.html template and on member_profile.html I added this line:
Code: [Select]
{if is_in_group_photographers} Hello photographers {endif is_in_group_photographers}
On member_profile.html I do not see the text "Hello photographers" (Because I am not in the usergroup photographers), but on the user_logininfo.html the text is showing.

What do I have to change to make it work on user_logininfo.html?

I appreciate any help,
Cruxy
Title: Re: Conditional User Group template tags
Post by: thunderstrike on November 11, 2007, 06:37:41 PM
On the  user_logininfo.html template and on member_profile.html I added this line:
Code: [Select]
{if is_in_group_photographers} Hello photographers {endif is_in_group_photographers}

See Jan post for tag...

Code: [Select]
{user_is_photographer_yes}
{user_is_photographer_no}

Is use in member.php file ...

Quote
What do I have to change to make it work on user_logininfo.html?

You need use code in includes/page_header.php file.
Title: Re: Conditional User Group template tags
Post by: Sun Zaza on November 11, 2007, 09:12:50 PM
Hi Thunderstrike,

It is still not working. I used the tags of Jan.
Whould you like to help me in this? :(

I just want to make it work on the user_logininfo.html template.
NOTE: The code is working fine on default templates like member_profile.html.
Title: Re: Conditional User Group template tags
Post by: thunderstrike on November 11, 2007, 09:32:22 PM
You need copy PHP code in includes/page_header.php file ... no only member.php file.
Title: Re: Conditional User Group template tags
Post by: Sun Zaza on December 05, 2007, 01:44:29 AM
Is there anyone to solve this issue. I mean using the conditional user group on the user_logininfo.html or on random_image.html?

I appreciate any help!
Title: Re: Conditional User Group template tags
Post by: Dragon.82 on October 05, 2008, 09:44:48 AM
thanks for you
Title: Re: Conditional User Group template tags
Post by: camera on October 29, 2008, 04:28:14 PM
I think we are very close to a good solution
Title: Re: Conditional User Group template tags
Post by: madonna007 on November 25, 2008, 09:38:29 AM
The text between the tags doesn't appear?





.
Title: Re: Conditional User Group template tags
Post by: softxgame on May 06, 2009, 05:57:58 AM
Thank you for the subject
Title: Re: Conditional User Group template tags
Post by: ali.f on September 08, 2009, 10:00:51 AM
thanks :)
Title: Re: Conditional User Group template tags
Post by: azndeb888 on February 28, 2010, 07:28:17 PM
you guys seem so knowledgeable on this forum!