Index: trunk/kernel/parser.php =================================================================== diff -u -r3282 -r3287 --- trunk/kernel/parser.php (.../parser.php) (revision 3282) +++ trunk/kernel/parser.php (.../parser.php) (revision 3287) @@ -5,8 +5,8 @@ $ParserFiles[] = "kernel/parser.php"; function m_ParseEnv($str = NULL) -{ - global $m_var_list, $objConfig, $objCatList, $objLanguages, $objThemes; +{ + global $m_var_list, $objConfig, $objCatList, $objLanguages, $objThemes; if ($str != NULL) { $str = substr($str,1); @@ -15,12 +15,12 @@ $m_var_list["cat"] = $pieces[0]; $m_var_list["p"] = $pieces[1]; $objCatList->Page = $m_var_list["p"]; - + $m_var_list["lang"] = $pieces[2]; $m_var_list["theme"] = $pieces[3]; $m_var_list['opener']=$pieces[4]; } - else + else { $m_var_list["cat"]=0; $m_var_list["p"] = 1; @@ -31,7 +31,7 @@ } function m_BuildEnv() -{ +{ global $m_var_list, $m_var_list_update; $module_vars = Array('cat','p','lang','theme','opener'); $ret = GenerateModuleEnv('m', $module_vars); @@ -40,7 +40,7 @@ } function m_BuildEnv_NEW() -{ +{ global $m_var_list, $m_var_list_update; $module_vars = Array( 'cat' => 'm_cat_id', 'p' => 'm_cat_page', 'lang' => 'm_lang', 'theme' => 'm_theme', 'opener' => 'm_opener'); @@ -72,7 +72,7 @@ IF(TargetId = %1\$s, TargetType, SourceType) AS SourceType, IF(TargetId = %1\$s, SourceType, TargetType) AS TargetType FROM %%s", $ResourceId); - + $where = "((SourceId=$ResourceId) OR (TargetId=$ResourceId AND Type=1)) AND Enabled=1"; $Relations->LoadRelated($where,"",$sql); $ids = array(); @@ -99,8 +99,8 @@ } $table = GetTablePrefix().$Item->Get("SourceTable"); if($ItemType!=1) - { - $cattable = GetTablePrefix()."CategoryItems"; + { + $cattable = GetTablePrefix()."CategoryItems"; $sql = "SELECT *,CategoryId FROM $table INNER JOIN $cattable ON "; $sql .=" ($table.ResourceId=$cattable.ItemResourceId) WHERE $table.Status=1 AND PrimaryCat=1 "; $sql .=" AND ResourceId IN (".implode(",",$ids[$ItemType]).")"; @@ -112,7 +112,7 @@ $sql .=" AND ResourceId IN (".implode(",",$ids[$ItemType]).")"; } // echo $sql."
\n"; - $RelatedItems->Query_Item($sql,-1,-1,$ItemType); + $RelatedItems->Query_Item($sql,-1,-1,$ItemType); } } } @@ -124,12 +124,12 @@ @attrib: _url:: Remote URL to include @attrib: _StartPos:: Numeric start point of text to include, or string match @attrib: _EndPos:: Numeric end point of text to include, or string match - @example: -*/ + @example: +*/ function m_insert_url($attribs=array()) { global $pathtoroot; - + $url = $attribs["_url"]; $StartPos = $attribs["_startpos"]; $EndPos = $attribs["_endpos"]; @@ -147,17 +147,17 @@ if(substr($tmp,-7)=="") $body = substr($body,0,-7); } - else + else $body = $txt; if(strlen($body)) - { + { if(strlen($StartPos)) { if(!is_numeric($StartPos)) { $start = strpos($body,$StartPos); } - else + else $start = (int)$StartPos; } else @@ -173,21 +173,21 @@ } else $end = NULL; - $o = substr($body,$start,$end-$start); + $o = substr($body,$start,$end-$start); } - return $o; + return $o; } /* @description: Displays a template depending on the login status of the user @attrib: _logintemplate:tpl: template to display when the user is NOT logged in @attrib: _LoggedinTemplate:tpl: template to display when the user is logged in - @example: -*/ + @example: +*/ function m_loginbox($attribs = array()) -{ +{ global $var_list, $objSession, $objUsers, $objTemplate; - + $userid = $objSession->Get("PortalUserId"); $groupid = $objSession->Get("GroupId"); if ($userid == 0) @@ -206,11 +206,11 @@ } /* @description: result of suggest site action -*/ +*/ function m_suggest_result() { global $suggest_result; - + return $suggest_result; } @@ -220,7 +220,7 @@ function m_subscribe_result() { global $SubscribeResult; - + if(strlen($SubscribeResult)) return language($SubscribeResult); return ""; @@ -232,20 +232,20 @@ function m_subscribe_address() { global $SubscribeAddress; - + if(strlen($_GET["subscribe_email"])) return $_GET["subscribe_email"]; - + return ""; } /* - @description: Error message of subscribe to mailing list action -*/ + @description: Error message of subscribe to mailing list action +*/ function m_subscribe_error() { global $SubscribeError; - + if(strlen($SubscribeError)) return language($SubscribeError); return ""; @@ -259,7 +259,7 @@ @attrib: _LangText:lang: Language var to use for field label @attrib: _plaintext:: Plain text to use for field label (langtext is used by default if both are set) @attrib: _Template:tpl: template used to display the field label (if not set "" is used - @attrib: _ErrorTemplate:tpl: If the field is in an error state (ie missing input) this template is used. Will default to the normal template if not set + @attrib: _ErrorTemplate:tpl: If the field is in an error state (ie missing input) this template is used. Will default to the normal template if not set */ function m_form_prompt($attribs = array()) { @@ -273,7 +273,7 @@ $o = ""; } else - { + { $t = $attribs["_template"]; if(!strlen($t)) { @@ -288,28 +288,28 @@ } else $txt = $attribs["_plaintext"]; - - if (strtolower($field) == "dob") + + if (strtolower($field) == "dob") { - if (isset($FormError[strtolower($form)][strtolower($field."_day")]) || isset($FormError[strtolower($form)][strtolower($field."_month")]) || isset($FormError[strtolower($form)][strtolower($field."_year")])) + if (isset($FormError[strtolower($form)][strtolower($field."_day")]) || isset($FormError[strtolower($form)][strtolower($field."_month")]) || isset($FormError[strtolower($form)][strtolower($field."_year")])) $rawtext = $objTemplate->GetTemplate($e, true); } - + if(isset($FormError[strtolower($form)][strtolower($field)])) { $rawtext = $objTemplate->GetTemplate($e); } elseif (strlen($t)) - $rawtext = $objTemplate->GetTemplate($t); - + $rawtext = $objTemplate->GetTemplate($t); + if(is_object($rawtext)) { $src = $rawtext->source; $o = str_replace("",$txt, $src); } else $o = str_replace("", $txt, $templateText); - + } return $o; } @@ -331,17 +331,17 @@ { $IsAuto = !$objConfig->Get("User_Password_Auto"); } - + if($IsAuto) { if(strlen($attribs["_langtext"])) { $ret = language($attribs["_langtext"]); } else - $ret = $attribs["_plaintext"]; + $ret = $attribs["_plaintext"]; if(!$ret) - return "true"; + return "true"; } return $ret; } @@ -405,12 +405,12 @@ $value = inp_htmlize($value); } } - + if($form=='new_pm' && $field=='pm_subject' && !get_magic_quotes_gpc()) { $value = stripslashes($value); } - + // print_pre($FormValues); // echo $form.".".$field."=".$value." = ".$attribs['_forgetvalue']."
\n"; @@ -433,9 +433,9 @@ @description: creates an INPUT tag (type checkbox) for a form field. All extra attributes are passed to the INPUT tag @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name - @attrib: _Value:bool: If true, the radio button is CHECKED + @attrib: _Value:bool: If true, the radio button is CHECKED @attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting - @attrib: _Custom:bool: If set, handled as a custom field + @attrib: _Custom:bool: If set, handled as a custom field @example: */ function m_form_checkbox($attribs = array()) @@ -485,7 +485,7 @@ $form = $attribs['_form']; $field = strtolower($attribs['_field']); $val = $attribs['_value']; - + if( GetVar($field) !== false ) { $value = GetVar($field); @@ -501,13 +501,13 @@ if( !isset($value) && getArrayValue($attribs,'_default') ) $value = $val; if($value==$val) $checked=' CHECKED'; } - + //echo $form.".".$field."=".$value."
\n"; $ret = ""; if($attribs["_required"]) $ret .= ""; if($attribs["_custom"]) - $ret .= ""; + $ret .= ""; return $ret; } @@ -532,92 +532,92 @@ { $value = ''; } - else - { + else + { $value = inp_htmlize($FormValues[$form][$field], 1); if (is_array($value)) { $value = is_null($value['lang_value'])? $value['value'] : $value['lang_value']; - } + } $value = inp_htmlize($value, 1); } //echo "
"; print_r($FormValues); echo "
"; return $value; } /* - @description: creates an form OPTION tag for a form SELECT tag. + @description: creates an form OPTION tag for a form SELECT tag. All extra attributes are passed to the OPTION tag. @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name @attrib: _Value:: Value to use for this option (ie the value attribute) If the current value of the select field is the same as this attribute, then this option will be set SELECTED. - @attrib: _langtext:lang: language tag to display for this option in the SELECT dropdown - @attrib: _plaintext:: plain text to display for this option in the SELECT dropdown (if _langtext is set, it is used instead of _plaintext) + @attrib: _langtext:lang: language tag to display for this option in the SELECT dropdown + @attrib: _plaintext:: plain text to display for this option in the SELECT dropdown (if _langtext is set, it is used instead of _plaintext) @example: GetPersistantVariable($field); // No need to read lan_value since it's options/drop-down field - if (is_array($value)) + if (is_array($value)) $value = $value['value']; - } - + } + $selected = (strtolower($val) == strtolower($value))? "SELECTED" : ""; - + //echo "Sel $field = $value: $selected
"; - + if( getArrayValue($attribs,'_langtext') ) { $txt = language($attribs["_langtext"]); } else $txt = $attribs["_plaintext"]; - + $o = ""; - + return $o; } function m_form_custom_options($attribs = array()) { global $FormValues, $objSession; $html_attribs = ExtraAttributes($attribs); - + $form = $attribs['_form']; $field = $attribs['_field']; - + $application =& kApplication::Instance(); $item_type = $application->getUnitOption($attribs['_prefix'], 'ItemType'); - + $sql = 'SELECT ValueList FROM '.GetTablePrefix().'CustomField WHERE FieldName = %s AND Type = %s'; $values = $application->DB->GetOne( sprintf($sql, $application->DB->qstr($field), $item_type ) ); if(!$values) return ''; - + if( GetVar($field) ) - { + { $value = GetVar($field); } else - { + { $value = $FormValues[$form][$field]; if( is_array($value) ) $value = $value['value']; - } - + } + $ret = ''; $values = explode(',', $values); $option_tpl = ''; @@ -628,7 +628,7 @@ $selected = $mixed_value[0] == $value ? ' selected' : ''; $ret .= sprintf($option_tpl, $mixed_value[0], $selected, $label); } - + return $ret; } @@ -638,7 +638,7 @@ @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name @attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting - @attrib: _Custom:bool: If set, handled as a custom field + @attrib: _Custom:bool: If set, handled as a custom field @example: */ function m_form_textarea($attribs = array()) @@ -697,7 +697,7 @@ $ret .= ""; $ret .= ""; if($is_default) $ret .= ''; - + if( getArrayValue($attribs,'_required') ) { $ret .= ""; @@ -709,14 +709,14 @@ @description: Returns the error text for a form field, or nothing if no error exists for the field @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name -*/ +*/ function m_form_error($attribs = array()) { global $FormError; $form = $attribs["_form"]; $field = $attribs["_field"]; - + return $FormError[$form][$field]; } @@ -729,17 +729,17 @@ // shows specified template once if form has error(-s) global $FormError; $f = $attribs["_form"]; - + $ret = is_array($FormError[$f]); if(!$ret) return ''; return isset($attribs["_asif"]) ? true : language('lu_errors_on_form'); } /** - @description: Lists form errors for all fields in a form + @description: Lists form errors for all fields in a form @attrib: _Form:: Form name for the field - @attrib: _ItemTemplate:tpl: Template used to display each form error (if not set, "" is used) -*/ + @attrib: _ItemTemplate:tpl: Template used to display each form error (if not set, "" is used) +*/ function m_list_form_errors($attribs = array()) { global $FormError, $content_set, $objTemplate; @@ -750,24 +750,24 @@ $f = $attribs["_form"]; $o = ""; if (strlen($t)) - { + { $rawtext = $objTemplate->GetTemplate($t, true); - $src = $rawtext->source; - } + $src = $rawtext->source; + } else $src = $templateText; - - //echo $f."
"; - //echo $t."
"; + + //echo $f."
"; + //echo $t."
"; // echo "
"; print_r($FormError); echo "
"; if( getArrayValue($FormError,$f) && is_array($FormError[$f])) - { + { foreach($FormError[$f] as $e) { $o .= str_replace("",$e, $src); } } - if(!strlen($o)) + if(!strlen($o)) $content_set = 0; return $o; } @@ -783,10 +783,10 @@ $FormValues[$FormName]["username"] = $u->Get("Login"); //$FormValues[$FormName]["password"] = $u->Get("Password"); //$FormValues[$FormName]["passwordverify"] = $u->Get("Password"); - + $FormValues[$FormName]["password"] = ""; $FormValues[$FormName]["passwordverify"] = ""; - + $FormValues[$FormName]["firstname"] = $u->Get("FirstName"); $FormValues[$FormName]["lastname"] = $u->Get("LastName"); $FormValues[$FormName]["email"] = $u->Get("Email"); @@ -796,15 +796,15 @@ $FormValues[$FormName]["state"] = $u->Get("State"); $FormValues[$FormName]["zip"] = $u->Get("Zip"); $FormValues[$FormName]["country"] = $u->Get("Country"); - + // $FormValues[$FormName]["dob"] = LangDate($u->Get("dob")); $FormValues[$FormName]["dob_day"] = adodb_date("d", $u->Get("dob")); $FormValues[$FormName]["dob_year"] = adodb_date("Y", $u->Get("dob")); - $FormValues[$FormName]["dob_month"] = adodb_date("m", $u->Get("dob")); - + $FormValues[$FormName]["dob_month"] = adodb_date("m", $u->Get("dob")); + $u->LoadCustomFields(); if(is_array($u->CustomFields)) - { + { foreach($u->CustomFields as $f=>$v) { $FormValues[$FormName][$f] = $v; @@ -828,10 +828,10 @@ } break; case "m_simplesearch": - $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); + $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); break; case "m_simple_subsearch": - $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); + $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); break; } @@ -851,40 +851,40 @@
  • m_subscribe: form to subscribe to the mailing list
  • subscribe_confirm: form to confirm subscription to the mailing list
  • m_unsubscribe: form to unsubscribe from the mailing list -
  • unsubscribe_confirm: form to confirm un-subscription from the mailing list -
  • m_acctinfo: user account information +
  • unsubscribe_confirm: form to confirm un-subscription from the mailing list +
  • m_acctinfo: user account information
  • m_profile: system-level profile information -
  • m_register: New User registration form +
  • m_register: New User registration form
  • m_addcat: Suggest Category form
  • m_addcat_confirm: Confirmation for add category -
  • m_simplesearch: Perform a simple search +
  • m_simplesearch: Perform a simple search
  • m_simple_subsearch: Search within results
  • m_adv_searchtype: Form to select type of advanced search
  • m_adv_subsearch: Advanced Search
  • m_sort_cats: Sort categories
  • error_access: form displayed on the access denied template -
  • error_template: Form displayed on the template error page -
  • m_set_theme: Form displayed for theme selection +
  • error_template: Form displayed on the template error page +
  • m_set_theme: Form displayed for theme selection @attrib: _SubscribeTemplate:tpl: The destination template with "m_subscribe", "subscribe_confirm", "unsubscribe_confirm" _Form actions. Can be reused in other scenarios as programmed. @attrib: _UnSubscribeTemplate:tpl: The destination template for "m_subscribe" _Form action. Can be reused in other scenarios as programmed. @attrib: _ConfirmTemplate:tpl: The destination template for "m_unsubscribe", "suggest" _Form actions. Can be reused in other scenarios as programmed. - @attrib: _DestTemplate:tpl: The destination template for "suggest_confirm", "suggest" _Form actions. Can be reused in other scenarios as programmed. - @attrib: _ErrorTemplate:tpl: The destination template extensively used in most of _Form actions in case of error. - @attrib: _Referer:bool: The destination template will be taken from referer page we can from. - - @example:
    "> + @attrib: _DestTemplate:tpl: The destination template for "suggest_confirm", "suggest" _Form actions. Can be reused in other scenarios as programmed. + @attrib: _ErrorTemplate:tpl: The destination template extensively used in most of _Form actions in case of error. + @attrib: _Referer:bool: The destination template will be taken from referer page we can from. + + @example: "> */ function m_form_action($attribs = array()) { global $var_list, $var_list_update, $m_var_list_update, $objSession, $objConfig, $objCatList; - + $var_list_update['t'] = getArrayValue($attribs, '_template') ? $attribs['_template'] : $var_list['t']; - + $ret = ''; $form = strtolower( $attribs['_form'] ); $url_params = Array(); - + switch($form) { case 'login': @@ -893,7 +893,7 @@ $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_login'); if( getArrayValue($attribs, '_successtemplate') ) { @@ -910,49 +910,49 @@ $url_params['pass'] = 'all'; } break; - + case 'logout': $url_params = Array('Action' => 'm_logout'); break; - + case 'forgotpw': if(!$objSession->SessionEnabled()) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_forgotpw'); $url_params['error'] = getArrayValue($attribs, '_errortemplate') ? $attribs['_errortemplate'] : $var_list['t']; if( getArrayValue($attribs, '_confirm') ) $url_params['Confirm'] = $attribs['_confirm']; } break; - + /*case 'forgotpw_confirm': break;*/ - + case 'm_sort_cats': $url_params = Array('Action' => 'm_sort_cats'); break; - + case 'suggest': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_suggest_email'); - + if( getArrayValue($attribs, '_confirmtemplate') ) { $url_params['Confirm'] = $attribs['_confirmtemplate']; $url_params['DestTemplate'] = $var_list['t']; - } + } if( getArrayValue($attribs, '_errortemplate') ) $url_params['Error'] = $attribs['_errortemplate']; } break; - + case 'suggest_confirm': if( !$objSession->SessionEnabled() ) { @@ -961,44 +961,44 @@ else { $var_list_update['t'] = getArrayValue($_GET, 'DestTemplate') ? $_GET['DestTemplate'] : 'index'; - } + } break; - + case 'm_subscribe': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_subscribe_confirm'); $params_map = Array('_subscribetemplate' => 'Subscribe', '_unsubscribetemplate' => 'Unsubscribe', '_errortemplate' => 'Error'); MapTagParams($url_params, $attribs, $params_map); } break; - - case 'subscribe_confirm': + + case 'subscribe_confirm': $url_params = Array('Action' => 'm_subscribe'); $params_map = Array('_subscribetemplate' => 'Subscribe'); MapTagParams($url_params, $attribs, $params_map); break; - + case 'unsubscribe_confirm': $url_params = Array('Action' => 'm_unsubscribe'); $params_map = Array('_subscribetemplate' => 'Subscribe'); MapTagParams($url_params, $attribs, $params_map); break; - + case 'm_unsubscribe': $params_map = Array('_confirmtemplate' => 'ErrorTemplate'); MapTagParams($url_params, $attribs, $params_map); - + if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params['Action'] = 'm_unsubscribe'; if( getArrayValue($attribs, '_confirmtemplate') ) { @@ -1007,33 +1007,33 @@ } } break; - + /*case 'm_unsubscribe_confirm': break;*/ - + case 'm_acctinfo': $url_params = Array('Action' => 'm_acctinfo', 'UserId' => $objSession->Get('PortalUserId') ); m_form_load_values( $form, $objSession->Get('PortalUserId') ); break; - + case 'm_profile': $url_params = Array('Action' => 'm_profile', 'UserId' => $objSession->Get('PortalUserId') ); m_form_load_values( $form, $objSession->Get('PortalUserId') ); break; - + case 'm_set_theme': $url_params = Array('Action' => 'm_set_theme'); break; - + case 'm_register': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_register'); - + switch ( $objConfig->Get('User_Allow_New') ) { case 1: @@ -1046,44 +1046,44 @@ $url_params['dest'] = $attribs['_logintemplate']; } break; - + case 2: if( getArrayValue($attribs, '_notallowedtemplate') ) $url_params['dest'] = $attribs['_notallowedtemplate']; break; - + case 3: if( getArrayValue($attribs, '_pendingtemplate') ) $url_params['dest'] = $attribs['_pendingtemplate']; break; } - } + } break; case 'register_confirm': if( !$objSession->SessionEnabled() ) $var_list_update['t'] = 'error_session'; break; - + case 'm_addcat': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_add_cat'); if ( $objSession->HasCatPermission('CATEGORY.ADD.PENDING') ) - { - + { + $url_params['Confirm'] = $attribs[ getArrayValue($attribs, '_confirmpending') ? '_confirmpending' : '_confirm' ]; $url_params['Action'] = 'm_add_cat_confirm'; - } + } - if ( $objSession->HasCatPermission('CATEGORY.ADD') ) - { - $url_params['Confirm'] = $attribs['_confirm']; + if ( $objSession->HasCatPermission('CATEGORY.ADD') ) + { + $url_params['Confirm'] = $attribs['_confirm']; $url_params['Action'] = 'm_add_cat_confirm'; } if( !$url_params['Confirm'] ) unset($url_params['Confirm']); - + if ( getArrayValue($attribs, '_mod_finishtemplate') ) { $CurrentCat = (int)$objCatList->CurrentCategoryID(); @@ -1113,12 +1113,12 @@ } } break; - + case 'm_addcat_confirm': $var_list_update['t'] = getArrayValue($_GET, 'DestTemplate') ? $_GET['DestTemplate'] : $var_list['t']; break; - - case 'm_simplesearch': + + case 'm_simplesearch': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; @@ -1130,48 +1130,48 @@ m_form_load_values($form, 0); } break; - + case 'm_simple_subsearch': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_simple_subsearch'); m_form_load_values($form,0); } break; - + case 'm_adv_search_type': if( !$objSession->SessionEnabled() ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_advsearch_type'); m_form_load_values($form,0); } break; - + case 'm_adv_search': $SearchType = getArrayValue($_GET, 'type') ? $_GET['type'] : $_POST['itemtype']; if( !$objSession->SessionEnabled() && !$SearchType ) { $var_list_update['t'] = 'error_session'; } else - { + { $url_params = Array('Action' => 'm_adv_search', 'type' => $SearchType); m_form_load_values($form,0); } break; - + case 'error_access': $var_list_update['t'] = getArrayValue($_GET, 'DestTemplate') ? $_GET['DestTemplate'] : 'login'; break; - + case 'error_template': $target_template = getArrayValue($_GET, 'DestTemplate'); if($attribs['_referer'] == 1) @@ -1184,21 +1184,23 @@ } $var_list_update['t'] = $target_template; break; - } + } return HREF_Wrapper('', $url_params); } /* @description: creates a URL to allow the user to log out. Accepts the same attributes as m_template_link - -*/ + +*/ function m_logout_link($attribs) { - $ret = m_template_link($attribs)."&Action=m_logout"; + $query = getArrayValue($attribs, '_query'); + $attribs['_query'] = $query.'&Action=m_logout'; + $ret = m_template_link($attribs) return $ret; } -/* +/* @description: returns a URL to the current theme @attrib: _page:: Additional address to be added to the end of the theme URL */ @@ -1208,7 +1210,7 @@ if(!is_object($CurrentTheme)) $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); - + $theme_url = PROTOCOL.SERVER_NAME.rtrim(BASE_PATH, '/').'/themes/'.$CurrentTheme->Get('Name').'/'; if(getArrayValue($attribs,'_page')) { @@ -1224,7 +1226,7 @@ return $theme_url; } -/* +/* @description: returns a URL to the current theme */ function m_current_page_url($attribs=array()) @@ -1236,7 +1238,7 @@ return $theme_url; } -/* +/* @description: returns a URL to the current theme @attrib: _fullpath:bool: Append the title with the full path of the current category @attrib: _currentcategory:bool: Append the title with the current category @@ -1245,20 +1247,20 @@ function m_page_title($attribs = array()) { global $objConfig, $objCatList; - + $ret = strip_tags( $objConfig->Get('Site_Name') ); if(getArrayValue($attribs,'_fullpath') || getArrayValue($attribs,'_currentcategory')) { $CurrentCat = $objCatList->CurrentCategoryID(); if((int)$CurrentCat>0) - { - $c = $objCatList->GetCategory($CurrentCat); + { + $c = $objCatList->GetCategory($CurrentCat); if($attribs["_fullpath"]) { $path = $c->Get("CachedNavbar"); - + if(strlen($path)) - $ret .= " - ".$path; + $ret .= " - ".$path; } else { @@ -1268,7 +1270,7 @@ if(!strlen($f)) $f = "Name"; $ret .= " - ".$c->Get($f); - } + } } } } @@ -1279,19 +1281,19 @@ /* @description: list all active themes @attrib: _ItemTemplate:tpl: Template to display each theme in the list -*/ +*/ function m_list_themes($attribs=array()) { global $objThemes; $t = $attribs["_itemtemplate"]; if(strlen($t)) - { + { $objThemes->Clear(); $objThemes->LoadThemes("Enabled=1","PrimaryTheme DESC"); - + foreach($objThemes->Items as $theme) - { + { $o .= $theme->ParseTemplate($t); } } @@ -1310,7 +1312,7 @@ $phrase = $attribs["_phrase"]; $LangId = (int)$ForceLanguage; if(strlen($phrase)) - { + { $lang = getArrayValue($attribs,'_language'); if(strlen($lang)) { @@ -1323,13 +1325,13 @@ return language($phrase,$LangId); } else - return ""; + return ""; } /* @description: Creates a URL used to set the current language for a user @attrib: _language:: Language to set (this value should be the language Pack Name) -*/ +*/ function m_setlang_link($attribs) { global $m_var_list_update, $objSession,$objLanguages; @@ -1344,7 +1346,7 @@ { $LangId = $objSession->Get('Language'); } - + if($LangId) { $m_var_list_update['lang'] = $LangId; @@ -1361,7 +1363,7 @@ /* @description: list all active languages @attrib: _ItemTemplate:tpl: Template to display each language in the list -*/ +*/ function m_list_languages($attribs) { global $objLanguages, $content_set; @@ -1383,7 +1385,7 @@ /* @description: returns the date format for a language @attrib: _lang:: Pack Name of language to use. The current language is used if this is not set -*/ +*/ function m_lang_dateformat($attribs=array()) { global $objLanguages, $objSession; @@ -1400,15 +1402,15 @@ } $fmt = GetDateFormat($LangId); $fmt = GetStdFormat($fmt); - + return $fmt; } /* @description: returns a language field value @attrib: _Field:: Language field to return @attrib: _lang:: Pack Name of language to use. The current language is used if this is not set -*/ +*/ function m_lang_field($attribs = array()) { global $objLanguages, $objSession; @@ -1439,7 +1441,7 @@ /* @description: Creates a URL used to set the current theme for a user @attrib: _theme:: Name of Theme to set. The template selected in the new them is always "index" -*/ +*/ function m_settheme_link($attribs) { global $m_var_list_update, $objSession, $objThemes, $CurrentTheme; @@ -1458,7 +1460,7 @@ $m_var_list_update['theme'] = $Id; $ret = HREF_Wrapper(); unset($m_var_list_update['theme']); - + return $ret; } @@ -1470,10 +1472,10 @@ // save current & previous category (used in pagination) global $objSession, $objCatList; global $var_list; - + $objSession->SetVariable('prev_category', $objSession->GetVariable('last_category') ); $objSession->SetVariable('last_category', $objCatList->CurrentCategoryID() ); - + //$last_cat = $objSession->GetVariable('last_category'); //$prev_cat = $objSession->GetVariable('prev_category'); //echo "Last CAT: [$last_cat]
    "; @@ -1489,8 +1491,8 @@ @attrib: _EdItemTemplate:tpl: Editors Pick template used for category list items @attrib: _ItemTemplate:tpl: default template used for category list items @attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag - @example: -*/ + @example: +*/ function m_list_cats($attribs = array()) { global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set, $objSystemCache; @@ -1548,7 +1550,7 @@ $content_set = 0; return ""; } - + $html_attr = ExtraAttributes($attribs); $o=""; @@ -1582,8 +1584,8 @@ $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } - if(!$parsed) - { + if(!$parsed) + { if (getArrayValue($attribs, '_editemtemplate') && (int)$cat->Get('EditorsPick')) { $o .= $cat->ParseTemplate($attribs["_editemtemplate"]); @@ -1607,7 +1609,7 @@ { if($cat->Get("ParentId")==$CategoryId) { - + if($row==0 && strlen($attribs["_firstitemtemplate"])) { //echo 'Saving ID in m_sub_cats[ first ] '.$cat->UniqueId().'
    '; @@ -1666,9 +1668,9 @@ } else $acl_where = "(FIND_IN_SET(0,acl))"; - + $order_by = "EdPick DESC,Relevance DESC"; - + if ($objSession->GetVariable("Category_Sortfield") != "") { $order_by = $objSession->GetVariable("Category_Sortfield")." ".$objSession->GetVariable("Category_Sortorder"); } @@ -1712,16 +1714,16 @@ /* @description: Used in conjuction with m_search_list_cats. This function generates a navigation link which is - used to switch from a short list to a longer list. The page number is not changed. - If this tag is called before the list tag, this function will load the category list. - Generally, it is good practice to duplicate all attributes set for m_search_list_cats. + used to switch from a short list to a longer list. The page number is not changed. + If this tag is called before the list tag, this function will load the category list. + Generally, it is good practice to duplicate all attributes set for m_search_list_cats. Any extra HTML attributes are passed to the anchor tag - @attrib: _Template:tpl: Template to link to + @attrib: _Template:tpl: Template to link to @attrib: _text:lang: language tag to include as text for the anchor tag @attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence if both are included. - @attrib: _image:: URL to an image to include inside the anchor tag. -*/ + @attrib: _image:: URL to an image to include inside the anchor tag. +*/ function m_search_cat_more($attribs = array()) { global $objSearchCats, $objConfig, $m_var_list_update; @@ -1736,12 +1738,12 @@ LoadCatSearchResults($attribs); } $max = $objConfig->Get($objSearchList->PerPageVar); - $val = $objSearchCats->QueryItemCount; + $val = $objSearchCats->QueryItemCount; if($val > $max) { - if($attribs["_root"]) + if($attribs["_root"]) $attribs["_category"]=0; - + $m_var_list_update["p"]=1; $url = m_template_link($attribs); unset($m_var_list_update["p"]); @@ -1759,28 +1761,28 @@ $o .= language($text); if(strlen($attribs["_image"])) { - $o .= ""; - } + $o .= "\"\"/"; + } $o .= ""; } return $o; } /* @description: Used in conjuction with l_list_cats. This function generates the page navigation - for the list. If this tag is called before the list tag, this function will load + for the list. If this tag is called before the list tag, this function will load the links. For that reason, the _ListType attribute is required if the pagnav - tag preceeds the l_list_links tag in the template. Generally, it is good practice to + tag preceeds the l_list_links tag in the template. Generally, it is good practice to duplicate all attributes set for l_list_links. @attrib: _PagesToList:int: Number of pages to list (default is 10) - @attrib: _ShortList:bool: If set, uses the shortlist configuration value for links + @attrib: _ShortList:bool: If set, uses the shortlist configuration value for links @attrib: _label:lang: language tag to include in the output if there are pages to list. If there are no pages listed, this text will not be included (resulting in an empty output) - @attrib: _ListType::Determines the type of list to generate
    + @attrib: _ListType::Determines the type of list to generate
    Possible values:
    • Category: List links from the current category (default) -
    - -*/ + + +*/ function l_cat_pagenav($attribs = array()) { global $objCatList, $objSession; @@ -1817,13 +1819,13 @@ /* @description: Used in conjuction with m_search_list_cats. This function generates the page navigation - for the list. If this tag is called before the list tag, this function will load - the category list. Generally, it is good practice to duplicate all attributes set for + for the list. If this tag is called before the list tag, this function will load + the category list. Generally, it is good practice to duplicate all attributes set for m_search_list_cats. @attrib: _PagesToList:int: Number of pages to list (default is 10) @attrib: _label:lang: language tag to include in the output if there are pages to list. If there are no pages listed, this text will not be included (resulting in an empty output) -*/ +*/ function m_search_cat_pagenav($attribs = array()) { global $objSearchCats, $objConfig, $objCatList, $objSession; @@ -1859,8 +1861,8 @@ @attrib: _LastItemTemplate:tpl: Template used for the last category listed @attrib: _ItemTemplate:tpl: default template used for category list items @attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag - @example: -*/ + @example: +*/ function m_search_list_cats($attribs = array()) { global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set, @@ -1879,25 +1881,25 @@ $m_var_list["p"] = 1; $objSearchCats->PerPageVar = "Perpage_Category_Short"; } - - $keywords = $objSession->GetVariable("Search_Keywords"); // for using in all this func branches - + + $keywords = $objSession->GetVariable("Search_Keywords"); // for using in all this func branches + if($objSearchCats->NumItems()==0) { LoadCatSearchResults($attribs); //echo "Cat count: ". $objSearchCats->QueryItemCount; $ret = 0; if ($keywords) { foreach ($objSearchCats->Items as $cat) { - + if (strstr(strip_tags(strtolower($cat->Data['Name'])), strtolower($_POST['keywords'])) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($_POST['keywords']))) { $ret++; } } } else { $ret = $objSearchCats->QueryItemCount; - } + } if ($ret == 0) //if ($objSearchCats->NumItems() == 0) { $content_set = 0; @@ -1919,22 +1921,22 @@ $o=""; $notable = $attribs["_notable"]; - + $max_categories = $objConfig->Get($objSearchCats->PerPageVar); $count=0; $row=0; $var_list_update["t"] = $var_list["t"]; - + if(!$notable) - { + { $per_row = ceil($objCatList->NumItems()/$cols); $o = ""; $o .= "
    "; foreach($objSearchCats->Items as $cat) - { + { $parsed=0; if($count==$per_row) - { + { $o .= ""; $count=0; } @@ -1945,8 +1947,8 @@ } if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { - $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); - $parsed=1; + $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); + $parsed=1; } if(!$parsed) $o.= $cat->ParseTemplate($attribs["_itemtemplate"]); @@ -1957,7 +1959,7 @@ $o .= "\n
    \n"; } else - { + { //echo "
    "; print_r($objSearchCats->Items); echo "
    "; foreach($objSearchCats->Items as $cat) { @@ -1972,8 +1974,8 @@ } if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { - $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); - $parsed=1; + $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); + $parsed=1; } if(!$parsed) $o.= $cat->ParseTemplate($attribs["_itemtemplate"]); @@ -1989,14 +1991,14 @@ } /* - @description: Parse a template based on the current advanced search type + @description: Parse a template based on the current advanced search type @attrib:_TypeSelect:tpl:Template to parse if no item type has been selected @attrib:_ItemSelect:tpl:Template to parse if an item type has been selected to search */ function m_advsearch_include($attribs) { global $objTemplate; - + $TypeSelectTemplate = $attribs["_typeselect"]; $ItemTemplate = $attribs["_itemselect"]; if((strlen($_GET["type"])>0 || $_POST["itemtype"]>0) && ($_GET["Action"]=="m_advsearch_type" || $_GET["Action"]=="m_adv_search")) @@ -2010,12 +2012,12 @@ /* @description: Returns the name of the item type currently being advanced searched - @attrib::_plaintext:bool:If set, simply returns the name of the item if not, builds a language tag (lu_searchtitle_[name]) + @attrib::_plaintext:bool:If set, simply returns the name of the item if not, builds a language tag (lu_searchtitle_[name]) */ function m_advsearch_type($attribs) { - global $objItemTypes; - + global $objItemTypes; + if($_GET["Action"]=="m_advsearch_type") { $ItemType = $_POST["itemtype"]; @@ -2032,7 +2034,7 @@ $name = strtolower($Item->Get("ItemName")); if($attribs["_plaintext"]) { - $o .= $name; + $o .= $name; } else $o = language("lu_searchtitle_".strtolower($name)); @@ -2047,15 +2049,15 @@ @attrib: _LastItemTemplate:tpl: Template used for the last field listed @attrib: _AltLastItemTemplate:tpl: Altername Template used for the last field listed @attrib: _ItemTemplate:tpl: default template used for field list items - @attrib: _AltTemplate:tpl: Alternate template used for field list items -*/ + @attrib: _AltTemplate:tpl: Alternate template used for field list items +*/ function m_advsearch_fields($attribs) { global $objItemTypes, $objTemplate, $objSearchConfig; - + if(!is_object($objSearchConfig)) $objSearchConfig = new clsSearchConfigList(); - + if($_GET["Action"]=="m_advsearch_type") { $ItemType = $_POST["itemtype"]; @@ -2078,25 +2080,25 @@ $row=0; if(is_array($objSearchConfig->Items)) { - $ItemCount = count($objSearchConfig->Items); + $ItemCount = count($objSearchConfig->Items); foreach($objSearchConfig->Items as $s) { $even = (($row+1) % 2 == 0); $parsed=0; if($row==0 && strlen($attribs["_firstitemtemplate"])) - { - $o .= $s->ParseTemplate($attribs["_firstitemtemplate"]); - $parsed=1; + { + $o .= $s->ParseTemplate($attribs["_firstitemtemplate"]); + $parsed=1; } if($row==$ItemCount-1 && $even && !$parsed && strlen($attribs["_altlastitemtemplate"])>0) { - $o .= $s->ParseTemplate($attribs["_altlastitemtemplate"]); - $parsed=1; + $o .= $s->ParseTemplate($attribs["_altlastitemtemplate"]); + $parsed=1; } if($row==$ItemCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { - $o .= $s->ParseTemplate($attribs["_lastitemtemplate"]); - $parsed=1; + $o .= $s->ParseTemplate($attribs["_lastitemtemplate"]); + $parsed=1; } if(!$parsed) { @@ -2106,14 +2108,14 @@ } else $o .= $s->ParseTemplate($attribs["_itemtemplate"]); - } + } $row++; - + } } } } - return $o; + return $o; } /* @@ -2124,16 +2126,16 @@ @attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list, the link will be generated. (If the _DeniedTemplate attribute is set, this template is used and the link is created.) - @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm + @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, - nothing is returned. (The link is not created.) + nothing is returned. (The link is not created.) @attrib: _Root:bool: If set, the current category is set to the module's root category @attrib: _text:lang: language tag to include as text for the anchor tag @attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence if both are included. - @attrib: _image:: URL to an image to include inside the anchor tag. - @attrib: _image_actions:: Image events. -*/ + @attrib: _image:: URL to an image to include inside the anchor tag. + @attrib: _image_actions:: Image events. +*/ function m_module_link($attribs = array()) { global $objCatList, $objSession; @@ -2142,13 +2144,13 @@ $o = ""; $tpath = GetModuleArray("template"); if(strlen($permission)) - { + { $perms = explode(",",$permission); $hasperm = FALSE; for($x=0;$xHasCatPermission($perms[$x])) - { + { $hasperm = TRUE; break; } @@ -2165,7 +2167,7 @@ { $module = $attribs["_module"]; if(ModuleEnabled($module)) - { + { $t = $tpath[$attribs["_module"]]; $t .= $attribs["_template"]; $attribs["_template"] = $t; @@ -2174,14 +2176,14 @@ { $func = ModuleTagPrefix($module)."_root_link"; if(function_exists($func)) - { + { $url = $func($attribs); } else $url = m_template_link($attribs); } - else - $url = m_template_link($attribs); + else + $url = m_template_link($attribs); $o = " "; @@ -2193,7 +2195,7 @@ { if(strlen($attribs["_image"])) { - $text = ""; + $text = "\"\""; } } $o .= $text.""; @@ -2202,7 +2204,7 @@ $o .= language($text).""; } else - { + { $o = ""; } } @@ -2215,28 +2217,28 @@ @attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list, the link will be generated. (If the _DeniedTemplate attribute is set, this template is used and the link is created.) - @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm + @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, - nothing is returned. (The link is not created.) + nothing is returned. (The link is not created.) @attrib: _text:lang: language tag to include as text for the anchor tag @attrib: _plaintext:: plain text to include as text for the anchor tag. The _text attribute takes presedence if both are included. - @attrib: _image:: URL to an image to include inside the anchor tag. -*/ + @attrib: _image:: URL to an image to include inside the anchor tag. +*/ function m_permission_link($attribs = array()) { global $objCatList, $objSession; $permission = $attribs["_perm"]; $o = ""; if(strlen($permission)) - { + { $perms = explode(",",$permission); $hasperm = FALSE; for($x=0;$xHasCatPermission($perms[$x])) - { + { $hasperm = TRUE; break; } @@ -2251,7 +2253,7 @@ } if($hasperm) { - $url = m_template_link($attribs); + $url = m_template_link($attribs); $o = " "; @@ -2263,7 +2265,7 @@ { if(strlen($attribs["_image"])) { - $text = ""; + $text = "\"\""; } } $o .= $text.""; @@ -2272,38 +2274,38 @@ $o .= language($text).""; } else - { + { $o = ""; } - + return $o; } function m_confirm_password_link($attribs = array()) { global $m_var_list_update, $var_list_update, $objSession, $objConfig; - - $template = "forgotpw_reset_result"; -// $user = $objSession->Get("tmp_user_id").";".$objSession->Get("tmp_email"); + + $template = "forgotpw_reset_result"; + // $user = $objSession->Get("tmp_user_id").";".$objSession->Get("tmp_email"); $tmp_user_id = $objSession->Get("tmp_user_id"); - - $conn = &GetADODBConnection(); - $code = md5(GenerateCode()); - $sql = 'UPDATE '.GetTablePrefix().'PortalUser SET PwResetConfirm="'.$code.'", PwRequestTime='.adodb_mktime().' WHERE PortalUserId='.$tmp_user_id; - $query = "&user_key=".$code."&Action=m_resetpw"; - - $conn->Execute($sql); - - $var_list_update["t"] = $template; + $conn = &GetADODBConnection(); + $code = md5(GenerateCode()); + $sql = 'UPDATE '.GetTablePrefix().'PortalUser SET PwResetConfirm="'.$code.'", PwRequestTime='.adodb_mktime().' WHERE PortalUserId='.$tmp_user_id; - $ret = ($attribs["_secure"]?"https://":"http://").ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv().$query; - - return $ret; + $query = "&user_key=".$code."&Action=m_resetpw"; + + $conn->Execute($sql); + + $var_list_update["t"] = $template; + + $ret = ($attribs["_secure"]?"https://":"http://").ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv().$query; + + return $ret; } /** - * Returns result of password reset confirmation + * Returns result of password reset confirmation * code validation as appropriate phrase * * @return string @@ -2316,7 +2318,7 @@ } /* - @description: Create a link to a template. + @description: Create a link to a template. @attrib: _Template:tpl: Template to link to (ex: "inbulletin/post_list") @attrib: _Query:str: Extra query sring to be added to link URL (ex: "&test=test") @attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged @@ -2325,89 +2327,89 @@ @attrib: _Module:str:Module Name @attrib: _Relative:bool: Is set, creates an relative url url (../..address) @example: "> -*/ +*/ function m_template_link($attribs = array()) { - global $var_list, $var_list_update, $m_var_list_update, $objCatList; - - $var_list_update['t'] = getArrayValue($attribs,'_template') ? $attribs['_template'] : $var_list['t']; - - $query_string = trim( getArrayValue($attribs,'_query') ); + global $var_list, $var_list_update, $m_var_list_update, $objCatList; + + $var_list_update['t'] = getArrayValue($attribs,'_template') ? $attribs['_template'] : $var_list['t']; + + $query_string = trim( getArrayValue($attribs,'_query') ); $url_params = $query_string ? ExtractParams($query_string) : Array(); - $cat = getArrayValue($attribs, '_category'); + $cat = getArrayValue($attribs, '_category'); - if($cat) $m_var_list_update['cat'] = ($cat == 'NULL') ? 0 : $cat; - if( getArrayValue($attribs,'_anchor') ) $url_params['anchor'] = $attribs['_anchor']; - - $ret = HREF_Wrapper('', $url_params); - - unset( $var_list_update['t'] ); - if($cat) unset( $m_var_list_update['cat'] ); - return $ret; + if($cat) $m_var_list_update['cat'] = ($cat == 'NULL') ? 0 : $cat; + if( getArrayValue($attribs,'_anchor') ) $url_params['anchor'] = $attribs['_anchor']; + + $ret = HREF_Wrapper('', $url_params); + + unset( $var_list_update['t'] ); + if($cat) unset( $m_var_list_update['cat'] ); + return $ret; } /* @description: create a link to a template based on user permissions. All extra HTML attributes are passed to the anchor tag created. @attrib: _Template:tpl: Template to link to if the user has access - @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm + @attrib: _DeniedTemplate:tpl: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, - the "login" template is used. + the "login" template is used. @attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list, the link will be generated. (If the _DeniedTemplate attribute is set, this template is used and the link is created.) @attrib: _System:bool: Set this attribute if one of the permissions in the list is a system permission (ie: LOGIN) @attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged - @example: "> -*/ + @example: "> +*/ function m_access_template_link($attribs = array(), $Permission="") { global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession; $cat = getArrayValue($attribs,'_category'); if(strlen($cat)) - { + { if($cat=="NULL") $cat = 0; } else $cat = $objCatList->CurrentCategoryID(); - if(!strlen($Permission)) - { + if(!strlen($Permission)) + { $Permission = strtoupper($attribs["_perm"]); } - + $o = ""; $hasperm = FALSE; if(strlen($Permission)) - { - $perms = explode(",",$Permission); - + { + $perms = explode(",",$Permission); + for($x=0;$xHasCatPermission(trim($perms[$x]),$cat)) - { + { $hasperm = TRUE; break; } } - + if(!$hasperm && $attribs["_system"]) { for($x=0;$xHasSystemPermission(trim($perms[$x]))) - { + { $hasperm = TRUE; break; } - } + } } } - + $url_params = Array('dest' => ''); - + $access = $attribs["_template"]; $denied = $attribs["_deniedtemplate"]; if(!strlen($denied)) @@ -2416,16 +2418,16 @@ $m_var_list_update["cat"] = $cat; if($hasperm) { - $template = $access; + $template = $access; if(!strlen($template)) - $template = $var_list["t"]; + $template = $var_list["t"]; $var_list_update["t"] = $template; } else - { + { $template = $denied; if(!strlen($template)) - $template = $var_list["t"]; + $template = $var_list["t"]; if($template == "login") { $url_params['dest'] = $access; @@ -2435,94 +2437,94 @@ if( !$url_params['dest'] ) unset($url_params['dest']); $ret = HREF_Wrapper('', $url_params); - + unset($var_list_update["t"]); - + return $ret; } /* @description: returns a text based on user permissions. Text from inside of the tag will be returned if text attributes are not specified and user has permissions to category, or if _NoPerm attribute set to 1 and user doesn't have permissions. Otherwise entire section will be excluded. @attrib: _Text:lang: Template to link to if the user has access - @attrib: _PlainText:: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, the "login" template is used. + @attrib: _PlainText:: This template is used if the user does not have a permission listed in the _perm attribute. If this attirbute is not included and the user does not have access, the "login" template is used. @attrib: _DenyText:lang: Template to link to if the user has access - @attrib: _PlainDenyText:: This exact text is used if the user does not have a permission listed in the _perm attribute and _DenyText attribute is not set. + @attrib: _PlainDenyText:: This exact text is used if the user does not have a permission listed in the _perm attribute and _DenyText attribute is not set. @attrib: _perm:: A list of permissions to check. If the user has any of the the permissions in the list, the link will be generated. @attrib: _System:bool: Set this attribute if one of the permissions in the list is a system permission (ie: LOGIN) @attrib: _Category:int: Set the current category to this ID. If not set, the current category is unchanged - @attrib: _MatchAllPerms:int: Checks for all listed Permissions to be TRUE. Note: this attribute is rarely used. - @attrib: _NoPerm:int: The whole tag will return inner text if user has no permissions and attribute set to 1. Default value is 0. + @attrib: _MatchAllPerms:int: Checks for all listed Permissions to be TRUE. Note: this attribute is rarely used. + @attrib: _NoPerm:int: The whole tag will return inner text if user has no permissions and attribute set to 1. Default value is 0. @example: Some HTML here! -*/ +*/ function m_perm_text($attribs = array()) { global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession; $cat = getArrayValue($attribs,'_category'); if(strlen($cat)) - { + { if($cat=="NULL") $cat = 0; } else $cat = $objCatList->CurrentCategoryID(); - //if(!strlen($Permission)) + //if(!strlen($Permission)) $Permission = strtoupper($attribs["_perm"]); - + $o = ""; $hasperm = FALSE; - + $count = 0; - + if(strlen($Permission)) - { - $perms = explode(",",$Permission); - + { + $perms = explode(",",$Permission); + for($x=0;$xHasCatPermission($perms[$x],$cat)) - { + { $hasperm = TRUE; - $_AllPermsCount[$count] = 1; + $_AllPermsCount[$count] = 1; // break; } - + $count++; } - + if( !$hasperm && getArrayValue($attribs,'_system') ) { for($x=0; $xHasSystemPermission($perms[$x])) - { + { $hasperm = TRUE; - $_AllPermsCount[$count] = 1; + $_AllPermsCount[$count] = 1; // break; } - + $count++; - } + } } } - + if ((int)getArrayValue($attribs,'_matchallperms')) { if (count($_AllPermsCount) != array_sum($_AllPermsCount)) - $hasperm = FALSE; + $hasperm = FALSE; } - + $text = getArrayValue($attribs,'_text'); $plaintext = getArrayValue($attribs,'_plaintext'); $denytext = getArrayValue($attribs,'_denytext'); - $plaindenytext = getArrayValue($attribs,'_plaindenytext'); + $plaindenytext = getArrayValue($attribs,'_plaindenytext'); $nopermissions_status = (int)getArrayValue($attribs,'_noperm')? 1 : 0; - + //if(!strlen($denied)) $denied = "login"; - + if (!$nopermissions_status) { if ($hasperm) @@ -2545,14 +2547,14 @@ { $ret = "1"; } - - return $ret; + + return $ret; } /* - @description: Returns the error string associated with a permission -*/ + @description: Returns the error string associated with a permission +*/ function m_permission_error($attribs = array()) { global $objPermissions; @@ -2561,7 +2563,7 @@ $perm = strtoupper($_GET["error"]); if(strlen($perm)) { - $ado = &GetADODBConnection(); + $ado = &GetADODBConnection(); $sql = "SELECT * FROM ".GetTablePrefix()."PermissionConfig WHERE PermissionName ='$perm'"; $rs = $ado->Execute($sql); if($rs && !$rs->EOF) @@ -2582,7 +2584,7 @@ function m_template_error($attribs = array()) { global $objTemplate; - + $ret = ""; if($objTemplate->ErrorNo<0) { @@ -2598,51 +2600,51 @@ @attrib: _LinkCurrent:bool: If set, the last (current) category is linked. Otherwise the current category is simply displayed @attrib: _Separator:: text to display between levels of the navigation bar @attrib: _Root:: Root category configuration variable to use. (ex: Link for In-Link's root category) If not set, the system root is used - @example: + @example: */ function m_navbar($attribs = array()) { global $m_var_list_update, $var_list, $objCatList, $objConfig, $objModules; - + $separator = getArrayValue($attribs, '_separator'); if(!$separator) $separator = " > "; - + $admin = (int)getArrayValue($attribs, 'admin'); - + $t = getArrayValue($attribs, '_template'); $LinkLeafNode = getArrayValue($attribs, '_linkcurrent'); $catid = (int)getArrayValue($attribs, '_catid'); - + if( getArrayValue($attribs, '_root') ) { $var = getArrayValue($attribs, '_root')."_Root"; $Root = (int)$objConfig->Get($var); } else $Root = 0; - + $RootTemplate = getArrayValue($attribs, '_roottemplate'); if($RootTemplate === false) $RootTemplate = ''; - + $Module = getArrayValue($attribs, '_module'); $ModuleRootTemplate = ''; if($Module) { $ModuleRootCat = $objModules->GetModuleRoot($Module); if($ModuleRootCat>0) - { - $modkey = "_moduleroottemplate"; + { + $modkey = "_moduleroottemplate"; $ModuleRootTemplate = getArrayValue($attribs, $modkey); } else - $ModuleRootTemplate=""; + $ModuleRootTemplate=""; } else $ModuleRootCat = 0; - + if(!$catid) - $catid = $objCatList->CurrentCategoryID(); - + $catid = $objCatList->CurrentCategoryID(); + $ret = $objCatList->cat_navbar($admin, $catid, $t, $separator,$LinkLeafNode,$Root,$RootTemplate,$ModuleRootCat,$ModuleRootTemplate); return $ret; } @@ -2652,22 +2654,22 @@ @attrib: _Field:: Category field to parse @attrib: _CatId:int: Category ID to parse (uses current category if not set) @attrib: _StripHTML:bool: if set, all HTML is removed from the output -*/ +*/ function m_category_field($attribs) { global $objCatList; - $ret = ""; + $ret = ""; $catid = (int)getArrayValue($attribs,'_catid'); $field = $attribs["_field"]; if(!$catid) $catid = $objCatList->CurrentCategoryID(); - if(strlen($field)) - { - $cat =& $objCatList->GetCategory($catid); + if(strlen($field)) + { + $cat =& $objCatList->GetCategory($catid); if(is_object($cat)) - { + { $element = new clsHtmlTag(); $element->name=$cat->TagPrefix; $element->attributes = $attribs; @@ -2688,21 +2690,21 @@ function m_category_modified($attribs) { global $objConfig, $objCatList; - + $ado = &GetADODBConnection(); $ret=''; if(getArrayValue($attribs,'_local') && $objCatList->CurrentCategoryID() != 0) { $c =& $objCatList->GetItem($objCatList->CurrentCategoryID()); $catlist = $c->GetSubCatIds(); - + $catwhere = "CategoryId IN (".explode(",",$catlist).")"; $sql = "SELECT MAX(Modified) as ModDate,MAX(CreatedOn) as NewDate FROM ".GetTablePrefix()."Category "; $sql .= "INNER JOIN ".GetTablePrefix()."CategoryItems ON (".GetTablePrefix()."Category.ResourceId=".GetTablePrefix()."CategoryItems.ItemResourceId) "; - $sql .= "WHERE $catwhere LIMIT 1"; + $sql .= "WHERE $catwhere LIMIT 1"; } else - { + { $sql = "SELECT MAX(Modified) as ModDate FROM ".GetTablePrefix()."Category LIMIT 1"; } $rs = $ado->Execute($sql); @@ -2722,9 +2724,9 @@ @description: creates LINK tags to include all module style sheets @attrib: _Modules:: Accepts a comma-separated list of modules to include (ie: "In-Link, In-News, In-Bulletin") @attrib: _*css:none: Each module may set a custom-named stylesheet. For example, for In-Link the attribute would be _In-Linkcss="..". - If a module does not have a *css attribute, the default (style.css) is assumed. - @example: -*/ + If a module does not have a *css attribute, the default (style.css) is assumed. + @example: +*/ function m_module_stylesheets($attribs) { global $TemplateRoot; @@ -2749,64 +2751,64 @@ /* @description: lists items related to a category @attrib:CatId:int: Category ID of category, or current category if not set - @attrib:_ListItem: Comma-separated list of item types (ie: Link, Topic, Category, News) The items are listed in the order this list provides, then by priority. + @attrib:_ListItem: Comma-separated list of item types (ie: Link, Topic, Category, News) The items are listed in the order this list provides, then by priority. Each item should have its own template passed in as an attribute (_{ItemType}Template) */ function m_related_items($attribs) { global $objItemTypes, $objCatList, $content_set, $CatRelations; static $Related; - + $cat = getArrayValue($attribs,'_catid'); if(!is_numeric($cat)) - { + { $cat = $objCatList->CurrentCategoryID(); } $c =& $objCatList->GetCategory($cat); $data_sent=0; if(is_object($c)) - { + { $ResourceId = $c->Get("ResourceId"); $IncludeList = explode(",",trim(strtolower($attribs["_listitems"]))); $o = ""; - + if(!is_object($CatRelations)) - { + { $CatRelations = new clsMultiTypeList(); LoadRelatedItems($Related, $CatRelations,$c->Get("ResourceId")); } if($CatRelations->NumItems()>0) - { + { for($inc=0;$incGetTypeByName($item_type); if(is_object($objType)) - { + { foreach($CatRelations->Items as $item) - { + { if(is_object($item)) - { + { if(strtolower($objType->Get("ItemName")) == strtolower($item_type) && $item->type==$objType->Get("ItemType")) - { + { if(strlen($item->BasePermissionName)) { $perm = $item->BasePermissionName.".VIEW"; - $haspem = $objSession->HasCatPermission($perm,$item->Get("CategoryId")); + $haspem = $objSession->HasCatPermission($perm,$item->Get("CategoryId")); } else $hasperm = 1; - + if($hasperm) { - $data_sent =1; - $classname = $objType->Get("ClassName"); + $data_sent =1; + $classname = $objType->Get("ClassName"); if(strlen($classname)) { $l = new $classname; @@ -2824,7 +2826,7 @@ } } if($data_sent) - { + { return $o; } else @@ -2834,7 +2836,7 @@ } } else - { + { $content_set = 0; return ""; } @@ -2857,7 +2859,7 @@ $cat = getArrayValue($attribs,'_catid'); if(!is_numeric($cat)) - { + { $cat = $objCatList->CurrentCategoryID(); } $c =& $objCatList->GetCategory($cat); @@ -2867,22 +2869,22 @@ { $ResourceId = $c->Get("ResourceId"); if(!is_object($CatRelations)) - { + { $CatRelations = new clsMultiTypeList(); LoadRelatedItems($Related, $CatRelations, $c->Get("ResourceId")); - } - + } + $item_type = getArrayValue($attribs,'_itemtype'); if(strlen($item_type)) { $objType = $objItemTypes->GetTypeByName($item_type); if(is_object($objType)) - { + { $TargetType = $objType->Get("ItemType"); } - else + else $TargetType=""; - } + } $count=0; if($CatRelations->NumItems()>0) { @@ -2891,7 +2893,7 @@ $a = $CatRelations->GetItemByIndex($x); if($a->type == $TargetType || !strlen($TargetType)) { - $count++; + $count++; } } } @@ -2901,8 +2903,8 @@ /* @description: Returns the MetaKeywords field for a category, or the system MetaKeywords value if the category doesn't have a value for MetaKeywords - @attrib: _CatId:int: Category to use (The current category is used by default) -*/ + @attrib: _CatId:int: Category to use (The current category is used by default) +*/ function m_meta_keywords($attribs = array()) { global $objCatList, $objConfig; @@ -2917,16 +2919,16 @@ $keywords = $c->Get("MetaKeywords"); } if(!strlen($keywords)) - { + { $keywords = $objConfig->Get("Category_MetaKey"); } return $keywords; } /* @description: Returns the MetaDescription field for a category, or the system MetaDescription value if the category doesn't have a value for MetaDescription - @attrib: _CatId:int: Category to use (The current category is used by default) -*/ + @attrib: _CatId:int: Category to use (The current category is used by default) +*/ function m_meta_description($attribs = array()) { global $objCatList, $objConfig; @@ -2942,7 +2944,7 @@ $desc = $c->Get("MetaDescription"); } if(!strlen($desc)) - { + { $desc = $objConfig->Get("Category_MetaDesc"); } return $desc; @@ -2957,7 +2959,7 @@ @attrib: _Today:bool: Count items added today @attrib: _GroupOnly:bool: Only count items the current user can view @attrib: _NoCache:bool: Count without using cache -*/ +*/ function m_itemcount($attribs = array()) { global $objItemTypes, $objCatList, $objSession, $objCountCache; @@ -2967,14 +2969,14 @@ $Bit_Owner = 2; $Bit_Global = 4; $Bit_SubCats=8; - + if(getArrayValue($attribs,'_categorycount')) - { + { $evar = m_BuildEnv(); } else $evar = ""; - + $cat = getArrayValue($attribs,'_catid'); if(!is_numeric($cat)) { @@ -2983,49 +2985,49 @@ if((int)$cat>0) $c = $objCatList->GetCategory($cat); - + if(is_numeric($attribs["_itemtype"])) { $item = $objItemTypes->GetItem($attribs["_itemtype"]); } - else + else $item = $objItemTypes->GetTypeByName($attribs["_itemtype"]); - + $DoUpdate=0; - + //echo "
    "; print_r($item); echo "
    "; - + $ExtraId=""; - + if(is_object($item)) - { + { if($item->Get("ItemType")==1) /* counting categories */ - { + { $ret = $objCatList->CountCategories($attribs); } else { - $ListVar =& GetItemCollection($attribs["_itemtype"]); - if(is_object($ListVar)) - { + $ListVar =& GetItemCollection($attribs["_itemtype"]); + if(is_object($ListVar)) + { //echo get_class($ListVar)."
    "; //print_pre($attribs); $ret = $ListVar->PerformItemCount($attribs); //echo "m_itemcount: $ret
    "; - } + } } } else - $ret = 0; - + $ret = 0; + return !$ret ? 0 : $ret; } /* @description: Parse a User field and return the value @attrib: _Field:: User field to parse @attrib: _UserId:int: Category ID to parse (uses current user if not set) -*/ +*/ function m_user_field($attribs) { global $objUsers, $objSession; @@ -3039,7 +3041,7 @@ { $u =& $objUsers->GetItem($userid); if(is_object($u)) - { + { $element = new clsHtmlTag(); $element->name = $u->TagPrefix; $element->attributes = $attribs; @@ -3052,8 +3054,8 @@ /* @description: Parses a user template @attrib:_Template:tpl: Template to parse - @attrib:_UserId:int: User ID to parse. If not set, the current user is used -*/ + @attrib:_UserId:int: User ID to parse. If not set, the current user is used +*/ function m_user_detail($attribs = array()) { global $objTemplate, $objUsers, $objSession; @@ -3068,13 +3070,13 @@ { $u = $objUsers->GetUser($UserId); $o = $u->ParseTemplate($tname); - } + } else { $u = new clsPortalUser(NULL); - $o = $u->ParseTemplate($tname); + $o = $u->ParseTemplate($tname); } - + return $o; } @@ -3087,10 +3089,10 @@ if((int)$_GET["UserId"]) { $attribs["_userid"] = $_GET["UserId"]; - } - + } + $ret = m_user_field($attribs); - + /* if ($ret == '') { $ret = admin_language("lu_Guest"); }*/ @@ -3101,15 +3103,15 @@ /* @description: Parses a user profile template @attrib:_Template:tpl: Template to parse - @attrib:_UserId:int: User ID to parse. If not set, the current user is used + @attrib:_UserId:int: User ID to parse. If not set, the current user is used */ function m_user_profile_detail($attribs) { if((int)$_GET["UserId"]) { $attribs["_userid"] = $_GET["UserId"]; } - $ret = m_user_detail($attribs); + $ret = m_user_detail($attribs); return $ret; } @@ -3145,7 +3147,7 @@ $src = $html; $src = str_replace("","",$src); $src = str_replace("lu_profile_field","lu_".$field,$src); - $o .= $u->ParseTemplateText($src); + $o .= $u->ParseTemplateText($src); } } @@ -3157,9 +3159,9 @@ /* @description: List users the current user has marked as 'friend' - @attrib: _Status:: Determines which online status to list, either "online" or "offline". + @attrib: _Status:: Determines which online status to list, either "online" or "offline". @attrib: _ItemTemplate:tpl: Template used to parse list items -*/ +*/ function m_list_friends($attribs = array()) { global $objUsers, $objSession; @@ -3169,10 +3171,10 @@ $ado = &GetADODBConnection(); $status = strtolower($attribs["_status"]); - + $logedin_user = $objSession->Get("PortalUserId"); $u =& $objUsers->GetUser($logedin_user); - + //echo "
    "; print_r($u); echo "
    "; if(!isset($online_friends) || $status=="online") { @@ -3188,17 +3190,17 @@ } } else - { + { $sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId,$stable.PortalUserId FROM $ftable "; $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) INNER JOIN $stable ON "; - $sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; //echo $sql; $rs = $ado->Execute($sql); while($rs && ! $rs->EOF) { $u =& $objUsers->GetItem($rs->fields["PortalUserId"]); if($status=="online") - { + { $o .= $u->ParseTemplate($attribs["_itemtemplate"]); } $online_friends[]=$rs->fields["PortalUserId"]; @@ -3211,26 +3213,26 @@ } } } - + if($status=="offline") { $ftable = GetTablePrefix()."Favorites"; $stable = GetTablePrefix()."UserSession"; $ptable = GetTablePrefix()."PortalUser"; - + $sessql = "SELECT DISTINCT(PortalUserId) FROM $stable"; if(count($online_friends)>0) - { + { $sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId FROM $ftable "; $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND "; - $sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; } else { $sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId FROM $ftable "; - $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; } - + //echo $sql; $rs = $ado->Execute($sql); while($rs && ! $rs->EOF) @@ -3251,18 +3253,18 @@ /* @description: Returns the number of users the current user has marked as 'friend' - @attrib: _Status:: Determines which online status to count, either "online" or "offline". -*/ + @attrib: _Status:: Determines which online status to count, either "online" or "offline". +*/ function m_friend_count($attribs=array()) { global $objUsers, $objSession; global $online_friends; $ado = &GetADODBConnection(); - + $logedin_user = $objSession->Get("PortalUserId"); - $u =& $objUsers->GetUser($logedin_user); + $u =& $objUsers->GetUser($logedin_user); $status = strtolower($attribs["_status"]); if(!isset($online_friends) || $status=="online") @@ -3275,11 +3277,11 @@ return count($online_friends); } else - { + { $online_friends = array(); $sql = "SELECT $ftable.ResourceId,$ftable.ItemTypeId, $ptable.PortalUserId,$stable.PortalUserId FROM $ftable "; $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) INNER JOIN $stable ON "; - $sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .= "($ptable.PortalUserId=$stable.PortalUserId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; //echo $sql."
    \n"; $rs = $ado->Execute($sql); while($rs && ! $rs->EOF) @@ -3296,25 +3298,25 @@ return count($online_friends); } } - + if($status=="offline") { $ftable = GetTablePrefix()."Favorites"; $stable = GetTablePrefix()."UserSession"; $ptable = GetTablePrefix()."PortalUser"; - + $sessql = "SELECT DISTINCT(PortalUserId) FROM $stable"; if(count($online_friends)>0) - { + { $sql = "SELECT count($ftable.ResourceId) as ItemCount FROM $ftable "; $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND "; - $sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .= " $ptable.PortalUserId NOT IN (".implode(",",$online_friends).") AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; } else { $sql = "SELECT count($ftable.ResourceId) as ItemCount FROM $ftable "; - $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; + $sql .="INNER JOIN $ptable ON ($ftable.ResourceId=$ptable.ResourceId) WHERE ItemTypeId=6 AND $ftable.PortalUserId = ".$logedin_user; //$u->Data['ResourceId']; } $rs = $ado->Execute($sql); return $rs->fields["ItemCount"]; @@ -3323,16 +3325,16 @@ /* @description: Returns the number of users the current user has marked as 'friend' today -*/ +*/ function m_friend_count_today($attribs) { global $objSession; - + $logedin_user = $objSession->Get("PortalUserId"); $ret =0; $ado = &GetADODBConnection(); - $today = adodb_mktime(0, 0, 0, adodb_date("m"), adodb_date("d"), adodb_date("Y")); + $today = adodb_mktime(0, 0, 0, adodb_date("m"), adodb_date("d"), adodb_date("Y")); $sql = "SELECT count(*) as c FROM ".GetTablePrefix()."Favorites WHERE ItemTypeId=6 and PortalUserId=".$objSession->Get("PortalUserId")." AND Modified>$today"; $rs = $ado->Execute($sql); if($rs && !$rs->EOF) @@ -3342,33 +3344,33 @@ /* @description: Returns the number of items in a search result - + @Example: () -*/ +*/ function m_search_item_count($attribs) { global $objItemTypes, $objCatList, $objSession, $CountVal; if(!is_array($CountVal)) - $CountVal=array(); - $item = $objItemTypes->GetTypeByName($attribs["_itemtype"]); + $CountVal=array(); + $item = $objItemTypes->GetTypeByName($attribs["_itemtype"]); if(is_object($item)) - { + { $val = $CountVal[$item->Get("ItemType")]; if(is_numeric($val)) - return $val; + return $val; $where = "ItemType=".$item->Get("ItemType"); $table = $objSession->GetSearchTable(); $ret = TableCount($table,$where,0); $CountVal[$item->Get("ItemType")]=(int)$ret; } - + return $ret; } /* @description: Returns the number of categories in a search result @Example: () -*/ +*/ function m_search_cat_count($attribs = array()) { global $objItemTypes, $objCatList, $objSession, $CountVal, $objSearchCats; @@ -3387,8 +3389,8 @@ LoadCatSearchResults($attribs); //echo "
    "; print_r($objSearchCats->Items); echo "
    "; $ret = 0; - $keywords = $objSession->GetVariable("Search_Keywords"); - + $keywords = $objSession->GetVariable("Search_Keywords"); + /*if ($keywords) { foreach ($objSearchCats->Items as $cat) { @@ -3400,19 +3402,19 @@ //else { $ret = $objSearchCats->QueryItemCount; //} - + if ($ret == '') { $ret = 0; } - + //echo $ret; //$objSearchCats->QueryItemCount = $ret; - + return $ret; } /* - @description: Returns super global variable by type and name + @description: Returns super global variable by type and name @attrib: _Name:: Name of variable @attrib: _Type:: Type super global variable
    Possible Values:
      @@ -3421,15 +3423,15 @@
    • cookie: $_COOKIE super variable
    • env: $_ENV super variable
    • server: $_SERVER super variable -
    • session: $_SESSION super variable +
    • session: $_SESSION super variable
    @Example: -*/ +*/ function m_get_var($attribs = array()) { $type = strtoupper( $attribs['_type'] ); $name = $attribs['_name']; - + $array_name = '_'.$type; $vars = $GLOBALS[ isset( $GLOBALS[$array_name] ) ? $array_name : '_POST' ]; return $vars[$name]; @@ -3441,24 +3443,24 @@ @attrib: _OwnCount:bool: Count user's own session */ function m_users_online($attribs = array()) -{ +{ global $objSession; - - $LastActive = (int)($attribs['_lastactive']); + + $LastActive = (int)($attribs['_lastactive']); $OwnCount = (int)($attribs['_owncount']); - + if ($LastActive && !is_null($LastActive)) - $sql_add = " AND LastAccessed>".(adodb_mktime()-$LastActive); - + $sql_add = " AND LastAccessed>".(adodb_mktime()-$LastActive); + if (!$OwnCount || is_null($OwnCount)) - $sql_add.= " AND SessionKey!='".$objSession->GetSessionKey()."'"; - + $sql_add.= " AND SessionKey!='".$objSession->GetSessionKey()."'"; + $ado = &GetADODBConnection(); $sql = "SELECT COUNT(*) AS Counter FROM ".GetTablePrefix()."UserSession WHERE Status=1".$sql_add; - $rs = $ado->Execute($sql); - $ret = ($rs && !$rs->EOF)? $rs->fields["Counter"] : 0; - - return $ret; + $rs = $ado->Execute($sql); + $ret = ($rs && !$rs->EOF)? $rs->fields["Counter"] : 0; + + return $ret; } function m_debug_mode($attribs = array()) @@ -3475,7 +3477,7 @@ global $objConfig; $ret = ThisDomain().$objConfig->Get('Site_Path'); break; - + default: $ret = ''; break; @@ -3487,91 +3489,91 @@ { global $objModules; $module = $attribs['_module']; - + // check if module is installed $ModuleItem = $objModules->GetItemByField('Name', $module); if( !is_object($ModuleItem) ) return ''; - + // module is enabled $ret = $ModuleItem->Get('Loaded') == 1; - + // check if installed module is licensed return $ret ? 'yes' : ''; } function m_recall($attribs = array()) { global $objSession; - return $objSession->GetVariable($attribs['_name']); + return $objSession->GetVariable($attribs['_name']); } function m_regional_option($attribs = array()) { - return GetRegionalOption($attribs['_name']); + return GetRegionalOption($attribs['_name']); } /* @description: Returns a sitemap @attrib: _CatId:int: Top Level Catagory ID to start sitemap with. - @attrib: _ModuleName:: Module name (optional, default none) + @attrib: _ModuleName:: Module name (optional, default none) @attrib: _MainItemTemplate:tpl: Item template for Top level category - @attrib: _SubCatItemTemplate:tpl: Item template for Sub categories + @attrib: _SubCatItemTemplate:tpl: Item template for Sub categories @attrib: _MaxDepth:: Max Depth, default all, minimum 2 @attrib: _MaxCats:: Maximum number of Categories for each Module, default 300 */ function m_sitemap($attribs = array()) { global $objModules, $objConfig; - - $html_attribs = ExtraAttributes($attribs); - + + $html_attribs = ExtraAttributes($attribs); + $mod_name = getArrayValue($attribs, "_modulename"); $StartCatId = getArrayValue($attribs, "_catid"); $MaxDepth = (int)getArrayValue($attribs, "_maxdepth"); $MaxCats = getArrayValue($attribs, "_maxcats"); $MaxCats = !empty($MaxCats) ? (int)$MaxCats : 300; - + if ($MaxDepth == 0) unset($MaxDepth); elseif ($MaxDepth < 2) $MaxDepth = 2; - + $MainItemTemplate = getArrayValue($attribs, "_mainitemtemplate"); $SubCatItemTemplate = getArrayValue($attribs, "_subcatitemtemplate"); - + if (!strlen($SubCatItemTemplate)) $SubCatItemTemplate = "sitemap_subcat_element"; - + if (!strlen($MainItemTemplate)) $MainItemTemplate = "sitemap_cat_element"; - - + + $cols = getArrayValue($attribs, "_columns"); $cols = ($cols<1)? 2 : $cols; - + if (!isset($StartCatId)) { if (!strlen($mod_name)) { - $_RootCat = 0; + $_RootCat = 0; } else { - $_RootCat = $objModules->GetModuleRoot($mod_name); + $_RootCat = $objModules->GetModuleRoot($mod_name); } } else { $_RootCat = (int)$StartCatId? (int)$StartCatId : 0; } - + // Get Root Categories of all installed Modules if (is_array($objModules->Items)) { foreach ($objModules->Items as $curr_mod) { if( !$curr_mod->Get('Loaded') || ($curr_mod->Get('Name') == 'In-Portal') ) continue; - + $mod_name = (int)$curr_mod->Get('RootCat'); if( !empty($mod_name) ) { @@ -3583,27 +3585,27 @@ } } } - + $_C_objCat = new clsCatList(); $_Where = GetTablePrefix()."Category.ParentId = $_RootCat AND Status = 1"; $_OrderBy = " ORDER BY ".GetTablePrefix()."Category.Priority DESC "; $_C_catList = $_C_objCat->LoadCategories($_Where, $_OrderBy, false); - + ## getting TOP level categories if( is_array($_C_catList) && count($_C_catList) ) { $ret = ""; $ret.= ""; - $ret.= "\n
    "; - + $CatCount = $_C_objCat->NumCategories(); $per_row = ceil($CatCount / $cols); - + foreach ($_C_catList as $cat) { $text = $cat->Get("Name"); - $val = $cat->Get("CategoryId"); + $val = $cat->Get("CategoryId"); $sub_path = $cat->Get("ParentPath"); - + $add_path = ""; if( is_array($modules) ) { @@ -3612,40 +3614,40 @@ if (strpos($sub_path, "|$curr|") !== false) { $add_path = $v; - break; - } - } + break; + } + } } if(!$add_path) continue; - + $main_templ = $add_path.$MainItemTemplate; $ret.= $cat->ParseTemplate($main_templ); - + $count++; $row++; - + $_C_objCatSubs = new clsCatList(); - + $ParentPath = empty($_RootCat) ? '|'.$val.'|%' : '|'.$_RootCat.'|'.$val.'|%'; - + $_Where = GetTablePrefix()."Category.ParentPath LIKE '$ParentPath' AND ".GetTablePrefix()."Category.CategoryId!=$val AND Status=1"; $_OrderBy = " ORDER BY ".GetTablePrefix()."Category.ParentPath ASC, ".GetTablePrefix()."Category.Name ASC"; $old_value = $objConfig->Get($_C_objCatSubs->PerPageVar); - $objConfig->Set($_C_objCatSubs->PerPageVar, (int)$MaxCats); - + $objConfig->Set($_C_objCatSubs->PerPageVar, (int)$MaxCats); + $SubCats = $_C_objCatSubs->LoadCategories($_Where, $_OrderBy, false); - + $objConfig->Set($_C_objCatSubs->PerPageVar, $old_value); - + if (is_array($SubCats) && count($SubCats)) { - foreach ($SubCats as $subcat) + foreach ($SubCats as $subcat) { $SubCatName = $subcat->Get("Name"); $SubCatId = $subcat->Get("CategoryId"); - + $SubPath = $subcat->Get("ParentPath"); - + $add_path = ""; if (is_array($modules)) { @@ -3654,43 +3656,43 @@ if (strpos($SubPath, "|$curr|") !== false) { $add_path = $v; - break; - } - } + break; + } + } } - + $CatIds = $subcat->GetParentIds(); - + $nbs = ""; - + if (!isset($MaxDepth) || (isset($MaxDepth) && ($MaxDepth >= count($CatIds)))) { for ($i = (count($CatIds)-2); $i>0; $i--) $nbs.= "        "; - + $sub_templ = $add_path.$SubCatItemTemplate; $ret.= $nbs.$subcat->ParseTemplate($sub_templ); } - } - } - + } + } + unset($_C_objCatSubs); - + if($count==$per_row) { $ret.= ""; $count=0; } else - $ret.= "
    "; + $ret.= "
    "; } - + if($count != $per_row) $ret .= "
    \n"; + $ret.= "\n\n"; } - - return $ret; + + return $ret; } function m_IsDebugMode($params)