Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
faddbook_maincols.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  * Choose attribute column to display
9  *
10  * @author Anakeen 2005
11  * @version $Id: faddbook_maincols.php,v 1.7 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 USERCARD
15  */
16 /**
17  */
18 include_once ("FDL/Lib.Dir.php");
19 
21 {
22 
23  global $_GET, $_POST, $ZONE_ARGS;
24  $dbaccess = $action->getParam("FREEDOM_DB");
25  // Get default visibilty => Abstract view from freedom
26  $sfam = GetHttpVars("dfam", $action->getParam("DEFAULT_FAMILY"));
27  $action->lay->set("dfam", $sfam);
28  $dnfam = new_Doc($dbaccess, $sfam);
29  $action->lay->set("dfamname", $dnfam->title);
30 
31  $reset = GetHttpVars("resetcols", 0);
32 
33  $ncols = array();
34  $prefix = "faddb_cols_";
35  if ($reset != 1) {
36  foreach ($_POST as $k => $v) {
37  if (substr($k, 0, strlen($prefix)) != $prefix) continue;
38  $id = substr($k, strlen($prefix));
39  $ncols[$sfam][$id] = ($v == "on" ? 1 : 0);
40  }
41  }
42 
43  $dfam = createDoc($dbaccess, $sfam, false);
44  $fattr = $dfam->GetAttributes();
45  $cols = array();
46  foreach ($fattr as $k => $v) {
47  if ($v->type != "menu" && $v->type != "frame" && $v->visibility != "H" && $v->visibility != "O" && $v->visibility != "I") {
48  $cols[$v->id] = array(
49  "l" => ($v->isInAbstract == 1 ? 1 : 0) ,
50  "order" => $v->ordered,
51  "label" => $v->getLabel()
52  );
53  }
54  }
55 
56  $pc = $action->getParam("FADDBOOK_MAINCOLS", "");
57  if (count($ncols) > 0 || $reset == 1) { // Modified state
58  $allcol = array();
59  foreach ($cols as $k => $v) {
60  if ($reset != 1) $cols[$k]["l"] = 0;
61  if (isset($ncols[$sfam][$k])) $cols[$k]["l"] = ($ncols[$sfam][$k] != "" ? $ncols[$sfam][$k] : 0);
62  if ($cols[$k]["l"] == 1) $allcol[] = $sfam . "%" . $k;
63  }
64  // AddWarningMsg("FADDBOOK_MAINCOLS = [$scol]");
65  if ($pc != "") {
66  $tccols = explode("|", $pc);
67  foreach ($tccols as $k => $v) {
68  if ($v == "") continue;
69  $x = explode("%", $v);
70  if ($x[0] != $sfam) $allcol[] = $x[0] . "%" . $x[1];
71  }
72  }
73  $scol = implode("|", $allcol);
74  if ($action->user->id == 1) $action->parent->param->Set("FADDBOOK_MAINCOLS", $scol, PARAM_APP, $action->parent->id);
75  $action->parent->param->set("FADDBOOK_MAINCOLS", $scol, PARAM_USER . $action->user->id, $action->parent->id);
76  } else { // User initial state
77  if ($pc != "") {
78  $tccols = explode("|", $pc);
79  // reset first
80  foreach ($cols as $k => $v) $cols[$k]["l"] = 0;
81 
82  foreach ($tccols as $k => $v) {
83  if ($v == "") continue;
84  $x = explode("%", $v);
85  if ($x[0] == $sfam && isset($cols[$x[1]])) {
86  $cols[$x[1]]["l"] = 1;
87  }
88  }
89  }
90  }
91 
92  foreach ($cols as $k => $v) {
93  $vcols[] = array(
94  "id" => $k,
95  "label" => $v["label"],
96  "pos" => $v["order"],
97  "l_view" => ($v["l"] == 1 ? "checked" : "")
98  );
99  }
100  $action->lay->setBlockData("Columns", $vcols);
101 }
102 ?>
← centre documentaire © anakeen - published under CC License - Dynacase