~piersharding/udi/master-udi

« back to all changes in this revision

Viewing changes to lib/HTMLTree.php

  • Committer: Piers Harding
  • Date: 2011-10-02 21:27:04 UTC
  • mfrom: (151.1.63)
  • Revision ID: git-v1:a3e8fccd857706bbe9f37a05061ddc2e2d0b8143
Merge branch 'master' into test-master-merge

Conflicts:
        lib/ds_ldap_pla.php
        lib/page.php

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
                if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
29
29
                        debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
30
30
 
 
31
                static $js_drawn = false;
31
32
                $server = $this->getServer();
32
33
 
33
 
                echo '<table class="tree" border=0>';
 
34
                echo '<table class="tree" border="0">';
34
35
                if (! $onlytree)
35
36
                        $this->draw_server_name();
36
37
 
60
61
                                        $server->getIndex());
61
62
                        }
62
63
 
63
 
                        echo '<table class="tree" border=0>';
 
64
                        echo '<table class="tree" border="0">';
64
65
 
65
66
                        if (! count($this->getBaseEntries())) {
66
67
                                # We didnt get any baseDN entries in our tree?
85
86
                         */
86
87
                        foreach ($this->getBaseEntries() as $base) {
87
88
                                if (! $base->isInLDAP()) {
 
89
                                        $js_drawn = false;
88
90
                                        $javascript_id++;
89
91
 
90
 
                                        printf('<tr><td class="spacer"></td><td class="spacer"></td><td><img src="%s/unknown.png" /></td><td colspan="%s">%s</td></tr>',
 
92
                                        $rdn = explode('=',get_rdn($base->getDN()));
 
93
                                        printf('<tr><td class="spacer"></td><td class="spacer"></td><td><img src="%s/unknown.png" alt="" /></td><td colspan="%s">%s</td></tr>',
91
94
                                                IMGDIR,$this->getDepth()+3-3,pretty_print_dn($base->getDN()));
92
95
 
93
 
                                        $this->javascript .= sprintf('<form name="create_base_form_%s" method="post" action="cmd.php?cmd=template_engine">',$javascript_id);
 
96
                                        $this->javascript .= sprintf('<form id="create_base_form_%s_%s" method="post" action="cmd.php">',$server->getIndex(),$javascript_id);
 
97
                                        $this->javascript .= '<div>';
 
98
                                        $this->javascript .= '<input type="hidden" name="cmd" value="template_engine" />';
94
99
                                        $this->javascript .= sprintf('<input type="hidden" name="server_id" value="%s" />',$server->getIndex());
95
100
                                        $this->javascript .= sprintf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($server->getContainer($base->getDN())));
96
101
                                        $this->javascript .= sprintf('<input type="hidden" name="rdn" value="%s" />',get_rdn($base->getDN()));
 
102
                                        $this->javascript .= sprintf('<input type="hidden" name="rdn_attribute[]" value="%s" />',$rdn[0]);
 
103
                                        $this->javascript .= sprintf('<input type="hidden" name="new_values[%s][]" value="%s" />',$rdn[0],$rdn[1]);
 
104
                                        $this->javascript .= '<input type="hidden" name="template" value="none" />';
 
105
                                        $this->javascript .= '<input type="hidden" name="create_base" value="true" />';
 
106
                                        $this->javascript .= '</div>';
97
107
                                        $this->javascript .= sprintf('</form>');
98
108
 
99
 
                                        printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s<a href="javascript:document.create_base_form_%s.submit()">%s</a></small></td></tr>',
100
 
                                                $this->getDepth()+3-3,_('This base entry does not exist.'),$javascript_id,_('Create it?'));
101
 
 
102
 
                                        echo '</table>';
103
 
 
104
 
                                        if (! $onlytree)
105
 
                                                echo '</div></td></tr>';
106
 
 
107
 
                                        echo '</table>';
108
 
                                        return;
 
109
                                        if (preg_match('/,/',$base->getDN()))
 
110
                                                printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s</small></td></tr>',
 
111
                                                        $this->getDepth()+3-3,_('This base cannot be created with PLA.'));
 
112
                                        else
 
113
                                                printf('<tr><td class="spacer"></td><td class="spacer"></td><td class="spacer"></td><td colspan="%s"><small>%s <a href="javascript:document.getElementById(\'create_base_form_%s_%s\').submit()">%s</a></small></td></tr>',
 
114
                                                        $this->getDepth()+3-3,_('This base entry does not exist.'),$server->getIndex(),$javascript_id,_('Create it?'));
109
115
 
110
116
                                } else {
111
117
                                        $this->draw_item($base->getDN(),-1);
120
126
                # We are not logged in, draw a login... link.
121
127
                } else {
122
128
                        switch ($server->getAuthType()) {
 
129
                                case 'cookie':
123
130
                                case 'http':
124
131
                                case 'session':
125
132
                                        $this->draw_login_link();
127
134
 
128
135
                                case 'config':
129
136
                                case 'proxy':
 
137
                                case 'sasl':
130
138
                                        break;
131
139
 
132
140
                                default:
138
146
                echo '</table>';
139
147
                echo "\n\n";
140
148
 
141
 
                static $js_drawn = false;
142
 
 
143
149
                if (! $js_drawn) {
144
150
                        $this->draw_javascript();
145
151
                        $js_drawn = true;
163
169
                if (! is_null($server->inactivityTime())) {
164
170
                        $m = sprintf(_('Inactivity will log you off at %s'),
165
171
                                strftime('%H:%M',$server->inactivityTime()));
166
 
                        printf(' <img width=14 height=14 src="%s/timeout.png" title="%s" alt="%s"/>',IMGDIR,$m,'Timeout');
 
172
                        printf(' <img width="14" height="14" src="%s/timeout.png" title="%s" alt="%s"/>',IMGDIR,$m,'Timeout');
167
173
                }
168
174
                echo '</td></tr>';
169
175
        }
335
341
                $server = $this->getServer();
336
342
                $href = sprintf('cmd.php?cmd=logout&server_id=%s',$server->getIndex());
337
343
 
338
 
                if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','logout') || in_array($server->getAuthType(),array('config','http','proxy')))
 
344
                if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','logout') || in_array($server->getAuthType(),array('config','http','proxy','sasl')))
339
345
                        return '';
340
346
                else
341
347
                        return sprintf('<a href="%s" title="%s"><img src="%s/%s" alt="%s" /><br />%s</a>',
433
439
                $href['edit'] = htmlspecialchars(sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$server->getIndex(),$dnENCODE));
434
440
 
435
441
                echo '<tr class="option">';
436
 
                printf('<td class="spacer" colspan=%s></td>',$level+2);
 
442
                printf('<td class="spacer" colspan="%s"></td>',$level+2);
437
443
 
438
444
                # Is this node expanded? (deciding whether to draw "+" or "-")
439
445
                if ($entry->isOpened())
450
456
                printf('<td class="icon"><a href="%s" id="node_%s_%s"><img src="%s/%s" alt="img" /></a></td>',
451
457
                        $href['edit'],$server->getIndex(),preg_replace('/=/','_',base64_encode($item)),IMGDIR,$entry->getIcon());
452
458
 
453
 
                printf('<td class="phplm" width=100%% colspan="%s"><span style="white-space: nowrap;">',$this->getDepth()+3-$level);
 
459
                printf('<td class="phplm" colspan="%s" style="width: 100%%;"><span style="white-space: nowrap;">',$this->getDepth()+3-$level);
454
460
                printf('<a href="%s">%s</a>',$href['edit'],$this->get_formatted_dn($entry,$level));
455
461
 
456
462
                if ($child_count)
506
512
                $href = htmlspecialchars(sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),$encoded_dn));
507
513
 
508
514
                echo '<tr>';
509
 
                printf('<td class="spacer" colspan=%s></td>',$level+3);
 
515
                printf('<td class="spacer" colspan="%s"></td>',$level+3);
510
516
                printf('<td class="icon"><a href="%s"><img src="%s/create.png" alt="%s" /></a></td>',$href,IMGDIR,_('new'));
511
517
                printf('<td class="link" colspan="%s"><a href="%s" title="%s %s">%s</a></td>',
512
518
                        $this->getDepth()+3-$level,$href,_('Create a new entry in'),$rdn,_('Create new entry here'));
538
544
 
539
545
                echo '</tr>';
540
546
 
541
 
                printf('<tr><td class="blank" colspan="%s">&nbsp;</td>',$this->getDepth()+3);
542
 
                printf('<tr><td class="blank" colspan="%s">&nbsp;</td>',$this->getDepth()+3);
 
547
                printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>',$this->getDepth()+3);
 
548
                printf('<tr><td class="blank" colspan="%s">&nbsp;</td></tr>',$this->getDepth()+3);
543
549
        }
544
550
 
545
551
        /**
553
559
                        echo "<!-- Forms for javascript submit to call to create base_dns -->\n";
554
560
                        echo $this->javascript;
555
561
                        echo "<!-- The end of the forms for javascript submit to call to create base_dns -->\n";
 
562
                        $this->javascript = '';
556
563
                }
557
564
        }
558
565