Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
affect.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Functions to allocate document to an user
9  *
10  * @author Anakeen 2000
11  * @version $Id: affect.php,v 1.6 2009/01/08 17:47:08 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/mailcard.php");
21 /**
22  * Edition to allocate document
23  * @param Action &$action current action
24  * @global id Http var : document id to affect
25  * @global _id_affectuser Http var : user identificator to affect
26  * @global _actioncomment Http var : description of the action
27  */
28 function affect(&$action)
29 {
30  $docid = GetHttpVars("id");
31  $uid = GetHttpVars("_id_affectuser");
32  $newstate = GetHttpVars("newstate", -1);
33  $commentstate = GetHttpVars("_statecomment");
34  $commentaction = GetHttpVars("_actioncomment");
35  $dbaccess = $action->GetParam("FREEDOM_DB");
36  $revstate = true;
37 
38  $doc = new_doc($dbaccess, $docid);
39  if (!$doc->isAlive()) $action->exitError(sprintf(_("document #%s not found. Affectation aborded") , $docid));
40  $wuid = 0;
41  if ($uid) {
42  $docu = new_doc($dbaccess, $uid);
43  if (!$docu->isAlive()) $action->addWarningMsg(sprintf(_("user #%s not found. Affectation aborded") , $uid));
44 
45  $wuid = $docu->getValue("us_whatid");
46  if (!($wuid > 0)) $action->addWarningMsg(sprintf(_("user #%s has not a real account. Affectation aborded") , $uid));
47  }
48  if ($newstate >= 0) {
49  $err = $doc->changeFreeState($newstate, $commentstate);
50  if ($err != "") $action->addWarningMsg($err);
51  else {
52  $revstate = false; // no need to revision one more
53  $action->addWarningMsg(sprintf(_("document %s has the new state %s") , $doc->title, $doc->getState()));
54  }
55  }
56  if ($wuid > 0) {
57  $err = $doc->allocate($wuid, $commentaction, $revstate);
58  if ($err != "") $action->addWarningMsg($err);
59 
60  if ($err == "") {
61  $action->AddActionDone("LOCKDOC", $doc->id);
62 
63  $action->addWarningMsg(sprintf(_("document %s has been allocate to %s") , $doc->title, $docu->title));
64 
65  $to = $docu->getValue("us_mail");
66  $subject = sprintf(_("allocation for %s document") , $doc->title);
67  $err = sendCard($action, $doc->id, $to, "", $subject, "", true, $commentaction, "", "", "htmlnotif");
68  if ($err != "") $action->addWarningMsg($err);
69  }
70  }
71 
72  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD&latest=Y&refreshfld=Y&id=" . $doc->id) , $action->GetParam("CORE_STANDURL"));
73 }
74 ?>
← centre documentaire © anakeen - published under CC License - Dynacase