public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); }
/** * * @param IXP_Form_Contact $form The form object * @param \Entities\Contact $object The Doctrine2 entity (being edited or blank for add) * @param bool $isEdit True of we are editing an object, false otherwise * @param array $options Options passed onto Zend_Form * @param string $cancelLocation Where to redirect to if 'Cancal' is clicked * @return void */ protected function formPostProcess($form, $object, $isEdit, $options = null, $cancelLocation = null) { $this->view->groups = $this->getD2EM()->getRepository("\\Entities\\ContactGroup")->getGroupNamesTypeArray(); $this->view->jsonGroups = json_encode($this->view->groups); // ROLE is treated as a special group and if it is not set, it will disable the contact role functionality if (!isset($this->_options['contact']['group']['types'][\Entities\ContactGroup::TYPE_ROLE])) { $form->removeElement('role'); } // redirect back to whence we came on form submission if ($this->getParam("user", false)) { $form->getElement('login')->setValue(1); $form->setAction(OSS_Utils::genUrl('contact', $isEdit ? 'edit' : 'add', false, ['user' => true])); } else { if ($this->getParam("uid", false)) { $form->setAction(OSS_Utils::genUrl('contact', $isEdit ? 'edit' : 'add', false, ['uid' => $this->getParam("uid")])); } } if ($cid = $this->getParam('cid', false)) { $form->updateCancelLocation(OSS_Utils::genUrl('customer', 'overview', false, ['id' => $cid, 'tab' => $this->getParam('user', false) || $this->getParam('uid', false) ? 'users' : 'contacts'])); } if ($isEdit) { $form->getElement('custid')->setValue($object->getCustomer()->getId()); $this->view->contactGroups = $this->getD2R("\\Entities\\ContactGroup")->getGroupNamesTypeArray(false, $object->getId()); } else { if ($this->getParam('custid', false) && ($cust = $this->getD2R('\\Entities\\Customer')->find($this->getParam('custid')))) { $form->getElement('custid')->setValue($cust->getId()); } } if ($object->getUser()) { $form->getElement('login')->setValue(1); $form->getElement('username')->setValue($object->getUser()->getUsername()); $form->getElement('password')->setAttrib('placeholder', 'Set to change password'); $form->getElement('privs')->setValue($object->getUser()->getPrivs()); $form->getElement('disabled')->setValue($object->getUser()->getDisabled()); } else { $form->getElement('password')->setValue(OSS_String::random(12)); $form->getElement('username')->addValidator('OSSDoctrine2Uniqueness', true, ['entity' => '\\Entities\\User', 'property' => 'username']); } switch ($this->getUser()->getPrivs()) { case \Entities\User::AUTH_SUPERUSER: $form->getElement('username')->removeValidator('stringLength'); break; case \Entities\User::AUTH_CUSTADMIN: $form->removeElement('password'); $form->removeElement('privs'); $form->removeElement('custid'); $form->removeElement('facilityaccess'); $form->removeElement('mayauthorize'); $form->removeElement('notes'); if ($isEdit && $object->getUser()) { $form->getElement('username')->setAttrib('readonly', 'readonly'); } break; default: throw new OSS_Exception('Unhandled user type / security issues'); } }