Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.PortFolio.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * PortFolio Methods
8  *
9  */
10 namespace Dcp\Core;
12 {
13  /**
14  * Call to create default tabs
15  */
16  function PostCreated()
17  {
18  if ($this->revision > 0) return '';
19  if (!method_exists($this, "addfile")) return '';
20  // copy all guide-card from default values
22  return $this->CreateDefaultTabs();
23  }
24 
26  {
27  include_once ("FDL/Lib.Dir.php");
28  $err='';
29  $child = getChildDir($this->dbaccess, 1, $this->initid, false, "TABLE");
30  if (count($child) == 0) {
31  $err = $this->CreateDefaultTabs();
32  }
33  return $err;
34  }
35  /**
36  * Create default tabs based on tabs of PFL_IDDEF document
37  * @return string message error (empty if no error)
38  */
39  function CreateDefaultTabs()
40  {
41 
42  $err = "";
43  include_once ("FDL/Lib.Dir.php");
44 
45  $ddocid = $this->getRawValue("PFL_IDDEF");
46 
47  if ($ddocid != "") {
48  $ddoc = new_Doc($this->dbaccess, $ddocid);
49  if ($ddoc->isAffected()) {
50  $child = getChildDir($this->dbaccess, $this->userid, $ddoc->initid, false, "TABLE");
51 
52  foreach ($child as $k => $tdoc) {
53  $doc = getDocObject($this->dbaccess, $tdoc);
54  $copy = $doc->duplicate();
55  if (!is_object($copy)) $err.= $copy;
56  else $err.= $this->insertDocument($copy->id, "latest", true, true);
57  }
58  } else {
59  $err = sprintf(_("Error in portfolio : folder %s not exists") , $ddocid);
60  }
61  }
62  return $err;
63  }
64  /**
65  * Create default tabs based on tabs of PFL_IDCOPYTAB parameter
66  * @return string message error (empty if no error)
67  */
69  {
70 
71  $err = "";
72  include_once ("FDL/Lib.Dir.php");
73 
74  $copytab = $this->getFamilyParameterValue("pfl_idcopytab");
75  if ($copytab) {
76  $copytab = $this->rawValueToArray($copytab);
77  foreach ($copytab as $k => $id) {
78  $tdoc = getTDoc($this->dbaccess, $id);
79 
80  $doc = getDocObject($this->dbaccess, $tdoc);
81  $copy = $doc->duplicate();
82  if (!is_object($copy)) $err.= $copy;
83  else $err.= $this->insertDocument($copy->id, "latest", true, true);
84  }
85  }
86 
87  return $err;
88  }
89  function postInsertDocument($docid, $multiple = false)
90  {
91  $doc = new_Doc($this->dbaccess, $docid);
92  if ($doc->doctype == "S") {
93  $doc->setValue("SE_IDCFLD", $this->initid);
94  $doc->refresh();
95  $doc->modify();
96  }
97  }
98  /**
99  * return document includes in portfolio an in each of its guide or searched inside portfolio
100  * @param bool $controlview if false all document are returned else only visible for current user document are return
101  * @param array $filter to add list sql filter for selected document
102  * @param int $famid family identifier to restrict search
103  * @param bool $insertguide if true merge each content of guide else same as a normal folder
104  * @return array array of document array
105  */
106  function getContent($controlview = true, array $filter = array() , $famid = "", $insertguide = false, $unused = "")
107  {
108  $tdoc = \Dir::getContent($controlview, $filter, $famid);
109  if ($insertguide) {
110  $todoc = array();
111  foreach ($tdoc as $k => $v) {
112  if (($v["doctype"] == "D") || ($v["doctype"] == "S")) {
113  /**
114  * @var \DocCollection $dir
115  */
116  $dir = new_Doc($this->dbaccess, $v["id"]);
117  $todoc = array_merge($todoc, $dir->getContent($controlview, $filter));
118  unset($tdoc[$k]);
119  }
120  }
121  if (count($todoc)) {
122  // array unique
123  $todoc = array_merge($tdoc, $todoc);
124  $tdoc = array();
125  foreach ($todoc as $k => $v) {
126  $tdoc[$v["id"]] = $v;
127  }
128  }
129  }
130  return $tdoc;
131  }
132 }
$tdoc
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
static rawValueToArray($v)
Definition: Class.Doc.php:6228
count($onlyprimary=false)
Definition: Class.Dir.php:916
getFamilyParameterValue($idp, $def="")
Definition: Class.Doc.php:1538
getContent($controlview=true, array $filter=array(), $famid="", $qtype="TABLE", $trash="")
Definition: Class.Dir.php:895
$docid
Definition: cleanFamily.php:13
getChildDir($dbaccess, $userid, $dirid, $notfldsearch=false, $restype="LIST")
Definition: Lib.Dir.php:38
revision(Action &$action)
Definition: revision.php:22
new_Doc($dbaccess, $id= '', $latest=false)
$dir
Definition: resizeimg.php:144
insertDocument($docid, $mode="latest", $noprepost=false, $forcerestrict=false, $nocontrol=false)
Definition: Class.Dir.php:315
if($file) if($subject==""&&$file) if($subject=="") $err
postInsertDocument($docid, $multiple=false)
getRawValue($idAttr, $def="")
Definition: Class.Doc.php:3117
getDocObject($dbaccess, $v, $k=0)
← centre documentaire © anakeen