>
<script type="dojo/method" event="onChange">
<![CDATA[
- if (current_ou && this.getValue()) this.store.setValue( current_ou, "parent_ou", this.getValue() );
- if ( this.store.getValue( current_ou, '_trueRoot' ) == 'true' ) this.required = false;
+ if (current_ou && this.getValue()) {
+ if(this.store.getValue( current_ou, 'id' ) == this.getValue()) {
+ this.isValid = function() { return false; };
+ return;
+ }
+ var seen_ous = {};
+ seen_ous[this.store.getValue( current_ou, 'id' )] = true;
+ var temp_ou;
+ ou_list_store.fetch({
+ query : { id : this.getValue() },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { if (this.isItem( item )) temp_ou = item; },
+ scope : ou_list_store
+ });
+ for(var i = 0; i < 100; i++) {
+ if(!this.store.getValue( temp_ou, 'parent_ou' ) ) {
+ break;
+ }
+ if(seen_ous[this.store.getValue( temp_ou, 'parent_ou' )]) {
+ this.isValid = function() { return false; };
+ return;
+ }
+ ou_list_store.fetch({
+ query : { id : this.store.getValue( temp_ou, 'parent_ou') },
+ queryOptions : { deep : true },
+ onItem : function (item, req) { if (this.isItem( item )) temp_ou = item; },
+ scope : ou_list_store
+ });
+ }
+ if(i == 100) {
+ this.isValid = function() { return false; };
+ return;
+ }
+ this.isValid = function() { return true; };
+ this.store.setValue( current_ou, "parent_ou", this.getValue() );
+ }
+ if ( this.store.getValue( current_ou, '_trueRoot' ) == 'true' ) {
+ this.required = false;
+ this.isValid = function() { return true; };
+ }
else this.required = true;
]]>
</script>