19 include_once (
"DATA/Class.Collection.php");
27 $mb1 = microtime(
true);
28 $id = getHttpVars(
"id");
29 $method = strtolower(getHttpVars(
"method"));
37 if ($returntype !=
"json") $action->lay->template =
$out;
41 else if (is_object(
$out))
$out->debuginfo =
getPerfoInfo(sprintf(
"%.03fs", microtime(
true) - $mb1));
44 $action->lay->template = json_encode(
$out);
46 $action->lay->noparse =
true;
49 include_once (
"WHAT/wdebug.php");
56 $trace[
"all"] = sprintf(
"%.03fs", microtime(
true) - $DEBUGINFO[
"mbinit"]);
57 $trace[
"queries"] = sprintf(
"%.03fs #%d", $SQLDELAY, count($TSQLDELAY));
58 if ($time)
$trace[
"action"] = $time;
59 $trace[
"initauthent"] = sprintf(
"%.03fs", $DEBUGINFO[
"mbaction"] - $DEBUGINFO[
"mbinit"]);
60 $trace[
"memory"] = sprintf(
"%dkb", round(memory_get_usage() / 1024));
74 $config = getHttpVars(
"config");
75 if (is_object($config)) {
76 include_once (
"DATA/Class.DocumentSelection.php");
78 $idssel = $sel->getIdentificators();
79 $out->content = array();
80 foreach ($idssel as $did) {
81 $out->content[][
"properties"][
"id"] = $did;
84 $out->error = sprintf(_(
"getSelection: no configuration set"));
90 $err = sprintf(_(
"empty reference"));
95 $doc->setContentCompleteProperties($action->
getArgument(
"completeProperties",
"false") ==
"true");
96 $doc->setContentOnlyValue($action->
getArgument(
"onlyValues",
"true") ==
"true");
102 $doc->setContentRecursiveLevel($action->
getArgument(
"recursiveLevel", 0));
103 $doc->setContentSearchProperty($action->
getArgument(
"searchProperty",
"svalues"));
108 $doc->setContentVerifyHasChild($action->
getArgument(
"verifyhaschild") ==
"true");
113 case 'getauthorizedfamilies':
116 $out->authorizedFamilies =
$doc->getAuthorizedFamilies();
120 case 'getsubfamilies':
121 $famid = getHttpVars(
"famid");
122 if (!
$famid)
$out->error = _(
"data:getsubfamilies no family parameter");
126 $cc = (getHttpVars(
"controlCreation",
"false") ==
"true");
133 $onlyValues = getHttpVars(
"onlyValues",
"true") ==
"true";
136 $key = getHttpVars(
"key");
137 $famid = getHttpVars(
"family", getHttpVars(
"famid", 0));
138 $start = getHttpVars(
"start", 0);
139 $slice = getHttpVars(
"slice", 100);
140 $mode = getHttpVars(
"mode",
"word");
141 $orderby = getHttpVars(
"orderBy");
142 $whl = (getHttpVars(
"withHighlight",
"false") ==
"true");
143 $filter = getHttpVars(
"filter");
144 $verifyhaschild = getHttpVars(
"verifyhaschild");
147 $searchproperty = getHttpVars(
"searchProperty",
"svalues");
148 $out =
$doc->simpleSearch($key,
$mode,
$famid,
$filter,
$start,
$slice, $orderby, $onlyValues, $searchproperty, $whl, $verifyhaschild);
152 case 'retrieveproposal':
153 $key = getHttpVars(
"key");
154 $aid = getHttpVars(
"attributeId");
155 $famid = getHttpVars(
"relationFamilyId");
156 if (((!
$id) || (
$id ==
"null") || (!$aid) || ($aid ==
"null")) && (
$famid)) {
157 include_once (
"DATA/Lib.Document.php");
163 $oa =
$doc->getAttribute($aid);
165 $out->error = sprintf(_(
"attribute unknow %s") , $aid);
168 $out->proposal =
$doc->getProposalDocuments($oa->id, $key);
174 case 'insertdocument':
177 $idtoadd = getHttpVars(
"idtoadd");
178 if (!$idtoadd)
$out->error = _(
"nothing to add");
179 else $out =
$doc->insertDocument($idtoadd);
183 case 'unlinkdocument':
186 $idtoadd = getHttpVars(
"idtounlink");
187 if (!$idtoadd)
$out->error = _(
"nothing to unlink");
188 else $out =
$doc->unlinkDocument($idtoadd);
195 $moveto = getHttpVars(
"folderId");
196 $movefrom = getHttpVars(
"fromFolderId");
197 $doc->moveto($moveto);
198 $out =
$doc->getDocument($onlyValues);
202 case 'unlinkdocuments':
205 $selection = getHttpVars(
"selection");
207 $selection = json_decode($selection);
208 $out =
$doc->unlinkDocuments($selection);
209 }
else $out->error = _(
"nothing to unlink");
213 case 'unlinkalldocuments':
220 case 'movedocuments':
223 $selection = getHttpVars(
"selection");
224 $targetId = getHttpVars(
"targetIdentificator");
226 $selection = json_decode($selection);
227 $out =
$doc->moveDocuments($selection, $targetId);
228 }
else $out->error = _(
"nothing to unlink");
232 case 'insertdocuments':
235 $selection = getHttpVars(
"selection");
237 $selection = json_decode($selection);
238 $out =
$doc->insertDocuments($selection);
239 }
else $out->error = _(
"nothing to insert");
247 $out->revisions =
$doc->getRevisions();
253 $temporary = (getHttpVars(
"temporary",
"false") ==
"true");
254 $doc->createDocument(
$id, $temporary);
255 $out =
$doc->getDocument($onlyValues);
258 case 'clonedocument':
260 $temporary = (getHttpVars(
"temporary",
"false") ==
"true");
261 $linkfld = (getHttpVars(
"linkFolder",
"true") ==
"true");
262 $copyfiles = (getHttpVars(
"cloneFiles",
"false") ==
"true");
263 $title = getHttpVars(
"title");
264 if (!
$id)
$out->error = _(
"no identificator set");
268 $clone =
$doc->cloneDocument($temporary, $linkfld, $copyfiles,
$title);
269 if ($clone)
$out = $clone->getDocument($onlyValues);
279 $out->error = _(
"no identificator set");
281 $to = getHttpVars(
"to");
282 $cc = getHttpVars(
"cc");
283 $bcc = getHttpVars(
"bcc");
286 $savecopy = getHttpVars(
"sendercopy");
293 $autounlock = (getHttpVars(
"autounlock") ==
"true");
296 $doc->setValueFromHttpVars();
297 $doc->setLogicalIdentificator();
301 $famid = getHttpVars(
"family", getHttpVars(
"familyid"));
302 $temporary = (getHttpVars(
"temporary",
"false") ==
"true");
304 $doc->setValueFromHttpVars();
305 $doc->setLogicalIdentificator();
310 if ($autounlock)
$doc->unlock(
true);
311 $out =
$doc->getDocument($onlyValues);
316 $autounlock = (getHttpVars(
"autounlock") ==
"true");
319 $doc->setValueFromHttpVars();
320 $doc->setFileValueFromHttpVars();
321 $doc->setLogicalIdentificator();
322 $callback = getHttpVars(
"callid");
324 if ((!
$doc->error) && $autounlock)
$doc->unlock(
true);
325 $data =
$doc->getDocument($onlyValues);
326 $out = sprintf(
"<html><script>var data=%s;</script><body onload=\"window.parent.Fdl._completeSave('%s',data)\"></body></html>", json_encode($data) , $callback);
328 $returntype =
"html";
333 $newstate = getHttpVars(
"state");
335 if (!
$doc->error)
$doc->changeState($newstate);
336 $out =
$doc->getDocument($onlyValues);
340 $tag = getHttpVars(
"tag");
344 $out =
$doc->getDocument($onlyValues,
true,
false,
true);
347 case 'deleteusertag':
348 $tag = getHttpVars(
"tag");
350 if (!
$doc->error)
$doc->deleteUserTag($tag);
351 $out =
$doc->getDocument($onlyValues,
true,
false,
true);
355 $auto = (getHttpVars(
"autolock") ==
"true");
357 if (!
$doc->error)
$doc->lock($auto);
358 $out =
$doc->getDocument($onlyValues);
362 $auto = (getHttpVars(
"autolock") ==
"true");
364 if (!
$doc->error)
$doc->unlock($auto);
365 $out =
$doc->getDocument($onlyValues);
369 $uid = getHttpVars(
"userSystemId");
370 $duid = getHttpVars(
"userId");
373 $uid = $du->getValue(
"us_whatid");
376 $revision = (getHttpVars(
"revision") ==
"true");
377 $autolock = (getHttpVars(
"lock") ==
"true");
380 $out =
$doc->getDocument($onlyValues);
385 $revision = (getHttpVars(
"revision") ==
"true");
388 $out =
$doc->getDocument($onlyValues);
392 $comment = (getHttpVars(
"comment"));
393 $version = (getHttpVars(
"version"));
394 $volatile = (getHttpVars(
"volatileVersion",
"false") ==
"true");
398 if ((!
$doc->error) && $volatile && $version) {
399 $doc->setVersion(
' ',
false);
403 $out =
$doc->getDocument($onlyValues);
407 $really = (getHttpVars(
"really") ==
"true");
409 if (!
$doc->error)
$doc->delete($really);
410 $out =
$doc->getDocument($onlyValues);
416 $out =
$doc->getDocument($onlyValues);
420 include_once (
"DATA/Lib.Document.php");
421 $vid = getHttpVars(
"vid");
426 case 'haswaitingfiles':
427 include_once (
"DATA/Lib.Document.php");
430 $out->haswaitingfiles =
$doc->hasWaitingFiles();
435 case 'getfollowingstates':
436 include_once (
"DATA/Lib.Document.php");
439 $out->followingStates =
$doc->getFollowingStates();
445 include_once (
"DATA/Lib.Document.php");
448 $out->userTags =
$doc->getUserTags();
453 case 'getattachedtimers':
454 include_once (
"DATA/Lib.Document.php");
457 $out->attachedTimers =
$doc->getAttachedTimers();
463 case 'modifyattribute':
464 case 'removeattribute':
465 include_once (
"DATA/Class.Family.php");
468 $aid = getHttpVars(
"attributeId");
469 $type = getHttpVars(
"type", null);
470 $parent = getHttpVars(
"parent", null);
471 $visibility = getHttpVars(
"visibility", null);
472 $label = getHttpVars(
"label", null);
473 $order = getHttpVars(
"order", null);
474 $inTitle = (getHttpVars(
"inTitle") ==
"true");
475 $inAbstract = (getHttpVars(
"inAbstract") ==
"true");
476 $needed = (getHttpVars(
"needed") ==
"true");
477 $link = getHttpVars(
"link", null);
478 $elink = getHttpVars(
"elink", null);
479 $constraint = getHttpVars(
"constraint", null);
480 $options = getHttpVars(
"options", null);
481 if ($options) $options = json_decode($options);
483 if (
$method ==
"addattribute") {
484 $doc->addAttribute($aid,
$label, $order,
$type, $parent, $visibility, $inTitle, $inAbstract, $needed, $link, $elink, $phpfile, $phpfunc, $constraint, $options);
485 } elseif (
$method ==
"removeattribute") {
486 $doc->removeAttribute($aid);
488 $doc->modifyAttribute($aid,
$label, $order,
$type, $parent, $visibility, $inTitle, $inAbstract, $needed, $link, $elink, $phpfile, $phpfunc, $constraint, $options);
490 $out =
$doc->getDocument($onlyValues);
494 case 'addtransition':
495 case 'removetransition':
496 include_once (
"DATA/Class.Workflow.php");
499 $start = getHttpVars(
"start");
500 $finish = getHttpVars(
"finish");
501 $transitiontype = getHttpVars(
"transitionType");
502 if (
$method ==
"addtransition")
$doc->addTransition(
$start, $finish, $transitiontype);
504 $out =
$doc->getDocument($onlyValues);
511 include_once (
"DATA/Class.Workflow.php");
514 $key = getHttpVars(
"key");
515 $label = getHttpVars(
"label");
516 $activity = getHttpVars(
"activity");
519 elseif (
$method ==
"removestate")
$doc->removeState($key);
520 else $doc->modifyState($key,
$label, $activity);
521 $out =
$doc->getDocument($onlyValues);
525 case 'addtransitiontype':
526 case 'removetransitiontype':
527 case 'modifytransitiontype':
528 include_once (
"DATA/Class.Workflow.php");
531 $key = getHttpVars(
"key");
532 $label = getHttpVars(
"label", null);
533 $preMethod = getHttpVars(
"preMathod", null);
534 $postMethod = getHttpVars(
"postMathod", null);
535 $noComment = getHttpVars(
"noComment", null);
536 $ask = getHttpVars(
"ask", null);
537 if ($ask) $ask = json_decode($ask);
538 if (
$method ==
"addtransitiontype")
$doc->addTransitiontype($key,
$label, $ask, $preMethod, $postmethod, $noComment);
539 elseif (
$method ==
"modifytransitiontype")
$doc->modifyTransitiontype($key,
$label, $ask, $preMethod, $postmethod, $noComment);
540 else $doc->removeTransitiontype($key);
541 $out =
$doc->getDocument($onlyValues);
545 case 'getsearchcriteria':
546 include_once (
"FDL/Class.DocSearch.php");
548 $operators =
$s->top;
550 $out->operators = array();
569 foreach ($operators as $k => $v) {
570 if (!is_array($v[
"type"])) $v[
"type"] = $alltype;
571 foreach ($v[
"type"] as
$type) {
572 $label = $v[
"label"] ? _($v[
"label"]) :
'';
573 $dynlabel = $v[
"dynlabel"] ? _($v[
"dynlabel"]) :
'';
575 foreach ($v[
"slabel"] as $kl => $vl) {
576 if ($kl == $type)
$label = _($vl);
579 if ($v[
"sdynlabel"]) {
580 foreach ($v[
"sdynlabel"] as $kl => $vl) {
581 if ($kl == $type) $dynlabel = _($vl);
586 "operand" => $v[
"operand"],
588 "tplLabel" => $dynlabel
597 if (!
$id)
$out->error = _(
"no identificator");
599 $config->onlyValues = getHttpVars(
"onlyValues",
"true") ==
"true";
600 $config->latest = (getHttpVars(
"latest",
"true") ==
"true");
601 $winfo = (getHttpVars(
"needWorkflow",
"false") ==
"true");
602 $config->propertiesInformation = (getHttpVars(
"propertiesInformation",
"false") ==
"true");
603 $config->completeProperties = getHttpVars(
"completeProperties",
"true") ==
"true";
604 $withContent = getHttpVars(
"contentStore",
"false") ==
"true";
605 $config->getUserTags = getHttpVars(
"getUserTags",
"false") ==
"true";
608 include_once (
"DATA/Class.Workflow.php");
611 $out =
$doc->getDocument($config->onlyValues, $config->completeProperties, $config->propertiesInformation, $config->getUserTags);
613 if (
$doc->isCollection()) {
614 $configContent = getHttpVars(
"contentConfig");
615 if ($configContent) {
616 $configContent = json_decode($configContent);
618 $doc->setContentCompleteProperties($configContent->completeProperties ===
true);
619 $doc->setContentOnlyValue($configContent->onlyValues !==
false);
620 $doc->setContentOrderBy($configContent->orderBy);
621 $doc->setContentSlice(($configContent->slice) ? $configContent->slice : 100);
622 $doc->setContentStart($configContent->start);
623 $doc->setContentKey($configContent->key);
624 $doc->setContentKeyMode($configContent->mode);
625 $doc->setContentSearchProperty($configContent->searchProperty);
626 $doc->setContentRecursiveLevel($configContent->recursiveLevel);
628 $doc->setContentFilter($configContent->filter);
629 $doc->setContentVerifyHasChild($configContent->verifyhaschild ===
true);
631 $out[
"storedContent"] =
$doc->getContent();
633 $out[
"storedContent"] = null;
641 $out->error = sprintf(_(
"method %s not possible") ,
$method);
646 $l =
$action->parent->GetLogMsg();
647 if (is_array($l) && (count($l) > 0)) {
648 foreach ($l as $k => $v) {
649 if (
$d = json_decode($v)) $l[$k] =
$d;
651 if (is_object(
$out)) {
653 $action->parent->ClearLogMsg();
655 if (is_array(
$out)) {
657 $action->parent->ClearLogMsg();