2011-06-14 20:50:35 +02:00
/ * *
* Javascript for Admin / Global categories
* /
// Record original value
var cat _original _owner ;
var permission _prompt ;
/ * *
* Check to see if admin has taken away access to a category
* /
2013-12-10 01:03:36 +01:00
function check _owner ( button ) {
var select _owner = button . getRoot ( ) . getWidgetById ( 'owner' )
var owner = select _owner . get _value ( ) ;
if ( typeof owner != 'object' )
{
owner = [ owner ] ;
}
var all _users = owner . indexOf ( '0' ) >= 0 ;
2011-06-14 20:50:35 +02:00
// If they checked all users, uncheck the others
2013-12-10 01:03:36 +01:00
if ( all _users ) {
select _owner . set _value ( [ '0' ] ) ;
2011-06-14 20:50:35 +02:00
return true ;
}
// Find out what changed
var seen = [ ] , diff = [ ] , labels = [ ] ;
2013-12-10 01:03:36 +01:00
var cat _original _owner = select _owner . getArrayMgr ( 'content' ) . getEntry ( 'owner' ) ;
if ( typeof cat _original _owner != "object" )
{
cat _original _owner = [ cat _original _owner ] ;
}
2011-06-14 20:50:35 +02:00
for ( var i = 0 ; i < cat _original _owner . length ; i ++ ) {
2013-12-10 01:03:36 +01:00
if ( owner . indexOf ( cat _original _owner [ i ] ) < 0 )
{
var checkbox = $j ( 'input[value="' + cat _original _owner [ i ] + '"]' , select _owner . node ) ;
2011-06-14 20:50:35 +02:00
diff . push ( cat _original _owner [ i ] ) ;
2011-07-03 11:00:36 +02:00
labels . push ( $j ( checkbox . get ( 0 ) . nextSibling ) . text ( ) ) ;
2011-06-14 20:50:35 +02:00
}
}
// Somebody will lose permission, give warning.
if ( diff . length > 0 ) {
2013-12-10 01:03:36 +01:00
var msg = egw . lang ( 'Removing access for groups may cause problems for data in this category. Are you sure? Users in these groups may no longer have access:' ) ;
2011-06-14 20:50:35 +02:00
for ( var i = 0 ; i < labels . length ; i ++ ) {
msg += labels [ i ] ;
}
2013-12-10 01:03:36 +01:00
return et2 _dialog . confirm ( button , msg ) ;
2011-06-14 20:50:35 +02:00
}
return true ;
}
2012-04-05 14:32:07 +02:00
/ * *
* Show icon based on icon - selectbox , hide placeholder ( broken image ) , if no icon selected
* /
2013-12-10 01:03:36 +01:00
function change _icon ( widget )
2012-04-05 14:32:07 +02:00
{
2013-12-10 01:03:36 +01:00
var img = widget . getRoot ( ) . getWidgetById ( 'icon_url' ) ;
2012-04-05 14:32:07 +02:00
2013-12-10 01:03:36 +01:00
if ( img )
2012-04-05 14:32:07 +02:00
{
2013-12-10 01:03:36 +01:00
img . set _src ( widget . getValue ( ) ) ;
2012-04-05 14:32:07 +02:00
}
}