Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Method.PortFolio.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  * PortFolio Methods
9  *
10  * @author Anakeen 2003
11  * @version $Id: Method.PortFolio.php,v 1.17 2008/01/22 16:44:48 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
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 _PORTFOLIO extends Doc
23 {
24  /*
25  * @end-method-ignore
26  */
27  /**
28  * Call to create default tabs
29  */
30  function PostCreated()
31  {
32  if ($this->revision > 0) return;
33  if (!method_exists($this, "addfile")) return;
34  // copy all guide-card from default values
36  return $this->CreateDefaultTabs();
37  }
38 
40  {
41  include_once ("FDL/Lib.Dir.php");
42  $child = getChildDir($this->dbaccess, 1, $this->initid, false, "TABLE");
43  if (count($child) == 0) {
44  $err = $this->CreateDefaultTabs();
45  }
46  return $err;
47  }
48  /**
49  * Create default tabs based on tabs of PFL_IDDEF document
50  * @return string message error (empty if no error)
51  */
52  function CreateDefaultTabs()
53  {
54 
55  $err = "";
56  include_once ("FDL/Lib.Dir.php");
57 
58  $ddocid = $this->getValue("PFL_IDDEF");
59 
60  if ($ddocid != "") {
61  $ddoc = new_Doc($this->dbaccess, $ddocid);
62  if ($ddoc->isAffected()) {
63  $child = getChildDir($this->dbaccess, $this->userid, $ddoc->initid, false, "TABLE");
64 
65  foreach ($child as $k => $tdoc) {
66  $doc = getDocObject($this->dbaccess, $tdoc);
67  $copy = $doc->Copy();
68  if (!is_object($copy)) $err.= $copy;
69  else $err.= $this->AddFile($copy->id, "latest", true, true);
70  }
71  } else {
72  $err = sprintf(_("Error in portfolio : folder %s not exists") , $ddocid);
73  }
74  }
75  return $err;
76  }
77  /**
78  * Create default tabs based on tabs of PFL_IDCOPYTAB parameter
79  * @return string message error (empty if no error)
80  */
82  {
83 
84  $err = "";
85  include_once ("FDL/Lib.Dir.php");
86 
87  $copytab = $this->getParamValue("pfl_idcopytab");
88  if ($copytab) {
89  $copytab = $this->_val2array($copytab);
90  foreach ($copytab as $k => $id) {
91  $tdoc = getTDoc($this->dbaccess, $id);
92 
93  $doc = getDocObject($this->dbaccess, $tdoc);
94  $copy = $doc->Copy();
95  if (!is_object($copy)) $err.= $copy;
96  else $err.= $this->AddFile($copy->id, "latest", true, true);
97  }
98  }
99 
100  return $err;
101  }
102  function postInsertDoc($docid, $multiple = false)
103  {
104  $doc = new_Doc($this->dbaccess, $docid);
105  if ($doc->doctype == "S") {
106  $doc->setValue("SE_IDCFLD", $this->initid);
107  $doc->refresh();
108  $doc->modify();
109  }
110  }
111  /**
112  * return document includes in portfolio an in each of its guide or searched inside portfolio
113  * @param bool $controlview if false all document are returned else only visible for current user document are return
114  * @param array $filter to add list sql filter for selected document
115  * @param int $famid family identificator to restrict search
116  * @param bool $insertguide if true merge each content of guide else same as a normal folder
117  * @return array array of document array
118  */
119  function getContent($controlview = true, $filter = array() , $famid = "", $insertguide = false)
120  {
121  $tdoc = Dir::getContent($controlview, $filter, $famid);
122  if ($insertguide) {
123  $todoc = array();
124  foreach ($tdoc as $k => $v) {
125  if (($v["doctype"] == "D") || ($v["doctype"] == "S")) {
126  $dir = new_Doc($this->dbaccess, $v["id"]);
127  $todoc = array_merge($todoc, $dir->getContent($controlview, $filter));
128  unset($tdoc[$k]);
129  }
130  }
131  if (count($todoc)) {
132  // array unique
133  $todoc = array_merge($tdoc, $todoc);
134  $tdoc = array();
135  foreach ($todoc as $k => $v) {
136  $tdoc[$v["id"]] = $v;
137  }
138  }
139  }
140  return $tdoc;
141  }
142  /**
143  * @begin-method-ignore
144  * this part will be deleted when construct document class until end-method-ignore
145  */
146 }
147 /*
148  * @end-method-ignore
149 */
150 ?>
← centre documentaire © anakeen - published under CC License - Dynacase