Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Method.DocUser.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  * Persons & LDAP methods
9  *
10  * @author Anakeen 2000
11  * @version $Id: Method.DocUser.php,v 1.37 2006/06/23 15:30:55 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage USERCARD
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 _USER extends Doc
23 {
24  /*
25  * @end-method-ignore
26  */
27 
28  var $defaultabstract = "USERCARD:VIEWABSTRACTCARD";
29  var $cviews = array(
30  "USERCARD:VIEWABSTRACTCARD"
31  );
32  // -----------------------------------
33  function viewabstractcard($target = "finfo", $ulink = true, $abstract = "Y")
34  {
35  // -----------------------------------
36  // doc::viewabstractcard($target,$ulink,$abstract);
37  $this->viewprop($target, $ulink, $abstract);
38  $this->viewattr($target, $ulink, $abstract);
39  }
40 
41  function PostModify()
42  {
43  $err = "";
44 
45  $err = $this->RefreshLdapCard();
46 
47  $this->SetPrivacity(); // set doc properties in concordance with its privacity
48  return ($err);
49  }
50 
51  function SpecRefresh()
52  {
53  // " gettitle(D,US_IDSOCIETY):US_SOCIETY,US_IDSOCIETY";
54  $this->refreshDocTitle("US_IDSOCIETY", "US_SOCIETY");
55 
56  $this->AddParamRefresh("US_IDSOCIETY,US_SOCADDR", "US_WORKADDR,US_WORKTOWN,US_WORKPOSTALCODE,US_WORKWEB,US_WORKCEDEX,US_COUNTRY,US_SPHONE,US_SFAX");
57  $this->AddParamRefresh("US_IDSOCIETY", "US_SCATG,US_JOB");
58 
59  $doc = new_Doc($this->dbaccess, $this->getValue("US_IDSOCIETY"));
60  if ($doc->isAlive()) {
61  if ($this->getValue("US_SOCADDR") != "") {
62  $this->setValue("US_WORKADDR", $doc->getValue("SI_ADDR", " "));
63  $this->setValue("US_WORKTOWN", $doc->getValue("SI_TOWN", " "));
64  $this->setValue("US_WORKPOSTALCODE", $doc->getValue("SI_POSTCODE", " "));
65  $this->setValue("US_WORKWEB", $doc->getValue("SI_WEB", " "));
66  $this->setValue("US_WORKCEDEX", $doc->getValue("SI_CEDEX", " "));
67  $this->setValue("US_COUNTRY", $doc->getValue("SI_COUNTRY", " "));
68  }
69  $this->setValue("US_SCATG", $doc->getValue("SI_CATG"));
70  $this->setValue("US_JOB", $doc->getValue("SI_JOB"));
71 
72  if ($this->getValue("US_PPHONE") != "") $this->setValue("US_PHONE", $this->getValue("US_PPHONE") . " (" . _("direct") . ")");
73  else $this->setValue("US_PHONE", $doc->getValue("SI_PHONE", " "));
74  if ($this->getValue("US_PFAX") != "") $this->setValue("US_FAX", $this->getValue("US_PFAX") . " (" . _("direct") . ")");
75  else $this->setValue("US_FAX", $doc->getValue("SI_FAX", " "));
76  } else {
77  $this->setValue("US_PHONE", $this->getValue("US_PPHONE", " "));
78  $this->setValue("US_FAX", $this->getValue("US_PFAX", " "));
79  }
80  }
81  /**
82  * refresh LDAP
83  */
84  function PostDelete()
85  {
86  $this->SetLdapParam();
87  $this->DeleteLdapCard();
88  }
89  /**
90  * test if the document can be set in LDAP
91  */
92  function canUpdateLdapCard()
93  {
94  // $priv=$this->GetValue("US_PRIVCARD");
95  if ($priv == "S") return false;
96  return true;
97  }
98  /**
99  * return different DN if is a private or not private card
100  */
101  function getUserLDAPDN($rdn, $path = "")
102  {
103  $priv = $this->GetValue("US_PRIVCARD");
104  if ($priv == "P") {
105  $u = new User("", $this->owner);
106  if ($u->isAffected()) {
107  $this->infoldap[$this->cindex]["ou"] = $u->login;
108  return sprintf("%s=%s,ou=%s,%s,%s", $rdn, $this->infoldap[$this->cindex][$rdn], $u->login, $path, $this->racine);
109  }
110  } elseif ($priv == "G") {
111  $tidg = $this->getTValue("us_idprivgroup");
112 
113  $tdn = array(); // array od DN
114  foreach ($tidg as $k => $idg) {
115  $t = getTDoc($this->dbaccess, $idg);
116  $login = getv($t, "us_login");
117  $this->infoldap[$this->cindex]["ou"] = $login;
118  $tdn[] = sprintf("%s=%s,ou=%s,%s,%s", $rdn, $this->infoldap[$this->cindex][$rdn], $login, $path, $this->racine);
119  }
120  if (count($tdn) == 0) return "";
121  elseif (count($tdn) == 1) return $tdn[0];
122  return $tdn;
123  } else {
124  return $this->getLDAPDN($rdn, $path);
125  }
126  }
127  /**
128  * recompute profil with privacy attribute value
129  * 5 possibilities :
130  * W : public in read/write
131  * R : public in read mode
132  * P : private
133  * G : group restriction
134  * S : specific profil : do nothing
135  */
136  function SetPrivacity()
137  {
138  $priv = $this->GetValue("US_PRIVCARD");
139  $err = "";
140 
141  switch ($priv) {
142  case "P":
143  if ($this->profid == "0") {
144  $err = $this->setControl();
145  } else {
146  $this->RemoveControl();
147  $err = $this->setControl();
148  }
149  $err = $this->lock();
150 
151  break;
152 
153  case "R":
154  if ($this->profid != "0") {
155  $err = $this->unsetControl();
156  }
157  $this->lock();
158  break;
159 
160  case "W":
161  if ($this->profid != "0") {
162  $err = $this->unsetControl();
163  }
164  $this->unlock();
165  break;
166 
167  case "G":
168  if ($this->profid == "0") {
169  $err = $this->setControl();
170  } elseif ($this->profid == $this->id) {
171  //already profil :reset
172  $this->RemoveControl();
173  $err = $this->setControl();
174  }
175  if ($this->profid == $this->id) {
176 
177  $tidg = $this->getTValue("us_idprivgroup");
178  foreach ($tidg as $k => $idg) {
179  $t = getTDoc($this->dbaccess, $idg);
180  $gid = getv($t, "us_whatid");
181 
182  $this->AddControl($gid, "view");
183  }
184  }
185 
186  $err = $this->lock();
187 
188  break;
189  }
190  if ($err != "") AddLogMsg($this->title . ":" . $err);
191  }
192  /**
193  * @begin-method-ignore
194  * this part will be deleted when construct document class until end-method-ignore
195  */
196 }
197 /*
198  * @end-method-ignore
199 */
200 ?>
← centre documentaire © anakeen - published under CC License - Dynacase