accountID = $GLOBALS['egw_info']['user']['account_id']; if($_signatureID !== NULL) { $this->read($_signatureID); } } function getDefaultSignature() { $db = clone($GLOBALS['egw']->db); $db->set_app('felamimail'); $where = array( 'fm_accountid' => $this->accountID, 'fm_defaultsignature' => true ); $db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature', $where, __LINE__, __FILE__); if(($row = $db->row(true))) { return $row['fm_signatureid']; } return false; } function read($_signatureID) { $db = clone($GLOBALS['egw']->db); $db->set_app('felamimail'); $where = array( 'fm_accountid' => $this->accountID, 'fm_signatureid' => $_signatureID ); $db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature', $where, __LINE__, __FILE__); if(($data = $db->row(true))) { if (empty($data['fm_description'])) { $buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($data['fm_signature'])),0,100)); $data['fm_description'] = $buff?$buff:lang('none'); } $this->fm_signatureid = $data['fm_signatureid']; $this->fm_description = $data['fm_description']; $this->fm_signature = $data['fm_signature']; $this->fm_defaultsignature = (bool)$data['fm_defaultsignature']; return TRUE; } return FALSE; } function delete($_signatureID = FALSE) { $db = clone($GLOBALS['egw']->db); $db->set_app('felamimail'); if($_signatureID !== FALSE) { $signatureID = (int)$_signatureID; } else { $signatureID = (int)$this->fm_signatureid; } $where = array( 'fm_accountid' => $this->accountID, 'fm_signatureid' => $signatureID ); $db->delete($this->tableName, $where, __LINE__, __FILE__); if ($db->affected_rows() === 0) { return false; } return true; } function save() { $db = clone($GLOBALS['egw']->db); $db->set_app('felamimail'); // reset fm_defaultsignature in all other rows to false if($this->fm_defaultsignature === true) { $where = array( 'fm_accountid' => $this->accountID, ); $data = array( 'fm_defaultsignature' => false, ); $db->update($this->tableName, $data, $where, __LINE__, __FILE__); } if (empty($this->fm_description)) { $buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($this->fm_signature)),0,100)); $this->fm_description = $buff?$buff:lang('none'); } $data = array( 'fm_accountid' => $this->accountID, 'fm_signature' => $this->fm_signature, 'fm_description' => $this->fm_description, 'fm_defaultsignature' => $this->fm_defaultsignature, ); if($this->fm_signatureid === NULL) { $db->insert($this->tableName, $data, '', __LINE__, __FILE__); $this->fm_signatureid = $db->get_last_insert_id($this->tableName,'fm_signatureid'); return TRUE; } else { $where = array( 'fm_accountid' => $this->accountID, 'fm_signatureid' => $this->fm_signatureid, ); $db->update($this->tableName, $data, $where, __LINE__, __FILE__); return TRUE; } } function search() { $signatures = array(); $db = clone($GLOBALS['egw']->db); $db->set_app('felamimail'); $where = array( 'fm_accountid' => $this->accountID ); $db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature', $where, __LINE__, __FILE__); while ($data = $db->row(true)) { if (empty($data['fm_description'])) { $buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($data['fm_signature'])),0,100)); $data['fm_description'] = $buff?$buff:lang('none'); } $signatureData = array( 'fm_signatureid' => $data['fm_signatureid'], 'fm_description' => $data['fm_description'], 'fm_signature' => $data['fm_signature'], 'fm_defaultsignature' => (bool)$data['fm_defaultsignature'], ); $signatures[$data['fm_signatureid']] = $signatureData; } return $signatures; } } ?>