Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/commands
In directory usw-pr-cvs1:/tmp/cvs-serv1618/chat/lib/commands
Modified Files:
promote.cmd.php3
Log Message:
* new strings to use with the new privileges system
* add grantor (for Nicolas ;))
Index: promote.cmd.php3
===================================================================
RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/commands/promote.cmd.php3,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** promote.cmd.php3 2001/12/04 20:01:34 1.8
--- promote.cmd.php3 2001/12/05 19:33:44 1.9
***************
*** 63,94 ****
$targetLatin1 = ($targetCharset == 'iso-8859-1') ? 1 : 0;
$isCommand = true;
! // Promote the user if he/she is not administrator or already moderator
! // for the current room
$dbLink->query("SELECT right_level FROM " . C_RIGHT_TBL . " WHERE username = '$slashedTarget' AND room IN ('$slashedRoom', '') LIMIT 1");
list($targetPerms) = $dbLink->nextRecord();
$dbLink->cleanResults();
! if ($targetPerms == 10)
{
! $error = sprintf(L_ADMIN, $cmd[1]);
}
! else if (empty($targetPerms))
{
$doRefreshMessages = true;
$targetForNotifications = pmcSlashSingleQuotes(pmcSpecialChars($slashedTarget, $targetLatin1), 2);
$promoteTime = time();
! $dbLink->query("INSERT INTO " . C_RIGHT_TBL . " (username, room, right_level) VALUES ('$slashedTarget', '$slashedRoom', 5)");
! $dbLink->query("UPDATE " . C_USR_TBL . " SET status = 5 WHERE username = '$slashedTarget' AND room = '$slashedCurrentRoomName'");
$msgQuery = 'INSERT INTO ' . C_MSG_TBL . ' '
. '(room, username, m_time, color, msg_original, msg_enhanced) '
. 'VALUES ('
! . "'$slashedCurrentRoomName', 'SYS promote', $promoteTime, '#666699', 'sprintf(L_MODERATOR, \'$targetForNotifications\')', 'sprintf(L_MODERATOR, \'$targetForNotifications\')'"
. ')';
$dbLink->query($msgQuery);
$dbLink->query("UPDATE " . C_ROOM_TBL . " SET last_user_modif = $promoteTime WHERE room_name = '$slashedCurrentRoomName'");
- }
- else
- {
- $error = sprintf(L_IS_MODERATOR, $cmd[1]);
}
}
--- 63,106 ----
$targetLatin1 = ($targetCharset == 'iso-8859-1') ? 1 : 0;
$isCommand = true;
! // Promote the user if his current right level + 1 is lower than the
! // one of the grantor
$dbLink->query("SELECT right_level FROM " . C_RIGHT_TBL . " WHERE username = '$slashedTarget' AND room IN ('$slashedRoom', '') LIMIT 1");
list($targetPerms) = $dbLink->nextRecord();
$dbLink->cleanResults();
! if ($targetPerms >= $dbSessionVars['status'] - 1)
{
! $error = sprintf(L_CANT_PROMOTE, $cmd[1]);
}
! else
{
$doRefreshMessages = true;
$targetForNotifications = pmcSlashSingleQuotes(pmcSpecialChars($slashedTarget, $targetLatin1), 2);
$promoteTime = time();
+ $targetPerms = max(3, $targetPerms + 1);
! // Target user will become super-moderator or administrator
! if ($targetPerms > 5)
! {
! $dbLink->query("DELETE FROM " . C_RIGHT_TBL . " WHERE username = '$slashedTarget'");
! $dbLink->query("INSERT INTO " . C_RIGHT_TBL . " (username, room, right_level, grantor) VALUES ('$slashedTarget', '', $targetPerms, '$slashedNick')");
! }
! // Target user were a level 3 moderator for the room
! else if ($targetPerms > 3)
! {
! $dbLink->query("UPDATE " . C_RIGHT_TBL . " SET right_level = $targetPerms, grantor = '$slashedNick' WHERE username = '$slashedTarget' AND room = '$slashedRoom'");
! }
! // Target user were a simple user for the room
! else
! {
! $dbLink->query("INSERT INTO " . C_RIGHT_TBL . " (username, room, right_level, grantor) VALUES ('$slashedTarget', '$slashedRoom', $targetPerms, '$slashedNick')");
! }
! $dbLink->query("UPDATE " . C_USR_TBL . " SET status = $targetPerms WHERE username = '$slashedTarget' AND room = '$slashedCurrentRoomName'");
$msgQuery = 'INSERT INTO ' . C_MSG_TBL . ' '
. '(room, username, m_time, color, msg_original, msg_enhanced) '
. 'VALUES ('
! . "'$slashedCurrentRoomName', 'SYS promote', $promoteTime, '#666699', 'sprintf(L_PROMOTED, \'$targetForNotifications\', L_RIGHT_$targetPerms)', 'sprintf(L_PROMOTED, \'$targetForNotifications\', L_RIGHT_$targetPerms)'"
. ')';
$dbLink->query($msgQuery);
$dbLink->query("UPDATE " . C_ROOM_TBL . " SET last_user_modif = $promoteTime WHERE room_name = '$slashedCurrentRoomName'");
}
}
|