11 use \Dcp\AttributeIdentifiers\Mask as myAttr;
22 "R" => _(
"read only") ,
23 "W" => _(
"read write") ,
24 "O" => _(
"write only") ,
26 "S" => _(
"read disabled") ,
27 "U" => _(
"static array") ,
49 foreach ($tattrid as $k => $v) {
50 if (($tneed[$k] ===
'-') && ($tvis[$k] ===
'-') || ($tneed[$k] ===
'') && ($tvis[$k] ===
'-')) {
56 $this->
setValue(
"MSK_NEEDEEDS", $tneed);
57 $this->
setValue(
"MSK_ATTRIDS", $tattrid);
58 $this->
setValue(
"MSK_VISIBILITIES", $tvis);
80 return \ErrorCode::getError(
"MSK0001", $this->
name);
82 $fam = new_doc($this->dbaccess,
$famid);
83 if ($fam->doctype !==
"C") {
84 return \ErrorCode::getError(
"MSK0002",
$famid, $this->
name);
89 if ($attribute->usefor !==
"Q") {
93 foreach ($mskAttrids as $mAttrid) {
94 if ($mAttrid && !in_array($mAttrid,
$attrids)) {
96 return \ErrorCode::getError(
"MSK0003", $mAttrid, $fam->name, $this->name);
107 $tvisibilities = array();
108 foreach ($tattrid as $k => $v) {
109 if ($tvisid[$k] !==
"-") {
110 $tvisibilities[$v] = $tvisid[$k];
113 return $tvisibilities;
121 $tvisibilities = array();
122 foreach ($tattrid as $k => $v) {
123 $tvisibilities[$v] = $tvisid[$k];
125 return $tvisibilities;
133 function viewmask($target =
"_self", $ulink =
true, $abstract =
false)
139 $tkey_visibilities = array_keys($tvisibilities);
143 $this->lay->Set(
"docid",
$docid);
146 if (!
$doc->isAlive()) {
151 $origattr =
$doc->attributes->attr;
154 $tmpdoc->applyMask($this->
id);
159 $tmpdoc->attributes->orderAttributes();
161 foreach ($tmpdoc->attributes->attr as $k => $attr) {
165 if (!$attr->visibility)
continue;
166 if ($attr->usefor ==
'Q')
continue;
167 $tmask[$k][
"attrname"] = $attr->getLabel();
168 $tmask[$k][
"type"] = $attr->type;
169 $tmask[$k][
"attrid"] = $attr->id;
170 $tmask[$k][
"visibility"] = $labelvis[$attr->visibility];
171 $tmask[$k][
"wneed"] = (!empty($origattr[$k]->needed)) ?
___(
"mandatory",
"mask") :
___(
"optional",
"mask");
172 $tmask[$k][
"bgcolor"] =
"inherits";
173 $tmask[$k][
"isNeed"] = (!empty($origattr[$k]->needed));
174 $tmask[$k][
"mvisibility"] = $labelvis[$attr->mvisibility];
175 $tmask[$k][
"classtype"] = strtok($attr->type,
'(');
177 if (in_array($k, $tkey_visibilities)) {
178 $tmask[$k][
"classtype"].=
" directmodified";
179 } elseif ($tmask[$k][
"visibility"] != $tmask[$k][
"mvisibility"]) {
180 if ($tmask[$k][
"mvisibility"] != $labelvis[$origattr[$k]->mvisibility]) $tmask[$k][
"classtype"].=
" inheritmodified";
182 $tmask[$k][
"classtype"].=
" notmodified";
184 $tmask[$k][
"isAneed"] = $tmask[$k][
"isNeed"];
185 if (isset($tneedeeds[$attr->id])) {
186 if (($tneedeeds[$attr->id] ==
"Y") || (($tneedeeds[$attr->id] ==
"-") && (!empty($attr->needed)))) {
187 $tmask[$k][
"waneed"] =
___(
"mandatory",
"mask");
188 $tmask[$k][
"isAneed"] =
true;
190 $tmask[$k][
"waneed"] =
___(
"optional",
"mask");
191 $tmask[$k][
"isAneed"] =
false;
194 $tmask[$k][
"waneed"] = $tmask[$k][
"wneed"];
197 if (in_array($attr->type, array(
204 $tmask[$k][
"waneed"] = $tmask[$k][
"wneed"] =
'';
207 if ($tmask[$k][
"wneed"] != $tmask[$k][
"waneed"]) {
208 $tmask[$k][
"classtype"].=
" needmodified";
211 if ($attr->fieldSet && $attr->fieldSet->id && $attr->fieldSet->id != \Adoc::HIDDENFIELD) $tmask[$k][
"framelabel"] = $attr->fieldSet->getLabel();
212 else $tmask[$k][
"framelabel"] =
"";
213 if (!empty($attr->waction)) $tmask[$k][
"framelabel"] = _(
"Action");
215 $tmask[$k][
"displayorder"] = ($attr->ordered) ? $attr->ordered : -2;
216 if ($attr->type ==
"menu" || $attr->type ==
"action") $tmask[$k][
"displayorder"]+= 1000000;
217 if (($attr->ordered > 0) && $attr->fieldSet && $attr->fieldSet->id && $attr->fieldSet->ordered < - 1) {
218 $attr->fieldSet->ordered = $attr->ordered - 1;
219 $tmask[$attr->fieldSet->id][
"displayorder"] = $attr->ordered - 1;
220 if ($attr->fieldSet->fieldSet && $attr->fieldSet->fieldSet->id) {
221 if ($attr->fieldSet->fieldSet->ordered < - 1) {
222 $attr->fieldSet->fieldSet->ordered = $attr->fieldSet->ordered - 1;
223 $tmask[$attr->fieldSet->fieldSet->id][
"displayorder"] = $attr->fieldSet->ordered - 1;
228 unset($tmask[\Adoc::HIDDENFIELD]);
229 uasort($tmask, array(
233 $this->lay->SetBlockData(
"MASK", $tmask);
243 $this->lay->Set(
"docid",
$docid);
254 $selectclass = array();
255 $tclassdoc =
GetClassesDoc($this->dbaccess, $this->userid, 0,
"TABLE");
256 foreach ($tclassdoc as $k => $cdoc) {
257 $selectclass[$k][
"idcdoc"] = $cdoc[
"id"];
258 $selectclass[$k][
"classname"] = $cdoc[
"title"];
259 $selectclass[$k][
"selected"] =
"";
262 $this->lay->SetBlockData(
"SELECTCLASS", $selectclass);
266 $this->lay->set(
"creation", (
$docid == 0));
267 $this->lay->set(
"family", $family->getTitle());
272 foreach ($labelvis as $k => $v) {
273 $selectvis[] = array(
279 foreach ($labelneed as $k => $v) {
280 $selectneed[] = array(
287 $tattr = $family->getAttributes();
289 foreach ($tattr as $k => $attr) {
293 if ($attr->usefor ==
"Q")
continue;
294 if ($attr->docid == 0)
continue;
295 $newelem[$k][
"attrid"] = $attr->id;
296 $newelem[$k][
"attrname"] = $attr->getLabel();
297 $newelem[$k][
"type"] = strtok($attr->type,
'(');
298 $newelem[$k][
"visibility"] = $labelvis[$attr->visibility];
300 $newelem[$k][
"wneed"] = (!empty($attr->needed)) ?
___(
"mandatory",
"mask") :
___(
"optional",
"mask");
301 $newelem[$k][
"isNeed"] = (!empty($attr->needed));
302 $newelem[$k][
"neweltid"] = $k;
303 $newelem[$k][
"attrinfo"] = $attr->id;
304 $newelem[$k][
"useNeed"] = (!in_array($attr->type, array(
312 if ($attr->fieldSet && $attr->fieldSet->id && $attr->fieldSet->id != \Adoc::HIDDENFIELD) {
313 $newelem[$k][
"attrinfo"].=
'/' . $attr->fieldSet->id;
314 if ($attr->fieldSet->fieldSet->id && $attr->fieldSet->fieldSet->id != \Adoc::HIDDENFIELD) $newelem[$k][
"attrinfo"].=
'/' . $attr->fieldSet->fieldSet->id;
317 if (($attr->type ==
"array") || (strtolower(get_class($attr)) ==
"fieldsetattribute")) $newelem[$k][
"fieldweight"] =
"bold";
318 else $newelem[$k][
"fieldweight"] =
"";
320 if ($attr->docid ==
$docid) {
321 $newelem[$k][
"disabled"] =
"";
323 $newelem[$k][
"disabled"] =
"disabled";
326 if ($attr->fieldSet && $attr->fieldSet->docid > 0) $newelem[$k][
"framelabel"] = $attr->fieldSet->getLabel();
327 else $newelem[$k][
"framelabel"] =
"";
328 if (!empty($attr->waction)) $newelem[$k][
"framelabel"] = _(
"Action");
331 foreach ($selectvis as $kopt => $opt) {
332 if (isset($tvisibilities[$attr->id]) && $opt[
"visid"] == $tvisibilities[$attr->id]) {
333 $selectvis[$kopt][
"selected"] =
"selected";
335 $selectvis[$kopt][
"selected"] =
"";
340 foreach ($selectneed as $kopt => $opt) {
341 if (isset($tneedeeds[$attr->id]) && $opt[
"needid"] == $tneedeeds[$attr->id]) {
342 $selectneed[$kopt][
"selectedneed"] =
"selected";
344 $selectneed[$kopt][
"selectedneed"] =
"";
347 $newelem[$k][
"displayorder"] = ($attr->ordered) ? $attr->ordered : -2;
348 if ($attr->type ==
"menu" || $attr->type ==
"action") $newelem[$k][
"displayorder"]+= 1000000;
349 if (($attr->ordered > 0) && $attr->fieldSet && $attr->fieldSet->id && $attr->fieldSet->ordered < - 1) {
350 $attr->fieldSet->ordered = $attr->ordered - 1;
351 $newelem[$attr->fieldSet->id][
"displayorder"] = $attr->ordered - 1;
352 if ($attr->fieldSet->fieldSet && $attr->fieldSet->fieldSet->id) {
353 if ($attr->fieldSet->fieldSet->ordered < - 1) {
354 $attr->fieldSet->fieldSet->ordered = $attr->fieldSet->ordered - 1;
355 $newelem[$attr->fieldSet->fieldSet->id][
"displayorder"] = $attr->fieldSet->ordered - 1;
359 $newelem[$k][
"SELECTVIS"] =
"SELECTVIS_$k";
360 $this->lay->SetBlockData($newelem[$k][
"SELECTVIS"], $selectvis);
361 $newelem[$k][
"SELECTNEED"] =
"SELECTNEED_$k";
362 $this->lay->SetBlockData($newelem[$k][
"SELECTNEED"], $selectneed);
366 unset($newelem[\Adoc::HIDDENFIELD]);
367 uasort($newelem, array(
371 $this->lay->SetBlockData(
"NEWELEM", $newelem);
383 if (isset(
$a[
"displayorder"]) && isset($b[
"displayorder"])) {
384 if (
$a[
"displayorder"] == $b[
"displayorder"])
return 0;
385 if (
$a[
"displayorder"] > $b[
"displayorder"])
return 1;
388 if (isset(
$a[
"displayorder"]))
return 1;
389 if (isset($b[
"displayorder"]))
return -1;
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
print $fam getTitle() $fam name
if(!function_exists('pgettext')) ___($message, $context="")
preImport(array $extra=array())
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
setValue($attrid, $value, $index=-1, &$kvalue=null)
getMultipleRawValues($idAttr, $def="", $index=-1)
static sortnewelem($a, $b)
new_Doc($dbaccess, $id= '', $latest=false)
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
getRawValue($idAttr, $def="")