Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
setlogicalname.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  * Enable/disable forum for documents
9  *
10  * @author Anakeen 2000
11  * @version $Id: setlogicalname.php,v 1.3 2008/09/26 12:34:57 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 
22 {
23 
24  $dbaccess = $action->GetParam("FREEDOM_DB");
25  $docid = GetHttpVars("id");
26  $name = GetHttpVars("name");
27  if ($docid && $name) {
28  if (!preg_match("/^[A-Z][[0-9A-Z\-_]*$/i", $name)) {
29  $action->addWarningMsg(sprintf(_("name must containt only alphanumeric characters: invalid [%s]") , $name));
30  } else {
31  $doc = new_Doc($dbaccess, $docid, true);
32  if (!$doc->isAffected()) $action->addWarningMsg(sprintf(_("cannot see unknow reference %s") , $docid));
33  else {
34  if (($doc->name != "") && ($doc->doctype != 'Z')) {
35  $action->addWarningMsg(sprintf(_("Logical name %s already set for %s") , $name, $doc->title));
36  } else {
37  // verify not use yet
38  $q = $doc->exec_query("select id from doc where doctype != 'Z' and name='" . pg_escape_string($name) . "'");
39  if ($doc->numrows() == 0) {
40  $doc->name = $name;
41  $err = $doc->modify(true, array(
42  "name"
43  ) , true);
44  if ($err != "") $action->addWarningMsg($err);
45  } else {
46  $action->addWarningMsg(sprintf(_("Logical name %s already use other document") , $name, $doc->title));
47  }
48  }
49  }
50  }
51  }
52 
53  redirect($action, "FDL", "IMPCARD&zone=FDL:VIEWPROPERTIES:T&id=" . $docid);
54 }
55 ?>
← centre documentaire © anakeen - published under CC License - Dynacase