Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modstate.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Document State modification
8  *
9  * @author Anakeen
10  * @version $Id: modstate.php,v 1.11 2008/10/30 16:11:44 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/modcard.php");
19 /**
20  * Edition to send mail
21  * @param Action &$action current action
22  * @global string $id id Http var : document id to change
23  * @global string $state Http var : new state
24  * @global string $comment Http var : additionnal comment for history
25  * @global string $force Http var : to force transition [Y|N]
26  */
27 function modstate(Action & $action)
28 {
29  // Get all the params
30  $docid = $action->getArgument("id");
31  $state = $action->getArgument("newstate"); // new state
32  $comment = $action->getArgument("comment"); // comment
33  $comment = rawurldecode($comment);
34  $force = ($action->getArgument("fstate", "no") == "yes"); // force change
35  if ($docid == 0) $action->exitError(_("the document is not referenced: cannot apply state modification"));
36 
37  $dbaccess = $action->dbaccess;
38  // initialise object
40 
41  if ($doc->wid > 0) {
42  if ($state != "-") {
43  /*
44  * @var Wdoc $wdoc
45  */
46  $wdoc = new_Doc($dbaccess, $doc->wid);
47  $wdoc->Set($doc);
48  $wdoc->disableEditControl(); // only to pass ask parameters
49  setPostVars($wdoc);
50  $wdoc->enableEditControl();
51  $msg = '';
52  $err = $wdoc->ChangeState($state, $comment, $force, true, true, true, true, true, true, $msg);
53  if ($err != "") $action->AddWarningMsg($err);
54  if ($msg != "") $action->AddWarningMsg($msg);
55  else $action->info(sprintf("Change state %s [%d] : %s", $doc->title, $doc->id, $state));
56  } else {
57  if ($comment != "") {
58  $doc->addHistoryEntry($comment);
59  $action->log->info(sprintf("Add comment %s [%d] : %s", $doc->title, $doc->id, $comment));
60  }
61  }
62  } else {
63  $action->AddLogMsg(sprintf(_("the document %s is not related to a workflow") , $doc->title));
64  }
65 
66  redirect($action, $action->getArgument("redirect_app", "FDL") , $action->getArgument("redirect_act", "FDL_CARD&refreshfld=Y&id=" . $doc->id) , $action->GetParam("CORE_STANDURL"));
67 }
$comment
Definition: fdl_execute.php:35
global $action
modstate(Action &$action)
Definition: modstate.php:27
info($msg)
setPostVars(Doc &$doc, &$info=array())
Definition: modcard.php:259
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
$force
new_Doc($dbaccess, $id= '', $latest=false)
static getArgument($k, $def= '')
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen