dolibarr  17.0.4
contact.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2012-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 // Load Dolibarr environment
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
32 if (isModEnabled('categorie')) {
33  require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
34 }
35 
36 // Load translation files required by the page
37 $langsLoad=array('projects', 'companies');
38 if (isModEnabled('eventorganization')) {
39  $langsLoad[]='eventorganization';
40 }
41 
42 $langs->loadLangs($langsLoad);
43 
44 $id = GETPOST('id', 'int');
45 $ref = GETPOST('ref', 'alpha');
46 $lineid = GETPOST('lineid', 'int');
47 $socid = GETPOST('socid', 'int');
48 $action = GETPOST('action', 'aZ09');
49 
50 $mine = GETPOST('mode') == 'mine' ? 1 : 0;
51 //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
52 
53 $object = new Project($db);
54 
55 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
56 if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
57  $object->fetchComments();
58 }
59 
60 // Security check
61 $socid = 0;
62 //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
63 $result = restrictedArea($user, 'projet', $id, 'projet&project');
64 
65 $hookmanager->initHooks(array('projectcontactcard', 'globalcard'));
66 
67 
68 /*
69  * Actions
70  */
71 
72 // Test if we can add contact to the tasks at the same times, if not or not required, make a redirect
73 $formconfirmtoaddtasks = '';
74 if ($action == 'addcontact') {
75  $form = new Form($db);
76 
77  $source=GETPOST("source", 'aZ09');
78 
79  $taskstatic = new Task($db);
80  $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0);
81  $nbTasks = count($task_array);
82 
83  //If no task avaiblable, redirec to to add confirm
84  $type_to = (GETPOST('typecontact') ? 'typecontact='.GETPOST('typecontact') : 'type='.GETPOST('type'));
85  $personToAffect = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
86  $affect_to = (GETPOST('userid') ? 'userid='.$personToAffect : 'contactid='.$personToAffect);
87  $url_redirect='?id='.$object->id.'&'.$affect_to.'&'.$type_to.'&source='.$source;
88 
89  if ($personToAffect > 0 && (empty($conf->global->PROJECT_HIDE_TASKS) || $nbTasks > 0)) {
90  $text = $langs->trans('AddPersonToTask');
91  $textbody = $text.' (<a href="#" class="selectall">'.$langs->trans("SelectAll").'</a>)';
92  $formquestion = array('text' => $textbody);
93 
94  $task_to_affect = array();
95  foreach ($task_array as $task) {
96  $task_already_affected=false;
97  $personsLinked = $task->liste_contact(-1, $source);
98  if (!is_array($personsLinked) && count($personsLinked) < 0) {
99  setEventMessage($object->error, 'errors');
100  } else {
101  foreach ($personsLinked as $person) {
102  if ($person['id']==$personToAffect) {
103  $task_already_affected = true;
104  break;
105  }
106  }
107  if (!$task_already_affected) {
108  $task_to_affect[$task->id] = $task->id;
109  }
110  }
111  }
112 
113  if (empty($task_to_affect)) {
114  $action = 'addcontact_confirm';
115  } else {
116  $formcompany = new FormCompany($db);
117  foreach ($task_array as $task) {
118  $key = $task->id;
119  $val = $task->ref . ' '.dol_trunc($task->label);
120  $formquestion[] = array(
121  'type' => 'other',
122  'name' => 'person_'.$key.',person_role_'.$key,
123  'label' => '<input type="checkbox" class="flat'.(in_array($key, $task_to_affect) ? ' taskcheckboxes"' : '" checked disabled').' id="person_'.$key.'" name="person_'.$key.'" value="1"> <label for="person_'.$key.'">'.$val.'<label>',
124  'value' => $formcompany->selectTypeContact($taskstatic, '', 'person_role_'.$key, $source, 'position', 0, 'minwidth100imp', 0, 1)
125  );
126  }
127  $formquestion[] = array('type'=> 'other', 'name'=>'tasksavailable', 'label'=>'', 'value' => '<input type="hidden" id="tasksavailable" name="tasksavailable" value="'.implode(',', array_keys($task_to_affect)).'">');
128  }
129 
130  $formconfirmtoaddtasks = $form->formconfirm($_SERVER['PHP_SELF'] . $url_redirect, $text, '', 'addcontact_confirm', $formquestion, '', ((count($formquestion) > 10) ? 0 : 1), 300, 590);
131  $formconfirmtoaddtasks .='
132  <script>
133  $(document).ready(function() {
134  var saveprop = false;
135  $(".selectall").click(function(){
136  console.log("We click on select all with "+saveprop);
137  if (!saveprop) {
138  $(".taskcheckboxes").prop("checked", true);
139  saveprop = true;
140  } else {
141  $(".taskcheckboxes").prop("checked", false);
142  saveprop = false;
143  }
144  });
145  });
146  </script>';
147  } else {
148  $action = 'addcontact_confirm';
149  }
150 }
151 
152 // Add new contact
153 if ($action == 'addcontact_confirm' && $user->rights->projet->creer) {
154  if (GETPOST('confirm', 'alpha') == 'no') {
155  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
156  exit;
157  }
158 
159  $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
160  $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
161 
162  if (! ($contactid > 0)) {
163  $error++;
164  $langs->load("errors");
165  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors');
166  }
167 
168  $result = 0;
169  $result = $object->fetch($id);
170 
171  if (!$error && $result > 0 && $id > 0) {
172  $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
173 
174  if ($result == 0) {
175  $langs->load("errors");
176  setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
177  } elseif ($result < 0) {
178  if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
179  $langs->load("errors");
180  setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
181  } else {
182  setEventMessages($object->error, $object->errors, 'errors');
183  }
184  }
185 
186  $affecttotask=GETPOST('tasksavailable', 'intcomma');
187  if (!empty($affecttotask)) {
188  require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
189  $task_to_affect = explode(',', $affecttotask);
190  if (!empty($task_to_affect)) {
191  foreach ($task_to_affect as $task_id) {
192  if (GETPOSTISSET('person_'.$task_id) && GETPOST('person_'.$task_id, 'san_alpha')) {
193  $tasksToAffect = new Task($db);
194  $result=$tasksToAffect->fetch($task_id);
195  if ($result < 0) {
196  setEventMessages($tasksToAffect->error, null, 'errors');
197  } else {
198  $result = $tasksToAffect->add_contact($contactid, GETPOST('person_role_'.$task_id), GETPOST("source", 'aZ09'));
199  if ($result < 0) {
200  if ($tasksToAffect->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
201  $langs->load("errors");
202  setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
203  } else {
204  setEventMessages($tasksToAffect->error, $tasksToAffect->errors, 'errors');
205  }
206  }
207  }
208  }
209  }
210  }
211  }
212  }
213 
214  if ($result >= 0) {
215  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
216  exit;
217  }
218 }
219 
220 // Change contact's status
221 if ($action == 'swapstatut' && $user->rights->projet->creer) {
222  if ($object->fetch($id)) {
223  $result = $object->swapContactStatus(GETPOST('ligne', 'int'));
224  } else {
225  dol_print_error($db);
226  }
227 }
228 
229 // Delete a contact
230 if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) {
231  $object->fetch($id);
232  $result = $object->delete_contact(GETPOST("lineid", 'int'));
233 
234  if ($result >= 0) {
235  header("Location: contact.php?id=".$object->id);
236  exit;
237  } else {
238  dol_print_error($db);
239  }
240 }
241 
242 
243 
244 /*
245  * View
246  */
247 
248 $form = new Form($db);
249 $contactstatic = new Contact($db);
250 $userstatic = new User($db);
251 
252 $title = $langs->trans('ProjectContact').' - '.$object->ref.' '.$object->name;
253 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
254  $title = $object->ref.' '.$object->name.' - '.$langs->trans('ProjectContact');
255 }
256 
257 $help_url = 'EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos|DE:Modul_Projekte';
258 
259 llxHeader('', $title, $help_url);
260 
261 
262 
263 if ($id > 0 || !empty($ref)) {
264  /*
265  * View
266  */
267  if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
268  $object->fetchComments();
269  }
270  // To verify role of users
271  //$userAccess = $object->restrictedProjectArea($user,'read');
272  $userWrite = $object->restrictedProjectArea($user, 'write');
273  //$userDelete = $object->restrictedProjectArea($user,'delete');
274  //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
275 
276  $head = project_prepare_head($object);
277  print dol_get_fiche_head($head, 'contact', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
278 
279  $formconfirm = $formconfirmtoaddtasks;
280 
281  // Call Hook formConfirm
282  $parameters = array('formConfirm' => $formconfirm);
283  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
284  if (empty($reshook)) {
285  $formconfirm .= $hookmanager->resPrint;
286  } elseif ($reshook > 0) {
287  $formconfirm = $hookmanager->resPrint;
288  }
289 
290  // Print form confirm
291  print $formconfirm;
292 
293  // Project card
294 
295  $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
296 
297  $morehtmlref = '<div class="refidno">';
298  // Title
299  $morehtmlref .= dol_escape_htmltag($object->title);
300  $morehtmlref .= '<br>';
301  // Thirdparty
302  if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
303  $morehtmlref .= $object->thirdparty->getNomUrl(1, 'project');
304  }
305  $morehtmlref .= '</div>';
306 
307  // Define a complementary filter for search of next/prev ref.
308  if (empty($user->rights->projet->all->lire)) {
309  $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
310  $object->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
311  }
312 
313  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
314 
315 
316  print '<div class="fichecenter">';
317  print '<div class="fichehalfleft">';
318  print '<div class="underbanner clearboth"></div>';
319 
320  print '<table class="border tableforfield centpercent">';
321 
322  // Usage
323  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || isModEnabled('eventorganization')) {
324  print '<tr><td class="tdtop">';
325  print $langs->trans("Usage");
326  print '</td>';
327  print '<td>';
328  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
329  print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
330  $htmltext = $langs->trans("ProjectFollowOpportunity");
331  print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
332  print '<br>';
333  }
334  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
335  print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
336  $htmltext = $langs->trans("ProjectFollowTasks");
337  print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
338  print '<br>';
339  }
340  if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
341  print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
342  $htmltext = $langs->trans("ProjectBillTimeDescription");
343  print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
344  print '<br>';
345  }
346  if (isModEnabled('eventorganization')) {
347  print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'"> ';
348  $htmltext = $langs->trans("EventOrganizationDescriptionLong");
349  print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
350  }
351  print '</td></tr>';
352  }
353 
354  // Visibility
355  print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
356  if ($object->public) {
357  print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
358  print $langs->trans('SharedProject');
359  } else {
360  print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
361  print $langs->trans('PrivateProject');
362  }
363  print '</td></tr>';
364 
365  if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) {
366  // Opportunity status
367  print '<tr><td>'.$langs->trans("OpportunityStatus").'</td><td>';
368  $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code');
369  if ($code) {
370  print $langs->trans("OppStatus".$code);
371  }
372 
373  // Opportunity percent
374  print ' <span title="'.$langs->trans("OpportunityProbability").'"> / ';
375  if (strcmp($object->opp_percent, '')) {
376  print price($object->opp_percent, 0, $langs, 1, 0).' %';
377  }
378  print '</span></td></tr>';
379 
380  // Opportunity Amount
381  print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
382  if (strcmp($object->opp_amount, '')) {
383  print '<span class="amount">'.price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency).'</span>';
384  if (strcmp($object->opp_percent, '')) {
385  print ' &nbsp; &nbsp; &nbsp; <span title="'.dol_escape_htmltag($langs->trans('OpportunityWeightedAmount')).'"><span class="opacitymedium">'.$langs->trans("Weighted").'</span>: <span class="amount">'.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).'</span></span>';
386  }
387  }
388  print '</td></tr>';
389  }
390 
391  // Budget
392  print '<tr><td>'.$langs->trans("Budget").'</td><td>';
393  if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
394  print '<span class="amount">'.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).'</span>';
395  }
396  print '</td></tr>';
397 
398  // Date start - end project
399  print '<tr><td>'.$langs->trans("Dates").'</td><td>';
400  $start = dol_print_date($object->date_start, 'day');
401  print ($start ? $start : '?');
402  $end = dol_print_date($object->date_end, 'day');
403  print ' <span class="opacitymedium">-</span> ';
404  print ($end ? $end : '?');
405  if ($object->hasDelay()) {
406  print img_warning("Late");
407  }
408  print '</td></tr>';
409 
410  // Other attributes
411  $cols = 2;
412  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
413 
414  print "</table>";
415 
416  print '</div>';
417  print '<div class="fichehalfright">';
418  print '<div class="underbanner clearboth"></div>';
419 
420  print '<table class="border tableforfield centpercent">';
421 
422  // Description
423  print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
424  print dol_htmlentitiesbr($object->description);
425  print '</td></tr>';
426 
427  // Categories
428  if (isModEnabled('categorie')) {
429  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
430  print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
431  print "</td></tr>";
432  }
433 
434  print '</table>';
435 
436  print '</div>';
437  print '</div>';
438 
439  print '<div class="clearboth"></div>';
440 
441  print dol_get_fiche_end();
442 
443  print '<br>';
444 
445  // Contacts lines (modules that overwrite templates must declare this into descriptor)
446  $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
447  foreach ($dirtpls as $reldir) {
448  $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
449  if ($res) {
450  break;
451  }
452  }
453 }
454 
455 // End of page
456 llxFooter();
457 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage contact/addresses.
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage tasks.
Definition: task.class.php:38
Class to manage Dolibarr users.
Definition: user.class.php:47
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
$formconfirm
if ($action == 'delbookkeepingyear') {
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
Definition: project.lib.php:38
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.