Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_forumaddentry.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  * FDL Forum edition action
9  *
10  * @author Anakeen 2000
11  * @version $Id: fdl_forumaddentry.php,v 1.7 2008/02/19 14:08:53 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 include_once ("FDL/Class.Doc.php");
19 include_once ("FDL/freedom_util.php");
20 
22 {
23 
24  $docid = GetHttpVars("docid", "");
25  $forid = - 1; // Used forum id store in document property -- GetHttpVars("fid", "");
26  $linkid = GetHttpVars("lid", -1);
27  $entrid = GetHttpVars("eid", -1);
28  $flag = GetHttpVars("flag", "");
29  $text = GetHttpVars("text", "");
30 
31  $dbaccess = GetParam("FREEDOM_DB");
32 
33  if ($docid == "") $action->exitError(_("no document reference"));
35  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
36  if ($doc->locked == - 1) { // it is revised document
37  $docid = $doc->latestId();
38  if ($docid != $doc->id) $doc = new_Doc($dbaccess, $docid);
39  }
40 
41  if ($doc->Control("edit") != "" && $doc->Control("forum") != "") $action->exitError(sprintf(_("you don't have privilege to edit forum for document %s") , $doc->title));
42 
43  $doc->disableEditControl();
44 
45  $forid = ($doc->forumid = "" || $doc->forumid < 1 ? -1 : $doc->forumid);
46 
47  $date = strftime("%d/%m/%y %H:%S", time());
48 
49  if ($forid <= 0) {
50 
51  $forum = createDoc($dbaccess, "FORUM");
52  $forum->disableEditControl();
53  $forum->setValue("forum_docid", $doc->id);
54  $forum->setProfil($doc->profid);
55  $forum->Add();
56  $doc->forumid = $forum->id;
57  $doc->modify(true, array(
58  "forumid"
59  ));
60 
61  $t_id = array(
62  $forum->getEntryId()
63  );
64  $t_lid = array(-1
65  ); // Be sure they are no back reference in the first forum entry
66  $t_userid = array(
67  $action->user->id
68  );
69  $t_user = array(
70  $doc->getTitle($dbaccess, $action->user->id)
71  );
72  $t_usermail = array(
73  getMailAddr($action->user->id)
74  );
75  $t_text = array(
76  $text
77  );
78  $t_flag = array(
79  $flag
80  );
81  $t_date = array(
82  $date
83  );
84  } else {
85 
86  $forum = new_Doc($dbaccess, $forid);
87  if (!$forum->isAffected()) $action->exitError(sprintf(_("cannot see unknow forum reference %s") , $forid));
88  $forum->disableEditControl();
89 
90  $t_id = $forum->getTValue("forum_d_id");
91  $t_lid = $forum->getTValue("forum_d_link");
92  $t_userid = $forum->getTValue("forum_d_userid");
93  $t_user = $forum->getTValue("forum_d_user");
94  $t_usermail = $forum->getTValue("forum_d_usermail");
95  $t_text = $forum->getTValue("forum_d_text");
96  $t_flag = $forum->getTValue("forum_d_flag");
97  $t_date = $forum->getTValue("forum_d_date");
98 
99  $newentry = ($entrid == - 1 ? true : false);
100  $entrid = ($entrid == - 1 ? $forum->getEntryId() : $entrid);
101 
102  $start = $entrid;
103  $validlink = false;
104  $ventry = - 1;
105  foreach ($t_id as $k => $v) {
106  if ($linkid == $t_id[$k] && $linkid != - 1) {
107  $validlink = true;
108  }
109  if ($entrid == $v) $ventry = $k;
110  }
111  if (!$validlink) $linkid = - 1;
112  if ($ventry == - 1) $ventry = count($t_id);
113 
114  if ($newentry) {
115  $start = $linkid;
116  $t_id[$ventry] = $entrid;
117  $t_lid[$ventry] = $linkid;
118  $t_userid[$ventry] = $action->user->fid;
119  $t_user[$ventry] = $doc->getTitle($dbaccess, $action->user->id);
120  $t_usermail[$ventry] = getMailAddr($action->user->id);
121  }
122  $t_text[$ventry] = $text;
123  $t_flag[$ventry] = $flag;
124  $t_date[$ventry] = $date;
125  }
126 
127  $forum->setValue("forum_d_id", $t_id);
128  $forum->setValue("forum_d_link", $t_lid);
129  $forum->setValue("forum_d_userid", $t_userid);
130  $forum->setValue("forum_d_user", $t_user);
131  $forum->setValue("forum_d_usermail", $t_usermail);
132  $forum->setValue("forum_d_text", $t_text);
133  $forum->setValue("forum_d_flag", $t_flag);
134  $forum->setValue("forum_d_date", $t_date);
135  $err = $forum->Modify();
136  if ($err != "") $action->exitError(sprintf(_("cannot modify forum %s") , $forum->id));;
137  $err = $forum->postModify();
138  if ($err != "") $action->exitError(sprintf(_("cannot modify forum %s") , $forum->id));;
139  // print_r2($forum);
140  redirect($action, "FDL", "IMPCARD&sole=Y&zone=FDL:FORUM_VIEW:S&id=" . $forum->id . "&start=" . $start);
141 }
142 ?>
← centre documentaire © anakeen - published under CC License - Dynacase