/**
  * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row
  * @param GD_Model_Server $obj
  * @param Zend_Db_Table_Row_Abstract $row
  */
 protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row)
 {
     $crypt = new GD_Crypt();
     $decrypted_pwd = $crypt->doDecrypt($row->password);
     $obj->setId($row->id)->setName($row->name)->setHostname($row->hostname)->setConnectionTypesId($row->connection_types_id)->setPort($row->port)->setUsername($row->username)->setPassword($decrypted_pwd)->setRemotePath($row->remote_path)->setProjectsId($row->projects_id);
     $ct_map = new GD_Model_ConnectionTypesMapper();
     $connection_type = new GD_Model_ConnectionType();
     $ct_map->populateObjectFromRow($connection_type, $row->findParentRow('GD_Model_DbTable_ConnectionTypes'));
     $obj->setConnectionType($connection_type);
 }
 public function __construct($options = null)
 {
     parent::__construct($options);
     $this->setName('serverSettings');
     $server_name = new Zend_Form_Element_Text('name');
     $server_name->setLabel(_r('Name'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Server Name'));
     $server_name->addValidators(array($not_empty));
     $hostname = new Zend_Form_Element_Text('hostname');
     $hostname->setLabel(_r('Hostname'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Hostname'));
     $hostname->addValidators(array($not_empty));
     $ct_map = new GD_Model_ConnectionTypesMapper();
     $connection_types = $ct_map->fetchAll();
     $connection_type_id = new Zend_Form_Element_Select('connectionTypeId');
     $connection_type_id->setLabel(_r('Connection Type'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please choose a Connection Type'));
     $connection_type_id->addValidators(array($not_empty));
     foreach ($connection_types as $connection_type) {
         $connection_type_id->addMultiOption($connection_type->getId(), $connection_type->getName());
     }
     $port = new Zend_Form_Element_Text('port');
     $port->setLabel(_r('Port'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Port Number'));
     $port->addValidators(array($not_empty));
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel(_r('Username'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off');
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Username'));
     $username->addValidators(array($not_empty));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('autocomplete', 'off')->setAttrib('renderPassword', true);
     $not_empty = new Zend_Validate_NotEmpty();
     $not_empty->setMessage(_r('Please enter the Password'));
     $password->addValidators(array($not_empty));
     $report_path = new Zend_Form_Element_Text('remotePath');
     $report_path->setLabel(_r('Remote Path'))->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
     $submit = new Zend_Form_Element_Image('btn_submit');
     $submit->setImage('/images/buttons/small/save-changes.png');
     $this->addElements(array($server_name, $hostname, $connection_type_id, $port, $username, $password, $report_path, $submit));
 }