CC-2126: User should not be delete himself

Done.
This commit is contained in:
James Moon 2011-05-05 15:38:33 -07:00 committed by mkonecny
parent b9c1f7356f
commit 2a5df8bed9
2 changed files with 24 additions and 2 deletions

View File

@ -159,7 +159,25 @@ class User {
public static function getUsersDataTablesInfo($datatables_post) {
$fromTable = "cc_subjs";
return StoredFile::searchFiles($fromTable, $datatables_post);
// get current user
$username = "";
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->login;
}
$res = StoredFile::searchFiles($fromTable, $datatables_post);
// mark record which is for the current user
foreach($res['aaData'] as &$record){
if($record[1] == $username){
$record[5] = "self";
}
}
return $res;
}
public static function getUserData($id){

View File

@ -36,7 +36,11 @@ function removeUserCallback(row_id, nRow){
function rowCallback( nRow, aData, iDisplayIndex ){
$(nRow).click(function(){rowClickCallback(aData[0])});
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData[0], nRow)});
if( aData[5] != "self"){
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData[0], nRow)});
}else{
$('td:eq(4)', nRow).empty();
}
if ( aData[4] == "A" )
{