cc-2126: user shouldnt be able to delete himself
-changed it so that the "x" is still visible, but when clicking, an error message shows. Did this because the columns were resizing when the x wasnt visible. Also the empty column looked weird with only one user.
This commit is contained in:
parent
2a5df8bed9
commit
359c4a4eb8
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
|
|
||||||
private $_userInstance;
|
private $_userInstance;
|
||||||
|
|
||||||
public function __construct($userId)
|
public function __construct($userId)
|
||||||
{
|
{
|
||||||
if (strlen($userId)==0){
|
if (strlen($userId)==0){
|
||||||
$this->_userInstance = $this->createUser();
|
$this->_userInstance = $this->createUser();
|
||||||
|
@ -13,96 +13,96 @@ class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->_userInstance->getDbId();
|
return $this->_userInstance->getDbId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHost($showId) {
|
public function isHost($showId) {
|
||||||
$userId = $this->_userInstance->getDbId();
|
$userId = $this->_userInstance->getDbId();
|
||||||
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAdmin() {
|
public function isAdmin() {
|
||||||
return $this->_userInstance->getDbType() === 'A';
|
return $this->_userInstance->getDbType() === 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLogin($login){
|
public function setLogin($login){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbLogin($login);
|
$user->setDbLogin($login);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPassword($password){
|
public function setPassword($password){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbPass(md5($password));
|
$user->setDbPass(md5($password));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFirstName($firstName){
|
public function setFirstName($firstName){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbFirstName($firstName);
|
$user->setDbFirstName($firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLastName($lastName){
|
public function setLastName($lastName){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbLastName($lastName);
|
$user->setDbLastName($lastName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setType($type){
|
public function setType($type){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbType($type);
|
$user->setDbType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmail($email){
|
public function setEmail($email){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbEmail($email);
|
$user->setDbEmail($email);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSkype($skype){
|
public function setSkype($skype){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbSkypeContact($skype);
|
$user->setDbSkypeContact($skype);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setJabber($jabber){
|
public function setJabber($jabber){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
$user->setDbJabberContact($jabber);
|
$user->setDbJabberContact($jabber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLogin(){
|
public function getLogin(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbLogin();
|
return $user->getDbLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword(){
|
public function getPassword(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbPass();
|
return $user->getDbPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFirstName(){
|
public function getFirstName(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbFirstName();
|
return $user->getDbFirstName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastName(){
|
public function getLastName(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbLastName();
|
return $user->getDbLastName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType(){
|
public function getType(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbType();
|
return $user->getDbType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail(){
|
public function getEmail(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbEmail();
|
return $user->getDbEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSkype(){
|
public function getSkype(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbSkypeContact();
|
return $user->getDbSkypeContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJabber(){
|
public function getJabber(){
|
||||||
$user = $this->_userInstance;
|
$user = $this->_userInstance;
|
||||||
return $user->getDbJabberContact();
|
return $user->getDbJabberContact();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,69 +116,69 @@ class User {
|
||||||
$this->_userInstance->delete();
|
$this->_userInstance->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createUser() {
|
private function createUser() {
|
||||||
$user = new CcSubjs();
|
$user = new CcSubjs();
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsers($type, $search=NULL) {
|
public static function getUsers($type, $search=NULL) {
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$sql;
|
$sql;
|
||||||
|
|
||||||
$sql_gen = "SELECT id AS value, login AS label FROM cc_subjs ";
|
$sql_gen = "SELECT id AS value, login AS label FROM cc_subjs ";
|
||||||
$sql = $sql_gen;
|
$sql = $sql_gen;
|
||||||
|
|
||||||
if(is_array($type)) {
|
if(is_array($type)) {
|
||||||
for($i=0; $i<count($type); $i++) {
|
for($i=0; $i<count($type); $i++) {
|
||||||
$type[$i] = "type = '{$type[$i]}'";
|
$type[$i] = "type = '{$type[$i]}'";
|
||||||
}
|
}
|
||||||
$sql_type = join(" OR ", $type);
|
$sql_type = join(" OR ", $type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql_type = "type = {$type}";
|
$sql_type = "type = {$type}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
||||||
|
|
||||||
if(!is_null($search)) {
|
if(!is_null($search)) {
|
||||||
$like = "login ILIKE '%{$search}%'";
|
$like = "login ILIKE '%{$search}%'";
|
||||||
|
|
||||||
$sql = $sql . " AND ".$like;
|
$sql = $sql . " AND ".$like;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $sql ." ORDER BY login";
|
$sql = $sql ." ORDER BY login";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getHosts($search=NULL) {
|
public static function getHosts($search=NULL) {
|
||||||
return User::getUsers(array('H'), $search);
|
return User::getUsers(array('H'), $search);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsersDataTablesInfo($datatables_post) {
|
public static function getUsersDataTablesInfo($datatables_post) {
|
||||||
|
|
||||||
$fromTable = "cc_subjs";
|
$fromTable = "cc_subjs";
|
||||||
|
|
||||||
// get current user
|
// get current user
|
||||||
$username = "";
|
$username = "";
|
||||||
$auth = Zend_Auth::getInstance();
|
$auth = Zend_Auth::getInstance();
|
||||||
|
|
||||||
if ($auth->hasIdentity()) {
|
if ($auth->hasIdentity()) {
|
||||||
$username = $auth->getIdentity()->login;
|
$username = $auth->getIdentity()->login;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = StoredFile::searchFiles($fromTable, $datatables_post);
|
$res = StoredFile::searchFiles($fromTable, $datatables_post);
|
||||||
|
|
||||||
// mark record which is for the current user
|
// mark record which is for the current user
|
||||||
foreach($res['aaData'] as &$record){
|
foreach($res['aaData'] as &$record){
|
||||||
if($record[1] == $username){
|
if($record[1] == $username){
|
||||||
$record[5] = "self";
|
$record[5] = "self";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUserData($id){
|
public static function getUserData($id){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
@ -191,12 +191,12 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetUserID($login){
|
public static function GetUserID($login){
|
||||||
$user = CcSubjsQuery::create()->findOneByDbLogin($login);
|
$user = CcSubjsQuery::create()->findOneByDbLogin($login);
|
||||||
if (is_null($user)){
|
if (is_null($user)){
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return $user->getDbId();
|
return $user->getDbId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ function rowCallback( nRow, aData, iDisplayIndex ){
|
||||||
if( aData[5] != "self"){
|
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)});
|
$('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{
|
}else{
|
||||||
$('td:eq(4)', nRow).empty();
|
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aData[4] == "A" )
|
if ( aData[4] == "A" )
|
||||||
|
|
Loading…
Reference in New Issue