@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 "<inp:form_prompt />" 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
@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<br>Possible Values:
<UL>
<LI>login: user login
<LI>logout: user logout
<LI>forgotpw: Form to prompt the user for forgotten password information
<LI>forgotpw_confirm: confirmation form for forgotpw
<LI>suggest: form to suggest the site to a friend
<LI>suggest_confirm: form to confirm suggestion of the site to a friend
<LI>m_subscribe: form to subscribe to the mailing list
<LI>subscribe_confirm: form to confirm subscription to the mailing list
<LI>m_unsubscribe: form to unsubscribe from the mailing list
<LI>unsubscribe_confirm: form to confirm un-subscription from the mailing list
<LI>m_acctinfo: user account information
<LI>m_profile: system-level profile information
<LI>m_register: New User registration form
<LI>m_addcat: Suggest Category form
<LI>m_addcat_confirm: Confirmation for add category
<LI>m_simplesearch: Perform a simple search
<LI>m_simple_subsearch: Search within results
<LI>m_adv_searchtype: Form to select type of advanced search
<LI>m_adv_subsearch: Advanced Search
<LI>error_access: form displayed on the access denied template
<LI>error_template: Form displayed on the template error page
<LI>m_set_theme: Form displayed for theme selection
</UL>
@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.
@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: <inp:m_perm_text _Text="!lu_allow_language_tag!" _PlainText="Just a text" _DenyText="!lu_deny_language_tag!" _PlainDenyText="Just a plain text" _Perm="login" _MatchAllPerms="1" _NoPerm="0">Some HTML here!</inp>
*/
function m_perm_text($attribs = array())
{
global $var_list, $var_list_update, $m_var_list_update, $objCatList, $objSession;
@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)
$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'];
$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
$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
$sql = "SELECT * FROM ".GetTablePrefix()."UserGroup INNER JOIN ".GetTablePrefix()."PortalGroup ON (".GetTablePrefix()."UserGroup.GroupId=".GetTablePrefix()."PortalGroup.GroupId) WHERE PrimaryGroup = 1 AND PortalUserId=".$this->Get("PortalUserId");
//echo $sql;
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
$this->PrimeGroup->SetFromArray($rs->fields);
}
}
$ret = $this->PrimeGroup->Get($ReturnField);
return $ret;
}
function SetPrimaryGroup($GroupId)
{
if($this->IsInGroup($GroupId))
{
$sql = "UPDATE ".GetTablePrefix()."UserGroup SET PrimaryGroup=0 WHERE PortalUserId=".$this->Get("PortalUserId");
$this->adodbConnection->Execute($sql);
$sql = "UPDATE ".GetTablePrefix()."UserGroup SET PrimaryGroup=1 WHERE GroupId=$GroupId AND PortalUserId=".$this->Get("PortalUserId");
$this->adodbConnection->Execute($sql);
}
}
function GetGroupList()
{
$ret = array();
$sql = "SELECT GroupId FROM %sUserGroup WHERE PortalUserId = %s ORDER BY PrimaryGroup";
$sql = "SELECT VariableName, VariableValue FROM ".GetTablePrefix()."PersistantSessionData WHERE PortalUserId = 0 OR PortalUserId = ".$user_id." ORDER BY PortalUserId ASC";
function SetPersistantVariable($variableName, $variableValue)
{
global $objConfig;
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
$userid = $this->Get("PortalUserId");
$objConfig->Set($variableName,$variableValue,1);
$fields = array_keys($this->Vars);
if(strlen($variableValue)>0)
{
if(in_array($variableName,$fields))
{
$sql = "UPDATE ".GetTablePrefix()."PersistantSessionData SET VariableValue='$variableValue' WHERE VariableName='$variableName' AND PortalUserId=$userid";
}
else
$sql = "INSERT INTO ".GetTablePrefix()."PersistantSessionData (VariableName,VariableValue,PortalUserId) VALUES ('$variableName','$variableValue',$userid)";
}
else
$sql = "DELETE FROM ".GetTablePrefix()."PersistantSessionData WHERE VariableName='$variableName' AND PortalUserId=$userid";
$this->Vars[$variableName] = $variableValue;
// echo "<BR>SQL: $sql<BR>";
$this->adodbConnection->Execute($sql);
}
function GetPersistantVariable($variableName)
{
global $objConfig;
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
$fields = array_keys($this->Vars);
if(in_array($variableName,$fields))
{
$val = $this->Vars[$variableName];
}
else
$val = $objConfig->Get($variableName);
return $val;
}
function GetAllPersistantVars()
{
if(!$this->VarsLoaded)
$this->LoadPersistantVars();
return $this->Vars;
}
function GetIcon()
{
}
function StatusIcon()
{
global $imagesURL;
$url = $imagesURL."/itemicons/icon16_user";
if($this->Get("Status")==0)
{
$url .= "_disabled";
}
else
if($this->Get("Status")==2)
{
$url .= "_pending";
}
$url .= ".gif";
return $url;
}
function IsFriend($UserId)
{
$ftable = GetTablePrefix()."Favorites";
$sql = "SELECT count(*) as FriendCount FROM $ftable WHERE PortalUserId=$UserId AND ResourceId=";
$sql .=$this->Get("ResourceId")." AND ItemTypeId=6";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
return ($rs->fields["FriendCount"]>0);
return FALSE;
}
function GetUserTime($timestamp)
{
if(is_numeric($this->Get("tz")))
{
return GetLocalTime($timestamp,$this->Get("tz"));
}
else
return GetLocalTime($timestamp);
}
function ParseObject($element)
{
global $objConfig, $objUsers, $objCatList,$objSession, $var_list_update, $var_list, $m_var_list_update;
$this->m_IsDirty = ($this->m_IsDirty or $changed or $force);
if($changed || $force)
{
$this->m_DirtyFields[$property] = $value;
}
$this->m_VarType[$property] = $type;
}
function Save()
{
if($this->m_IsDirty==TRUE)
{
foreach($this->m_DirtyFields as $field=>$value)
{
if($this->m_VarType[$field]==0)
{
$sql = sprintf("UPDATE ".GetTablePrefix()."ConfigurationValues SET VariableValue=%s WHERE VariableName=%s", $this->adodbConnection->qstr($value), $this->adodbConnection->qstr($field));
// echo $sql."<br>\n";
$rs = $this->adodbConnection->execute($sql);
}
}
}
$this->m_IsDirty=FALSE;
unset($this->m_DirtyFields);
}
function TimeFormat()
{
if($this->Get("ampm_time")=="1")
{
$format = "g:i:s A";
}
else
$format = "H:i:s";
return $format;
}
/* vartype should be either 1 or 2, 1 = perstant data, 2 = session data */
function GetDirtySessionValues($VarType)
{
$result = array();
if(is_array($this->m_DirtyFields))
{
foreach($this->m_DirtyFields as $property=>$values)
{
if($this->m_VarType[$property]==$VarType)
$result[$property] = $values;
}
}
return $result;
}
function GetConfigValues($postfix = '')
{
// return only varibles, that match specified criteria
if(!$postfix) return $this->config;
$result = Array();
$postfix_len = $postfix ? strlen($postfix) : 0;
foreach($this->config as $config_var => $var_value)
$sql = "SELECT * FROM ".GetTablePrefix()."UserSession WHERE (CurrentTempKey = '$id' OR PrevTempKey='$id' OR CurrentTempKey='$LastKey' OR PrevTempKey='$LastKey') ";
}
else
$sql = "SELECT * FROM ".GetTablePrefix()."UserSession WHERE CurrentTempKey = '$id' AND PrevTempKey IS NULL";
}
else
$sql = "SELECT * FROM ".GetTablePrefix()."UserSession WHERE CurrentTempKey = '$id' AND PrevTempKey IS NULL";
$sql = "SELECT *,MD5(".$pre."PortalUser.Password) as md5pw FROM ".$pre."PortalUser LEFT JOIN ".$pre."UserGroup USING (PortalUserId) "
."LEFT JOIN ".$pre."PortalGroup ON (".$pre."UserGroup.GroupId=".$pre."PortalGroup.GroupId)
WHERE
".$pre."PortalUser.Login='$userLogin' AND ".$pre."PortalUser.Status=1
AND (".$pre."PortalUser.Password='$userPassword' OR MD5(".$pre."PortalUser.Password)='$userPassword' OR ".$pre."PortalUser.Password='".md5($userPassword)."')
ORDER BY ".$pre."UserGroup.PrimaryGroup DESC, ".$pre."PortalGroup.Personal DESC";
function TableCount($TableName, $where="",$JoinCats=1)
{
$db = GetADODBConnection();
if(!$JoinCats)
{
$sql = "SELECT count(*) as TableCount FROM $TableName";
}
else
$sql = "SELECT count(*) as TableCount FROM $TableName INNER JOIN ".GetTablePrefix()."CategoryItems ON ".GetTablePrefix()."CategoryItems.ItemResourceId=$TableName.ResourceId";
if(strlen($where)>0)
$sql .= " WHERE ".$where;
$rs = $db->Execute($sql);
// echo "SQL TABLE COUNT: ".$sql."<br>\n";
$res = $rs->fields["TableCount"];
return $res;
}
Function QueryCount($sql)
{
$countsql = "SELECT count(*) as TableCount ".substr($sql,strpos($sql," FROM "));