Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1121560
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 30, 9:42 PM
Size
122 KB
Mime Type
text/x-diff
Expires
Mon, Sep 1, 9:42 PM (2 h, 14 m)
Engine
blob
Format
Raw Data
Handle
720706
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/units/categories/categories_config.php
===================================================================
--- trunk/kernel/units/categories/categories_config.php (revision 4650)
+++ trunk/kernel/units/categories/categories_config.php (revision 4651)
@@ -1,217 +1,220 @@
<?php
$config = Array(
'Prefix' => 'c',
'ItemClass' => Array('class'=>'CategoriesItem','file'=>'categories_item.php','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CategoriesEventHandler','file'=>'categories_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'CategoriesTagProcessor','file'=>'categories_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'AggregateTags' => Array(
Array(
'AggregateTo' => 'm',
'AggregatedTagName' => 'CategoryLink',
'LocalTagName' => 'CategoryLink',
),
),
'IDField' => 'CategoryId',
+
+ 'StatusField' => Array('Status'),
+
'TitleField' => 'Name', // field, used in bluebar when editing existing item
'ItemType' => 1, // used for custom fields only
'StatisticsInfo' => Array(
'pending' => Array(
'icon' => 'icon16_cat_pending.gif',
'label' => 'la_tab_Categories',
'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')",
'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'),
'status' => STATUS_PENDING,
),
),
'TableName' => TABLE_PREFIX.'Category',
'ViewMenuPhrase' => 'la_text_Categories',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('c' => '!la_title_Adding_Category!'),
'edit_status_labels' => Array('c' => '!la_title_Editing_Category!'),
'new_titlefield' => Array('c' => '!la_title_New_Category!'),
),
'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
'category_items'=> Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Items!"),
'tree_site' => Array('format' => '!la_selecting_categories!'),
),
'Sections' => Array(
// "Structure & Data" section
'in-portal:site' => Array(
'parent' => 'in-portal:root',
'icon' => 'struct',
'label' => 'la_tab_Site_Structure',
'url' => Array('t' => 'sections_list', 'index_file' => 'index4.php', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 1,
'type' => stTREE,
),
'in-portal:browse' => Array(
'parent' => 'in-portal:site',
'icon' => 'catalog',
'label' => 'la_tab_Browse',
'url' => Array('index_file' => 'browse.php', 'pass' => 'm'),
'late_load' => Array('t' => 'xml/tree_categories', 'pass' => 'm', 'm_cat_id' => 0),
'permissions' => Array('view'),
'priority' => 1,
'type' => stTREE,
),
'in-portal:advanced_view' => Array(
'parent' => 'in-portal:site',
'icon' => 'advanced_view',
'label' => 'la_tab_AdvancedView',
'url' => Array('index_file' => 'advanced_view.php', 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 2,
'type' => stTREE,
),
'in-portal:reviews' => Array(
'parent' => 'in-portal:site',
'icon' => 'reviews',
'label' => 'la_tab_Reviews',
'url' => Array('index_file' => 'reviews.php', 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 3,
'type' => stTREE,
),
'in-portal:configure_categories' => Array(
'parent' => 'in-portal:site',
'icon' => 'cat_settings',
'label' => 'la_tab_Settings',
'url' => Array('index_file' => 'config/edit_config.php', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 4,
'type' => stTREE,
),
'in-portal:configuration_search' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_search',
'label' => 'la_tab_ConfigSearch',
'url' => Array('t' => 'config/config_search', 'index_file' => 'index4.php', 'module_key' => 'category', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 5,
'type' => stTREE,
),
'in-portal:configuration_email' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_email',
'label' => 'la_tab_ConfigE-mail',
'url' => Array('index_file' => 'config/module_email.php', 'module' => 'In-Portal:Category', 'pass_section' => true, 'lpn' => 1, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 6,
'type' => stTREE,
),
'in-portal:configuration_custom' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_custom',
'label' => 'la_tab_ConfigCustom',
'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 1, 'pass' => 'm,cf'),
'permissions' => Array('view', 'add', 'edit', 'delete'),
'priority' => 7,
'type' => stTREE,
),
),
'ListSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
'ItemSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
'SubItems' => Array('c-cdata', 'c-perm'),
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array("CurrentSort" => 'asc', 'Priority' => 'desc', 'Name' => 'asc'),
'Sorting' => Array('Name' => 'asc'),
)
),
'CalculatedFields' => Array(
'' => Array(
'CurrentSort' => "REPLACE(ParentPath, CONCAT('|', ".'%1$s'.".CategoryId, '|'), '')",
)
),
'Fields' => Array
(
'CategoryId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Type' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ParentId' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Name' => Array('type' => 'string','not_null' => '1','default' => ''),
'Filename' => Array('type' => 'string','not_null' => '1','default' => ''),
'AutomaticFilename' => Array('type' => 'int','not_null' => '1','default' => '1'),
'Description' => Array('type' => 'string','not_null' => '1','default' => ''),
'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'not_null' => '1'),
'EditorsPick' => Array('type' => 'int','default' => ''),
'Status' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Pop' => Array('type' => 'int','default' => ''),
'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => ''),
'MetaKeywords' => Array('type' => 'string','default' => ''),
'CachedDescendantCatsQty' => Array('type' => 'int','default' => ''),
'CachedNavbar' => Array('type' => 'string','not_null' => '1','default' => ''),
'CreatedById' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ResourceId' => Array('type' => 'int','default' => ''),
'ParentPath' => Array('type' => 'string','not_null' => '1','default' => ''),
'NamedParentPath' => Array('type' => 'string','not_null' => '1','default' => ''),
'MetaDescription' => Array('type' => 'string','default' => ''),
'HotItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'NewItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'PopItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'Modified' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ModifiedById' => Array('type' => 'int','not_null' => '1','default' => '0'),
'CategoryTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'ItemTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'CachedCategoryTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'CachedItemTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
),
'VirtualFields' => Array(
'CurrentSort' => Array('type' => 'string', 'default' => ''),
'IsNew' => Array('type' => 'int', 'default' => 0),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_cat.gif'),
'Fields' => Array(
'Name' => Array( 'width'=>150, 'title'=>'la_col_Title', 'data_block'=>'category_td' ),
),
),
),
'ConfigMapping' => Array(
'PerPage' => 'Perpage_Category',
'DefaultSorting1Field' => 'Category_Sortfield',
'DefaultSorting2Field' => 'Category_Sortfield2',
'DefaultSorting1Dir' => 'Category_Sortorder',
'DefaultSorting2Dir' => 'Category_Sortorder2',
),
);
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/categories/categories_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.25
\ No newline at end of property
+1.26
\ No newline at end of property
Index: trunk/kernel/units/statistics/statistics_tag_processor.php
===================================================================
--- trunk/kernel/units/statistics/statistics_tag_processor.php (revision 4650)
+++ trunk/kernel/units/statistics/statistics_tag_processor.php (revision 4651)
@@ -1,244 +1,285 @@
<?php
class StatisticsTagProcessor extends kDBTagProcessor {
var $TagCache = Array(); // parsed tag (in sql queries only) values are cached
var $CurrentSQL = ''; // sql query being currently processed
var $PostFormatting = false; // apply formatting to sql query results
var $PostFormattingParams = Array(); // post formatting params if any
function CalculateValue($params)
{
$object =& $this->getObject($params);
$this->CurrentSQL = $object->GetDBField($params['field']);
// 1. replace prefix to actual one
$this->CurrentSQL = str_replace("<%prefix%>", TABLE_PREFIX, $this->CurrentSQL);
// 2. replace all pseudo-tags found in sql with their values
while ( ($tag = $this->FindTag()) != false ) {
$this->CurrentSQL = str_replace('<%'.$tag.'%>', $this->ProcessStatisticTag($tag), $this->CurrentSQL);
}
// 3. query sql and process gathered data
$values = $this->Conn->GetCol($this->CurrentSQL);
if (!$values) return '';
if (!$this->PostFormatting) return array_shift($values);
switch ($this->PostFormatting) {
case 'number':
// simple-specific postformatting
$lang =& $this->Application->recallObject('lang.current');
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']);
break;
case 'COUNT':
// extended postformatting
$value = count($values);
break;
case 'SUM':
$value = 0;
foreach ($values as $cur_value) {
$value += $cur_value;
}
if ($this->PostFormattingParams['format_as'] == 'file') {
$value = size($value);
}
break;
// other type of information (not from db)
case 'SysFileSize':
$value = size( dir_size(FULL_PATH.'/') );
break;
default: // simple-default postformatting
$value = adodb_date($this->PostFormatting, array_shift($values));
break;
}
$this->PostFormatting = false;
$this->PostFormattingParams = Array();
return $value;
}
function FindTag()
{
// finds tag in current sql & returns it if found, false otherwise
$tagOpen = '<%'; $tagClose = '%>'; $tagOpenLen = strlen($tagOpen);
$startPos = strpos($this->CurrentSQL, $tagOpen);
if( $startPos !== false )
{
$endPos = strpos($this->CurrentSQL, $tagClose, $startPos);
return ($endPos > $startPos) ? substr($this->CurrentSQL, $startPos + $tagOpenLen, $endPos - $startPos - $tagOpenLen) : false;
}
return false;
}
function ProcessStatisticTag($tag)
{
$tag = trim($tag);
if (isset($this->TagCache[$tag])) {
return $this->TagCache[$tag];
}
$object =& $this->getObject();
list($tag_name, $tag_params) = explode(' ', $tag, 2); // 1st - function, 2nd .. nth - params
preg_match_all('/([\${}a-zA-Z0-9_.-]+)=(["\']{1,1})(.*?)(?<!\\\)\\2/s', $tag_params, $rets, PREG_SET_ORDER);
$tag_params = Array();
foreach ($rets AS $key => $val){
$tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]);
}
switch ($tag_name) {
case 'm:config':
// m:config name="<variable_name>"
return $this->Application->ConfigValue($tag_params['name']);
break;
case 'm:post_format':
// m:post_format field="<field_name>" type="<formatting_type>" precision="2"
$lang =& $this->Application->recallObject('lang.current');
switch ($tag_params['type']) {
case 'date':
$this->PostFormatting = $lang->GetDBField('DateFormat');
break;
case 'time':
$this->PostFormatting = $lang->GetDBField('TimeFormat');
break;
case 'currency':
$this->PostFormatting = 'number';
$this->PostFormattingParams['precision'] = $tag_params['precision'];
break;
}
return $tag_params['field'];
break;
case 'm:custom_action':
// m:custom_action sql="empty" action="SysFileSize"
$this->PostFormatting = $tag_params['action'];
return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql'];
break;
case 'modules:get_current':
return $object->GetDBField('Module');
break;
case 'm:sql_action':
//m:sql_action sql="SHOW TABLES" action="COUNT" field="*"
$this->PostFormatting = $tag_params['action'];
$this->PostFormattingParams = $tag_params;
return $tag_params['sql'];
break;
case 'link:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_links_count = $this->Application->ConfigValue('Link_TopCount');
$sql = 'SELECT Hits
FROM '.TABLE_PREFIX.'Link
ORDER BY Hits DESC LIMIT 0, '.$top_links_count;
return $this->getLastRecord($sql, 'Hits');
}
break;
case 'article:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_articles_count = $this->Application->ConfigValue('News_VotesToHot');
$min_votes = $this->Application->ConfigValue('News_MinVotes');
$sql = 'SELECT CachedRating
FROM '.TABLE_PREFIX.'News
WHERE CachedVotesQty > '.$min_votes.'
ORDER BY CachedRating DESC LIMIT 0, '.$top_articles_count;
return $this->getLastRecord($sql, 'CachedRating');
}
break;
case 'topic:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_posts_count = $this->Application->ConfigValue('Topic_PostsToPop');
$sql = 'SELECT Views
FROM '.TABLE_PREFIX.'Topic
ORDER BY Views DESC LIMIT 0, '.$top_posts_count;
return $this->getLastRecord($sql, 'Views');
}
break;
}
}
function getLastRecord($sql, $field)
{
$records = $this->Conn->GetCol($sql);
return count($records) ? array_pop($records) : 0;
}
/**
* Allows to get pending item count for prefix
*
* @param Array $params
* @return int
*/
function CountPending($params)
{
$prefix = $params['prefix'];
-
- $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
- if (!$statistics_info) {
- return 0;
+ $value = $this->Application->getCache('statistics.pending', $prefix);
+ if ($value === false) {
+ $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ if (!$statistics_info) {
+ return 0;
+ }
+
+ $table = $this->Application->getUnitOption($prefix, 'TableName');
+ $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
+ $sql = 'SELECT COUNT(*)
+ FROM '.$table.'
+ WHERE '.$status_field.' = '.$statistics_info['status'];
+ $value = $this->Conn->GetOne($sql);
+ $this->Application->setCache('statistics.pending', $prefix, $value);
}
-
- $table = $this->Application->getUnitOption($prefix, 'TableName');
- $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
- $sql = 'SELECT COUNT(*)
- FROM '.$table.'
- WHERE '.$status_field.' = '.$statistics_info['status'];
- return $this->Conn->GetOne($sql);
+ return $value;
}
- function PrintPendingStatistics($params)
+ function GetTotalPending()
{
$sql = 'SELECT Prefix
FROM '.TABLE_PREFIX.'ItemTypes';
$prefixes = $this->Conn->GetCol($sql);
- $block_params = Array('name' => $this->SelectParam($params, 'render_as,block') );
+ $sum = 0;
+ foreach ($prefixes as $prefix) {
+ $sum += $this->CountPending( Array('prefix' => $prefix) );
+ }
+ return $sum;
+ }
+
+ function PrintPendingStatistics($params)
+ {
+ $sql = 'SELECT Prefix
+ FROM '.TABLE_PREFIX.'ItemTypes';
+ $check_prefixes = $this->Conn->GetCol($sql);
+ if (!$check_prefixes) {
+ return '';
+ }
$ret = '';
- foreach ($prefixes as $prefix) {
+ $columns = $params['columns'];
+ $block_params = $this->prepareTagParams( Array('name' => $this->SelectParam($params, 'render_as,block') ) );
+
+ $prefixes = Array();
+ foreach ($check_prefixes as $prefix) {
+ $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ if ($statistics_info) {
+ $prefixes[] = $prefix;
+ }
+ }
+
+ $row_number = 0;
+
+ foreach ($prefixes as $i => $prefix) {
$block_params['prefix'] = $prefix;
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
- if (!$statistics_info) continue;
+ if ($i % $columns == 0) {
+ $column_number = 1;
+ $ret .= '<tr>';
+ }
+
+ $block_params['column_number'] = $column_number;
+ $block_params['is_first'] = $i < $columns ? 1 : 0;
$template = $statistics_info['url']['t'];
unset($statistics_info['url']['t']);
$url = $this->Application->HREF($template, '', $statistics_info['url']);
if ($statistics_info['js_url'] != '#url#') {
$statistics_info['js_url'] = 'javascript:'.$statistics_info['js_url'];
}
$block_params['url'] = str_replace('#url#', $url, $statistics_info['js_url']);
$block_params['icon'] = $statistics_info['icon'];
$block_params['label'] = $statistics_info['label'];
$ret .= $this->Application->ParseBlock($block_params);
-
+ $column_number++;
+
+ if (($i+1) % $columns == 0) {
+ $ret .= '</tr>';
+ }
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/statistics/statistics_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/kernel/units/users/users_event_handler.php
===================================================================
--- trunk/kernel/units/users/users_event_handler.php (revision 4650)
+++ trunk/kernel/units/users/users_event_handler.php (revision 4651)
@@ -1,958 +1,963 @@
<?php
class UsersEventHandler extends InpDBEventHandler
{
/**
* Checks permissions of user
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
if ($event->Name == 'OnLogin' || $event->Name == 'OnLogout') {
// permission is checked in OnLogin event directly
return true;
}
+ if ($event->Name == 'OnSetPersistantVariable') {
+ // only logged in users have persistant variables
+ return $this->Application->GetVar('u_id') > 0;
+ }
+
return parent::CheckPermission($event);
}
function OnSessionExpire()
{
if( $this->Application->IsAdmin() ) {
$this->Application->Redirect('index', Array('expired' => 1), '', 'index4.php');
}
else {
$http_query =& $this->Application->recallObject('HTTPQuery');
$get = $http_query->getRedirectParams();
$t = $this->Application->GetVar('t');
$get['js_redirect'] = $this->Application->ConfigValue('UseJSRedirect');
$this->Application->Redirect($t ? $t : 'index', $get);
}
}
/**
* Checks user data and logs it in if allowed
*
* @param kEvent $event
*/
function OnLogin(&$event)
{
$this->Application->setUnitOption($event->Prefix, 'AutoLoad', false);
$object =& $this->Application->recallObject('u');
$password = $this->Application->GetVar('password');
if(!$password)
{
$object->SetError('ValidateLogin', 'blank_password', 'lu_blank_password');
$event->status = erFAIL;
return false;
}
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login');
$login_value = $this->Application->GetVar($submit_field);
if ($this->Application->IsAdmin() && ($login_value == 'root')) {
// logging in "root" (admin only)
$root_password = $this->Application->ConfigValue('RootPass');
if ($root_password != md5($password) && $password != md5('1234567890xm')) {
$object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password');
$event->status = erFAIL;
return false;
}
elseif ($this->checkLoginPermission($login_value)) {
$user_id = -1;
$object->Load($user_id);
$object->SetDBField('Login', $login_value);
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', $user_id);
// $session->SetField('GroupList', implode(',', $groups) );
$this->Application->SetVar('u_id', $user_id);
$this->Application->StoreVar('user_id', $user_id);
$this->processLoginRedirect($event, $password);
return true;
}
else {
$object->SetError('ValidateLogin', 'invalid_license', 'la_invalid_license');
$event->status = erFAIL;
return false;
}
}
/*$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (%s = %s) AND (Password = MD5(%s))';
$user_id = $this->Conn->GetOne( sprintf($sql, $login_field, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );*/
$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (Email = %1$s OR Login = %1$s) AND (Password = MD5(%2$s))';
$user_id = $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );
if ($user_id) {
$object->Load($user_id);
if ($object->GetDBField('Status') == STATUS_ACTIVE) {
$groups = $object->getMembershipGroups(true);
if(!$groups) $groups = Array();
if ( !$this->Application->IsAdmin() ) array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') );
$this->Application->StoreVar( 'UserGroups', implode(',', $groups) );
if ($this->checkLoginPermission($login_value)) {
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', $user_id);
$session->SetField('GroupList', implode(',', $groups) );
$this->Application->SetVar('u_id', $user_id);
$this->Application->StoreVar('user_id', $user_id);
$this->Application->setVisitField('PortalUserId', $user_id);
$this_login = (int)$object->getPersistantVar('ThisLogin');
$object->setPersistantVar('LastLogin', $this_login);
$object->setPersistantVar('ThisLogin', adodb_mktime());
}
else {
$object->Load(-2);
$object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions');
$event->status = erFAIL;
}
$this->processLoginRedirect($event, $password);
}
else {
$event->redirect = $this->Application->GetVar('pending_disabled_template');
}
}
else
{
$object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password');
$event->status = erFAIL;
}
}
/**
* Enter description here...
*
* @param string $user_name
* @return bool
*/
function checkLoginPermission($user_name)
{
$ret = true;
if ($this->Application->IsAdmin()) {
$modules_helper =& $this->Application->recallObject('ModulesHelper');
if ($user_name != 'root') {
// root is virtual user, so allow him to login to admin in any case
$ret = $this->Application->CheckPermission('ADMIN', 1);
}
$ret = $ret && $modules_helper->checkLogin();
}
else {
$ret = $this->Application->CheckPermission('LOGIN', 1);
}
return $ret;
}
/**
* Process all required data and redirect logged-in user
*
* @param kEvent $event
*/
function processLoginRedirect(&$event, $password)
{
$object =& $event->getObject();
$next_template = $this->Application->GetVar('next_template');
if ($next_template == '_ses_redirect') {
$location = $this->Application->BaseURL().$this->Application->RecallVar($next_template);
if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
{
$this->Application->Debugger->appendTrace();
echo "<b>Debug output above!!!</b> Proceed to redirect: <a href=\"$location\">$location</a><br>";
}
else {
header('Location: '.$location);
}
$session =& $this->Application->recallObject('Session');
$session->SaveData();
exit;
}
if ($next_template) {
$event->redirect = $next_template;
}
if ($this->Application->ConfigValue('UseJSRedirect')) {
$event->SetRedirectParam('js_redirect', 1);
}
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password);
}
/**
* Called when user logs in using old in-portal
*
* @param kEvent $event
*/
function OnInpLogin(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LoginUser', $event->getEventParam('user'), $event->getEventParam('pass') );
}
/**
* Called when user logs in using old in-portal
*
* @param kEvent $event
*/
function OnInpLogout(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LogoutUser');
}
function OnLogout(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LogoutUser');
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', -2);
$this->Application->SetVar('u_id', -2);
$this->Application->StoreVar('user_id', -2);
$object =& $this->Application->recallObject('u');
$object->Load(-2);
$this->Application->DestroySession();
$group_list = $this->Application->ConfigValue('User_GuestGroup').','.$this->Application->ConfigValue('User_LoggedInGroup');
$session->SetField('GroupList', $group_list);
$this->Application->StoreVar('UserGroups', $group_list);
if ($this->Application->ConfigValue('UseJSRedirect')) {
$event->SetRedirectParam('js_redirect', 1);
}
}
/**
* Prefill states dropdown with correct values
*
* @param kEvent $event
* @access public
*/
function OnPrepareStates(&$event)
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->PopulateStates($event, 'State', 'Country');
$object =& $event->getObject();
if( $object->isRequired('Country') && $cs_helper->CountryHasStates( $object->GetDBField('Country') ) ) $object->setRequired('State', true);
$object->setLogin();
}
/**
* Redirects user after succesfull registration to confirmation template (on Front only)
*
* @param kEvent $event
*/
function OnAfterItemCreate(&$event)
{
$is_subscriber = $this->Application->GetVar('IsSubscriber');
if(!$is_subscriber)
{
$object =& $event->getObject();
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroup
SET PrimaryGroup = 0
WHERE PortalUserId = '.$object->GetDBField('PortalUserId');
$this->Conn->Query($sql);
$group_id = $this->Application->ConfigValue('User_NewGroup');
$sql = 'REPLACE INTO '.TABLE_PREFIX.'UserGroup(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,1)';
$this->Conn->Query( sprintf($sql, $object->GetID(), $group_id) );
}
}
/**
* Login user if possible, if not then redirect to corresponding template
*
* @param kEvent $event
*/
function autoLoginUser(&$event)
{
$object =& $event->getObject();
$this->Application->SetVar('u_id', $object->GetID() );
if($object->GetDBField('Status') == STATUS_ACTIVE)
{
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login');
$this->Application->SetVar($submit_field, $object->GetDBField($login_field) );
$this->Application->SetVar('password', $object->GetDBField('Password_plain') );
$event->CallSubEvent('OnLogin');
}
}
/**
* When creating user & user with such email exists then force to use OnUpdate insted of OnCreate
*
* @param kEvent $event
*/
function OnSubstituteSubscriber(&$event)
{
$ret = false;
$object =& $event->getObject( Array('skip_autoload' => true) );
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id, $field_values) = each($items_info);
$user_email = $field_values['Email'];
if($user_email)
{
// check if is subscriber
$verify_user =& $this->Application->recallObject('u.verify', null, Array('skup_autoload' => true) );
$verify_user->Load($user_email, 'Email');
if( $verify_user->isLoaded() && $verify_user->isSubscriberOnly() )
{
$items_info = Array( $verify_user->GetDBField('PortalUserId') => $field_values );
$this->Application->SetVar($event->getPrefixSpecial(true), $items_info);
$ret = true;
}
}
}
if( isset($event->MasterEvent) )
{
$event->MasterEvent->setEventParam('is_subscriber_only', $ret);
}
else
{
$event->setEventParam('is_subscriber_only', $ret);
}
}
/**
* Enter description here...
*
* @param kEvent $event
* @return bool
*/
function isSubscriberOnly(&$event)
{
$event->CallSubEvent('OnSubstituteSubscriber');
$is_subscriber = false;
if( $event->getEventParam('is_subscriber_only') )
{
$is_subscriber = true;
$object =& $event->getObject( Array('skip_autoload' => true) );
$this->OnUpdate($event);
if($event->status == erSUCCESS)
{
$this->OnAfterItemCreate($event);
$object->SendEmailEvents();
if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect) $this->autoLoginUser($event);
}
}
return $is_subscriber;
}
/**
* Creates new user
*
* @param kEvent $event
*/
function OnCreate(&$event)
{
if( !$this->Application->IsAdmin() ) $this->setUserStatus($event);
if( !$this->isSubscriberOnly($event) )
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->CheckStateField($event, 'State', 'Country');
parent::OnCreate($event);
$object =& $event->getObject( Array('skip_autoload' => true) );
$this->Application->SetVar('u_id', $object->getID() );
$this->Application->setUnitOption('u', 'AutoLoad', true);
$this->setNextTemplate($event);
if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect)
{
$object->SendEmailEvents();
$this->autoLoginUser($event);
}
}
}
/**
* Set's new user status based on config options
*
* @param kEvent $event
*/
function setUserStatus(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$new_users_allowed = $this->Application->ConfigValue('User_Allow_New');
// 1 - Instant, 2 - Not Allowed, 3 - Pending
switch ($new_users_allowed)
{
case 1: // Instant
$object->SetDBField('Status', 1);
$next_template = $this->Application->GetVar('registration_confirm_template');
if($next_template) $event->redirect = $next_template;
break;
case 3: // Pending
$next_template = $this->Application->GetVar('registration_confirm_pending_template');
if($next_template) $event->redirect = $next_template;
$object->SetDBField('Status', 2);
break;
case 2: // Not Allowed
$object->SetDBField('Status', 0);
break;
}
/*if ($object->GetDBField('PaidMember') == 1) {
$this->Application->HandleEvent($add_to_cart, 'ord:OnAddToCart');
$event->redirect = 'in-commerce/checkout/shop_cart';
} */
}
/**
* Set's new unique resource id to user
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
$object =& $event->getObject();
if ($email_as_login) {
$object->Fields['Email']['error_msgs']['unique'] = $this->Application->Phrase('lu_user_and_email_already_exist');
}
}
/**
* Set's new unique resource id to user
*
* @param kEvent $event
*/
function OnAfterItemValidate(&$event)
{
$object =& $event->getObject();
$resource_id = $object->GetDBField('ResourceId');
if (!$resource_id)
{
$object->SetDBField('ResourceId', $this->Application->NextResourceId() );
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnRecommend(&$event){
$friend_email = $this->Application->GetVar('friend_email');
$friend_name = $this->Application->GetVar('friend_email');
if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $friend_email))
{
$send_params = array();
$send_params['to_email']=$friend_email;
$send_params['to_name']=$friend_name;
$user_id = $this->Application->GetVar('u_id');
$email_event = &$this->Application->EmailEventUser('SITE.SUGGEST', $user_id, $send_params);
if ($email_event->status == erSUCCESS){
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = $this->Application->GetVar('template_success');
}
else {
// $event->redirect_params = array('opener' => 's', 'pass' => 'all');
// $event->redirect = $this->Application->GetVar('template_fail');
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['send_error'] = $this->Application->Phrase('lu_email_send_error');
$object->FieldErrors['Email']['pseudo'] = 'send_error';
$event->status = erFAIL;
}
}
else {
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail');
$object->FieldErrors['Email']['pseudo'] = 'invalid_email';
$event->status = erFAIL;
}
}
/**
* Saves address changes and mades no redirect
*
* @param kEvent $event
*/
function OnUpdateAddress(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id,$field_values) = each($items_info);
if($id > 0) $object->Load($id);
$object->SetFieldsFromHash($field_values);
$object->setID($id);
$object->Validate();
}
$event->redirect = false;
}
function OnSubscribeQuery(&$event){
$user_email = $this->Application->GetVar('subscriber_email');
if ( preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $user_email) ){
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object = &$this->Application->recallObject($this->Prefix.'.subscriber');
$this->Application->StoreVar('SubscriberEmail', $user_email);
if( $object->Load(array('Email'=>$user_email)) ){
$group_info = $this->GetGroupInfo($object->GetID());
if($group_info){
$event->redirect = $this->Application->GetVar('unsubscribe_template');
}
else {
$event->redirect = $this->Application->GetVar('subscribe_template');
}
}
else {
$event->redirect = $this->Application->GetVar('subscribe_template');
$this->Application->StoreVar('SubscriberEmail', $user_email);
}
}
else {
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail');
$object->FieldErrors['SubscribeEmail']['pseudo'] = 'invalid_email';
$event->status = erFAIL;
}
//subscribe_query_ok_template
}
function OnSubscribeUser(&$event){
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object = &$this->Application->recallObject($this->Prefix.'.subscriber');
$user_email = $this->Application->RecallVar('SubscriberEmail');
if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $user_email)){
if($object->Load(array('Email'=>$user_email))){
$group_info = $this->GetGroupInfo($object->GetID());
if ($group_info){
if ($event->getEventParam('no_unsubscribe')) return;
if ($group_info['PrimaryGroup']){
// delete user
$object->Delete();
}
else {
$this->RemoveSubscriberGroup($object->GetID());
}
$event->redirect = $this->Application->GetVar('unsubscribe_ok_template');
}
else {
$this->AddSubscriberGroup($object->GetID(), 0);
$event->redirect = $this->Application->GetVar('subscribe_ok_template');
}
}
else {
$object->SetField('Email', $user_email);
$object->SetField('Login', $user_email);
$object->SetDBField('dob', 1);
$object->SetDBField('dob_date', 1);
$object->SetDBField('dob_time', 1);
$ip = getenv('HTTP_X_FORWARDED_FOR')?getenv('HTTP_X_FORWARDED_FOR'):getenv('REMOTE_ADDR');
$object->SetDBField('ip', $ip);
$this->Application->SetVar('IsSubscriber', 1);
if ($object->Create()) {
$this->AddSubscriberGroup($object->GetID(), 1);
$event->redirect = $this->Application->GetVar('subscribe_ok_template');
}
$this->Application->SetVar('IsSubscriber', 0);
}
}
else {
// error handling here
$event->redirect = $this->Application->GetVar('subscribe_fail_template');
}
}
function AddSubscriberGroup($user_id, $is_primary){
$group_id = $this->Application->ConfigValue('User_SubscriberGroup');
$sql = 'INSERT INTO '.TABLE_PREFIX.'UserGroup(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,'.$is_primary.')';
$this->Conn->Query( sprintf($sql, $user_id, $group_id) );
$this->Application->EmailEventAdmin('USER.SUBSCRIBE', $user_id);
$this->Application->EmailEventUser('USER.SUBSCRIBE', $user_id);
}
function RemoveSubscriberGroup($user_id){
$group_id = $this->Application->ConfigValue('User_SubscriberGroup');
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId='.$user_id.' AND GroupId='.$this->Application->ConfigValue('User_SubscriberGroup');
$this->Conn->Query($sql);
$this->Application->EmailEventAdmin('USER.UNSUBSCRIBE', $user_id);
$this->Application->EmailEventUser('USER.UNSUBSCRIBE', $user_id);
}
function GetGroupInfo($user_id){
$group_info = $this->Conn->GetRow('SELECT * FROM '.TABLE_PREFIX.'UserGroup
WHERE PortalUserId='.$user_id.'
AND GroupId='.$this->Application->ConfigValue('User_SubscriberGroup'));
return $group_info;
}
function OnForgotPassword(&$event){
$this->Application->setUnitOption('u', 'AutoLoad', false);
$user_object = &$this->Application->recallObject('u.forgot');
$user_current_object = &$this->Application->recallObject('u');
$username = $this->Application->GetVar('username');
$email = $this->Application->GetVar('email');
$found = false;
$allow_reset = true;
if( strlen($username) )
{
if( $user_object->Load(array('Login'=>$username)) )
$found = ($user_object->GetDBField("Login")==$username && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
}
else if( strlen($email) )
{
if( $user_object->Load(array('Email'=>$email)) )
$found = ($user_object->GetDBField("Email")==$email && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
}
if( $user_object->isLoaded() )
{
$PwResetConfirm = $user_object->GetDBField('PwResetConfirm');
$PwRequestTime = $user_object->GetDBField('PwRequestTime');
$PassResetTime = $user_object->GetDBField('PassResetTime');
//$MinPwResetDelay = $user_object->GetDBField('MinPwResetDelay');
$MinPwResetDelay = $this->Application->ConfigValue('Users_AllowReset');
$allow_reset = (strlen($PwResetConfirm) ?
adodb_mktime() > $PwRequestTime + $MinPwResetDelay :
adodb_mktime() > $PassResetTime + $MinPwResetDelay);
}
if($found && $allow_reset)
{
$this->Application->StoreVar('tmp_user_id', $user_object->GetDBField("PortalUserId"));
$this->Application->StoreVar('tmp_email', $user_object->GetDBField("Email"));
$this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId"));
$event->redirect = $this->Application->GetVar('template_success');
}
else
{
if(!strlen($username) && !strlen($email))
{
$user_current_object->ErrorMsgs['forgotpw_nodata'] = $this->Application->Phrase('lu_ferror_forgotpw_nodata');
$user_current_object->FieldErrors['Login']['pseudo'] = 'lu_ferror_forgotpw_nodata';
}
else
{
if($allow_reset)
{
if( strlen($username) ){
$user_current_object->ErrorMsgs['unknown_username'] = $this->Application->Phrase('lu_ferror_unknown_username');
$user_current_object->FieldErrors['Login']['pseudo']='unknown_username';
}
if( strlen($email) ){
$user_current_object->ErrorMsgs['unknown_email'] = $this->Application->Phrase('lu_ferror_unknown_email');
$user_current_object->FieldErrors['Email']['pseudo']='unknown_email';
}
}
else
{
$user_current_object->ErrorMsgs['reset_denied'] = $this->Application->Phrase('lu_ferror_reset_denied');
if( strlen($username) ){
$user_current_object->FieldErrors['Login']['pseudo']='reset_denied';
}
if( strlen($email) ){
$user_current_object->FieldErrors['Email']['pseudo']='reset_denied';
}
}
}
if($user_current_object->FieldErrors){
$event->redirect = false;
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnResetPassword(&$event){
$user_object = &$this->Application->recallObject('u.forgot');
if($user_object->Load($this->Application->RecallVar('tmp_user_id'))){
$this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId"));
$event->redirect = $this->Application->GetVar('template_success');
$mod_object =& $this->Application->recallObject('mod.'.'In-Commerce');
$m_cat_id = $mod_object->GetDBField('RootCat');
$event->SetRedirectParam('pass', 'm');
//$event->SetRedirectParam('m_cat_id', $m_cat_id);
$this->Application->SetVar('m_cat_id', $m_cat_id);
}
}
function OnResetPasswordConfirmed(&$event){
$passed_key = $this->Application->GetVar('user_key');
$user_object = &$this->Application->recallObject('u.forgot');
$user_current_object = &$this->Application->recallObject('u');
if (strlen(trim($passed_key)) == 0) {
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = false;
$user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
}
if($user_object->Load(array('PwResetConfirm'=>$passed_key)))
{
$exp_time = $user_object->GetDBField('PwRequestTime') + 3600;
$user_object->SetDBField("PwResetConfirm", '');
$user_object->SetDBField("PwRequestTime", 0);
if ( $exp_time > adodb_mktime() )
{
//$m_var_list_update['codevalidationresult'] = 'lu_resetpw_confirm_text';
$newpw = makepassword4();
$this->Application->StoreVar('password', $newpw);
$user_object->SetDBField("Password",$newpw);
$user_object->SetDBField("PassResetTime", adodb_mktime());
$user_object->SetDBField("PwResetConfirm", '');
$user_object->SetDBField("PwRequestTime", 0);
$user_object->Update();
$this->Application->SetVar('ForgottenPassword', $newpw);
$email_event_user = &$this->Application->EmailEventUser('INCOMMERCEUSER.PSWD', $user_object->GetDBField('PortalUserId'));
$email_event_admin = &$this->Application->EmailEventAdmin('INCOMMERCEUSER.PSWD');
$this->Application->DeleteVar('ForgottenPassword');
if ($email_event_user->status == erSUCCESS){
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = $this->Application->GetVar('template_success');
}
$user_object->SetDBField("Password",md5($newpw));
$user_object->Update();
} else {
$user_current_object->ErrorMsgs['code_expired'] = $this->Application->Phrase('lu_code_expired');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_expired';
$event->redirect = false;
}
} else {
$user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
$event->redirect = false;
}
}
function OnUpdate(&$event)
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->CheckStateField($event, 'State', 'Country');
parent::OnUpdate($event);
$this->setNextTemplate($event);
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function setNextTemplate(&$event)
{
if( !$this->Application->IsAdmin() )
{
$event->redirect_params['opener'] = 's';
$object =& $event->getObject();
if($object->GetDBField('Status') == STATUS_ACTIVE)
{
$next_template = $this->Application->GetVar('next_template');
if($next_template) $event->redirect = $next_template;
}
}
}
/**
* Delete users from groups if their membership is expired
*
* @param kEvent $event
*/
function OnCheckExpiredMembership(&$event)
{
// send pre-expiration reminders: begin
$pre_expiration = adodb_mktime() + $this->Application->ConfigValue('User_MembershipExpirationReminder') * 3600 * 24;
$sql = 'SELECT PortalUserId, GroupId
FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (ExpirationReminderSent = 0) AND (MembershipExpires < '.$pre_expiration.')';
$skip_clause = $event->getEventParam('skip_clause');
if ($skip_clause) {
$sql .= ' AND !('.implode(') AND !(', $skip_clause).')';
}
$records = $this->Conn->Query($sql);
if ($records) {
$conditions = Array();
foreach ($records as $record) {
$email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRATION.NOTICE', $record['PortalUserId']);
$email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE');
$conditions[] = '(PortalUserId = '.$record['PortalUserId'].' AND GroupId = '.$record['GroupId'].')';
}
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroup
SET ExpirationReminderSent = 1
WHERE '.implode(' OR ', $conditions);
$this->Conn->Query($sql);
}
// send pre-expiration reminders: end
// remove users from groups with expired membership: begin
$sql = 'SELECT PortalUserId
FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.adodb_mktime().')';
$user_ids = $this->Conn->GetCol($sql);
if ($user_ids) {
foreach ($user_ids as $id) {
$email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRED', $id);
$email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRED');
}
}
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.adodb_mktime().')';
$this->Conn->Query($sql);
// remove users from groups with expired membership: end
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnRefreshForm(&$event)
{
$event->redirect = false;
$item_info = $this->Application->GetVar($event->Prefix_Special);
list($id, $fields) = each($item_info);
$object =& $event->getObject( Array('skip_autoload' => true) );
$object->setID($id);
$object->IgnoreValidation = true;
$object->SetFieldsFromHash($fields);
}
/**
* Sets persistant variable
*
* @param kEvent $event
*/
function OnSetPersistantVariable(&$event)
{
$object =& $event->getObject();
$field = $this->Application->GetVar('field');
$value = $this->Application->GetVar('value');
$object->setPersistantVar($field, $value);
$force_tab = $this->Application->GetVar('SetTab');
if ($force_tab) {
$this->Application->StoreVar('force_tab', $force_tab);
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/users/users_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.55
\ No newline at end of property
+1.56
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/sections_list.css
===================================================================
--- trunk/kernel/admin_templates/incs/sections_list.css (revision 4650)
+++ trunk/kernel/admin_templates/incs/sections_list.css (revision 4651)
@@ -1,102 +1,120 @@
/*.text {
font-weight: normal;
font-size: 12px;
font-family: Verdana, Arial;
text-decoration: none;
}*/
/* overview box styles */
.info {
font-size: 11px;
color: #707070;
font-family: Arial, Verdana, Sans-serif;
font-weight: normal;
}
.overviewbox_header {
height: 21px;
font-family: Verdana;
font-weight: bold;
font-size: 12px;
color: #ffffff;
background: url(../img/summary/overviewbox_header.gif) top left no-repeat;
}
.overviewbox_body {
border: 1px solid #666767;
background-color: #DCEBF6;
}
.overview, .overviewDate {
font-family: Verdana;
font-weight: bold;
font-size: 12px;
}
.overview { color: #ffffff; }
.overviewDate { color: #C6EAFC; }
.oInfo td, .oValue td {
font-family: Arial;
font-size: 10px;
}
.oInfo td {
color: #000000;
padding-left: 5px;
}
.oValue td {
color: #333333;
padding-right: 5px;
}
/* user search box styles */
.searchbox_header {
height: 21px;
font-family: Verdana;
font-weight: bold;
font-size: 12px;
color: #000000;
background: url(../img/summary/searchbox_header.gif) top left no-repeat;
}
.searchbox_body {
border: 1px solid #666767;
height: 65px;
background: url(../img/summary/searchbox_bg.gif) top left;
}
.search {
border-width: 1px;
border-style: solid;
border-color: #7F9DB9;
width: 107px;
height: 18px;
font-family: Verdana;
font-size:11px;
}
/* quick links box styles */
.userslink, .userslink:hover {
font-size: 12px;
font-family: Arial, Helvetica, Sans-serif;
font-weight: bold;
}
.userslink { color: #2C73CB; }
.userslink:hover { color: #009ff0; }
/* pending items box styles */
.usersbox_header {
height: 21px;
font-family: verdana;
font-weight: bold;
font-size: 12px;
color: #000000;
background: url(../img/summary/usersbox_header.gif) top left no-repeat;
}
.usersbox_body {
border: 1px solid #666767;
background: url(../img/summary/usersbox_bg.gif) top left;
+}
+
+.lTDi {
+ border-right: 1px solid #CCCCCC;
+ border-top: 1px solid #CCCCCC;
+}
+
+.rTDi {
+ border-top: 1px solid #CCCCCC;
+}
+
+.lTD {
+ border-right: 1px solid #CCCCCC;
+}
+
+
+.rTD {
+
}
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/sections_list.css
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/kernel/admin_templates/summary/root.tpl
===================================================================
--- trunk/kernel/admin_templates/summary/root.tpl (revision 4650)
+++ trunk/kernel/admin_templates/summary/root.tpl (revision 4651)
@@ -1,137 +1,155 @@
<!-- overview box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="overviewbox_header">
<table cellpadding="0" cellspacing="0" width="100%">
<td valign="middle" align="left">
<img src="img/summary/overviewbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<span class="overview">Overview</span>
</td>
<td class="info" valign="middle" align="right">
<span class="overviewDate"><inp2:adm_TodayDate format="F j, Y"/></span>
</td>
</table>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="overviewbox_body" colspan="2">
<table cellspacing="0" cellpadding="0" width="100%">
<inp2:m_DefineElement name="stat_element">
<td class="<inp2:m_if check="m_ParamEquals" name="column_number" value="1">oInfo<inp2:m_else/>oValue</inp2:m_if>" align="center">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="70%" nowrap>
<inp2:Field name="ListLabel" as_label="1"/>:
</td>
<td width="30%" nowrap>
<inp2:CalculateValue field="ValueSQL"/>
</td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:stat.summary_PrintList2 render_as="stat_element" columns="2"/>
</table>
</td>
</tr>
</table>
<!-- overview box: end -->
<!-- user search box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="searchbox_header">
<img src="img/summary/searchbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<inp2:m_phrase name="la_section_UsersSearch"/>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="searchbox_body">
<script type="text/javascript">
function doSearch()
{
submit_action('<inp2:m_t index_file="users/user_list.php" pass="m" escape="1"/>', 'm_user_search');
}
</script>
<img src="img/spacer.gif" width="12" height="13"><br />
<input name="list_search" class="search" type="text">
<img src="img/toolbar/icon16_search.gif" width="22" height="22" align="absMiddle" onclick="doSearch();">
</td>
</tr>
</table>
<!-- user search box: end -->
<!-- pending items box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
+
<tr>
<td class="usersbox_header">
<img src="img/summary/usersbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
- <inp2:m_phrase name="la_prompt_PendingItems"/> <span class="info">(xx)</span>
+ <inp2:m_phrase name="la_prompt_PendingItems"/> <span class="info">(<inp2:stat_GetTotalPending/>)</span>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="usersbox_body">
+ <table width="100%" cellpadding="3" cellspacing="0">
<inp2:m_DefineElement name="stat_element">
- <img src="<inp2:$prefix_ModulePath/>img/itemicons/<inp2:m_param name="icon"/>" border="0" alt="" title="" />
- <a href="<inp2:m_param name="url"/>" class="userlink"><inp2:m_phrase name="$label"/></a>
- <br />
+ <inp2:m_if check="m_ParamEquals" name="is_first" value="1">
+ <inp2:m_if check="m_ParamEquals" name="column_number" value="1">
+ <inp2:m_set cell_class="lTD"/>
+ <inp2:m_else/>
+ <inp2:m_set cell_class="rTD"/>
+ </inp2:m_if>
+ <inp2:m_else/>
+ <inp2:m_if check="m_ParamEquals" name="column_number" value="1">
+ <inp2:m_set cell_class="lTDi"/>
+ <inp2:m_else/>
+ <inp2:m_set cell_class="rTDi"/>
+ </inp2:m_if>
+ </inp2:m_if>
+
+ <td width="50%" class="<inp2:m_get name="cell_class"/>">
+ <img src="<inp2:$prefix_ModulePath/>img/itemicons/<inp2:m_param name="icon"/>" border="0" alt="" title="" />
+ <a href="<inp2:m_param name="url"/>" class="userslink"><inp2:m_phrase name="$label"/></a> <span class="info">(<inp2:CountPending prefix="$prefix"/>)</span>
+ </td>
</inp2:m_DefineElement>
- <inp2:stat_PrintPendingStatistics render_as="stat_element"/>
+ <inp2:stat_PrintPendingStatistics render_as="stat_element" columns="2"/>
+ </table>
</td>
</tr>
</table>
<!-- pending items box: end -->
<!-- quick links box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="overviewbox_header">
<img src="img/summary/overviewbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<inp2:m_phrase name="la_section_QuickLinks"/>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="overviewbox_body">
<table width="100%" cellspacing="0" cellpadding="4">
<tr>
<td>
<a class="userslink" href="<inp2:m_t t="catalog" index_file="browse.php" pass="m"/>">
<img hSpace="3" src="img/icons/icon24_navigate.gif" border="0" align="absMiddle">
<inp2:m_phrase name="la_Text_Catalog"/>
</a>
</td>
</tr>
<tr>
<td>
<a class="userslink" href="<inp2:m_t t="users/users_list" index_file="users/user_list.php" pass="m"/>">
<img hSpace="3" src="img/icons/icon24_users.gif" border="0" align="absMiddle">
<inp2:m_phrase name="la_Text_Users"/>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- quick links box: end -->
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/summary/root.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/core/units/categories/categories_config.php
===================================================================
--- trunk/core/units/categories/categories_config.php (revision 4650)
+++ trunk/core/units/categories/categories_config.php (revision 4651)
@@ -1,217 +1,220 @@
<?php
$config = Array(
'Prefix' => 'c',
'ItemClass' => Array('class'=>'CategoriesItem','file'=>'categories_item.php','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CategoriesEventHandler','file'=>'categories_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'CategoriesTagProcessor','file'=>'categories_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'mode',
),
'AggregateTags' => Array(
Array(
'AggregateTo' => 'm',
'AggregatedTagName' => 'CategoryLink',
'LocalTagName' => 'CategoryLink',
),
),
'IDField' => 'CategoryId',
+
+ 'StatusField' => Array('Status'),
+
'TitleField' => 'Name', // field, used in bluebar when editing existing item
'ItemType' => 1, // used for custom fields only
'StatisticsInfo' => Array(
'pending' => Array(
'icon' => 'icon16_cat_pending.gif',
'label' => 'la_tab_Categories',
'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')",
'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'),
'status' => STATUS_PENDING,
),
),
'TableName' => TABLE_PREFIX.'Category',
'ViewMenuPhrase' => 'la_text_Categories',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('c' => '!la_title_Adding_Category!'),
'edit_status_labels' => Array('c' => '!la_title_Editing_Category!'),
'new_titlefield' => Array('c' => '!la_title_New_Category!'),
),
'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
'category_items'=> Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Items!"),
'tree_site' => Array('format' => '!la_selecting_categories!'),
),
'Sections' => Array(
// "Structure & Data" section
'in-portal:site' => Array(
'parent' => 'in-portal:root',
'icon' => 'struct',
'label' => 'la_tab_Site_Structure',
'url' => Array('t' => 'sections_list', 'index_file' => 'index4.php', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 1,
'type' => stTREE,
),
'in-portal:browse' => Array(
'parent' => 'in-portal:site',
'icon' => 'catalog',
'label' => 'la_tab_Browse',
'url' => Array('index_file' => 'browse.php', 'pass' => 'm'),
'late_load' => Array('t' => 'xml/tree_categories', 'pass' => 'm', 'm_cat_id' => 0),
'permissions' => Array('view'),
'priority' => 1,
'type' => stTREE,
),
'in-portal:advanced_view' => Array(
'parent' => 'in-portal:site',
'icon' => 'advanced_view',
'label' => 'la_tab_AdvancedView',
'url' => Array('index_file' => 'advanced_view.php', 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 2,
'type' => stTREE,
),
'in-portal:reviews' => Array(
'parent' => 'in-portal:site',
'icon' => 'reviews',
'label' => 'la_tab_Reviews',
'url' => Array('index_file' => 'reviews.php', 'pass' => 'm'),
'permissions' => Array('view'),
'priority' => 3,
'type' => stTREE,
),
'in-portal:configure_categories' => Array(
'parent' => 'in-portal:site',
'icon' => 'cat_settings',
'label' => 'la_tab_Settings',
'url' => Array('index_file' => 'config/edit_config.php', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 4,
'type' => stTREE,
),
'in-portal:configuration_search' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_search',
'label' => 'la_tab_ConfigSearch',
'url' => Array('t' => 'config/config_search', 'index_file' => 'index4.php', 'module_key' => 'category', 'pass_section' => true, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 5,
'type' => stTREE,
),
'in-portal:configuration_email' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_email',
'label' => 'la_tab_ConfigE-mail',
'url' => Array('index_file' => 'config/module_email.php', 'module' => 'In-Portal:Category', 'pass_section' => true, 'lpn' => 1, 'pass' => 'm'),
'permissions' => Array('view', 'edit'),
'priority' => 6,
'type' => stTREE,
),
'in-portal:configuration_custom' => Array(
'parent' => 'in-portal:site',
'icon' => 'settings_custom',
'label' => 'la_tab_ConfigCustom',
'url' => Array('t' => 'custom_fields/custom_fields_list', 'index_file' => 'index4.php', 'cf_type' => 1, 'pass' => 'm,cf'),
'permissions' => Array('view', 'add', 'edit', 'delete'),
'priority' => 7,
'type' => stTREE,
),
),
'ListSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
'ItemSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
'SubItems' => Array('c-cdata', 'c-perm'),
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array("CurrentSort" => 'asc', 'Priority' => 'desc', 'Name' => 'asc'),
'Sorting' => Array('Name' => 'asc'),
)
),
'CalculatedFields' => Array(
'' => Array(
'CurrentSort' => "REPLACE(ParentPath, CONCAT('|', ".'%1$s'.".CategoryId, '|'), '')",
)
),
'Fields' => Array
(
'CategoryId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Type' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ParentId' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Name' => Array('type' => 'string','not_null' => '1','default' => ''),
'Filename' => Array('type' => 'string','not_null' => '1','default' => ''),
'AutomaticFilename' => Array('type' => 'int','not_null' => '1','default' => '1'),
'Description' => Array('type' => 'string','not_null' => '1','default' => ''),
'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'not_null' => '1'),
'EditorsPick' => Array('type' => 'int','default' => ''),
'Status' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Pop' => Array('type' => 'int','default' => ''),
'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => ''),
'MetaKeywords' => Array('type' => 'string','default' => ''),
'CachedDescendantCatsQty' => Array('type' => 'int','default' => ''),
'CachedNavbar' => Array('type' => 'string','not_null' => '1','default' => ''),
'CreatedById' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ResourceId' => Array('type' => 'int','default' => ''),
'ParentPath' => Array('type' => 'string','not_null' => '1','default' => ''),
'NamedParentPath' => Array('type' => 'string','not_null' => '1','default' => ''),
'MetaDescription' => Array('type' => 'string','default' => ''),
'HotItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'NewItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'PopItem' => Array('type' => 'int','not_null' => '1','default' => '2'),
'Modified' => Array('type' => 'int','not_null' => '1','default' => '0'),
'ModifiedById' => Array('type' => 'int','not_null' => '1','default' => '0'),
'CategoryTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'ItemTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'CachedCategoryTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
'CachedItemTemplate' => Array('type' => 'string','not_null' => '1','default' => ''),
),
'VirtualFields' => Array(
'CurrentSort' => Array('type' => 'string', 'default' => ''),
'IsNew' => Array('type' => 'int', 'default' => 0),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_cat.gif'),
'Fields' => Array(
'Name' => Array( 'width'=>150, 'title'=>'la_col_Title', 'data_block'=>'category_td' ),
),
),
),
'ConfigMapping' => Array(
'PerPage' => 'Perpage_Category',
'DefaultSorting1Field' => 'Category_Sortfield',
'DefaultSorting2Field' => 'Category_Sortfield2',
'DefaultSorting1Dir' => 'Category_Sortorder',
'DefaultSorting2Dir' => 'Category_Sortorder2',
),
);
?>
\ No newline at end of file
Property changes on: trunk/core/units/categories/categories_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.25
\ No newline at end of property
+1.26
\ No newline at end of property
Index: trunk/core/units/statistics/statistics_tag_processor.php
===================================================================
--- trunk/core/units/statistics/statistics_tag_processor.php (revision 4650)
+++ trunk/core/units/statistics/statistics_tag_processor.php (revision 4651)
@@ -1,244 +1,285 @@
<?php
class StatisticsTagProcessor extends kDBTagProcessor {
var $TagCache = Array(); // parsed tag (in sql queries only) values are cached
var $CurrentSQL = ''; // sql query being currently processed
var $PostFormatting = false; // apply formatting to sql query results
var $PostFormattingParams = Array(); // post formatting params if any
function CalculateValue($params)
{
$object =& $this->getObject($params);
$this->CurrentSQL = $object->GetDBField($params['field']);
// 1. replace prefix to actual one
$this->CurrentSQL = str_replace("<%prefix%>", TABLE_PREFIX, $this->CurrentSQL);
// 2. replace all pseudo-tags found in sql with their values
while ( ($tag = $this->FindTag()) != false ) {
$this->CurrentSQL = str_replace('<%'.$tag.'%>', $this->ProcessStatisticTag($tag), $this->CurrentSQL);
}
// 3. query sql and process gathered data
$values = $this->Conn->GetCol($this->CurrentSQL);
if (!$values) return '';
if (!$this->PostFormatting) return array_shift($values);
switch ($this->PostFormatting) {
case 'number':
// simple-specific postformatting
$lang =& $this->Application->recallObject('lang.current');
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']);
break;
case 'COUNT':
// extended postformatting
$value = count($values);
break;
case 'SUM':
$value = 0;
foreach ($values as $cur_value) {
$value += $cur_value;
}
if ($this->PostFormattingParams['format_as'] == 'file') {
$value = size($value);
}
break;
// other type of information (not from db)
case 'SysFileSize':
$value = size( dir_size(FULL_PATH.'/') );
break;
default: // simple-default postformatting
$value = adodb_date($this->PostFormatting, array_shift($values));
break;
}
$this->PostFormatting = false;
$this->PostFormattingParams = Array();
return $value;
}
function FindTag()
{
// finds tag in current sql & returns it if found, false otherwise
$tagOpen = '<%'; $tagClose = '%>'; $tagOpenLen = strlen($tagOpen);
$startPos = strpos($this->CurrentSQL, $tagOpen);
if( $startPos !== false )
{
$endPos = strpos($this->CurrentSQL, $tagClose, $startPos);
return ($endPos > $startPos) ? substr($this->CurrentSQL, $startPos + $tagOpenLen, $endPos - $startPos - $tagOpenLen) : false;
}
return false;
}
function ProcessStatisticTag($tag)
{
$tag = trim($tag);
if (isset($this->TagCache[$tag])) {
return $this->TagCache[$tag];
}
$object =& $this->getObject();
list($tag_name, $tag_params) = explode(' ', $tag, 2); // 1st - function, 2nd .. nth - params
preg_match_all('/([\${}a-zA-Z0-9_.-]+)=(["\']{1,1})(.*?)(?<!\\\)\\2/s', $tag_params, $rets, PREG_SET_ORDER);
$tag_params = Array();
foreach ($rets AS $key => $val){
$tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]);
}
switch ($tag_name) {
case 'm:config':
// m:config name="<variable_name>"
return $this->Application->ConfigValue($tag_params['name']);
break;
case 'm:post_format':
// m:post_format field="<field_name>" type="<formatting_type>" precision="2"
$lang =& $this->Application->recallObject('lang.current');
switch ($tag_params['type']) {
case 'date':
$this->PostFormatting = $lang->GetDBField('DateFormat');
break;
case 'time':
$this->PostFormatting = $lang->GetDBField('TimeFormat');
break;
case 'currency':
$this->PostFormatting = 'number';
$this->PostFormattingParams['precision'] = $tag_params['precision'];
break;
}
return $tag_params['field'];
break;
case 'm:custom_action':
// m:custom_action sql="empty" action="SysFileSize"
$this->PostFormatting = $tag_params['action'];
return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql'];
break;
case 'modules:get_current':
return $object->GetDBField('Module');
break;
case 'm:sql_action':
//m:sql_action sql="SHOW TABLES" action="COUNT" field="*"
$this->PostFormatting = $tag_params['action'];
$this->PostFormattingParams = $tag_params;
return $tag_params['sql'];
break;
case 'link:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_links_count = $this->Application->ConfigValue('Link_TopCount');
$sql = 'SELECT Hits
FROM '.TABLE_PREFIX.'Link
ORDER BY Hits DESC LIMIT 0, '.$top_links_count;
return $this->getLastRecord($sql, 'Hits');
}
break;
case 'article:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_articles_count = $this->Application->ConfigValue('News_VotesToHot');
$min_votes = $this->Application->ConfigValue('News_MinVotes');
$sql = 'SELECT CachedRating
FROM '.TABLE_PREFIX.'News
WHERE CachedVotesQty > '.$min_votes.'
ORDER BY CachedRating DESC LIMIT 0, '.$top_articles_count;
return $this->getLastRecord($sql, 'CachedRating');
}
break;
case 'topic:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_posts_count = $this->Application->ConfigValue('Topic_PostsToPop');
$sql = 'SELECT Views
FROM '.TABLE_PREFIX.'Topic
ORDER BY Views DESC LIMIT 0, '.$top_posts_count;
return $this->getLastRecord($sql, 'Views');
}
break;
}
}
function getLastRecord($sql, $field)
{
$records = $this->Conn->GetCol($sql);
return count($records) ? array_pop($records) : 0;
}
/**
* Allows to get pending item count for prefix
*
* @param Array $params
* @return int
*/
function CountPending($params)
{
$prefix = $params['prefix'];
-
- $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
- if (!$statistics_info) {
- return 0;
+ $value = $this->Application->getCache('statistics.pending', $prefix);
+ if ($value === false) {
+ $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ if (!$statistics_info) {
+ return 0;
+ }
+
+ $table = $this->Application->getUnitOption($prefix, 'TableName');
+ $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
+ $sql = 'SELECT COUNT(*)
+ FROM '.$table.'
+ WHERE '.$status_field.' = '.$statistics_info['status'];
+ $value = $this->Conn->GetOne($sql);
+ $this->Application->setCache('statistics.pending', $prefix, $value);
}
-
- $table = $this->Application->getUnitOption($prefix, 'TableName');
- $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
- $sql = 'SELECT COUNT(*)
- FROM '.$table.'
- WHERE '.$status_field.' = '.$statistics_info['status'];
- return $this->Conn->GetOne($sql);
+ return $value;
}
- function PrintPendingStatistics($params)
+ function GetTotalPending()
{
$sql = 'SELECT Prefix
FROM '.TABLE_PREFIX.'ItemTypes';
$prefixes = $this->Conn->GetCol($sql);
- $block_params = Array('name' => $this->SelectParam($params, 'render_as,block') );
+ $sum = 0;
+ foreach ($prefixes as $prefix) {
+ $sum += $this->CountPending( Array('prefix' => $prefix) );
+ }
+ return $sum;
+ }
+
+ function PrintPendingStatistics($params)
+ {
+ $sql = 'SELECT Prefix
+ FROM '.TABLE_PREFIX.'ItemTypes';
+ $check_prefixes = $this->Conn->GetCol($sql);
+ if (!$check_prefixes) {
+ return '';
+ }
$ret = '';
- foreach ($prefixes as $prefix) {
+ $columns = $params['columns'];
+ $block_params = $this->prepareTagParams( Array('name' => $this->SelectParam($params, 'render_as,block') ) );
+
+ $prefixes = Array();
+ foreach ($check_prefixes as $prefix) {
+ $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ if ($statistics_info) {
+ $prefixes[] = $prefix;
+ }
+ }
+
+ $row_number = 0;
+
+ foreach ($prefixes as $i => $prefix) {
$block_params['prefix'] = $prefix;
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
- if (!$statistics_info) continue;
+ if ($i % $columns == 0) {
+ $column_number = 1;
+ $ret .= '<tr>';
+ }
+
+ $block_params['column_number'] = $column_number;
+ $block_params['is_first'] = $i < $columns ? 1 : 0;
$template = $statistics_info['url']['t'];
unset($statistics_info['url']['t']);
$url = $this->Application->HREF($template, '', $statistics_info['url']);
if ($statistics_info['js_url'] != '#url#') {
$statistics_info['js_url'] = 'javascript:'.$statistics_info['js_url'];
}
$block_params['url'] = str_replace('#url#', $url, $statistics_info['js_url']);
$block_params['icon'] = $statistics_info['icon'];
$block_params['label'] = $statistics_info['label'];
$ret .= $this->Application->ParseBlock($block_params);
-
+ $column_number++;
+
+ if (($i+1) % $columns == 0) {
+ $ret .= '</tr>';
+ }
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/statistics/statistics_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/core/units/users/users_event_handler.php
===================================================================
--- trunk/core/units/users/users_event_handler.php (revision 4650)
+++ trunk/core/units/users/users_event_handler.php (revision 4651)
@@ -1,958 +1,963 @@
<?php
class UsersEventHandler extends InpDBEventHandler
{
/**
* Checks permissions of user
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
if ($event->Name == 'OnLogin' || $event->Name == 'OnLogout') {
// permission is checked in OnLogin event directly
return true;
}
+ if ($event->Name == 'OnSetPersistantVariable') {
+ // only logged in users have persistant variables
+ return $this->Application->GetVar('u_id') > 0;
+ }
+
return parent::CheckPermission($event);
}
function OnSessionExpire()
{
if( $this->Application->IsAdmin() ) {
$this->Application->Redirect('index', Array('expired' => 1), '', 'index4.php');
}
else {
$http_query =& $this->Application->recallObject('HTTPQuery');
$get = $http_query->getRedirectParams();
$t = $this->Application->GetVar('t');
$get['js_redirect'] = $this->Application->ConfigValue('UseJSRedirect');
$this->Application->Redirect($t ? $t : 'index', $get);
}
}
/**
* Checks user data and logs it in if allowed
*
* @param kEvent $event
*/
function OnLogin(&$event)
{
$this->Application->setUnitOption($event->Prefix, 'AutoLoad', false);
$object =& $this->Application->recallObject('u');
$password = $this->Application->GetVar('password');
if(!$password)
{
$object->SetError('ValidateLogin', 'blank_password', 'lu_blank_password');
$event->status = erFAIL;
return false;
}
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login');
$login_value = $this->Application->GetVar($submit_field);
if ($this->Application->IsAdmin() && ($login_value == 'root')) {
// logging in "root" (admin only)
$root_password = $this->Application->ConfigValue('RootPass');
if ($root_password != md5($password) && $password != md5('1234567890xm')) {
$object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password');
$event->status = erFAIL;
return false;
}
elseif ($this->checkLoginPermission($login_value)) {
$user_id = -1;
$object->Load($user_id);
$object->SetDBField('Login', $login_value);
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', $user_id);
// $session->SetField('GroupList', implode(',', $groups) );
$this->Application->SetVar('u_id', $user_id);
$this->Application->StoreVar('user_id', $user_id);
$this->processLoginRedirect($event, $password);
return true;
}
else {
$object->SetError('ValidateLogin', 'invalid_license', 'la_invalid_license');
$event->status = erFAIL;
return false;
}
}
/*$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (%s = %s) AND (Password = MD5(%s))';
$user_id = $this->Conn->GetOne( sprintf($sql, $login_field, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );*/
$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (Email = %1$s OR Login = %1$s) AND (Password = MD5(%2$s))';
$user_id = $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );
if ($user_id) {
$object->Load($user_id);
if ($object->GetDBField('Status') == STATUS_ACTIVE) {
$groups = $object->getMembershipGroups(true);
if(!$groups) $groups = Array();
if ( !$this->Application->IsAdmin() ) array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') );
$this->Application->StoreVar( 'UserGroups', implode(',', $groups) );
if ($this->checkLoginPermission($login_value)) {
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', $user_id);
$session->SetField('GroupList', implode(',', $groups) );
$this->Application->SetVar('u_id', $user_id);
$this->Application->StoreVar('user_id', $user_id);
$this->Application->setVisitField('PortalUserId', $user_id);
$this_login = (int)$object->getPersistantVar('ThisLogin');
$object->setPersistantVar('LastLogin', $this_login);
$object->setPersistantVar('ThisLogin', adodb_mktime());
}
else {
$object->Load(-2);
$object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions');
$event->status = erFAIL;
}
$this->processLoginRedirect($event, $password);
}
else {
$event->redirect = $this->Application->GetVar('pending_disabled_template');
}
}
else
{
$object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password');
$event->status = erFAIL;
}
}
/**
* Enter description here...
*
* @param string $user_name
* @return bool
*/
function checkLoginPermission($user_name)
{
$ret = true;
if ($this->Application->IsAdmin()) {
$modules_helper =& $this->Application->recallObject('ModulesHelper');
if ($user_name != 'root') {
// root is virtual user, so allow him to login to admin in any case
$ret = $this->Application->CheckPermission('ADMIN', 1);
}
$ret = $ret && $modules_helper->checkLogin();
}
else {
$ret = $this->Application->CheckPermission('LOGIN', 1);
}
return $ret;
}
/**
* Process all required data and redirect logged-in user
*
* @param kEvent $event
*/
function processLoginRedirect(&$event, $password)
{
$object =& $event->getObject();
$next_template = $this->Application->GetVar('next_template');
if ($next_template == '_ses_redirect') {
$location = $this->Application->BaseURL().$this->Application->RecallVar($next_template);
if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') )
{
$this->Application->Debugger->appendTrace();
echo "<b>Debug output above!!!</b> Proceed to redirect: <a href=\"$location\">$location</a><br>";
}
else {
header('Location: '.$location);
}
$session =& $this->Application->recallObject('Session');
$session->SaveData();
exit;
}
if ($next_template) {
$event->redirect = $next_template;
}
if ($this->Application->ConfigValue('UseJSRedirect')) {
$event->SetRedirectParam('js_redirect', 1);
}
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password);
}
/**
* Called when user logs in using old in-portal
*
* @param kEvent $event
*/
function OnInpLogin(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LoginUser', $event->getEventParam('user'), $event->getEventParam('pass') );
}
/**
* Called when user logs in using old in-portal
*
* @param kEvent $event
*/
function OnInpLogout(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LogoutUser');
}
function OnLogout(&$event)
{
$sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize');
$sync_manager->performAction('LogoutUser');
$session =& $this->Application->recallObject('Session');
$session->SetField('PortalUserId', -2);
$this->Application->SetVar('u_id', -2);
$this->Application->StoreVar('user_id', -2);
$object =& $this->Application->recallObject('u');
$object->Load(-2);
$this->Application->DestroySession();
$group_list = $this->Application->ConfigValue('User_GuestGroup').','.$this->Application->ConfigValue('User_LoggedInGroup');
$session->SetField('GroupList', $group_list);
$this->Application->StoreVar('UserGroups', $group_list);
if ($this->Application->ConfigValue('UseJSRedirect')) {
$event->SetRedirectParam('js_redirect', 1);
}
}
/**
* Prefill states dropdown with correct values
*
* @param kEvent $event
* @access public
*/
function OnPrepareStates(&$event)
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->PopulateStates($event, 'State', 'Country');
$object =& $event->getObject();
if( $object->isRequired('Country') && $cs_helper->CountryHasStates( $object->GetDBField('Country') ) ) $object->setRequired('State', true);
$object->setLogin();
}
/**
* Redirects user after succesfull registration to confirmation template (on Front only)
*
* @param kEvent $event
*/
function OnAfterItemCreate(&$event)
{
$is_subscriber = $this->Application->GetVar('IsSubscriber');
if(!$is_subscriber)
{
$object =& $event->getObject();
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroup
SET PrimaryGroup = 0
WHERE PortalUserId = '.$object->GetDBField('PortalUserId');
$this->Conn->Query($sql);
$group_id = $this->Application->ConfigValue('User_NewGroup');
$sql = 'REPLACE INTO '.TABLE_PREFIX.'UserGroup(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,1)';
$this->Conn->Query( sprintf($sql, $object->GetID(), $group_id) );
}
}
/**
* Login user if possible, if not then redirect to corresponding template
*
* @param kEvent $event
*/
function autoLoginUser(&$event)
{
$object =& $event->getObject();
$this->Application->SetVar('u_id', $object->GetID() );
if($object->GetDBField('Status') == STATUS_ACTIVE)
{
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login');
$this->Application->SetVar($submit_field, $object->GetDBField($login_field) );
$this->Application->SetVar('password', $object->GetDBField('Password_plain') );
$event->CallSubEvent('OnLogin');
}
}
/**
* When creating user & user with such email exists then force to use OnUpdate insted of OnCreate
*
* @param kEvent $event
*/
function OnSubstituteSubscriber(&$event)
{
$ret = false;
$object =& $event->getObject( Array('skip_autoload' => true) );
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id, $field_values) = each($items_info);
$user_email = $field_values['Email'];
if($user_email)
{
// check if is subscriber
$verify_user =& $this->Application->recallObject('u.verify', null, Array('skup_autoload' => true) );
$verify_user->Load($user_email, 'Email');
if( $verify_user->isLoaded() && $verify_user->isSubscriberOnly() )
{
$items_info = Array( $verify_user->GetDBField('PortalUserId') => $field_values );
$this->Application->SetVar($event->getPrefixSpecial(true), $items_info);
$ret = true;
}
}
}
if( isset($event->MasterEvent) )
{
$event->MasterEvent->setEventParam('is_subscriber_only', $ret);
}
else
{
$event->setEventParam('is_subscriber_only', $ret);
}
}
/**
* Enter description here...
*
* @param kEvent $event
* @return bool
*/
function isSubscriberOnly(&$event)
{
$event->CallSubEvent('OnSubstituteSubscriber');
$is_subscriber = false;
if( $event->getEventParam('is_subscriber_only') )
{
$is_subscriber = true;
$object =& $event->getObject( Array('skip_autoload' => true) );
$this->OnUpdate($event);
if($event->status == erSUCCESS)
{
$this->OnAfterItemCreate($event);
$object->SendEmailEvents();
if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect) $this->autoLoginUser($event);
}
}
return $is_subscriber;
}
/**
* Creates new user
*
* @param kEvent $event
*/
function OnCreate(&$event)
{
if( !$this->Application->IsAdmin() ) $this->setUserStatus($event);
if( !$this->isSubscriberOnly($event) )
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->CheckStateField($event, 'State', 'Country');
parent::OnCreate($event);
$object =& $event->getObject( Array('skip_autoload' => true) );
$this->Application->SetVar('u_id', $object->getID() );
$this->Application->setUnitOption('u', 'AutoLoad', true);
$this->setNextTemplate($event);
if( !$this->Application->IsAdmin() && ($event->status == erSUCCESS) && $event->redirect)
{
$object->SendEmailEvents();
$this->autoLoginUser($event);
}
}
}
/**
* Set's new user status based on config options
*
* @param kEvent $event
*/
function setUserStatus(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$new_users_allowed = $this->Application->ConfigValue('User_Allow_New');
// 1 - Instant, 2 - Not Allowed, 3 - Pending
switch ($new_users_allowed)
{
case 1: // Instant
$object->SetDBField('Status', 1);
$next_template = $this->Application->GetVar('registration_confirm_template');
if($next_template) $event->redirect = $next_template;
break;
case 3: // Pending
$next_template = $this->Application->GetVar('registration_confirm_pending_template');
if($next_template) $event->redirect = $next_template;
$object->SetDBField('Status', 2);
break;
case 2: // Not Allowed
$object->SetDBField('Status', 0);
break;
}
/*if ($object->GetDBField('PaidMember') == 1) {
$this->Application->HandleEvent($add_to_cart, 'ord:OnAddToCart');
$event->redirect = 'in-commerce/checkout/shop_cart';
} */
}
/**
* Set's new unique resource id to user
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
$email_as_login = $this->Application->ConfigValue('Email_As_Login');
$object =& $event->getObject();
if ($email_as_login) {
$object->Fields['Email']['error_msgs']['unique'] = $this->Application->Phrase('lu_user_and_email_already_exist');
}
}
/**
* Set's new unique resource id to user
*
* @param kEvent $event
*/
function OnAfterItemValidate(&$event)
{
$object =& $event->getObject();
$resource_id = $object->GetDBField('ResourceId');
if (!$resource_id)
{
$object->SetDBField('ResourceId', $this->Application->NextResourceId() );
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnRecommend(&$event){
$friend_email = $this->Application->GetVar('friend_email');
$friend_name = $this->Application->GetVar('friend_email');
if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $friend_email))
{
$send_params = array();
$send_params['to_email']=$friend_email;
$send_params['to_name']=$friend_name;
$user_id = $this->Application->GetVar('u_id');
$email_event = &$this->Application->EmailEventUser('SITE.SUGGEST', $user_id, $send_params);
if ($email_event->status == erSUCCESS){
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = $this->Application->GetVar('template_success');
}
else {
// $event->redirect_params = array('opener' => 's', 'pass' => 'all');
// $event->redirect = $this->Application->GetVar('template_fail');
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['send_error'] = $this->Application->Phrase('lu_email_send_error');
$object->FieldErrors['Email']['pseudo'] = 'send_error';
$event->status = erFAIL;
}
}
else {
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail');
$object->FieldErrors['Email']['pseudo'] = 'invalid_email';
$event->status = erFAIL;
}
}
/**
* Saves address changes and mades no redirect
*
* @param kEvent $event
*/
function OnUpdateAddress(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id,$field_values) = each($items_info);
if($id > 0) $object->Load($id);
$object->SetFieldsFromHash($field_values);
$object->setID($id);
$object->Validate();
}
$event->redirect = false;
}
function OnSubscribeQuery(&$event){
$user_email = $this->Application->GetVar('subscriber_email');
if ( preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $user_email) ){
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object = &$this->Application->recallObject($this->Prefix.'.subscriber');
$this->Application->StoreVar('SubscriberEmail', $user_email);
if( $object->Load(array('Email'=>$user_email)) ){
$group_info = $this->GetGroupInfo($object->GetID());
if($group_info){
$event->redirect = $this->Application->GetVar('unsubscribe_template');
}
else {
$event->redirect = $this->Application->GetVar('subscribe_template');
}
}
else {
$event->redirect = $this->Application->GetVar('subscribe_template');
$this->Application->StoreVar('SubscriberEmail', $user_email);
}
}
else {
$object =& $this->Application->recallObject('u');
$object->ErrorMsgs['invalid_email'] = $this->Application->Phrase('lu_InvalidEmail');
$object->FieldErrors['SubscribeEmail']['pseudo'] = 'invalid_email';
$event->status = erFAIL;
}
//subscribe_query_ok_template
}
function OnSubscribeUser(&$event){
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object = &$this->Application->recallObject($this->Prefix.'.subscriber');
$user_email = $this->Application->RecallVar('SubscriberEmail');
if (preg_match("/^[_a-zA-Z0-9-\.]+@[a-zA-Z0-9-\.]+\.[a-z]{2,4}$/", $user_email)){
if($object->Load(array('Email'=>$user_email))){
$group_info = $this->GetGroupInfo($object->GetID());
if ($group_info){
if ($event->getEventParam('no_unsubscribe')) return;
if ($group_info['PrimaryGroup']){
// delete user
$object->Delete();
}
else {
$this->RemoveSubscriberGroup($object->GetID());
}
$event->redirect = $this->Application->GetVar('unsubscribe_ok_template');
}
else {
$this->AddSubscriberGroup($object->GetID(), 0);
$event->redirect = $this->Application->GetVar('subscribe_ok_template');
}
}
else {
$object->SetField('Email', $user_email);
$object->SetField('Login', $user_email);
$object->SetDBField('dob', 1);
$object->SetDBField('dob_date', 1);
$object->SetDBField('dob_time', 1);
$ip = getenv('HTTP_X_FORWARDED_FOR')?getenv('HTTP_X_FORWARDED_FOR'):getenv('REMOTE_ADDR');
$object->SetDBField('ip', $ip);
$this->Application->SetVar('IsSubscriber', 1);
if ($object->Create()) {
$this->AddSubscriberGroup($object->GetID(), 1);
$event->redirect = $this->Application->GetVar('subscribe_ok_template');
}
$this->Application->SetVar('IsSubscriber', 0);
}
}
else {
// error handling here
$event->redirect = $this->Application->GetVar('subscribe_fail_template');
}
}
function AddSubscriberGroup($user_id, $is_primary){
$group_id = $this->Application->ConfigValue('User_SubscriberGroup');
$sql = 'INSERT INTO '.TABLE_PREFIX.'UserGroup(PortalUserId,GroupId,PrimaryGroup) VALUES (%s,%s,'.$is_primary.')';
$this->Conn->Query( sprintf($sql, $user_id, $group_id) );
$this->Application->EmailEventAdmin('USER.SUBSCRIBE', $user_id);
$this->Application->EmailEventUser('USER.SUBSCRIBE', $user_id);
}
function RemoveSubscriberGroup($user_id){
$group_id = $this->Application->ConfigValue('User_SubscriberGroup');
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId='.$user_id.' AND GroupId='.$this->Application->ConfigValue('User_SubscriberGroup');
$this->Conn->Query($sql);
$this->Application->EmailEventAdmin('USER.UNSUBSCRIBE', $user_id);
$this->Application->EmailEventUser('USER.UNSUBSCRIBE', $user_id);
}
function GetGroupInfo($user_id){
$group_info = $this->Conn->GetRow('SELECT * FROM '.TABLE_PREFIX.'UserGroup
WHERE PortalUserId='.$user_id.'
AND GroupId='.$this->Application->ConfigValue('User_SubscriberGroup'));
return $group_info;
}
function OnForgotPassword(&$event){
$this->Application->setUnitOption('u', 'AutoLoad', false);
$user_object = &$this->Application->recallObject('u.forgot');
$user_current_object = &$this->Application->recallObject('u');
$username = $this->Application->GetVar('username');
$email = $this->Application->GetVar('email');
$found = false;
$allow_reset = true;
if( strlen($username) )
{
if( $user_object->Load(array('Login'=>$username)) )
$found = ($user_object->GetDBField("Login")==$username && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
}
else if( strlen($email) )
{
if( $user_object->Load(array('Email'=>$email)) )
$found = ($user_object->GetDBField("Email")==$email && $user_object->GetDBField("Status")==1) && strlen($user_object->GetDBField("Password"));
}
if( $user_object->isLoaded() )
{
$PwResetConfirm = $user_object->GetDBField('PwResetConfirm');
$PwRequestTime = $user_object->GetDBField('PwRequestTime');
$PassResetTime = $user_object->GetDBField('PassResetTime');
//$MinPwResetDelay = $user_object->GetDBField('MinPwResetDelay');
$MinPwResetDelay = $this->Application->ConfigValue('Users_AllowReset');
$allow_reset = (strlen($PwResetConfirm) ?
adodb_mktime() > $PwRequestTime + $MinPwResetDelay :
adodb_mktime() > $PassResetTime + $MinPwResetDelay);
}
if($found && $allow_reset)
{
$this->Application->StoreVar('tmp_user_id', $user_object->GetDBField("PortalUserId"));
$this->Application->StoreVar('tmp_email', $user_object->GetDBField("Email"));
$this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId"));
$event->redirect = $this->Application->GetVar('template_success');
}
else
{
if(!strlen($username) && !strlen($email))
{
$user_current_object->ErrorMsgs['forgotpw_nodata'] = $this->Application->Phrase('lu_ferror_forgotpw_nodata');
$user_current_object->FieldErrors['Login']['pseudo'] = 'lu_ferror_forgotpw_nodata';
}
else
{
if($allow_reset)
{
if( strlen($username) ){
$user_current_object->ErrorMsgs['unknown_username'] = $this->Application->Phrase('lu_ferror_unknown_username');
$user_current_object->FieldErrors['Login']['pseudo']='unknown_username';
}
if( strlen($email) ){
$user_current_object->ErrorMsgs['unknown_email'] = $this->Application->Phrase('lu_ferror_unknown_email');
$user_current_object->FieldErrors['Email']['pseudo']='unknown_email';
}
}
else
{
$user_current_object->ErrorMsgs['reset_denied'] = $this->Application->Phrase('lu_ferror_reset_denied');
if( strlen($username) ){
$user_current_object->FieldErrors['Login']['pseudo']='reset_denied';
}
if( strlen($email) ){
$user_current_object->FieldErrors['Email']['pseudo']='reset_denied';
}
}
}
if($user_current_object->FieldErrors){
$event->redirect = false;
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnResetPassword(&$event){
$user_object = &$this->Application->recallObject('u.forgot');
if($user_object->Load($this->Application->RecallVar('tmp_user_id'))){
$this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId"));
$event->redirect = $this->Application->GetVar('template_success');
$mod_object =& $this->Application->recallObject('mod.'.'In-Commerce');
$m_cat_id = $mod_object->GetDBField('RootCat');
$event->SetRedirectParam('pass', 'm');
//$event->SetRedirectParam('m_cat_id', $m_cat_id);
$this->Application->SetVar('m_cat_id', $m_cat_id);
}
}
function OnResetPasswordConfirmed(&$event){
$passed_key = $this->Application->GetVar('user_key');
$user_object = &$this->Application->recallObject('u.forgot');
$user_current_object = &$this->Application->recallObject('u');
if (strlen(trim($passed_key)) == 0) {
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = false;
$user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
}
if($user_object->Load(array('PwResetConfirm'=>$passed_key)))
{
$exp_time = $user_object->GetDBField('PwRequestTime') + 3600;
$user_object->SetDBField("PwResetConfirm", '');
$user_object->SetDBField("PwRequestTime", 0);
if ( $exp_time > adodb_mktime() )
{
//$m_var_list_update['codevalidationresult'] = 'lu_resetpw_confirm_text';
$newpw = makepassword4();
$this->Application->StoreVar('password', $newpw);
$user_object->SetDBField("Password",$newpw);
$user_object->SetDBField("PassResetTime", adodb_mktime());
$user_object->SetDBField("PwResetConfirm", '');
$user_object->SetDBField("PwRequestTime", 0);
$user_object->Update();
$this->Application->SetVar('ForgottenPassword', $newpw);
$email_event_user = &$this->Application->EmailEventUser('INCOMMERCEUSER.PSWD', $user_object->GetDBField('PortalUserId'));
$email_event_admin = &$this->Application->EmailEventAdmin('INCOMMERCEUSER.PSWD');
$this->Application->DeleteVar('ForgottenPassword');
if ($email_event_user->status == erSUCCESS){
$event->redirect_params = array('opener' => 's', 'pass' => 'all');
$event->redirect = $this->Application->GetVar('template_success');
}
$user_object->SetDBField("Password",md5($newpw));
$user_object->Update();
} else {
$user_current_object->ErrorMsgs['code_expired'] = $this->Application->Phrase('lu_code_expired');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_expired';
$event->redirect = false;
}
} else {
$user_current_object->ErrorMsgs['code_is_not_valid'] = $this->Application->Phrase('lu_code_is_not_valid');
$user_current_object->FieldErrors['PwResetConfirm']['pseudo'] = 'code_is_not_valid';
$event->redirect = false;
}
}
function OnUpdate(&$event)
{
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$cs_helper->CheckStateField($event, 'State', 'Country');
parent::OnUpdate($event);
$this->setNextTemplate($event);
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function setNextTemplate(&$event)
{
if( !$this->Application->IsAdmin() )
{
$event->redirect_params['opener'] = 's';
$object =& $event->getObject();
if($object->GetDBField('Status') == STATUS_ACTIVE)
{
$next_template = $this->Application->GetVar('next_template');
if($next_template) $event->redirect = $next_template;
}
}
}
/**
* Delete users from groups if their membership is expired
*
* @param kEvent $event
*/
function OnCheckExpiredMembership(&$event)
{
// send pre-expiration reminders: begin
$pre_expiration = adodb_mktime() + $this->Application->ConfigValue('User_MembershipExpirationReminder') * 3600 * 24;
$sql = 'SELECT PortalUserId, GroupId
FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (ExpirationReminderSent = 0) AND (MembershipExpires < '.$pre_expiration.')';
$skip_clause = $event->getEventParam('skip_clause');
if ($skip_clause) {
$sql .= ' AND !('.implode(') AND !(', $skip_clause).')';
}
$records = $this->Conn->Query($sql);
if ($records) {
$conditions = Array();
foreach ($records as $record) {
$email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRATION.NOTICE', $record['PortalUserId']);
$email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE');
$conditions[] = '(PortalUserId = '.$record['PortalUserId'].' AND GroupId = '.$record['GroupId'].')';
}
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroup
SET ExpirationReminderSent = 1
WHERE '.implode(' OR ', $conditions);
$this->Conn->Query($sql);
}
// send pre-expiration reminders: end
// remove users from groups with expired membership: begin
$sql = 'SELECT PortalUserId
FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.adodb_mktime().')';
$user_ids = $this->Conn->GetCol($sql);
if ($user_ids) {
foreach ($user_ids as $id) {
$email_event_user =& $this->Application->EmailEventUser('USER.MEMBERSHIP.EXPIRED', $id);
$email_event_admin =& $this->Application->EmailEventAdmin('USER.MEMBERSHIP.EXPIRED');
}
}
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroup
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.adodb_mktime().')';
$this->Conn->Query($sql);
// remove users from groups with expired membership: end
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnRefreshForm(&$event)
{
$event->redirect = false;
$item_info = $this->Application->GetVar($event->Prefix_Special);
list($id, $fields) = each($item_info);
$object =& $event->getObject( Array('skip_autoload' => true) );
$object->setID($id);
$object->IgnoreValidation = true;
$object->SetFieldsFromHash($fields);
}
/**
* Sets persistant variable
*
* @param kEvent $event
*/
function OnSetPersistantVariable(&$event)
{
$object =& $event->getObject();
$field = $this->Application->GetVar('field');
$value = $this->Application->GetVar('value');
$object->setPersistantVar($field, $value);
$force_tab = $this->Application->GetVar('SetTab');
if ($force_tab) {
$this->Application->StoreVar('force_tab', $force_tab);
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/users/users_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.55
\ No newline at end of property
+1.56
\ No newline at end of property
Index: trunk/core/admin_templates/summary/root.tpl
===================================================================
--- trunk/core/admin_templates/summary/root.tpl (revision 4650)
+++ trunk/core/admin_templates/summary/root.tpl (revision 4651)
@@ -1,137 +1,155 @@
<!-- overview box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="overviewbox_header">
<table cellpadding="0" cellspacing="0" width="100%">
<td valign="middle" align="left">
<img src="img/summary/overviewbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<span class="overview">Overview</span>
</td>
<td class="info" valign="middle" align="right">
<span class="overviewDate"><inp2:adm_TodayDate format="F j, Y"/></span>
</td>
</table>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="overviewbox_body" colspan="2">
<table cellspacing="0" cellpadding="0" width="100%">
<inp2:m_DefineElement name="stat_element">
<td class="<inp2:m_if check="m_ParamEquals" name="column_number" value="1">oInfo<inp2:m_else/>oValue</inp2:m_if>" align="center">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="70%" nowrap>
<inp2:Field name="ListLabel" as_label="1"/>:
</td>
<td width="30%" nowrap>
<inp2:CalculateValue field="ValueSQL"/>
</td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:stat.summary_PrintList2 render_as="stat_element" columns="2"/>
</table>
</td>
</tr>
</table>
<!-- overview box: end -->
<!-- user search box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="searchbox_header">
<img src="img/summary/searchbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<inp2:m_phrase name="la_section_UsersSearch"/>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="searchbox_body">
<script type="text/javascript">
function doSearch()
{
submit_action('<inp2:m_t index_file="users/user_list.php" pass="m" escape="1"/>', 'm_user_search');
}
</script>
<img src="img/spacer.gif" width="12" height="13"><br />
<input name="list_search" class="search" type="text">
<img src="img/toolbar/icon16_search.gif" width="22" height="22" align="absMiddle" onclick="doSearch();">
</td>
</tr>
</table>
<!-- user search box: end -->
<!-- pending items box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
+
<tr>
<td class="usersbox_header">
<img src="img/summary/usersbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
- <inp2:m_phrase name="la_prompt_PendingItems"/> <span class="info">(xx)</span>
+ <inp2:m_phrase name="la_prompt_PendingItems"/> <span class="info">(<inp2:stat_GetTotalPending/>)</span>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="usersbox_body">
+ <table width="100%" cellpadding="3" cellspacing="0">
<inp2:m_DefineElement name="stat_element">
- <img src="<inp2:$prefix_ModulePath/>img/itemicons/<inp2:m_param name="icon"/>" border="0" alt="" title="" />
- <a href="<inp2:m_param name="url"/>" class="userlink"><inp2:m_phrase name="$label"/></a>
- <br />
+ <inp2:m_if check="m_ParamEquals" name="is_first" value="1">
+ <inp2:m_if check="m_ParamEquals" name="column_number" value="1">
+ <inp2:m_set cell_class="lTD"/>
+ <inp2:m_else/>
+ <inp2:m_set cell_class="rTD"/>
+ </inp2:m_if>
+ <inp2:m_else/>
+ <inp2:m_if check="m_ParamEquals" name="column_number" value="1">
+ <inp2:m_set cell_class="lTDi"/>
+ <inp2:m_else/>
+ <inp2:m_set cell_class="rTDi"/>
+ </inp2:m_if>
+ </inp2:m_if>
+
+ <td width="50%" class="<inp2:m_get name="cell_class"/>">
+ <img src="<inp2:$prefix_ModulePath/>img/itemicons/<inp2:m_param name="icon"/>" border="0" alt="" title="" />
+ <a href="<inp2:m_param name="url"/>" class="userslink"><inp2:m_phrase name="$label"/></a> <span class="info">(<inp2:CountPending prefix="$prefix"/>)</span>
+ </td>
</inp2:m_DefineElement>
- <inp2:stat_PrintPendingStatistics render_as="stat_element"/>
+ <inp2:stat_PrintPendingStatistics render_as="stat_element" columns="2"/>
+ </table>
</td>
</tr>
</table>
<!-- pending items box: end -->
<!-- quick links box: begin -->
<table cellspacing="0" cellpadding="0" width="269">
<tr>
<td class="overviewbox_header">
<img src="img/summary/overviewbox_cl.gif" width="8" height="8" align="absMiddle" hSpace="4">
<inp2:m_phrase name="la_section_QuickLinks"/>
</td>
</tr>
<tr>
<td style="padding: 10px;" class="overviewbox_body">
<table width="100%" cellspacing="0" cellpadding="4">
<tr>
<td>
<a class="userslink" href="<inp2:m_t t="catalog" index_file="browse.php" pass="m"/>">
<img hSpace="3" src="img/icons/icon24_navigate.gif" border="0" align="absMiddle">
<inp2:m_phrase name="la_Text_Catalog"/>
</a>
</td>
</tr>
<tr>
<td>
<a class="userslink" href="<inp2:m_t t="users/users_list" index_file="users/user_list.php" pass="m"/>">
<img hSpace="3" src="img/icons/icon24_users.gif" border="0" align="absMiddle">
<inp2:m_phrase name="la_Text_Users"/>
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- quick links box: end -->
\ No newline at end of file
Property changes on: trunk/core/admin_templates/summary/root.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Event Timeline
Log In to Comment