* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011, Franck Villaume - TrivialDev
+ * Copyright 2011-2012, Franck Villaume - TrivialDev
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'docman/Parsedata.class.php';
require_once $gfcommon.'docman/DocumentManager.class.php';
+require_once $gfcommon.'docman/DocumentGroup.class.php';
+
class Document extends Error {
*/
var $Group;
- /**
- * The Search engine path.
- *
- * @var string $engine_path
- */
- var $engine_path;
-
/**
* Constructor.
*
* @param array The associative array of data.
* @return boolean success.
*/
- function Document(&$Group, $docid = false, $arr = false, $engine = '') {
+ function Document(&$Group, $docid = false, $arr = false) {
$this->Error();
if (!$Group || !is_object($Group)) {
- $this->setNotValidGroupObjectError();
+ $this->setError('Document:: '. _('No Valid Group Object'));
return false;
}
if ($Group->isError()) {
}
}
}
- $this->engine_path = $engine;
return true;
}
return false;
}
+ $result = db_query_params('SELECT title FROM docdata_vw where title = $1 AND doc_group = $2',
+ array($title, $doc_group));
+ if (!$result || db_numrows($result) > 0) {
+ $this->setError(_('Document already published in this directory'));
+ return false;
+ }
+
// If $filetype is "text/plain", $body convert UTF-8 encoding.
if (strcasecmp($filetype,"text/plain") === 0 &&
function_exists('mb_convert_encoding') &&
db_rollback();
return false;
}
+
+ $localDg = new DocumentGroup($this->Group, $doc_group);
+ if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
+ $this->setError(_('Error updating document group:').$localDg->getErrorMessage());
+ db_rollback();
+ return false;
+ }
$this->sendNotice(true);
db_commit();
return true;
$res = db_query_params('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
array($docid, $this->Group->getID()));
if (!$res || db_numrows($res) < 1) {
- $this->setError(_('Document:: Invalid docid'));
+ $this->setError(_('Document: Invalid docid'));
return false;
}
$this->data_array = db_fetch_array($res);
}
}
}
-
+ $this->fetchData($this->getID());
$this->sendNotice(false);
return true;
}
*
* @param boolean true = new document (default value)
*/
- function sendNotice($new=true) {
+ function sendNotice($new = true) {
$BCC = $this->Group->getDocEmailAddress();
if ($this->isMonitoredBy('ALL')) {
$BCC .= $this->getMonitoredUserEmailAddress();
}
if (strlen($BCC) > 0) {
+ $sess = session_get_user();
if ($new) {
$status = _('New document');
} else {
- $status = _('Updated document');
+ $status = _('Updated document').' '._('by').' ' . $sess->getRealName();
+ }
+ $BCCarray = explode(',',$BCC);
+ foreach ($BCCarray as $dest_email) {
+ if ($new) {
+ $status = _('New document');
+ } else {
+ $status = _('Updated document');
+ }
+ $subject = '['.$this->Group->getPublicName().'] '.$status.' - '.$this->getName();
+ $body = _('Project:').' '.$this->Group->getPublicName()."\n";
+ $body .= _('Directory:').' '.$this->getDocGroupName()."\n";
+ $body .= _('Document title:').' '.$this->getName()."\n";
+ $body .= _('Document description:').' '.util_unconvert_htmlspecialchars($this->getDescription())."\n";
+ $body .= _('Submitter:').' '.$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
+ $body .= "\n\n-------------------------------------------------------\n".
+ _('For more info, visit:').
+ "\n\n" . util_make_url('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
+
+ util_send_message($dest_email, $subject, $body, 'noreply@'.forge_get_config('web_host'), '', _('Docman'));
}
- $subject = '['.$this->Group->getPublicName().'] '.$status.' - '.$this->getName();
- $body = _('Project:').' '.$this->Group->getPublicName()."\n";
- $body .= _('Directory:').' '.$this->getDocGroupName()."\n";
- $body .= _('Document title:').' '.$this->getName()."\n";
- $body .= _('Document description:').' '.util_unconvert_htmlspecialchars($this->getDescription())."\n";
- $body .= _('Submitter:').' '.$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
- $body .= "\n\n-------------------------------------------------------\n".
- _('For more info, visit:').
- "\n\n" . util_make_uri('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
-
- util_send_message('', $subject, $body, '', $BCC);
}
return true;