コード例 #1
0
 public function add_post()
 {
     try {
         $name = trim($_REQUEST['name']);
         $address = trim($_REQUEST['address']);
         if ($this->getClass('LDAPManager')->exists(trim($_REQUEST['name']))) {
             throw new Exception('LDAP server already Exists, please try again.');
         }
         if (!$name) {
             throw new Exception('Please enter a name for this LDAP server.');
         }
         if (empty($address)) {
             throw new Exception('Please enter a LDAP server address');
         }
         $LDAP = new LDAP(array('name' => trim($_REQUEST['name']), 'description' => $_REQUEST['description'], 'address' => $_REQUEST['address'], 'DN' => $_REQUEST['DN'], 'port' => $_REQUEST['port']));
         if ($LDAP->save()) {
             $this->FOGCore->setMessage('LDAP Server Added, editing!');
             $this->FOGCore->redirect('?node=ldap&sub=edit&id=' . $LDAP->get('id'));
         }
     } catch (Exception $e) {
         $this->FOGCore->setMessage($e->getMessage());
         $this->FOGCore->redirect($this->formAction);
     }
 }