Core  3.2
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  * @package FDL
5 */
6 /**
7  * Functions to allocate document to an user
8  *
9  * @author Anakeen
10  * @version $Id: affect.php,v 1.6 2009/01/08 17:47:08 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/mailcard.php");
19 /**
20  * Edition to allocate document
21  * @param Action &$action current action
22  * @global id int Http var : document id to affect
23  * @global _id_affectuser int Http var : user identifier to affect
24  * @global _actioncomment string Http var : description of the action
25  */
26 function affect(&$action)
27 {
28  $docid = GetHttpVars("id");
29  $uid = GetHttpVars("_id_affectuser");
30  $newstate = GetHttpVars("newstate", -1);
31  $commentstate = GetHttpVars("_statecomment");
32  $commentaction = GetHttpVars("_actioncomment");
33  $dbaccess = $action->dbaccess;
34  $revstate = true;
35 
36  $doc = new_doc($dbaccess, $docid);
37  if (!$doc->isAlive()) $action->exitError(sprintf(_("document #%s not found. Affectation aborded") , $docid));
38  $wuid = 0;
39  if ($uid) {
40  $docu = new_doc($dbaccess, $uid);
41  if (!$docu->isAlive()) $action->addWarningMsg(sprintf(_("user #%s not found. Affectation aborded") , $uid));
42 
43  $wuid = $docu->getRawValue("us_whatid");
44  if (!($wuid > 0)) $action->addWarningMsg(sprintf(_("user #%s has not a real account. Affectation aborded") , $uid));
45  }
46  if ($newstate >= 0) {
47  $err = $doc->changeFreeState($newstate, $commentstate);
48  if ($err != "") $action->addWarningMsg($err);
49  else {
50  $revstate = false; // no need to revision one more
51  $action->addWarningMsg(sprintf(_("document %s has the new state %s") , $doc->title, $doc->getState()));
52  }
53  }
54  if ($wuid > 0) {
55  $err = $doc->allocate($wuid, $commentaction, $revstate);
56  if ($err != "") $action->addWarningMsg($err);
57 
58  if ($err == "") {
59  $action->AddActionDone("LOCKDOC", $doc->id);
60 
61  $action->addWarningMsg(sprintf(_("document %s has been allocate to %s") , $doc->title, $docu->title));
62 
63  $to = $docu->getRawValue("us_mail");
64  $subject = sprintf(_("allocation for %s document") , $doc->title);
65  $err = sendCard($action, $doc->id, $to, "", $subject, "", true, $commentaction, "", "", "htmlnotif");
66  if ($err != "") $action->addWarningMsg($err);
67  }
68  }
69 
70  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD&latest=Y&refreshfld=Y&id=" . $doc->id) , $action->GetParam("CORE_STANDURL"));
71 }
global $action
affect(&$action)
Definition: affect.php:26
sendCard(Action &$action, $docid, $to, $cc, $subject, $zonebodycard="", $ulink=false, $comment="", $from="", $bcc="", $format="html", $sendercopy=true, $addfiles=array(), $userinfo=null, $savecopy=false)
Definition: mailcard.php:156
$to
$subject
$docid
Definition: cleanFamily.php:13
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen