本文整理汇总了PHP中Project::getProjectsAuthorizedForUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getProjectsAuthorizedForUser方法的具体用法?PHP Project::getProjectsAuthorizedForUser怎么用?PHP Project::getProjectsAuthorizedForUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project::getProjectsAuthorizedForUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
$projectstatic->fetch($id);
$projectstatic->societe->fetch($projectstatic->societe->id);
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Show description of content
if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
else print $langs->trans("ProjectsPublicDesc").'<br><br>';
}
// Get list of project id allowed to user
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_product);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="mode" value="'.GETPOST('mode').'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
示例2: accessforbidden
if ($user->societe_id > 0) {
$socid = $user->societe_id;
}
if (!$user->rights->projet->lire) {
accessforbidden();
}
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
/*
* View
*/
$socstatic = new Societe($db);
$projectstatic = new Project($db);
$userstatic = new User($db);
$tasktmp = new Task($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine ? $mine : (empty($user->rights->projet->all->lire) ? 0 : 2), 1);
//var_dump($projectsListId);
llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos");
$text = $langs->trans("Projects");
if ($mine) {
$text = $langs->trans("MyProjects");
}
print_fiche_titre($text);
// Show description of content
if ($mine) {
print $langs->trans("MyProjectsDesc") . '<br><br>';
} else {
if (!empty($user->rights->projet->all->lire) && !$socid) {
print $langs->trans("ProjectsDesc") . '<br><br>';
} else {
print $langs->trans("ProjectsPublicDesc") . '<br><br>';
示例3: GETPOST
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
$search_ref = GETPOST("search_ref");
$search_label = GETPOST("search_label");
$search_societe = GETPOST("search_societe");
$search_all = GETPOST("search_all");
/*
* View
*/
$projectstatic = new Project($db);
$socstatic = new Societe($db);
llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos");
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine ? $mine : ($user->rights->projet->all->lire ? 2 : 0), 1, $socid);
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_statut, p.public, p.fk_user_creat";
$sql .= ", p.datec as date_create, p.dateo as date_start, p.datee as date_end";
$sql .= ", s.nom as name, s.rowid as socid";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as p";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s on p.fk_soc = s.rowid";
$sql .= " WHERE p.entity = " . $conf->entity;
if ($mine || !$user->rights->projet->all->lire) {
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
}
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
}
if ($search_ref) {
示例4: restrictedArea
//.........这里部分代码省略.........
} else {
if (!empty($conf->multicompany->enabled)) {
$sql = "SELECT s.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE s.rowid = " . $objectid;
$sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
} else {
if (in_array($feature, $checkother)) {
// If external user: Check permission for external users
if ($user->societe_id > 0) {
$sql = "SELECT dbt.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt.rowid = " . $objectid;
$sql .= " AND dbt.fk_soc = " . $user->societe_id;
} else {
if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
$sql = "SELECT dbt.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '" . $user->id . "'";
$sql .= " WHERE dbt.rowid = " . $objectid;
$sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
// Contact not linked to a company or to a company of user
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
} else {
if (!empty($conf->multicompany->enabled)) {
$sql = "SELECT dbt.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt.rowid = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
} else {
if (in_array($feature, $checkproject)) {
if (!empty($conf->projet->enabled) && !$user->rights->projet->all->lire) {
include_once DOL_DOCUMENT_ROOT . "/projet/class/project.class.php";
$projectstatic = new Project($db);
$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
$tmparray = explode(',', $tmps);
if (!in_array($objectid, $tmparray)) {
accessforbidden();
}
} else {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
} else {
if (!in_array($feature, $nocheck)) {
// If external user: Check permission for external users
if ($user->societe_id > 0) {
$sql = "SELECT dbt." . $dbt_keyfield;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt.rowid = " . $objectid;
$sql .= " AND dbt." . $dbt_keyfield . " = " . $user->societe_id;
} else {
if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
$sql = "SELECT sc.fk_soc";
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= ", " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND sc.fk_soc = dbt." . $dbt_keyfield;
$sql .= " AND dbt." . $dbt_keyfield . " = s.rowid";
$sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
$sql .= " AND sc.fk_user = " . $user->id;
} else {
if (!empty($conf->multicompany->enabled)) {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
}
}
}
}
}
//print $sql."<br>";
if ($sql) {
$resql = $db->query($sql);
if ($resql) {
if ($db->num_rows($resql) == 0) {
accessforbidden();
}
} else {
dol_syslog("security.lib:restrictedArea sql=" . $sql, LOG_ERR);
accessforbidden();
}
}
}
}
return 1;
}
示例5: selectTasks
/**
* Output a combo list with projects qualified for a third party
*
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id task preselected
* @param string $htmlname Name of HTML select
* @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
* @param int $forcefocus Force focus on field (works with javascript only)
* @param int $disabled Disabled
* @return int Nbr of project if OK, <0 if KO
*/
function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0)
{
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$out = '';
$hideunselectables = false;
if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
$hideunselectables = true;
}
$projectsListId = false;
if (empty($user->rights->projet->all->lire)) {
$projectstatic = new Project($this->db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
}
// Search all projects
$sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,';
$sql .= ' s.nom as name';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p';
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
$sql .= ', ' . MAIN_DB_PREFIX . 'projet_task as t';
$sql .= " WHERE p.entity = " . $conf->entity;
$sql .= " AND t.fk_projet = p.rowid";
if ($projectsListId !== false) {
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
}
if ($socid == 0) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
}
if ($socid > 0) {
$sql .= " AND (p.fk_soc=" . $socid . " OR p.fk_soc IS NULL)";
}
$sql .= " ORDER BY p.ref, t.ref ASC";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$minmax = '';
// Use select2 selector
$nodatarole = '';
if (!empty($conf->use_javascript_ajax)) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out .= $comboenhancement;
$nodatarole = $comboenhancement ? ' data-role="none"' : '';
$minmax = 'minwidth200';
}
if (empty($option_only)) {
$out .= '<select class="flat' . ($minmax ? ' ' . $minmax : '') . '"' . ($disabled ? ' disabled="disabled"' : '') . ' id="' . $htmlname . '" name="' . $htmlname . '"' . $nodatarole . '>';
}
if (!empty($show_empty)) {
$out .= '<option value="0"> </option>';
}
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) {
// Do nothing
} else {
if ($discard_closed == 1 && $obj->fk_statut == 2) {
$i++;
continue;
}
$labeltoshow = dol_trunc($obj->ref, 18);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$labeltoshow .= ' ' . dol_trunc($obj->title, $maxlength);
if ($obj->name) {
$labeltoshow .= ' (' . $obj->name . ')';
}
$disabled = 0;
if ($obj->fk_statut == 0) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("Draft");
} else {
if ($obj->fk_statut == 2) {
if ($discard_closed == 2) {
$disabled = 1;
}
$labeltoshow .= ' - ' . $langs->trans("Closed");
} else {
if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
}
//.........这里部分代码省略.........
示例6: Project
$project = new Project($db);
$taskstatic = new Task($db);
$prev = dol_getdate($daytoparse - 24 * 3600);
$prev_year = $prev['year'];
$prev_month = $prev['mon'];
$prev_day = $prev['mday'];
$next = dol_getdate($daytoparse + 24 * 3600);
$next_year = $next['year'];
$next_month = $next['mon'];
$next_day = $next['mday'];
$title = $langs->trans("TimeSpent");
if ($mine) {
$title = $langs->trans("MyTimeSpent");
}
$usertoprocess = $user;
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, 0, 1);
// Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id) {
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject = 1;
// or -1
$tasksarray = $taskstatic->getTasksArray(0, 0, $project->id ? $project->id : 0, $socid, 0, '', $onlyopenedproject);
// We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, $project->id ? $project->id : 0, 0, $onlyopenedproject);
$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, $project->id ? $project->id : 0, 0, $onlyopenedproject);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("", $title, "");
示例7: in
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
// To verify role of users
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$task->getListContactId('internal');
$head = task_prepare_head($task);
dol_fiche_head($head, 'note', $langs->trans('Task'), 0, 'projecttask');
print '<table class="border" width="100%">';
//$linkback="<a href=\"".$_SERVER["PHP_SELF"]."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder\">".$langs->trans("BackToList")."</a>";
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
print '</td></tr>';
// Third party
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1);
示例8: while
if ($search_project_user > 0) $puser->fetch($search_project_user);
if ($search_task_user > 0) $tuser->fetch($search_task_user);
$title=$langs->trans("Activities");
if ($search_task_user == $user->id) $title=$langs->trans("MyActivities");
llxHeader("",$title,"Projet");
if ($id)
{
$projectstatic->fetch($id);
$projectstatic->societe->fetch($projectstatic->societe->id);
}
// Get list of project id allowed to user (in a string list separated by coma)
if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid);
//var_dump($projectsListId);
// Get id of types of contacts for projects (This list never contains a lot of elements)
$listofprojectcontacttype=array();
$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'";
$sql.= " AND ctc.source = 'internal'";
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
{
$listofprojectcontacttype[$obj->rowid]=$obj->code;
}
}
示例9: checkUserAccessToObject
//.........这里部分代码省略.........
$sql .= " WHERE s.rowid = " . $objectid;
$sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
} else {
if (in_array($feature, $checkother)) {
// If external user: Check permission for external users
if ($user->societe_id > 0) {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.fk_soc = " . $user->societe_id;
} else {
if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '" . $user->id . "'";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)";
// Contact not linked to a company or to a company of user
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
} else {
if (!empty($conf->multicompany->enabled)) {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
} else {
if (in_array($feature, $checkproject)) {
if (!empty($conf->projet->enabled) && !$user->rights->projet->all->lire) {
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
$tmparray = explode(',', $tmps);
if (!in_array($objectid, $tmparray)) {
return false;
}
} else {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
} else {
if (!in_array($feature, $nocheck)) {
// If external user: Check permission for external users
if ($user->societe_id > 0) {
if (empty($dbt_keyfield)) {
dol_print_error('', 'Param dbt_keyfield is required but not defined');
}
$sql = "SELECT dbt." . $dbt_keyfield;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt.rowid = " . $objectid;
$sql .= " AND dbt." . $dbt_keyfield . " = " . $user->societe_id;
} else {
if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
if (empty($dbt_keyfield)) {
dol_print_error('', 'Param dbt_keyfield is required but not defined');
}
$sql = "SELECT sc.fk_soc";
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= ", " . MAIN_DB_PREFIX . "societe as s";
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND sc.fk_soc = dbt." . $dbt_keyfield;
$sql .= " AND dbt." . $dbt_keyfield . " = s.rowid";
$sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
$sql .= " AND sc.fk_user = " . $user->id;
} else {
if (!empty($conf->multicompany->enabled)) {
$sql = "SELECT dbt." . $dbt_select;
$sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
$sql .= " WHERE dbt." . $dbt_select . " = " . $objectid;
$sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
}
}
}
}
}
}
}
}
//print "sql=".$sql."<br>";
if ($sql) {
$resql = $db->query($sql);
if ($resql) {
if ($db->num_rows($resql) == 0) {
return false;
}
} else {
return false;
}
}
}
return true;
}
示例10: Project
/**
* Show a combo list with projects qualified for a third party
*
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id project preselected
* @param string $htmlname Nom de la zone html
* @param int $maxlength Maximum length of label
* @param int $option_only Option only
* @param int $show_empty Add an empty line
* @return int Nber of project if OK, <0 if KO
*/
function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1)
{
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$out = '';
$hideunselectables = false;
if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
$hideunselectables = true;
}
$projectsListId = false;
if (empty($user->rights->projet->all->lire)) {
$projectstatic = new Project($this->db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
}
// Search all projects
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p';
$sql .= " WHERE p.entity = " . $conf->entity;
if ($projectsListId !== false) {
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
}
if ($socid == 0) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
}
if ($socid > 0) {
$sql .= " AND (p.fk_soc=" . $socid . " OR p.fk_soc IS NULL)";
}
$sql .= " ORDER BY p.ref ASC";
dol_syslog(get_class($this) . "::select_projects sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if (empty($option_only)) {
$out .= '<select class="flat" name="' . $htmlname . '">';
}
if (!empty($show_empty)) {
$out .= '<option value="0"> </option>';
}
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) {
// Do nothing
} else {
$labeltoshow = dol_trunc($obj->ref, 18);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) {
$out .= '<option value="' . $obj->rowid . '" selected="selected">' . $labeltoshow . ' - ' . dol_trunc($obj->title, $maxlength) . '</option>';
} else {
$disabled = 0;
$labeltoshow .= ' ' . dol_trunc($obj->title, $maxlength);
if (!$obj->fk_statut > 0) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("Draft");
}
if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
}
if ($hideunselectables && $disabled) {
$resultat = '';
} else {
$resultat = '<option value="' . $obj->rowid . '"';
if ($disabled) {
$resultat .= ' disabled="disabled"';
}
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$resultat .= '>';
$resultat .= $labeltoshow;
$resultat .= '</option>';
}
$out .= $resultat;
}
}
$i++;
}
}
if (empty($option_only)) {
$out .= '</select>';
}
print $out;
$this->db->free($resql);
return $num;
} else {
dol_print_error($this->db);
//.........这里部分代码省略.........
示例11: Project
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
function load_board($user)
{
global $conf, $langs;
$mine=0; $socid=$user->societe_id;
$projectstatic = new Project($this->db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
// List of tasks (does not care about permissions. Filtering will be done later)
$sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
$sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
$sql.= " t.dateo as date_start, t.datee as datee";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " WHERE p.entity IN (".getEntity('project').')';
$sql.= " AND p.fk_statut = 1";
$sql.= " AND t.fk_projet = p.rowid";
$sql.= " AND t.progress < 100"; // tasks to do
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
//print $sql;
$resql=$this->db->query($sql);
if ($resql)
{
$task_static = new Task($this->db);
$response = new WorkboardResponse();
$response->warning_delay = $conf->projet->task->warning_delay/60/60/24;
$response->label = $langs->trans("OpenedTasks");
if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project';
else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project';
$response->img = img_object($langs->trans("Tasks"),"task");
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
$task_static->projectstatus = $obj->projectstatus;
$task_static->progress = $obj->progress;
$task_static->fk_statut = $obj->status;
$task_static->datee = $this->db->jdate($obj->datee);
if ($task_static->hasDelay()) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
示例12: restrictedArea
//.........这里部分代码省略.........
else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
{
$sql = "SELECT s.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE s.rowid = ".$objectid;
$sql.= " AND s.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
}
else if (in_array($feature,$checkother))
{
// If external user: Check permission for external users
if ($user->societe_id > 0)
{
$sql = "SELECT dbt.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.rowid = ".$objectid;
$sql.= " AND dbt.fk_soc = ".$user->societe_id;
}
// If internal user: Check permission for internal users that are restricted on their objects
else if (! $user->rights->societe->client->voir)
{
$sql = "SELECT dbt.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
$sql.= " WHERE dbt.rowid = ".$objectid;
$sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
$sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
// If multicompany and internal users with all permissions, check user is in correct entity
else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
{
$sql = "SELECT dbt.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.rowid = ".$objectid;
$sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
}
else if (in_array($feature,$checkproject))
{
if (! $user->rights->projet->all->lire)
{
include_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
$projectstatic=new Project($db);
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,$user->societe_id);
$tmparray=explode(',',$tmps);
if (! in_array($objectid,$tmparray)) accessforbidden();
}
}
else if (! in_array($feature,$nocheck)) // By default we check with link to third party
{
// If external user: Check permission for external users
if ($user->societe_id > 0)
{
$sql = "SELECT dbt.".$dbt_keyfield;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.rowid = ".$objectid;
$sql.= " AND dbt.".$dbt_keyfield." = ".$user->societe_id;
}
// If internal user: Check permission for internal users that are restricted on their objects
else if (! $user->rights->societe->client->voir)
{
$sql = "SELECT sc.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield;
$sql.= " AND dbt.".$dbt_keyfield." = s.rowid";
$sql.= " AND s.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
$sql.= " AND sc.fk_user = ".$user->id;
}
// If multicompany and internal users with all permissions, check user is in correct entity
else if ($conf->global->MAIN_MODULE_MULTICOMPANY)
{
$sql = "SELECT dbt.".$dbt_select;
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
$sql.= " AND dbt.entity IN (0,".(! empty($conf->entities[$dbtablename]) ? $conf->entities[$dbtablename] : $conf->entity).")";
}
}
//print $sql."<br>";
if ($sql)
{
$resql=$db->query($sql);
if ($resql)
{
if ($db->num_rows($resql) == 0) accessforbidden();
}
else
{
dol_syslog("functions.lib:restrictedArea sql=".$sql, LOG_ERR);
accessforbidden();
}
}
}
}
return 1;
}
示例13:
$prev = dol_getdate($daytoparse - (24 * 3600));
$prev_year = $prev['year'];
$prev_month = $prev['mon'];
$prev_day = $prev['mday'];
$next = dol_getdate($daytoparse + (24 * 3600));
$next_year = $next['year'];
$next_month = $next['mon'];
$next_day = $next['mday'];
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
$usertoprocess = $user;
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id)
{
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject=1; // or -1
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
示例14: select_projects
/**
* \brief Show a combo list with projects qualified for a third party
* \param socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* \param selected Id project preselected
* \param htmlname Nom de la zone html
* \return int Nbre of project if OK, <0 if KO
*/
function select_projects($socid = -1, $selected = '', $htmlname = 'projectid')
{
global $db, $user, $conf, $langs;
$projectstatic = new Project($db);
$projectsListId = '';
if (empty($user->rights->projet->all->lire)) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
}
// On recherche les projets
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p';
$sql .= " WHERE p.entity = " . $conf->entity;
if ($projectsListId) {
$sql .= " AND p.rowid in (" . $projectsListId . ")";
}
if ($socid == 0) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
}
//if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; // We will filter later
$sql .= " ORDER BY p.title ASC";
//print $sql;
//var_dump($user->rights);
dol_syslog("project.lib::select_projects sql=" . $sql);
$resql = $db->query($sql);
if ($resql) {
print '<select class="flat" name="' . $htmlname . '">';
print '<option value="0"> </option>';
$num = $db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) {
// Do nothing
} else {
$labeltoshow = dol_trunc($obj->ref, 16);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) {
print '<option value="' . $obj->rowid . '" selected="selected">' . $labeltoshow . '</option>';
} else {
$disabled = 0;
print '<option value="' . $obj->rowid . '"';
if (!$obj->fk_statut > 0) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("Draft");
}
if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
}
if ($disabled == 1) {
print ' disabled="true"';
} else {
$labeltoshow .= ' - ' . dol_trunc($obj->title, 12);
}
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
print '>' . $labeltoshow . '</option>';
}
}
$i++;
}
}
print '</select>';
$db->free($resql);
return $num;
} else {
dol_print_error($db);
return -1;
}
}
示例15: custom_select_projects
/**
* Override de la fonction classique de la class FormProject
* Show a combo list with projects qualified for a third party
*
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id project preselected
* @param string $htmlname Nom de la zone html
* @param int $maxlength Maximum length of label
* @param int $option_only Option only
* @param int $show_empty Add an empty line
* @return string select or options if OK, void if KO
*/
function custom_select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $type_aff = 'view', $maxlength = 25, $option_only = 0, $show_empty = 1)
{
global $user, $conf, $langs, $db;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$out = '';
if ($type_aff == 'view') {
if ($selected > 0) {
$project = new Project($db);
$project->fetch($selected);
//return dol_trunc($project->ref,18).' - '.dol_trunc($project->title,$maxlength);
return $project->getNomUrl(1) . ' - ' . dol_trunc($project->title, $maxlength);
} else {
return $out;
}
}
$hideunselectables = false;
if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
$hideunselectables = true;
}
$projectsListId = false;
if (empty($user->rights->projet->all->lire)) {
$projectstatic = new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
}
// Search all projects
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p';
$sql .= " WHERE p.entity IN (" . getEntity('project', 1) . ")";
if ($projectsListId !== false) {
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
}
if ($socid == 0) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
}
if ($socid > 0) {
$sql .= " AND (p.fk_soc=" . $socid . " OR p.fk_soc IS NULL)";
}
$sql .= " ORDER BY p.ref ASC";
$resql = $db->query($sql);
if ($resql) {
if (empty($option_only)) {
$out .= '<select class="flat" name="' . $htmlname . '">';
}
if (!empty($show_empty)) {
$out .= '<option value="0"> </option>';
}
$num = $db->num_rows($resql);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$user->rights->societe->lire) {
// Do nothing
} else {
$labeltoshow = dol_trunc($obj->ref, 18);
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
if (!empty($selected) && $selected == $obj->rowid && $obj->fk_statut > 0) {
$out .= '<option value="' . $obj->rowid . '" selected="selected">' . $labeltoshow . ' - ' . dol_trunc($obj->title, $maxlength) . '</option>';
} else {
$disabled = 0;
$labeltoshow .= ' ' . dol_trunc($obj->title, $maxlength);
if (!$obj->fk_statut > 0) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("Draft");
}
if ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
$disabled = 1;
$labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany");
}
if ($hideunselectables && $disabled) {
$resultat = '';
} else {
$resultat = '<option value="' . $obj->rowid . '"';
if ($disabled) {
$resultat .= ' disabled="disabled"';
}
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
$resultat .= '>';
$resultat .= $labeltoshow;
$resultat .= '</option>';
}
$out .= $resultat;
}
}
$i++;
//.........这里部分代码省略.........