";print_r($pieces);echo ""; $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]; } else { $m_var_list["cat"]=0; $m_var_list["p"] = 1; $m_var_list["lang"] = $objLanguages->GetPrimary(); $m_var_list["theme"]= $objThemes->GetPrimaryTheme(); } } function m_BuildEnv() { global $m_var_list, $m_var_list_update; $module_vars = Array('cat','p','lang','theme'); $ret = GenerateModuleEnv('m', $module_vars); if( isset($GLOBALS['m_var_list_update']['cat']) ) unset($GLOBALS['m_var_list_update']['cat']); return $ret; } function m_GetVar($name) { // get variable from template variable's list global $m_var_list, $m_var_list_update; return isset($m_var_list_update[$name]) ? $m_var_list_update[$name] : $m_var_list[$name]; } function &LoadRelatedItems(&$Relations,&$RelatedItems,$ResourceId) { global $objItemTypes; if(!is_object($Relations)) { $Relations = new clsRelationshipList(); } //$Relations->debuglevel = 2; if ($ResourceId != '') { $sql = sprintf("SELECT RelationshipId, Type, Enabled, Priority, IF(TargetId = %1\$s, TargetId, SourceId) AS SourceId, IF(TargetId = %1\$s, SourceId, TargetId) AS TargetId, 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(); if($Relations->NumItems()>0) { foreach($Relations->Items as $r) { if($r->Get("SourceId")==$ResourceId) { $ids[$r->Get("TargetType")][] = $r->Get("TargetId"); } if($r->Get("TargetId")==$ResourceId && $r->Get("Type")==1) { $ids[$r->Get("SourceType")][] = $ResourceId; } } foreach($ids as $ItemType=>$idlist) { $Item =& $objItemTypes->GetItem($ItemType); $table = GetTablePrefix().$Item->Get("SourceTable"); if($ItemType!=1) { $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]).")"; } else { $sql = "SELECT *,CategoryId FROM $table "; $sql .="WHERE $table.Status=1 "; $sql .=" AND ResourceId IN (".implode(",",$ids[$ItemType]).")"; } // echo $sql."
\n"; $RelatedItems->Query_Item($sql,-1,-1,$ItemType); } } } } /* @description: Inserts the html from a remote source @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: */ function m_insert_url($attribs=array()) { global $pathtoroot; $url = $attribs["_url"]; $StartPos = $attribs["_startpos"]; $EndPos = $attribs["_endpos"]; $socket = new Socket($url,0,NULL); $txt = $socket->socket_read_all(); $lines = explode("\n",$txt); $txt = substr($txt,strpos($txt,"<")); $tmp = strtolower($txt); $bodypos = strpos($tmp,"0) { $head = substr($txt,0,$bodypos-1); $body = substr($txt,$bodypos); if(substr($tmp,-7)=="") $body = substr($body,0,-7); } else $body = $txt; if(strlen($body)) { if(strlen($StartPos)) { if(!is_numeric($StartPos)) { $start = strpos($body,$StartPos); } else $start = (int)$StartPos; } else $start = 0; if(strlen($EndPos)) { if(!is_numeric($EndPos)) { $end = strpos($body,$EndPos,$start) + strlen($EndPos); } else $end = (int)$EndPos; } else $end = NULL; $o = substr($body,$start,$end-$start); } 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: */ function m_loginbox($attribs = array()) { global $var_list, $objSession, $objUsers, $objTemplate; $userid = $objSession->Get("PortalUserId"); $groupid = $objSession->Get("GroupId"); if ($userid == 0) { if (strlen($attribs["_logintemplate"])) $t = $objTemplate->ParseTemplate($attribs["_logintemplate"]); return $t; } else { $user =& $objUsers->GetItem($userid); if (strlen($attribs["_loggedintemplate"])) $t = $user->ParseTemplate($attribs["_loggedintemplate"]); return $t; } } /* @description: result of suggest site action */ function m_suggest_result() { global $suggest_result; return $suggest_result; } /* @description: result of subscribe to mailing list action */ function m_subscribe_result() { global $SubscribeResult; if(strlen($SubscribeResult)) return language($SubscribeResult); return ""; } /* @description: email address of user subscribing to mailing list */ function m_subscribe_address() { global $SubscribeAddress; if(strlen($SubscribeAddress)) return $SubscribeAddress; return ""; } /* @description: Error message of subscribe to mailing list action */ function m_subscribe_error() { global $SubscribeError; if(strlen($SubscribeError)) return language($SubscribeError); return ""; } /* @description: Displays a prompt for a form field @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name @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 */ function m_form_prompt($attribs = array()) { global $FormError, $objTemplate, $objConfig; $form = strtolower($attribs["_form"]); $field = strtolower($attribs["_field"]); if($form=="m_register" && ($field=="password" || $field=="passwordverify") && $objConfig->Get("User_Password_Auto")) { $o = ""; } else { $t = $attribs["_template"]; if(!strlen($t)) { $templateText = ""; } $e = $attribs["_errortemplate"]; if(!strlen($e)) $e = $t; if(strlen($attribs["_langtext"])) { $txt = language($attribs["_langtext"]); } else $txt = $attribs["_plaintext"]; 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")])) $rawtext = $objTemplate->GetTemplate($e, true); } if(isset($FormError[strtolower($form)][strtolower($field)])) { $rawtext = $objTemplate->GetTemplate($e); } elseif (strlen($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; } /* @description: Returns text if system is configured to use auto-generated passwords @attrib:_LangText:lang:Language tag to return @attrib:_PlainText::Plain text to return (_LangText takes precedece) @attrib:_Value:bool:Auto Password setting value to match */ function m_autopassword($attribs = array()) { global $objConfig; if($attribs["_value"]=="true" || $attribs["_value"]==1) { $IsAuto = $objConfig->Get("User_Password_Auto"); } else { $IsAuto = !$objConfig->Get("User_Password_Auto"); } if($IsAuto) { if(strlen($attribs["_langtext"])) { $ret = language($attribs["_langtext"]); } else $ret = $attribs["_plaintext"]; if(!$ret) return "true"; } return $ret; } /* @description: checks if field specified is equals to value specified @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name @attrib: _Value:: Field value to compare to @example: true */ function m_field_equals($attribs = array()) { global $FormValues; //print_pre($attribs); $form = $attribs["_form"]; $field = $attribs["_field"]; if(isset($_POST[$field])) { $value = $_POST[$field]; } else $value = $FormValues[$form][$field]; //echo "POST_VALUE: [$value] vs USER_VALUE: [".$attribs['_value']."]
"; return $value == $attribs['_value'] ? 1 : ''; } /* @description: creates an INPUT tag 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: _ForgetValue:bool: if true, forget value @attrib: _Required:bool: If set, In-Portal requires this field have a value when submitting @example: */ function m_form_input($attribs = array()) { global $FormValues, $objConfig; $html_attribs = ExtraAttributes($attribs); $form = $attribs["_form"]; $field = strtolower($attribs["_field"]); // $field = $attribs["_field"]; if(isset($_POST[$field]) && $attribs['_forgetvalue'] != 1) { $value = inp_htmlize($_POST[$field],1); } else { if ($attribs['_forgetvalue'] != 1) { $value = inp_htmlize($FormValues[$form][$field]); } } //echo $form.".".$field."=".$value." = ".$attribs['_forgetvalue']."
\n"; if($form=="m_register" && ($field=="password" || $field=="passwordverify") && $objConfig->Get("User_Password_Auto")) { $ret = ""; } else { $ret = ""; if($attribs["_required"]) $ret .= ""; if($attribs["_custom"]) $ret .= ""; } return $ret; } /* @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: _Required:bool: If set, In-Portal requires this field have a value when submitting @attrib: _Custom:bool: If set, handled as a custom field @example: */ function m_form_checkbox($attribs = array()) { global $FormValues, $objConfig; $html_attribs = ExtraAttributes($attribs); $form = $attribs["_form"]; $field = strtolower($attribs["_field"]); if(isset($_POST[$field])) { $value = (int)$_POST[$field]; if($value==1) $checked = " CHECKED"; } else { $value = (int)$FormValues[$form][$field]; if($value==1) $checked=" CHECKED"; } //echo $form.".".$field."=".$value."
\n"; $ret = ""; if($attribs["_required"]) $ret .= ""; if($attribs["_custom"]) $ret .= ""; return $ret; } /* @description: creates an INPUT tag (type radio) 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:: Value assigned to radio button. If the form field value matches this attribute, 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 @example: */ function m_form_radio($attribs = array()) { global $FormValues, $objConfig; $html_attribs = ExtraAttributes($attribs); $form = $attribs["_form"]; $field = strtolower($attribs["_field"]); $val = $attribs["_value"]; if(isset($_POST[$field])) { $value = (int)$_POST[$field]; if($value==1) $checked = " CHECKED"; } else { $value = (int)$FormValues[$form][$field]; if($value==$val) $checked=" CHECKED"; } //echo $form.".".$field."=".$value."
\n"; $ret = ""; if($attribs["_required"]) $ret .= ""; if($attribs["_custom"]) $ret .= ""; return $ret; } /* @description: returns the value for a form field. This may be defaulted by the system or set by a previus submit (as in an error condition) @attrib: _Form:: Form name for the field @attrib: _Field:: Field Name @example: */ function m_form_value($attribs = array()) { global $FormValues; $form = $attribs["_form"]; $field = strtolower($attribs["_field"]); if(isset($_POST[$field])) { $value = inp_htmlize($_POST[$field],1); } else $value = inp_htmlize($FormValues[$form][$field]); //echo "
"; print_r($FormValues); echo "
"; return $value; } /* @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) @example: $txt"; return $o; } /* @description: creates an form TEXTAREA field. All extra attributes are passed to the TEXTAREA tag @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 @example: */ function m_form_textarea($attribs = array()) { global $FormValues; $html_attribs = ExtraAttributes($attribs); $field = $attribs["_field"]; $form = $attribs["_form"]; if(isset($_POST[$field])) { $value = inp_htmlize($_POST[$field],1); } else { $value = inp_htmlize($FormValues[$attribs["_form"]][$field]); } $ret = ""; if($attribs["_required"]) { $ret .= ""; } if($attribs["_custom"]) { $ret .= ""; } return $ret; } /* @description: creates an form field to upload images. (INPUT type=file) All extra attributes are passed to the INPUT tag @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: _ImageTypes:: Comma-separated list of file extensions allowed @attrib: _Thumbnail:bool: If true, image is treated as a thumbnail @attrib: _ImageName:: System name of image being uploaded @attrib: _MaxSize:int: Maximum size of image to upload, or 0 to allow all */ function m_form_imageupload($attribs = array()) { $html_attribs = ExtraAttributes($attribs); $field = $attribs["_field"]; $form = $attribs["_form"]; $TypesAllowed = $attribs["_imagetypes"]; $isthumb = (int)$attribs["_thumbnail"]; $imgname = $attribs["_imagename"]; $maxsize = $attribs["_maxsize"]; $ret = ""; $ret .= ""; $ret .= ""; $ret .= ""; $ret .= ""; if($attribs["_required"]) $ret .= ""; return $ret; } /* @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]; } /** @description: Provides a simple solution for displaying a language flag when a form has an error. Generic and limited to 1 language vairable. @attrib: _Form:: Form name for the field */ function m_form_has_errors($attribs = array()) { // 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 @attrib: _Form:: Form name for the field @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; $t = $attribs["_itemtemplate"]; if(!strlen($t)) $templateText = ""; $f = $attribs["_form"]; $o = ""; if (strlen($t)) { $rawtext = $objTemplate->GetTemplate($t, true); $src = $rawtext->source; } else $src = $templateText; //echo $f."
"; //echo $t."
"; // echo "
"; print_r($FormError); echo "
"; if(is_array($FormError[$f])) { foreach($FormError[$f] as $e) { $o .= str_replace("",$e, $src); } } if(!strlen($o)) $content_set = 0; return $o; } function m_form_load_values($FormName,$IdValue) { global $FormValues, $objUsers, $objSession, $objConfig; switch($FormName) { case "m_acctinfo": $u =& $objUsers->GetItem($IdValue); $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"); $FormValues[$FormName]["phone"] = $u->Get("Phone"); $FormValues[$FormName]["street"] = $u->Get("Street"); $FormValues[$FormName]["city"] = $u->Get("City"); $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")); $u->LoadCustomFields(); if(is_array($u->CustomFields)) { foreach($u->CustomFields as $f=>$v) { $FormValues[$FormName][$f] = $v; } } break; case "m_profile": $u =& $objUsers->GetItem($IdValue); if(is_object($u)) { $FormValues[$FormName]["pp_firstname"] = $objSession->GetPersistantVariable("pp_firstname"); $FormValues[$FormName]["pp_lastname"] = $objSession->GetPersistantVariable("pp_lastname"); $FormValues[$FormName]["pp_dob"] = $objSession->GetPersistantVariable("pp_dob"); $FormValues[$FormName]["pp_email"] = $objSession->GetPersistantVariable("pp_email"); $FormValues[$FormName]["pp_phone"] = $objSession->GetPersistantVariable("pp_phone"); $FormValues[$FormName]["pp_street"] = $objSession->GetPersistantVariable("pp_street"); $FormValues[$FormName]["pp_city"] = $objSession->GetPersistantVariable("pp_city"); $FormValues[$FormName]["pp_state"] = $objSession->GetPersistantVariable("pp_state"); $FormValues[$FormName]["pp_zip"] = $objSession->GetPersistantVariable("pp_zip"); $FormValues[$FormName]["pp_country"] = $objSession->GetPersistantVariable("pp_country"); } break; case "m_simplesearch": $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); break; case "m_simple_subsearch": $FormValues[$FormName]["keywords"] = $objSession->GetVariable("Search_Keywords"); break; } } /* @description: Generates the ACTTION property for a FORM tag used by In-Portal @attrib: _Template:tpl: If set, this is the template the form submits to (default is the current template) @attrib: _Form:: The form name
Possible Values:
  • login: user login
  • logout: user logout
  • forgotpw: Form to prompt the user for forgotten password information
  • forgotpw_confirm: confirmation form for forgotpw
  • suggest: form to suggest the site to a friend
  • suggest_confirm: form to confirm suggestion of the site to a friend
  • 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
  • m_profile: system-level profile information
  • 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_simple_subsearch: Search within results
  • m_adv_searchtype: Form to select type of advanced search
  • m_adv_subsearch: Advanced Search
  • 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
@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:
"> */ function m_form_action($attribs = array()) { global $var_list, $var_list_update, $m_var_list_update, $objSession, $objConfig, $objCatList; $target_template = $attribs["_template"]; if(strlen($target_template)) { $var_list_update["t"] = $target_template; } else $var_list_update["t"] = $var_list["t"]; $ret = ""; $form = strtolower($attribs["_form"]); switch($form) { case "login": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_login"; if($attribs["_successtemplate"]) { $ret .= "&dest=".$attribs["_successtemplate"]; } else if(strlen($var_list["dest"])) $ret .= "&dest=".$var_list["dest"]; } break; case "logout": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_logout"; break; case "forgotpw": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { if(strlen($attribs["_errortemplate"])) { $err = $attribs["_errortemplate"]; } else $err = $var_list["t"]; $ret = GetIndexURL(2)."?env=".BuildEnv()."&Action=m_forgotpw&error=$err"; } break; case "forgotpw_confirm": $ret = GetIndexURL(2)."?env=".BuildEnv(); break; case "suggest": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_suggest_email"; if(strlen($attribs["_confirmtemplate"])>0) { $ret .= "&Confirm=".$attribs["_confirmtemplate"]; } if(strlen($Dest)) { $ret .= "&DestTemplate=$Dest"; } else { if(strlen($attribs["_confirmtemplate"])>0) $ret .="&DestTemplate=".$var_list["t"]; } if(strlen($attribs["_errortemplate"])>0) { $ret .= "&Error=".$attribs["_errortemplate"]; } } break; case "suggest_confirm": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { if(strlen($_GET["DestTemplate"])) { $var_list_update["t"] = $_GET["DestTemplate"]; } else $var_list_update["t"] = "index"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } break; case "m_subscribe": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_subscribe_confirm"; if(strlen($attribs["_subscribetemplate"])) { $ret .="&Subscribe=".$attribs["_subscribetemplate"]; } if(strlen($attribs["_unsubscribetemplate"])>0) { $ret .= "&Unsubscribe=".$attribs["_unsubscribetemplate"]; } if(strlen($attribs["_errortemplate"])>0) { $ret .= "&Error=".$attribs["_errortemplate"]; } } break; case "subscribe_confirm": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_subscribe"; if($attribs["_subscribetemplate"]) $ret .= "&Subscribe=".$attribs["_subscribetemplate"]; break; case "unsubscribe_confirm": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_unsubscribe"; if($attribs["_subscribetemplate"]) $ret .= "&Subscribe=".$attribs["_subscribetemplate"]; break; case "m_unsubscribe": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_unsubscribe"; if(strlen($attribs["_confirmtemplate"])>0) { $ret .= "&Confirm=".$attribs["_confirmtemplate"]; } if(strlen($Dest)) { $ret .= "&DestTemplate=$Dest"; } else { if(strlen($attribs["_confirmtemplate"])>0) $ret .="&DestTemplate=".$var_list["t"]; } } if(strlen($attribs["_confirmtemplate"])>0) { $ret .="&ErrorTemplate=".$attribs["_confirmtemplate"]; } break; case "m_unsubscribe_confirm": $ret = GetIndexURL(2)."?env=" . BuildEnv(); break; case "m_acctinfo": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_acctinfo&UserId=".$objSession->Get("PortalUserId"); m_form_load_values($form, $objSession->Get("PortalUserId")); break; case "m_profile": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_profile&UserId=".$objSession->Get("PortalUserId"); m_form_load_values($form,$objSession->Get("PortalUserId")); break; case "m_set_theme": $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_set_theme"; break; case "m_register": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_register"; switch ($objConfig->Get("User_Allow_New")) { case "1": if(strlen($attribs["_confirmtemplate"]) && $objConfig->Get("User_Password_Auto")) $_dest = "&dest=".$attribs["_confirmtemplate"]; else $_dest = "&dest=".$attribs["_logintemplate"]; break; case "2": if(strlen($attribs["_notallowedtemplate"])) $_dest = "&dest=".$attribs["_notallowedtemplate"]; break; case "3": if(strlen($attribs["_pendingtemplate"])) $_dest = "&dest=".$attribs["_pendingtemplate"]; break; } if (strlen($_dest)) $ret .= $_dest; } break; case "register_confirm": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv(); } break; case "m_addcat": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $action = "m_add_cat"; if ($objSession->HasCatPermission("CATEGORY.ADD.PENDING")) { if(strlen($attribs["_confirmpending"])) { $ConfirmTemplate = $attribs["_confirmpending"]; } else $ConfirmTemplate = $attribs["_confirm"]; $action="m_add_cat_confirm"; } if ($objSession->HasCatPermission("CATEGORY.ADD")) { $ConfirmTemplate = $attribs["_confirm"]; $action="m_add_cat_confirm"; } $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=$action"; if(strlen($ConfirmTemplate)) $ret .= "&Confirm=$ConfirmTemplate"; if (strlen($attribs["_mod_finishtemplate"])) { $CurrentCat = $objCatList->CurrentCategoryID(); if((int)$CurrentCat>0) { $c = $objCatList->GetCategory($CurrentCat); //will prefix the template with module template root path depending on category $ids = $c->GetParentIds(); $tpath = GetModuleArray("template"); $roots = GetModuleArray("rootcat"); // get template path of module, by searching for moudle name // in this categories first parent category // and then using found moudle name as a key for module template paths array $path = $tpath[array_search ($ids[0], $roots)]; $t = $path . $attribs["_mod_finishtemplate"]; } else { $t = $attribs["_mod_finishtemplate"]; //Just in case } } else { $t = $attribs["_finishtemplate"]; } $ret .="&DestTemplate=".$t; } break; case "m_addcat_confirm": $target_template = $_GET["DestTemplate"]; if(strlen($target_template)) { $var_list_update["t"] = $target_template; } else $var_list_update["t"] = $var_list["t"]; $ret = GetIndexURL(2)."?env=".BuildEnv(); break; case "m_simplesearch": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_simple_search"; if(strlen($attribs["_errortemplate"])) $ret.= "&Error=".$attribs["_errortemplate"]; m_form_load_values($form, 0); } break; case "m_simple_subsearch": if(!$objSession->SessionEnabled()) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&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"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_advsearch_type"; m_form_load_values($form,0); } break; case "m_adv_search": $SearchType = $_GET["type"]; if(!is_numeric($SearchType)) $SearchType = $_POST["itemtype"]; if(!$objSession->SessionEnabled() && !strlen($SearchType)) { $var_list_update["t"] = "error_session"; $ret = GetIndexURL(2)."?env=" . BuildEnv(); } else { $ret = GetIndexURL(2)."?env=" . BuildEnv()."&Action=m_adv_search&type=$SearchType"; m_form_load_values($form,0); } break; case "error_access": $target_template = $_GET["DestTemplate"]; if(!strlen($target_template)) $target_template="login"; $var_list_update["t"] = $target_template; $ret = GetIndexURL(2)."?env=" . BuildEnv(); break; case "error_template": $target_template = $_GET["DestTemplate"]; if($attribs["_referer"] == 1) { $target_template = "_referer_"; } elseif (!strlen($target_template)) { $target_template = "index"; } $var_list_update["t"] = $target_template; // $m_var_list_update["cat"]=0; $ret = GetIndexURL(2)."?env=".BuildEnv(); break; } return $ret; } /* @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"; return $ret; } /* @description: returns a URL to the current theme @attrib: _page:: Additional address to be added to the end of the theme URL */ function m_theme_url($attribs=array()) { global $objConfig,$objSession, $objThemes, $CurrentTheme; if(!is_object($CurrentTheme)) $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); $theme_url = "http://". ThisDomain().$objConfig->Get("Site_Path")."themes/".$CurrentTheme->Get("Name")."/"; if($attribs["_page"]) { if ($attribs["_page"] != 'current') { $theme_url .= $attribs["_page"]; } else { $theme_url = "http://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv(); } } return $theme_url; } /* @description: returns a URL to the current theme */ function m_current_page_url($attribs=array()) { global $objConfig,$objSession; $theme_url = "http://".$objConfig->Get("Site_Path")."index.php?env=".BuildEnv(); 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 @attrib: _catfield:: If _currentcategory is used, this attribute determines which category field to use (Name, Description, etc) Defaults to Name */ function m_page_title($attribs = array()) { global $objConfig, $objCatList; $ret = $objConfig->Get("Site_Name"); if($attribs["_fullpath"] || $attribs["_currentcategory"]) { $CurrentCat = $objCatList->CurrentCategoryID(); if((int)$CurrentCat>0) { $c = $objCatList->GetCategory($CurrentCat); if($attribs["_fullpath"]) { $path = $c->Get("CachedNavbar"); if(strlen($path)) $ret .= " - ".$path; } else { if($attribs["_currentcategory"]) { $f = $attribs["_catfield"]; if(!strlen($f)) $f = "Name"; $ret .= " - ".$c->Get($f); } } } } $ret = stripslashes($ret); return $ret; } /* @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); } } return $o; } /* @description: display text based on the user's language @attrib: _Phrase:lang: label to replace with language-specific text @example: */ function m_language($attribs) { global $objSession, $objLanguages, $ForceLanguage; $phrase = $attribs["_phrase"]; $LangId = (int)$ForceLanguage; if(strlen($phrase)) { $lang = getArrayValue($attribs,'_language'); if(strlen($lang)) { $l = $objLanguages->GetItemByField("PackName",$lang); if(is_object($l)) { $LangId = $l->Get("LanguageId"); } } return language($phrase,$LangId); } else 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; $lang = $attribs["_language"]; if(strlen($lang)) { $l = $objLanguages->GetItemByField("PackName",$lang); if(is_object($l)) $LangId = $l->Get("LanguageId"); } else $LangId=$objSession->Get("Language"); if($LangId) { $m_var_list_update["lang"] = $LangId; $ret = GetIndexURL(2)."?env=".BuildEnv(); unset($m_var_list_update["lang"]); } else $ret = ""; return $ret; } /* @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; $sql = "SELECT * FROM ".GetTablePrefix()."Language WHERE Enabled=1"; $objLanguages->Clear(); $objLanguages->Query_Item($sql); if($objLanguages->NumItems()>0) { foreach($objLanguages->Items as $l) $o .= $l->ParseTemplate($attribs["_itemtemplate"]); } else $content_set=0; return $o; } /* @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; $lang = $attribs["_lang"]; if(!strlen($lang)) { $LangId = $objSession->Get("Language"); $l = $objLanguages->GetItem($LangId); } else { $l = $objLanguages->GetItemByField("PackName",$lang); } $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; if(!strlen($attribs["_field"])) return ""; $lang = $attribs["_lang"]; if(!strlen($lang)) { $LangId = $objSession->Get("Language"); $l = $objLanguages->GetItem($LangId); } else { $l = $objLanguages->GetItemByField("PackName",$lang); } if(is_object($l)) { //$ret = $l->Get($attribs["_field"]); $e = new clsHtmlTag(); $e->name=$l->TagPrefix; $e->attributes=$attribs; $ret = $l->ParseObject($e); } return $ret; } /* @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; $ThemeName = $attribs["_theme"]; if(strlen($ThemeName)) { $t = $objThemes->GetItemByField("Name",$ThemeName); if(is_object($t)) { $Id = $t->Get("ThemeId"); } else $Id = 0; } else { $t = $CurrentTheme; $Id = 0; } $m_var_list_update["theme"] = $Id; $ret = GetIndexURL(2)."?env=".BuildEnv(); unset($m_var_list_update["theme"]); return $ret; } /* @description: Initializes categories */ function m_init_cats($attribs = array()) { // save current & previous category (used in pagination) global $objSession, $objCatList; global $var_list; //echo "SID_INIT: ".$var_list["sid"].'(COOKIE_SID: '.$_COOKIE["sid"].')
'; $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]
"; //echo "Prev CAT: [$prev_cat]
"; } /* @description: List all subcategories a user is allowed to view @attrib: _columns:int: Numver of columns to display the categories in (defaults to 1) @attrib: _maxlistcount:int: Maximum number of categories to list @attrib: _FirstItemTemplate:tpl: Template used for the first category listed @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: */ function m_list_cats($attribs = array()) { global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set, $objSystemCache; $CachedList = GetTagCache("kernel","m_list_cats",$attribs,m_BuildEnv()); if(strlen($CachedList)) { return $CachedList; } $cols = $attribs["_columns"]; if($cols<1) $cols =1; $CategoryId = $attribs["_catid"]; if(!is_numeric($CategoryId)) $CategoryId = $objCatList->CurrentCategoryID(); $cat_count = (int)$attribs["_maxlistcount"]; /* validation */ if(strlen($attribs["_itemtemplate"])==0) { if($attribs["dataexists"]) $content_set = 0; return ""; } $GroupList = $objSession->Get("GroupList"); if(strlen($GroupList)) { $Groups = explode(",",$GroupList); } $acl_where = ""; if(@count($Groups)>0 && is_array($Groups)) { $acl_where = array(); for($i=0;$iClear(); $OrderBy = $objCatList->QueryOrderByClause(TRUE,TRUE,TRUE); $objCatList->LoadCategories("ParentId=$CategoryId AND Status=1",$OrderBy); if ($objCatList->NumItems() == 0) { if($attribs["_dataexists"]) $content_set = 0; return ""; } $html_attr = ExtraAttributes($attribs); $o=""; $notable = $attribs["_notable"]; $count=0; $row=0; $var_list_update["t"] = $var_list["t"]; if(!$notable) { $per_row = ceil($objCatList->NumItems()/$cols); $o = ""; $o .= ""; $o .= "\n
"; $CatCount = $objCatList->NumItems(); foreach($objCatList->Items as $cat) { $parsed=0; if($count==$per_row) { $o .= ""; $count=0; } if($row==0 && strlen($attribs["_firstitemtemplate"])) { $o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]); $parsed=1; } if($row==$CatCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } if(!$parsed) $o.= $cat->ParseTemplate($attribs["_itemtemplate"]); $count++; $row++; } if($count != $per_row) $o .= "
\n"; } else { $CatCount = $objCatList->NumItems(); foreach($objCatList->Items as $cat) { if($cat->Get("ParentId")==$CategoryId) { if($row==0 && strlen($attribs["_firstitemtemplate"])) { //echo 'Saving ID in m_sub_cats[ first ] '.$cat->UniqueId().'
'; //$GLOBALS['cat_ID'] = $cat->UniqueId(); $o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]); $parsed=1; } if($row==$CatCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { //echo 'Saving ID in m_sub_cats[ last ] '.$cat->UniqueId().'
'; //$GLOBALS['cat_ID'] = $cat->UniqueId(); $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } if(!$parsed) { //echo 'Saving ID in m_sub_cats[ each ] '.$cat->UniqueId().'
'; //$GLOBALS['cat_ID'] = $cat->UniqueId(); $o .= $cat->ParseTemplate($attribs["_itemtemplate"]); } $row++; $i++; $count++; if($count>=$cat_count && $cat_count>0) break; } } } unset($var_list_update["t"]); SaveTagCache("kernel","m_list_cats",$attribs,m_BuildEnv(),$o); return $o; } function LoadCatSearchResults($attribs) { global $objSession, $objPermissions, $objCatList, $objSearchCats, $objConfig, $CountVal, $m_var_list; $GroupList = $objSession->Get("GroupList"); if(strlen($GroupList)) $Groups = explode(",",$GroupList); $acl_where = ""; if(@count($Groups)>0 && is_array($Groups)) { $acl_where = array(); for($i=0;$iGetPermId("CATEGORY.VIEW"); $ctable = $objCatList->SourceTable; $stable = $objSession->GetSearchTable(); // $objSearchCats->SourceTable; $ptable = GetTablePrefix()."PermCache"; $sql = "SELECT * FROM $stable INNER JOIN $ctable ON ($stable.ItemId=$ctable.CategoryId) "; $sql .= "INNER JOIN $ptable ON ($ctable.CategoryId=$ptable.CategoryId) "; $sql .="WHERE ItemType=1 AND Status=1 AND $acl_where AND PermId=$CAT_VIEW ORDER BY EdPick DESC,Relevance DESC "; $objSearchCats->Page = $m_var_list["p"]; if($objSearchCats->Page<1) $objSearchCats->Page=1; if(is_numeric($objConfig->Get($objSearchCats->PerPageVar))) { $Start = ($objSearchCats->Page-1)*$objConfig->Get($objSearchCats->PerPageVar); $limit = "LIMIT ".$Start.",".$objConfig->Get($objSearchCats->PerPageVar); } else $limit = NULL; if(strlen($limit)) $sql .= $limit; // echo "TEST:
$sql
\n"; $objSearchCats->Query_Item($sql); $where = "ItemType=1"; if(is_numeric($CountVal[1])) { $objSearchCats->QueryItemCount = $CountVal[1]; } else { $objSearchCats->QueryItemCount = QueryCount($sql); $CountVal[1]= $objSearchCats->QueryItemCount; } } /* @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. Any extra HTML attributes are passed to the anchor tag @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. */ function m_search_cat_more($attribs = array()) { global $objSearchCats, $objConfig, $m_var_list_update; $html_attribs = ExtraAttributes($attribs); $DestTemplate = $attribs["_template"]; if($attribs["_shortlist"]) $objSearchList->PerPageVar = "Perpage_Category_Short"; if($objSearchCats->NumItems()==0) { LoadCatSearchResults($attribs); } $max = $objConfig->Get($objSearchList->PerPageVar); $val = $objSearchCats->QueryItemCount; if($val > $max) { if($attribs["_root"]) $attribs["_category"]=0; $m_var_list_update["p"]=1; $url = m_template_link($attribs); unset($m_var_list_update["p"]); $o = ""; $text = $attribs["_text"]; if(!strlen($text)) { $text = $attribs["_plaintext"]; if(!strlen($text)) { } $o .= $text.""; } else $o .= language($text); if(strlen($attribs["_image"])) { $o .= ""; } $o .= ""; } return $o; } /* @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 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; $DestTemplate = $attribs["_template"]; $PagesToList = $attribs["_pagestolist"]; if(!is_numeric($PagesToList)) $PagesToList = 10; $CatId = $attribs["_catid"]; if(!is_numeric($CatId)) $CatId = $objCatList->CurrentCategoryID(); $objSearchCats->PerPageVar = "Perpage_Category"; if($attribs["_shortlist"]) $objSearchCats->PerPageVar = "Perpage_Category_Short"; if($objSearchCats->NumItems()==0) { LoadCatSearchResults($attribs); } $o = $objSearchCats->GetPageLinkList($DestTemplate); if(strlen($o) && strlen($attribs["_label"])) $o = language($attribs["_label"]).$o; return $o; } /* @description: List all categories matched in a search @attrib: _columns:int: Numver of columns to display the categories in (defaults to 1) @attrib: _maxlistcount:int: Maximum number of categories to list @attrib: _ShortList:bool: If set, the Perpage_Category_Short setting is used instead of Perpage_Category @attrib: _FirstItemTemplate:tpl: Template used for the first category listed @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: */ function m_search_list_cats($attribs = array()) { global $var_list, $objConfig, $objSession, $objCatList, $var_list_update, $content_set, $objSearchCats, $objPermissions, $m_var_list; if(!is_object($objSearchCats)) { $objSearchCats = new clsCatList(); $objSearchCats->SourceTable = $objSession->GetSessionTable('Search'); //"ses_".$objSession->GetSessionKey()."_Search" $objSearchCats->Clear(); } $objSearchCats->PerPageVar = "Perpage_Category"; if($attribs["_shortlist"]) { $objSearchCats->Page=1; $m_var_list["p"] = 1; $objSearchCats->PerPageVar = "Perpage_Category_Short"; } $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; return language("lu_no_categories"); } } $html_attr = ExtraAttributes($attribs); $cols = $attribs["_columns"]; if($cols<1) $cols =1; $cat_count = (int)$attribs["_maxlistcount"]; /* validation */ if(strlen($attribs["_itemtemplate"])==0) { $content_set = 0; return "ERROR -1"; } $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 .= ""; $o .= "\n
"; foreach($objSearchCats->Items as $cat) { $parsed=0; if($count==$per_row) { $o .= ""; $count=0; } if($row==0 && strlen($attribs["_firstitemtemplate"])) { $o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]); $parsed=1; } if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } if(!$parsed) $o.= $cat->ParseTemplate($attribs["_itemtemplate"]); $count++; } if($count != $per_row) $o .= "
\n"; } else { //echo "
"; print_r($objSearchCats->Items); echo "
"; foreach($objSearchCats->Items as $cat) { //$cat->Keywords = GetKeywords($objSession->GetVariable("Search_Keywords")); $keywords_found = strstr( strip_tags(strtolower($cat->Data['Name'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($keywords)); if(!$keywords) $keywords_found = true; if ($keywords_found) { if($row==0 && strlen($attribs["_firstitemtemplate"])) { $o.= $cat->ParseTemplate($attribs["_firstitemtemplate"]); $parsed=1; } if($row==$objSearchCats->NumItems()-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { $o .= $cat->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } if(!$parsed) $o.= $cat->ParseTemplate($attribs["_itemtemplate"]); $row++; $i++; $count++; if($count == $max_categories) break; } } } unset($var_list_update["t"]); return $o; } /* @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")) { $o = $objTemplate->ParseTemplate($ItemTemplate); } else $o = $objTemplate->ParseTemplate($TypeSelectTemplate); return $o; } /* @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]) */ function m_advsearch_type($attribs) { global $objItemTypes; if($_GET["Action"]=="m_advsearch_type") { $ItemType = $_POST["itemtype"]; } elseif($_GET["Action"]=="m_adv_search") $ItemType = $_GET["type"]; $o = ""; if((int)$ItemType>0) { $Item = $objItemTypes->GetItem($ItemType); if(is_object($Item)) { $name = strtolower($Item->Get("ItemName")); if($attribs["_plaintext"]) { $o .= $name; } else $o = language("lu_searchtitle_".strtolower($name)); } } return $o; } /* @description: Lists advanced search fields for the selected item type @attrib: _FirstItemTemplate:tpl: Template used for the first field listed @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 */ 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"]; } elseif($_GET["Action"]=="m_adv_search") $ItemType = $_GET["type"]; $o = ""; if((int)$ItemType>0) { $Item = $objItemTypes->GetItem($ItemType); if(is_object($Item)) { $name = strtolower($Item->Get("ItemName")); $table = $Item->Get("SourceTable"); $sql = "SELECT * FROM ".$objSearchConfig->SourceTable." WHERE TableName='$table' AND AdvancedSearch=1 ORDER BY DisplayOrder"; $objSearchConfig->Query_Item($sql); $row=0; if(is_array($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; } if($row==$ItemCount-1 && $even && !$parsed && strlen($attribs["_altlastitemtemplate"])>0) { $o .= $s->ParseTemplate($attribs["_altlastitemtemplate"]); $parsed=1; } if($row==$ItemCount-1 && !$parsed && strlen($attribs["_lastitemtemplate"])>0) { $o .= $s->ParseTemplate($attribs["_lastitemtemplate"]); $parsed=1; } if(!$parsed) { if($even && strlen($attribs["_altitemtemplate"])>0) { $o .= $s->ParseTemplate($attribs["_altitemtemplate"]); } else $o .= $s->ParseTemplate($attribs["_itemtemplate"]); } $row++; } } } } return $o; } /* @description: create a link to a template based on attributes passed into the tag. All extra HTML attributes are passed to the anchor tag created. @attrib: _Template:tpl: Template to link to. Just the template name is listed here. (ex: use "index" instead if "inlink/index") @attrib: _Module:: Module being linked to (ie In-Bulletin or In-News or In-Link) @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 attribute. If this attirbute is not included and the user does not have access, 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. */ function m_module_link($attribs = array()) { global $objCatList, $objSession; $permission = $attribs["_perm"]; $o = ""; $tpath = GetModuleArray("template"); if(strlen($permission)) { $perms = explode(",",$permission); $hasperm = FALSE; for($x=0;$xHasCatPermission($perms[$x])) { $hasperm = TRUE; break; } } } else $hasperm = TRUE; if(!$hasperm && strlen($attribs["_deniedtemplate"])>0) { $hasperm = TRUE; $attribs["_template"]=$attribs["_deniedtemplate"]; } if($hasperm) { $module = $attribs["_module"]; if(ModuleEnabled($module)) { $t = $tpath[$attribs["_module"]]; $t .= $attribs["_template"]; $attribs["_template"] = $t; $html_attr = ExtraAttributes($attribs); if($attribs["_root"]) { $func = ModuleTagPrefix($module)."_root_link"; if(function_exists($func)) { $url = $func($attribs); } else $url = m_template_link($attribs); } else $url = m_template_link($attribs); $o = " "; $text = $attribs["_text"]; if(!strlen($text)) { $text = $attribs["_plaintext"]; if(!strlen($text)) { if(strlen($attribs["_image"])) { $text = ""; } } $o .= $text.""; } else $o .= language($text).""; } else { $o = ""; } } return $o; } /* @description: create a link to a template based on attributes passed into the tag. All extra HTML attributes are passed to the anchor tag created. @attrib: _Template:tpl: Template to link to. Just the template name is listed here. (ex: use "index" instead if "inlink/index") @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 attribute. If this attirbute is not included and the user does not have access, 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. */ 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; } } } else $hasperm = TRUE; if(!$hasperm && strlen($attribs["_deniedtemplate"])>0) { $hasperm = TRUE; $attribs["_template"]=$attribs["_deniedtemplate"]; } if($hasperm) { $url = m_template_link($attribs); $o = " "; $text = $attribs["_text"]; if(!strlen($text)) { $text = $attribs["_plaintext"]; if(!strlen($text)) { if(strlen($attribs["_image"])) { $text = ""; } } $o .= $text.""; } else $o .= language($text).""; } else { $o = ""; } return $o; } function m_confirm_password_link($attribs = array()) { global $var_list, $var_list_update, $m_var_list_update, $objSession, $objConfig; $template = "forgotpw_reset_result"; $user = $objSession->Get("tmp_user_id").";".$objSession->Get("tmp_email"); $query = "&user_key=".base64_encode($user)."&Action=m_resetpw"; $var_list["t"] = $template; if($attribs["_secure"]) { $ret = "https://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv().$query; } else { $ret = "http://".ThisDomain().$objConfig->Get("Site_Path")."index.php?env=".BuildEnv().$query; } return $ret; } /* @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 @attrib: _anchor:: If included, a local anchor (#) is added. (ex: _anchor="top" results in ) @attrib: _Root:bool:If set, gets module root category id @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; $template = $attribs["_template"]; $query = trim($attribs["_query"]); $query = !ereg("^&", $query)? "&$query" : $query; if(!strlen($template)) $template = $var_list["t"]; $cat = $attribs["_category"]; $var_list_update["t"] = $template; if(strlen($cat)) { if($cat=="NULL") { $m_var_list_update["cat"]=0; } else { $m_var_list_update["cat"] = $cat; } } $link_type = getArrayValue($attribs,'_relative') ? 0 : 2; $ret = GetIndexURL($link_type)."?env=".BuildEnv().$query; if(strlen($attribs["_anchor"])) $ret .= "#".$attribs["_anchor"]; unset($var_list_update["t"]); if(strlen($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 attribute. If this attirbute is not included and the user does not have access, 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: "> */ function m_access_template_link($attribs = array(), $Permission="") { global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession; $cat = $attribs["_category"]; if(strlen($cat)) { if($cat=="NULL") $cat = 0; } else $cat = $objCatList->CurrentCategoryID(); if(!strlen($Permission)) { $Permission = strtoupper($attribs["_perm"]); } $o = ""; $hasperm = FALSE; if(strlen($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; } } } } $access = $attribs["_template"]; $denied = $attribs["_deniedtemplate"]; if(!strlen($denied)) $denied = "login"; $m_var_list_update["cat"] = $cat; if($hasperm) { $template = $access; if(!strlen($template)) $template = $var_list["t"]; $var_list_update["t"] = $template; } else { $template = $denied; if(!strlen($template)) $template = $var_list["t"]; if($template == "login") { $dest = $access; } $var_list_update["t"] = $template; } $ret = GetIndexURL(2)."?env=".BuildEnv(); unset($var_list_update["t"]); if(strlen($dest)) $ret .= "&dest=$dest"; 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: _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: _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. @example: Some HTML here! */ function m_perm_text($attribs = array()) { global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession; $cat = $attribs["_category"]; if(strlen($cat)) { if($cat=="NULL") $cat = 0; } else $cat = $objCatList->CurrentCategoryID(); if(!strlen($Permission)) { $Permission = strtoupper($attribs["_perm"]); } $o = ""; $hasperm = FALSE; $count = 0; if(strlen($Permission)) { $perms = explode(",",$Permission); for($x=0;$xHasCatPermission($perms[$x],$cat)) { $hasperm = TRUE; $_AllPermsCount[$count] = 1; // break; } $count++; } if(!$hasperm && $attribs["_system"]) { for($x=0; $xHasSystemPermission($perms[$x])) { $hasperm = TRUE; $_AllPermsCount[$count] = 1; // break; } $count++; } } } if ((int)$attribs["_matchallperms"]) { if (count($_AllPermsCount) != array_sum($_AllPermsCount)) $hasperm = FALSE; } $text = $attribs["_text"]; $plaintext = $attribs["_plaintext"]; $denytext = $attribs["_denytext"]; $plaindenytext = $attribs["_plaindenytext"]; $nopermissions_status = (int)$attribs["_noperm"]? 1 : 0; if(!strlen($denied)) $denied = "login"; if (!$nopermissions_status) { if ($hasperm) { if (strlen($text) || strlen($plaintext)) $ret = strlen($text)? language($text) : $plaintext; else $ret = "1"; } else $ret = strlen($denytext)? language($denytext) : $plaindenytext; } elseif (!$hasperm) { $ret = "1"; } return $ret; } /* @description: Returns the error string associated with a permission */ function m_permission_error($attribs = array()) { global $objPermissions; $ret = ""; $perm = strtoupper($_GET["error"]); if(strlen($perm)) { $ado = &GetADODBConnection(); $sql = "SELECT * FROM ".GetTablePrefix()."PermissionConfig WHERE PermissionName ='$perm'"; $rs = $ado->Execute($sql); if($rs && !$rs->EOF) { $data = $rs->fields; $error_tag = $data["ErrorMessage"]; } else $error_tag = "lu_unknown_error"; $ret = language($error_tag); } return $ret; } /* @description: Returns the error text encountered when parsing templates */ function m_template_error($attribs = array()) { global $objTemplate; $ret = ""; if($objTemplate->ErrorNo<0) { $ret = $objTemplate->ErrorStr; } return $ret; } /* @description: Creates a category navigation bar @attrib: _Template:tpl: template to use for navigation links @attrib: _RootTemplate:bool: If set, this template is linked to for the root category @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: */ 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"; $ModuleRootTemplate = getArrayValue($attribs, $modkey); } else $ModuleRootTemplate=""; } else $ModuleRootCat = 0; if(!$catid) $catid = $objCatList->CurrentCategoryID(); $ret = $objCatList->cat_navbar($admin, $catid, $t, $separator,$LinkLeafNode,$Root,$RootTemplate,$ModuleRootCat,$ModuleRootTemplate); return $ret; } /* @description: Parse a category field and return the value @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 = ""; $catid = (int)$attribs["_catid"]; $field = $attribs["_field"]; if(!$catid) $catid = $objCatList->CurrentCategoryID(); if(strlen($field)) { $cat =& $objCatList->GetCategory($catid); if(is_object($cat)) { $element = new clsHtmlTag(); $element->name=$cat->TagPrefix; $element->attributes = $attribs; $ret = $cat->ParseObject($element); } } if($attribs["_striphtml"]) $ret = strip_tags($ret); return $ret; } /* @description: returns the date of the last modification to a category @attrib: _Part:: part of the date to display @attrib: _Local:bool: If set, only subcategories of the current category is checked @example: */ function m_category_modified($attribs) { global $objConfig, $objCatList; $ado = &GetADODBConnection(); if($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"; } else $sql = "SELECT MAX(Modified) as ModDate FROM ".GetTablePrefix()."Category LIMIT 1"; $rs = $ado->Execute($sql); if($rs && ! $rs->EOF) { $mod = $rs->fields["ModDate"]; if($mod) { $part = strtolower($attribs["_part"]); if(strlen($part)) { $ret = ExtractDatePart($part,$mod); } else { $ret = LangDate($mod); } } } return $ret; } /* @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: */ function m_module_stylesheets($attribs) { global $TemplateRoot; $IncludeList = explode(",",trim($attribs["_modules"])); $tpath = GetModuleArray("template"); for($inc=0;$inc\n"; } return $ret; } /* @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. Each item should have its own template passed in as an attribute (_{ItemType}Template) */ function m_related_items($attribs) { global $objItemTypes, $objCatList, $content_set; static $Related; global $CatRelations; $cat = $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")); } else $hasperm = 1; if($hasperm) { $data_sent =1; $classname = $objType->Get("ClassName"); if(strlen($classname)) { $l = new $classname; $l->Data = $item->Data; $o .= $l->ParseTemplate($t); } } } } $item = NULL; } } else echo $item_type." not found
\n"; } } if($data_sent) { return $o; } else { $content_set=0; return ""; } } else { $content_set = 0; return ""; } } else { $content_set = 0; return ""; } } /* @description: Returns the number of items related to the current category @attrib:_CatId:int: If set, this is the category ID to use, otherwise the current category is used @attrib:_ItemType::Name of item to count. If not set, all related items are counted */ function m_related_count($attribs) { global $objItemTypes, $objCatList, $content_set; $cat = $attribs["_catid"]; if(!is_numeric($cat)) { $cat = $objCatList->CurrentCategoryID(); } $c =& $objCatList->GetCategory($cat); $data_sent=0; //echo "Category: $cat
";  print_r($c); echo " 
"; if(is_object($c)) { $ResourceId = $c->Get("ResourceId"); if(!is_object($CatRelations)) { $CatRelations = new clsMultiTypeList(); LoadRelatedItems($Related, $CatRelations, $c->Get("ResourceId")); } $item_type = $attribs["_itemtype"]; if(strlen($item_type)) { $objType = $objItemTypes->GetTypeByName($item_type); if(is_object($objType)) { $TargetType = $objType->Get("ItemType"); } else $TargetType=""; } if($CatRelations->NumItems()>0) { for($x=0;$x<$CatRelations->NumItems();$x++) { $a = $CatRelations->GetItemByIndex($x); if($a->type == $TargetType || !strlen($TargetType)) { $count++; } } } } return $count; } /* @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) */ function m_meta_keywords($attribs = array()) { global $objCatList, $objConfig; $catid = (int)$attribs["_catid"]; if(!$catid) { $catid = $objCatList->CurrentCategoryID(); } if($catid) { $c = $objCatList->GetItem($catid); $keywords = $c->Get("MetaKeywords"); } if(!strlen($keywords)) { $keywords = $objConfig->Get("MetaKeywords"); } 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) */ function m_meta_description($attribs = array()) { global $objCatList, $objConfig; $catid = (int)$attribs["_catid"]; if(!$catid) { $catid = $objCatList->CurrentCategoryID(); } if($catid) { $c = $objCatList->GetItem($catid); $desc = $c->Get("MetaDescription"); } if(!strlen($desc)) { $desc = $objConfig->Get("MetaDescription"); } return $desc; } /* @description: return the number of items in the database @attrib: _ItemType:: Name of item to count @attrib: _ListType:: Type of item to count (ie: favorites, editor's pick, etc) @attrib: _CategoryCount:int: Limit scope to the current category @attrib: _SubCats:bool: Count items in all subcategories (_CategoryCount must be set) @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; $Bit_None = 0; $Bit_Today = 1; $Bit_Owner = 2; $Bit_Global = 4; $Bit_SubCats=8; if($attribs["_categorycount"]) { $evar = m_BuildEnv(); } else $evar = ""; $cat = $attribs["_catid"]; if(!is_numeric($cat)) { $cat = $objCatList->CurrentCategoryID(); } if((int)$cat>0) $c = $objCatList->GetCategory($cat); if(is_numeric($attribs["_itemtype"])) { $item = $objItemTypes->GetItem($attribs["_itemtype"]); } 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)) { $ret = $ListVar->PerformItemCount($attribs); } } } else $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; $o = ""; $userid = $attribs["_userid"]; if(!is_numeric($userid) || $userid=="0") $userid = $objSession->Get("PortalUserId"); if($userid) { $u =& $objUsers->GetItem($userid); if(is_object($u)) { $element = new clsHtmlTag(); $element->name = $u->TagPrefix; $element->attributes = $attribs; $o = $u->ParseObject($element); } } return $o; } /* @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 */ function m_user_detail($attribs = array()) { global $objTemplate, $objUsers, $objSession; $tname = $attribs["_template"]; $UserId = (int)$attribs["_userid"]; if(!$UserId) { $UserId=$objSession->Get("PortalUserId"); } if($UserId>0) { $u = $objUsers->GetUser($UserId); $o = $u->ParseTemplate($tname); } else { $u = new clsPortalUser(NULL); $o = $u->ParseTemplate($tname); } return $o; } /* @description: returns a user field from the current profile being viewed @example: */ function m_user_profile_field($attribs = array()) { if((int)$_GET["UserId"]) { $attribs["_userid"] = $_GET["UserId"]; } $ret = m_user_field($attribs); /* if ($ret == '') { $ret = admin_language("lu_Guest"); }*/ return $ret; } /* @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 */ function m_user_profile_detail($attribs) { if((int)$_GET["UserId"]) { $attribs["_userid"] = $_GET["UserId"]; } $ret = m_user_detail($attribs); return $ret; } /* @description: Lists all user profile fields the user has indicated to be public @attrib: _ItemTemplate:tpl: Template used to list each field @example: */ function m_user_profile($attribs = array()) { global $objTemplate, $objUsers; $tname = $attribs["_itemtemplate"]; $t = $objTemplate->GetTemplate($tname); if(is_object($t)) { $html = $t->source; } $userid = $_GET["UserId"]; $o = ""; if((int)$userid>0) { $u = $objUsers->GetItem($userid); $vars = $u->GetAllPersistantVars(); foreach($vars as $field=>$value) { if(substr($field,0,3)=="pp_") { if($value==1) { $src = $html; $src = str_replace("","",$src); $src = str_replace("lu_profile_field","lu_".$field,$src); $o .= $u->ParseTemplateText($src); } } } } return $o; } /* @description: List users the current user has marked as 'friend' @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; global $online_friends; $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") { $ftable = GetTablePrefix()."Favorites"; $stable = GetTablePrefix()."UserSession"; $ptable = GetTablePrefix()."PortalUser"; if(isset($online_friends)) { foreach($online_friends as $id=>$name) { $u =& $objUsers->GetUser($id); $o .= $u->ParseTemplate($attribs["_itemtemplate"]); } } 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']; //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"]; if(ADODB_EXTENSION>0) { adodb_movenext($rs); } else $rs->MoveNext(); } } } 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']; } 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']; } //echo $sql; $rs = $ado->Execute($sql); while($rs && ! $rs->EOF) { $u = $objUsers->GetItem($rs->fields["PortalUserId"]); $o .= $u->ParseTemplate($attribs["_itemtemplate"]); if(ADODB_EXTENSION>0) { adodb_movenext($rs); } else $rs->MoveNext(); } } $t = $attribs["_itemtemplate"]; return $o; } /* @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". */ function m_friend_count($attribs=array()) { global $objUsers, $objSession; global $online_friends; $ado = &GetADODBConnection(); $logedin_user = $objSession->Get("PortalUserId"); $u =& $objUsers->GetUser($logedin_user); $status = strtolower($attribs["_status"]); if(!isset($online_friends) || $status=="online") { $ftable = GetTablePrefix()."Favorites"; $stable = GetTablePrefix()."UserSession"; $ptable = GetTablePrefix()."PortalUser"; if(isset($online_friends) && $status="online") { 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']; //echo $sql."
\n"; $rs = $ado->Execute($sql); while($rs && ! $rs->EOF) { $online_friends[$rs->fields["PortalUserId"]]=$rs->fields["PortalUserId"]; if(ADODB_EXTENSION>0) { adodb_movenext($rs); } else $rs->MoveNext(); } if($status=="online") 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']; } 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']; } $rs = $ado->Execute($sql); return $rs->fields["ItemCount"]; } } /* @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 = mktime(0,0,0,date("m"),date("d"),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) $ret = $rs->fields["c"]; return $ret; } /* @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"]); if(is_object($item)) { $val = $CountVal[$item->Get("ItemType")]; if(is_numeric($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; if(!is_object($objSearchCats)) { $objSearchCats = new clsCatList(); $objSearchCats->SourceTable = $objSession->GetSearchTable(); $objSearchCats->Clear(); } LoadCatSearchResults($attribs); //echo "
"; print_r($objSearchCats->Items); echo "
"; $ret = 0; $keywords = $objSession->GetVariable("Search_Keywords"); /*if ($keywords) { foreach ($objSearchCats->Items as $cat) { if (strstr(strip_tags(strtolower($cat->Data['Name'])), strtolower($keywords)) || strstr(strip_tags(strtolower($cat->Data['Description'])), strtolower($keywords))) { $ret++; } } }*/ //else { $ret = $objSearchCats->QueryItemCount; //} if ($ret == '') { $ret = 0; } //echo $ret; //$objSearchCats->QueryItemCount = $ret; return $ret; } /* @description: Returns super global variable by type and name @attrib: _Name:: Name of variable @attrib: _Type:: Type super global variable
Possible Values:
  • get: $_GET super variable
  • post: $_POST super variable
  • cookie: $_COOKIE super variable
  • env: $_ENV super variable
  • server: $_SERVER super variable
  • session: $_SESSION super variable
@Example: */ function m_get_var($attribs = array()) { global $_GET, $_POST, $_COOKIE, $_FILES, $_ENV, $_SERVER, $_SESSION; $type = strtolower($attribs['_type']); $name = $attribs['_name']; switch ($type) { case "get": $vars = $_GET; break; case "cookie": $vars = $_COOKIE; break; case "files": $vars = $_FILES; break; case "server": $vars = $_SERVER; break; case "session": $vars = $_SESSION; break; case "env": $vars = $_ENV; break; case "post": $vars = $_POST; break; default : $vars = $_POST; break; } $ret = $vars[$name]; return $ret; } /* @description: Returns number of users currently on-line @attrib: _LastActive:: Last user/session activity in seconds @attrib: _OwnCount:bool: Count user's own session */ function m_users_online($attribs = array()) { global $objSession; $LastActive = (int)($attribs['_lastactive']); $OwnCount = (int)($attribs['_owncount']); if ($LastActive && !is_null($LastActive)) $sql_add = " AND LastAccessed>".(time()-$LastActive); if (!$OwnCount || is_null($OwnCount)) $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; } function m_debug_mode($attribs = array()) { $const_name = $attribs['_debugconst']; return defined($const_name) && (constant($const_name) == 1) ? 'yes' : ''; } function m_info($attribs = array()) { switch ($attribs['_infotype']) { case 'site': global $objConfig; $ret = ThisDomain().$objConfig->Get('Site_Path'); break; default: $ret = ''; break; } return $ret; } function m_module_enabled($attribs = array()) { 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']); } function m_regional_option($attribs = array()) { return GetRegionalOption($attribs['_name']); } ?>