Index: trunk/kernel/admin_templates/users/users_list.tpl =================================================================== diff -u -N -r7867 -r8796 --- trunk/kernel/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 7867) +++ trunk/kernel/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 8796) @@ -46,7 +46,13 @@ ) ); a_toolbar.AddButton( new ToolBarSeparator('sep2') ); - + + + a_toolbar.AddButton( new ToolBarButton('in-portal:e-mail', '', function() { + openSelector('u', '', 'UserEmail'); + } + ) ); + a_toolbar.AddButton( new ToolBarButton('view', '', function() { show_viewmenu(a_toolbar,'view'); } @@ -61,6 +67,6 @@ \ No newline at end of file Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r8786 -r8796 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8786) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8796) @@ -2043,6 +2043,8 @@ } } } + + $this->clearSelectedIDs($event); } /** Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r8729 -r8796 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8729) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8796) @@ -1015,8 +1015,6 @@ } } - - /** * Delete users from groups if their membership is expired * @@ -1243,6 +1241,99 @@ $virtual_users = Array (-1, -2); // root, Guest return ($object->GetDBField('Status') == STATUS_ACTIVE) || in_array($object->GetID(), $virtual_users); } + + /** + * Sends approved/declined email event on user status change + * + * @param kEvent $event + */ + function OnAfterItemUpdate(&$event) + { + $object =& $event->getObject(); + /* @var $object UsersItem */ + + if (!$this->Application->IsAdmin() || $object->IsTempTable()) { + return ; + } + + $this->sendStatusChangeEvent($object->GetID(), $object->GetOriginalField('Status'), $object->GetDBField('Status')); + } + + /** + * Stores user's original Status before overwriting with data from temp table + * + * @param kEvent $event + */ + function OnBeforeDeleteFromLive(&$event) + { + $user_status = $this->Application->GetVar('user_status'); + if (!$user_status) { + $user_status = Array (); + } + + $user_id = $event->getEventParam('id'); + if ($user_id > 0) { + $user_status[$user_id] = $this->getUserStatus($user_id); + $this->Application->SetVar('user_status', $user_status); + } + } + + /** + * Sends approved/declined email event on user status change (in temp tables during editing) + * + * @param kEvent $event + */ + function OnAfterCopyToLive(&$event) + { + $temp_id = $event->getEventParam('temp_id'); + if ($temp_id == 0) { + // this is new user create, don't send email events + return ; + } + + $new_status = $this->getUserStatus($temp_id); + $user_status = $this->Application->GetVar('user_status'); + + $this->sendStatusChangeEvent($temp_id, $user_status[$temp_id], $new_status); + } + + /** + * Returns user status (active, pending, disabled) based on ID and temp mode setting + * + * @param int $user_id + * @return int + */ + function getUserStatus($user_id) + { + $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); + + $sql = 'SELECT Status + FROM '.$table_name.' + WHERE '.$id_field.' = '.$user_id; + return $this->Conn->GetOne($sql); + } + + /** + * Sends approved/declined email event on user status change + * + * @param int $user_id + * @param int $prev_status + * @param int $new_status + */ + function sendStatusChangeEvent($user_id, $prev_status, $new_status) + { + $status_events = Array ( + STATUS_ACTIVE => 'USER.APPROVE', + STATUS_DISABLED => 'USER.DENY', + ); + $email_event = isset($status_events[$new_status]) ? $status_events[$new_status] : false; + + if (($prev_status != $new_status) && $email_event) { + $this->Application->EmailEventUser($email_event, $user_id); + $this->Application->EmailEventAdmin($email_event); + } + } } ?> \ No newline at end of file Index: trunk/core/units/user_profile/user_profile_config.php =================================================================== diff -u -N -r8636 -r8796 --- trunk/core/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8636) +++ trunk/core/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8796) @@ -14,7 +14,7 @@ 4 => 'mode', ), - 'IDField' => 'UserProfileId', + 'IDField' => 'VariableName', 'TableName' => TABLE_PREFIX.'PersistantSessionData', 'ForeignKey' => 'PortalUserId', @@ -31,10 +31,6 @@ 'VariableName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), 'VariableValue' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), ), - - 'VirtualFields' => Array ( - 'UserProfileId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,), - ), ); ?> \ No newline at end of file Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r8612 -r8796 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8612) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8796) @@ -1418,6 +1418,8 @@ } } } + + $this->clearSelectedIDs($event); } /** Index: trunk/kernel/units/user_profile/user_profile_config.php =================================================================== diff -u -N -r8636 -r8796 --- trunk/kernel/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8636) +++ trunk/kernel/units/user_profile/user_profile_config.php (.../user_profile_config.php) (revision 8796) @@ -14,7 +14,7 @@ 4 => 'mode', ), - 'IDField' => 'UserProfileId', + 'IDField' => 'VariableName', 'TableName' => TABLE_PREFIX.'PersistantSessionData', 'ForeignKey' => 'PortalUserId', @@ -31,10 +31,6 @@ 'VariableName' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), 'VariableValue' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), ), - - 'VirtualFields' => Array ( - 'UserProfileId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,), - ), ); ?> \ No newline at end of file Index: trunk/core/units/general/helpers/captcha_helper.php =================================================================== diff -u -N -r7391 -r8796 --- trunk/core/units/general/helpers/captcha_helper.php (.../captcha_helper.php) (revision 7391) +++ trunk/core/units/general/helpers/captcha_helper.php (.../captcha_helper.php) (revision 8796) @@ -2,22 +2,23 @@ class kCaptchaHelper extends kHelper { + var $width; + var $height; + function GenerateCaptchaCode($len = 5) { - $chars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $s = ''; - for ($i = 0; $i < $len; $i++) { - $s .= $chars[ rand(0, strlen($chars)-1) ]; - } - return $s; + $chars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $s = ''; + for ($i = 0; $i < $len; $i++) { + $s .= $chars[ rand(0, strlen($chars)-1) ]; + } + return $s; } - var $width; - var $height; - - function graphics($w, $h) { - $this->width = $w; - $this->height = $h; + function graphics($w, $h) + { + $this->width = $w; + $this->height = $h; } function GenerateCaptchaImage($rand, $width, $height, $filter_blur = false) @@ -46,8 +47,8 @@ imagettftext($image, $height*0.75, 0, floor(($width - $dimensions[4])/2), floor(($height - $dimensions[5])/2), $textColor, KERNEL_PATH.'/fonts/monofont.ttf', $rand); -// $font = imageloadfont(KERNEL_PATH.'/fonts/monofont.ttf'); -// imagestring($image, $font, 3, 0, $rand, $textColor); + // $font = imageloadfont(KERNEL_PATH.'/fonts/monofont.ttf'); + // imagestring($image, $font, 3, 0, $rand, $textColor); if ($filter_blur) $this->blur($image, 3); @@ -72,7 +73,8 @@ imagedestroy($image); } - function blur(&$gdimg, $radius = 5.0) { + function blur(&$gdimg, $radius = 5.0) + { // Taken from Torstein H�nsi's phpUnsharpMask (see phpthumb.unsharp.php) $radius = round(max(0, min($radius, 50)) * 2); Index: trunk/kernel/action.php =================================================================== diff -u -N -r7391 -r8796 --- trunk/kernel/action.php (.../action.php) (revision 7391) +++ trunk/kernel/action.php (.../action.php) (revision 8796) @@ -266,6 +266,8 @@ foreach($_POST["itemlist"] as $userid) { $user = $objUsers->GetItemByField("ResourceId",$userid); + /* @var $user clsPortalUser */ + $user->Approve(); } $objUsers->Clear(); @@ -276,6 +278,8 @@ foreach($_POST["itemlist"] as $userid) { $user = $objUsers->GetItemByField("ResourceId",$userid); + /* @var $user clsPortalUser */ + $user->Deny(); } $objUsers->Clear();