Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.Emailing.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Methods for emailing family
8  */
9 namespace Dcp\Core;
11 {
12  /*
13  * @end-method-ignore
14  */
15  var $defaultedit = "FDL:FDL_PUBEDIT";
16  var $defaultmview = "FDL:FDL_PUBMAIL:T";
17  /**
18  * @param string $target
19  * @param bool $ulink
20  * @param bool $abstract
21  * @templateController
22  */
23  function fdl_pubsendmail($target = "_self", $ulink = true, $abstract = false)
24  {
25  $this->viewdefaultcard($target, $ulink, $abstract);
26  $this->lay->set("V_PUBM_BODY", str_replace("&#x5B;", "[", $this->lay->get("V_PUBM_BODY")));
27 
28  $uid = getHttpVars("uid");
29  if ($uid) {
30  $udoc = new_Doc($this->dbaccess, $uid);
31  if ($udoc->isAlive()) {
32  $listattr = $udoc->GetNormalAttributes();
33  $atarget = ""; // must not be mail the same bacuse it is not the doc itself
34  foreach ($listattr as $k => $v) {
35  $value = $udoc->getRawValue($v->id);
36 
37  if ($value || ($v->type == "image")) $this->lay->Set(strtoupper($v->id) , $udoc->GetHtmlValue($v, $value, $atarget, $ulink));
38  else $this->lay->Set(strtoupper($v->id) , false);
39  }
40  }
41  }
42  }
43  /**
44  * @param string $target
45  * @param bool $ulink
46  * @param bool $abstract
47  * @templateController
48  */
49  function fdl_pubprintone($target = "_self", $ulink = true, $abstract = false)
50  {
51  $this->fdl_pubsendmail($target, $ulink, $abstract);
52  }
53  /**
54  * @templateController
55  */
56  function fdl_pubedit()
57  {
58  $this->editattr();
59  $famid = $this->getRawValue("PUBM_IDFAM", "IUSER");
60  $udoc = createDoc($this->dbaccess, $famid, false);
61  if (!$udoc) {
62  addWarningMsg(sprintf(_("fdl_pubedit error: family %s not found") , $famid));
63  AddLogMsg(sprintf(_("fdl_pubedit error: family %s not found") , $famid));
64  return false;
65  }
66  $listattr = $udoc->GetNormalAttributes();
67  $tatt = array();
68  foreach ($listattr as $k => $v) {
69  $tatt[$k] = array(
70  "aid" => "[" . strtoupper($k) . "]",
71  "alabel" => str_replace("'", "\\'", $v->getLabel())
72  );
73  }
74  $listattr = $udoc->GetFileAttributes();
75  foreach ($listattr as $k => $v) {
76  if ($v->type == "image") {
77  $tatt[$k] = array(
78  "aid" => "<img src=\"[" . strtoupper($k) . "]\">",
79  "alabel" => str_replace("'", "\\'", $v->getLabel())
80  );
81  } else {
82  $tatt[$k] = array(
83  "aid" => "<a href=\"[" . strtoupper($k) . "]\">" . $v->getLabel() . "</a>",
84  "alabel" => str_replace("'", "\\'", $v->getLabel())
85  );
86  }
87  }
88  $this->lay->set("famattr", sprintf(_("%s attribute") , $this->getRawValue("pubm_fam", "personne")));
89  $this->lay->setBlockData("ATTR", $tatt);
90  return true;
91  }
92  /**
93  * Fusion all document to be printed
94  * @param \Action &$action current action
95  * @global uid string Http var : user document id (if not all use rpresent in folder)
96  * @templateController
97  */
98  function fdl_pubprint($target = "_self", $ulink = true, $abstract = false)
99  {
100  global $action;
101  // GetAllParameters
102  $udocid = GetHttpVars("uid");
103  $subject = $this->getRawValue("pubm_title");
104  $body = $this->getRawValue("pubm_body");
105  $zonebodycard = "FDL:FDL_PUBPRINTONE:S"; // define view zone
106  $tlay = array();
107  if ($udocid > 0) {
108  $t[] = getTDoc($this->dbaccess, $udocid);
109  } else {
110  $t = $this->getContent();
111  }
112 
113  if (preg_match("/\[[a-z]+_[a-z0-9_]+\]/i", str_replace("&#x5B;", "[", $body))) {
114  foreach ($t as $k => $v) {
115  $zoneu = $zonebodycard . "?uid=" . $v["id"];
116  $tlay[] = array(
117  "doc" => $this->viewDoc($zoneu, "", true) ,
118  "subject" => $v["title"]
119  );
120  }
121  } else {
122  $laydoc = $this->viewDoc($zonebodycard, "", true);
123 
124  foreach ($t as $k => $v) {
125  $tlay[] = array(
126  "doc" => $laydoc,
127  "subject" => $v["title"]
128  );
129  }
130  }
131  if (count($t) == 0) $action->AddWarningMsg(_("no available persons found"));
132 
133  $this->lay->setBlockData("DOCS", $tlay);
134  $this->lay->set("BGIMG", $this->getHtmlAttrValue("pubm_bgimg"));
135  }
136  /**
137  * Fusion all document to be displayed
138  * idem as fdl_pubprint but without new page
139  * @param \Action &$action current action
140  * @global uid string Http var : user document id (if not all use rpresent in folder)
141  * @templateController
142  */
143  function fdl_pubdisplay($target = "_self", $ulink = true, $abstract = false)
144  {
145  $this->fdl_pubprint($target, $ulink, $abstract);
146  }
147  /**
148  * @param string $target
149  * @param bool $ulink
150  * @param bool $abstract
151  * @templateController
152  */
153  function fdl_pubmail($target = "_self", $ulink = true, $abstract = false)
154  {
155  include_once ("FDL/mailcard.php");
156  global $action;
157  $subject = $this->getRawValue("pubm_title");
158  $body = $this->getRawValue("pubm_body");
159  $err = "";
160  $t = $this->getContent();
161  $mailattr = strtolower($this->getRawValue("PÜBM_MAILATT", "us_mail"));
162 
163  $tout = array();
164  $zonebodycard = "FDL:FDL_PUBSENDMAIL:S";
165  if (preg_match("/\[[a-z]+_[a-z0-9_]+\]/i", $body)) {
166  foreach ($t as $k => $v) {
167  $mail = getv($v, $mailattr);
168  if ($mail != "") {
169  $zoneu = $zonebodycard . "?uid=" . $v["id"];
170  $to = $mail;
171  $cc = "";
172  $err = sendCard($action, $this->id, $to, $cc, $subject, $zoneu);
173  $tout[] = array(
174  "name" => $v["title"],
175  "mailto" => $to,
176  "color" => ($err) ? "#ea4c4c" : "#7df89d",
177  "status" => ($err) ? $err : "OK"
178  );
179  }
180  }
181  } else {
182  $tmail = array();
183  foreach ($t as $k => $v) {
184  $mail = getv($v, $mailattr);
185  if ($mail != "") $tmail[] = $mail;
186  }
187  $to = "";
188  $bcc = implode(",", $tmail);
189  $cc = "";
190  $err = sendCard($action, $this->id, $to, $cc, $subject, $zonebodycard, false, "", "", $bcc);
191  $tout[] = array(
192  "name" => "-",
193  "mailto" => $bcc,
194  "color" => ($err) ? "#ea4c4c" : "#7df89d",
195  "status" => ($err) ? $err : "OK"
196  );
197  }
198  if ($err) $action->AddWarningMsg($err);
199  $this->lay->setBlockData("MAILS", $tout);
200  $this->viewattr($target, $ulink, $abstract);
201  }
202  /**
203  * Preview of each document to be printed
204  * @templateController
205  */
206  function fdl_pubpreview($target = "_self", $ulink = true, $abstract = false)
207  {
208 
209  $this->lay->set("dirid", $this->id);
210  }
211  /**
212  * Preview of each document to be printed
213  * @templateController
214  */
215  function fdl_pubnavpreview($target = "_self", $ulink = true, $abstract = false)
216  {
217 
218  $t = $this->getContent();
219  $tlay = array();
220  foreach ($t as $k => $v) {
221  $tlay[] = array(
222  "udocid" => $v["id"],
223  "utitle" => $v["title"]
224  );
225  }
226 
227  $this->lay->setBlockData("DOCS", $tlay);
228  $this->lay->set("dirid", $this->id);
229  }
230 }
fdl_pubmail($target="_self", $ulink=true, $abstract=false)
getHtmlAttrValue($attrid, $target="_self", $htmllink=2, $index=-1, $entities=true, $abstract=false)
Definition: Class.Doc.php:6489
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
global $action
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
fdl_pubdisplay($target="_self", $ulink=true, $abstract=false)
getv(&$t, $k, $d="")
addWarningMsg($msg)
Definition: Lib.Common.php:95
count($onlyprimary=false)
Definition: Class.Dir.php:916
viewattr($target="_self", $ulink=true, $abstract=false, $viewhidden=false)
Definition: Class.Doc.php:7695
viewdefaultcard($target="_self", $ulink=true, $abstract=false, $viewhidden=false)
Definition: Class.Doc.php:7099
fdl_pubsendmail($target="_self", $ulink=true, $abstract=false)
$to
$subject
editattr($withtd=true)
Definition: Class.Doc.php:8129
AddLogMsg($msg, $cut=80)
Definition: Lib.Common.php:77
fdl_pubnavpreview($target="_self", $ulink=true, $abstract=false)
$tout
Definition: checklist.php:47
getContent($controlview=true, array $filter=array(), $famid="", $insertguide=true, $unused="")
fdl_pubpreview($target="_self", $ulink=true, $abstract=false)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
$bcc
new_Doc($dbaccess, $id= '', $latest=false)
$cc
viewDoc($layout="FDL:VIEWBODYCARD", $target="_self", $ulink=true, $abstract=false, $changelayout=false)
Definition: Class.Doc.php:6994
fdl_pubprintone($target="_self", $ulink=true, $abstract=false)
if($file) if($subject==""&&$file) if($subject=="") $err
fdl_pubprint($target="_self", $ulink=true, $abstract=false)
getRawValue($idAttr, $def="")
Definition: Class.Doc.php:3117
$value
← centre documentaire © anakeen