Project

General

Profile

« Previous | Next » 

Revision f14ff867

Added by Phil Davis over 9 years ago

system_usermanager remove unused code

1) Line 448 "Remove this certificate association? (Certificate will not be deleted)" there was the text "Delete" being displayed and not looking good, in addition to the trash bin icon. Just the trash bin icon seems to be all that is needed.
2) Old line 757 there was a weird-looking "else;" - that seemed to be effectively an empty "else" clause hanging off the end of the "if" block above it. In that case it does nothing and I have removed it.
3) Remove the extra indent of a whole lot of code below old line 757 that actually was not in any "else" clause. This lines it up the way it actually works.
4) Old line 758
$section = new Form_Section('User Certificates');
That made a new $section and chunks of code below it added stuff to the section and then it was thrown away - there was nothing that actually added the section tp the form. That code is similar to what was already above that uses build_cert_table() to make a new Form_StaticText().
So I deleted the code from old line 758 that was functionally useless.

I think it all still works :)

Please review this carefully and make sure I have done good things. The code seemed a bit of a mess to me - maybe it was, or maybe I have no idea!

View differences:

src/usr/local/www/system_usermanager.php
445 445
			$certhtml .=		'<td>' . htmlspecialchars($ca['descr']) . '</td>';
446 446
			$certhtml .=		'<td>';
447 447
			$certhtml .=			'<a id="delcert' . $i .'" class="fa fa-trash no-confirm icon-pointer" title="';
448
			$certhtml .=			gettext('Remove this certificate association? (Certificate will not be deleted)') . '">Delete</a>';
448
			$certhtml .=			gettext('Remove this certificate association? (Certificate will not be deleted)') . '"></a>';
449 449
			$certhtml .=		'</td>';
450 450
			$certhtml .=	'</tr>';
451 451
			$i++;
......
754 754

  
755 755
		$form->add($section);
756 756
	}
757
else;
758
		$section = new Form_Section('User Certificates');
759 757

  
760
		foreach ((array)$a_user[$id]['cert'] as $i => $certref) {
761
			$cert = lookup_cert($certref);
762
			$ca = lookup_ca($cert['caref']);
763

  
764
			// We reverse name and action for readability of longer names
765
			$section->addInput(new Form_Checkbox(
766
				'certid[]',
767
				'Delete certificate',
768
				$cert['descr']. (is_cert_revoked($cert) ? ' <b>revoked</b>' : ''),
769
				false,
770
				$i
771
			));
772
		}
773

  
774
		#FIXME; old ui supplied direct export links to each certificate
758
	// ==== Add user certificate for a new user
759
	if (is_array($config['ca']) && count($config['ca']) > 0) {
760
		$section = new Form_Section('Create certificate for user');
761
		$section->addClass('cert-options');
775 762

  
776
		$section->addInput(new Form_StaticText(
777
			null,
778
			new Form_Button(null, 'add certificate', 'system_certmanager.php?act=new&userid='. $id).
779
			new Form_Button(null, 'export certificates', 'system_certmanager.php')
780
		));
763
		$nonPrvCas = array();
764
		foreach($config['ca'] as $ca) {
765
			if (!$ca['prv']) {
766
				continue;
767
			}
781 768

  
782
		// ==== Add user certificate for a new user
783
		if (is_array($config['ca']) && count($config['ca']) > 0) {
784
			$section = new Form_Section('Create certificate for user');
785
			$section->addClass('cert-options');
769
			$nonPrvCas[ $ca['refid'] ] = $ca['descr'];
770
		}
786 771

  
787
			$nonPrvCas = array();
788
			foreach($config['ca'] as $ca) {
789
				if (!$ca['prv']) {
790
					continue;
791
				}
772
		if (!empty($nonPrvCas)) {
773
			$section->addInput(new Form_Input(
774
				'name',
775
				'Descriptive name',
776
				'text',
777
				$pconfig['name']
778
			));
792 779

  
793
				$nonPrvCas[ $ca['refid'] ] = $ca['descr'];
794
			}
780
			$section->addInput(new Form_Select(
781
				'caref',
782
				'Certificate authority',
783
				null,
784
				$nonPrvCas
785
			));
795 786

  
796
			if (!empty($nonPrvCas)) {
797
				$section->addInput(new Form_Input(
798
					'name',
799
					'Descriptive name',
800
					'text',
801
					$pconfig['name']
802
				));
803

  
804
				$section->addInput(new Form_Select(
805
					'caref',
806
					'Certificate authority',
807
					null,
808
					$nonPrvCas
809
				));
810

  
811
				$section->addInput(new Form_Select(
812
					'keylen',
813
					'Key length',
814
					2048,
815
					array(
816
						512 => '512 bits',
817
						1024 => '1024 bits',
818
						2048 => '2049 bits',
819
						4096 => '4096 bits',
820
					)
821
				));
822

  
823
				$section->addInput(new Form_Input(
824
					'lifetime',
825
					'Lifetime',
826
					'number',
827
					$pconfig['lifetime']
828
				));
829
			}
787
			$section->addInput(new Form_Select(
788
				'keylen',
789
				'Key length',
790
				2048,
791
				array(
792
					512 => '512 bits',
793
					1024 => '1024 bits',
794
					2048 => '2049 bits',
795
					4096 => '4096 bits',
796
				)
797
			));
830 798

  
831
			$form->add($section);
799
			$section->addInput(new Form_Input(
800
				'lifetime',
801
				'Lifetime',
802
				'number',
803
				$pconfig['lifetime']
804
			));
832 805
		}
833 806

  
807
		$form->add($section);
808
	}
809

  
834 810
endif;
835 811
// ==== Paste a key for the new user
836 812
$section = new Form_Section('Keys');

Also available in: Unified diff