Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_setusertag.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 
8 include_once ("FDL/Class.Dir.php");
9 /**
10  * add a user tag to a document
11  * @param Action &$action current action
12  * @global string $docid Http var : document identifier to use
13  * @global string $tag Http var : tag name
14  * @global string $value Http var : tag value
15  */
17 {
18  // -----------------------------------
19  $usage = new ActionUsage($action);
20  $usage->setDefinitionText("add user tag to a document");
21  $docid = $usage->addRequiredParameter("id", "document identifier");
22  $tagName = $usage->addRequiredParameter("tag", "tag name");
23  $tagValue = $usage->addOptionalParameter("value", "tag value");
24  $usage->verify();
25  $dbaccess = $action->dbaccess;
26 
27  if (!is_numeric($docid)) $docid = getIdFromName($dbaccess, $docid);
28  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , $docid));
30  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
31  $err = $doc->control("view");
32  if ($err != "") $action->exitError($err);
33 
34  $err = $doc->addUtag($action->user->id, $tagName, $tagValue);
35  $out = array(
36  "error" => $err
37  );
38  header('Content-type: application/json');
39  $action->lay->template = json_encode($out);
40  $action->lay->noparse = true;
41 }
global $action
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
Verify arguments for action function.
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
fdl_setusertag(Action &$action)
← centre documentaire © anakeen