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