0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-03-15 22:04:51 +00:00
salesagility_SuiteCRM/modules/SecurityGroups/SecurityGroupUserRelationship.php

99 lines
3.1 KiB
PHP
Raw Normal View History

2013-10-20 16:24:09 +00:00
<?php
2019-01-25 13:51:46 +00:00
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
2013-10-20 16:24:09 +00:00
require_once('data/SugarBean.php');
// Contact is used to store customer information.
2023-06-01 13:10:03 +00:00
#[\AllowDynamicProperties]
2019-01-25 13:51:46 +00:00
class SecurityGroupUserRelationship extends SugarBean
{
2013-10-20 16:24:09 +00:00
// Stored fields
public $id;
public $securitygroup_id;
public $securitygroup_noninheritable;
public $user_id;
public $noninheritable;
public $primary_group;
2016-03-24 09:22:57 +00:00
2013-10-20 16:24:09 +00:00
// Related fields
public $securitygroup_name;
public $user_name;
2013-10-20 16:24:09 +00:00
public $table_name = "securitygroups_users";
public $object_name = "SecurityGroupUserRelationship";
public $column_fields = array("id"
2013-10-20 16:24:09 +00:00
,"securitygroup_id"
,"user_id"
,"noninheritable"
,"primary_group"
,'date_modified'
);
public $new_schema = true;
2016-03-24 09:22:57 +00:00
public $additional_column_fields = array();
public $field_defs = array(
2013-10-20 16:24:09 +00:00
'id'=>array('name' =>'id', 'type' =>'char', 'len'=>'36', 'default'=>'')
, 'securitygroup_id'=>array('name' =>'securitygroup_id', 'type' =>'char', 'len'=>'36', )
, 'user_id'=>array('name' =>'user_id', 'type' =>'char', 'len'=>'36',)
, 'noninheritable'=>array('name' =>'noninheritable', 'type' =>'bool', 'len'=>'1')
, 'primary_group'=>array('name' =>'primary_group', 'type' =>'bool', 'len'=>'1')
, 'date_modified'=>array('name' => 'date_modified','type' => 'datetime')
2013-10-20 16:24:09 +00:00
, 'deleted'=>array('name' =>'deleted', 'type' =>'bool', 'len'=>'1', 'default'=>'0', 'required'=>true)
);
public function __construct()
2019-01-25 13:51:46 +00:00
{
2013-10-20 16:24:09 +00:00
$this->db = DBManagerFactory::getInstance();
$this->dbManager = DBManagerFactory::getInstance();
$this->disable_row_level_security =true;
2019-01-25 13:51:46 +00:00
}
2013-10-20 16:24:09 +00:00
public function fill_in_additional_detail_fields()
2013-10-20 16:24:09 +00:00
{
2023-06-01 13:26:16 +00:00
if (isset($this->securitygroup_id) && $this->securitygroup_id != "") {
2013-10-20 16:24:09 +00:00
$query = "SELECT name from securitygroups where id='$this->securitygroup_id' AND deleted=0";
2019-01-25 14:14:52 +00:00
$result =$this->db->query($query, true, " Error filling in additional detail fields: ");
2013-10-20 16:24:09 +00:00
// Get the id and the name.
$row = $this->db->fetchByAssoc($result);
2019-01-25 13:51:46 +00:00
if ($row != null) {
2013-10-20 16:24:09 +00:00
$this->securitygroup_name = $row['name'];
}
}
2023-06-01 13:26:16 +00:00
if (isset($this->user_id) && $this->user_id != "") {
2013-10-20 16:24:09 +00:00
$query = "SELECT user_name from users where id='$this->user_id' AND deleted=0";
2019-01-25 14:14:52 +00:00
$result =$this->db->query($query, true, " Error filling in additional detail fields: ");
2013-10-20 16:24:09 +00:00
// Get the id and the name.
$row = $this->db->fetchByAssoc($result);
2019-01-25 13:51:46 +00:00
if ($row != null) {
2013-10-20 16:24:09 +00:00
$this->user_name = $row['user_name'];
}
}
}
public function create_list_query(&$order_by, &$where)
2013-10-20 16:24:09 +00:00
{
$query = "SELECT id, first_name, last_name, user_name FROM users ";
$where_auto = "deleted=0";
2019-01-25 13:51:46 +00:00
if ($where != "") {
2013-10-20 16:24:09 +00:00
$query .= "where $where AND ".$where_auto;
2019-01-25 13:51:46 +00:00
} else {
2013-10-20 16:24:09 +00:00
$query .= "where ".$where_auto;
2019-01-25 13:51:46 +00:00
}
2013-10-20 16:24:09 +00:00
$query .= " ORDER BY last_name, first_name";
return $query;
}
}