本文整理汇总了PHP中ACLController::requireOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP ACLController::requireOwner方法的具体用法?PHP ACLController::requireOwner怎么用?PHP ACLController::requireOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACLController
的用法示例。
在下文中一共展示了ACLController::requireOwner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSseVisibilityFilter
public function addSseVisibilityFilter($engine, $filter)
{
if ($this->bean->bean_implements('ACL') && ACLController::requireOwner($this->bean->module_dir, 'list')) {
if ($engine instanceof SugarSearchEngineElastic) {
$filter->addMust($engine->getOwnerTermFilter());
}
}
return $filter;
}
示例2: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$ret_array = create_export_query_relate_link_patch($type, $searchFields, $where);
if (!empty($ret_array['join'])) {
$query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
} else {
$query = $focus->create_export_query($order_by, $ret_array['where']);
}
}
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result, true);
// setup the "header" line with proper delimiters
$header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
if ($members) {
$header = str_replace('"ea_deleted"' . getDelimiter() . '"ear_deleted"' . getDelimiter() . '"primary_address"' . getDelimiter() . '', '', $header);
}
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
$pre_id = '';
while ($val = $db->fetchByAssoc($result, -1, false)) {
$new_arr = array();
if ($members) {
if ($pre_id == $val['id']) {
continue;
}
if ($val['ea_deleted'] == 1 || $val['ear_deleted'] == 1) {
$val['primary_email_address'] = '';
}
unset($val['ea_deleted']);
unset($val['ear_deleted']);
unset($val['primary_address']);
}
$pre_id = $val['id'];
$vals = array_values($val);
foreach ($vals as $key => $value) {
//getting content values depending on their types
$fieldType = $focus->field_name_map[$fields_array[$key]]['type'];
if (isset($fieldType)) {
switch ($fieldType) {
//if our value is a currency field, then apply the users locale
//.........这里部分代码省略.........
示例3: findEmailFromBeanIds
function findEmailFromBeanIds($beanIds, $beanType, $whereArr)
{
global $current_user;
$q = '';
$whereAdd = "";
$relatedIDs = '';
if ($beanIds != '') {
foreach ($beanIds as $key => $value) {
$beanIds[$key] = '\'' . $value . '\'';
}
$relatedIDs = implode(',', $beanIds);
}
if ($beanType == 'accounts') {
if (isset($whereArr['first_name'])) {
$whereArr['name'] = $whereArr['first_name'];
}
unset($whereArr['last_name']);
unset($whereArr['first_name']);
}
foreach ($whereArr as $column => $clause) {
if (!empty($whereAdd)) {
$whereAdd .= " OR ";
}
$clause = $current_user->db->quote($clause);
$whereAdd .= "{$column} LIKE '{$clause}%'";
}
$table = $beanType;
$module = ucfirst($table);
$class = substr($module, 0, strlen($module) - 1);
require_once "modules/{$module}/{$class}.php";
$person = new $class();
if ($person->ACLAccess('list')) {
if ($relatedIDs != '') {
$where = "({$table}.deleted = 0 AND eabr.primary_address = 1 AND {$table}.id in ({$relatedIDs}))";
} else {
$where = "({$table}.deleted = 0 AND eabr.primary_address = 1)";
}
if (ACLController::requireOwner($module, 'list')) {
$where = $where . " AND ({$table}.assigned_user_id = '{$current_user->id}')";
}
// if
if (!empty($whereAdd)) {
$where .= " AND ({$whereAdd})";
}
if ($beanType === 'accounts') {
$t = "SELECT {$table}.id, '' first_name, {$table}.name last_name, eabr.primary_address, ea.email_address, '{$module}' module ";
} else {
$t = "SELECT {$table}.id, {$table}.first_name, {$table}.last_name, eabr.primary_address, ea.email_address, '{$module}' module ";
}
$t .= "FROM {$table} ";
$t .= "JOIN email_addr_bean_rel eabr ON ({$table}.id = eabr.bean_id and eabr.deleted=0) ";
$t .= "JOIN email_addresses ea ON (eabr.email_address_id = ea.id) ";
$t .= " WHERE {$where}";
/* BEGIN - SECURITY GROUPS */
//this function may not even be used anymore. Seems like findEmailFromBeanIds is preferred now
if ($person->bean_implements('ACL') && ACLController::requireSecurityGroup($module, 'list')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $person->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($table, $module, $current_user->id);
$t .= " AND (" . $owner_where . " or " . $group_where . ") ";
}
/* END - SECURITY GROUPS */
}
// if
return $t;
}
示例4: create_where_statement
/**
* @return array
*/
public function create_where_statement()
{
$where_clauses = array();
foreach ($this->field_search_params as $merge_field => $vDefArray) {
if (isset($vDefArray['source']) && $vDefArray['source'] == 'custom_fields') {
$table_name = $this->merge_bean->table_name . '_cstm';
} else {
$table_name = $this->merge_bean->table_name;
}
//Should move these if's into a central location for extensibility and addition for other search filters
//Must do the same for pulling values in js dropdown
if (isset($vDefArray['search_type']) && $vDefArray['search_type'] == 'like') {
if ($merge_field != 'email1' && $merge_field != 'email2' && $merge_field != 'release_name') {
if ($vDefArray['value'] != '') {
array_push($where_clauses, $table_name . '.' . $merge_field . " LIKE '%" . $GLOBALS['db']->quote($vDefArray['value']) . "%'");
}
} elseif ($merge_field == 'release_name') {
if (isset($vDefArray['value'])) {
$in = $this->release_name_query('like', $vDefArray['value']);
array_push($where_clauses, $table_name . ".found_in_release IN ({$in})");
}
} else {
$query = $this->email_addresses_query($table_name, $this->merge_module, $this->merge_bean->id);
$query .= " AND ea.email_address LIKE '%" . $GLOBALS['db']->quote($vDefArray['value']) . "%')";
$where_clauses[] = $query;
}
} elseif (isset($vDefArray['search_type']) && $vDefArray['search_type'] == 'start') {
if ($merge_field != 'email1' && $merge_field != 'email2' && $merge_field != 'release_name') {
array_push($where_clauses, $table_name . '.' . $merge_field . " LIKE '" . $GLOBALS['db']->quote($vDefArray['value']) . "%'");
} elseif ($merge_field == 'release_name') {
if (isset($vDefArray['value'])) {
$in = $this->release_name_query('start', $vDefArray['value']);
array_push($where_clauses, $table_name . ".found_in_release IN ({$in})");
}
} else {
$query = $this->email_addresses_query($table_name, $this->merge_module, $this->merge_bean->id);
$query .= " AND ea.email_address LIKE '" . $GLOBALS['db']->quote($vDefArray['value']) . "%')";
$where_clauses[] = $query;
}
} else {
if ($merge_field != 'email1' && $merge_field != 'email2' && $merge_field != 'release_name') {
array_push($where_clauses, $table_name . '.' . $merge_field . "='" . $GLOBALS['db']->quote($vDefArray['value']) . "'");
} elseif ($merge_field == 'release_name') {
if (isset($vDefArray['value'])) {
$in = $this->release_name_query('exact', $vDefArray['value']);
array_push($where_clauses, $table_name . ".found_in_release IN ({$in})");
}
} else {
$query = $this->email_addresses_query($table_name, $this->merge_module, $this->merge_bean->id);
$query .= " AND ea.email_address = '" . $GLOBALS['db']->quote($vDefArray['value']) . "')";
$where_clauses[] = $query;
}
}
}
// Add ACL Check
if ($this->merge_bean->bean_implements('ACL') && ACLController::requireOwner($this->merge_bean->module_dir, 'delete')) {
global $current_user;
$where_clauses[] = $this->merge_bean->getOwnerWhere($current_user->id);
}
array_push($where_clauses, $this->merge_bean->table_name . ".id !='" . $GLOBALS['db']->quote($this->merge_bean->id) . "'");
return $where_clauses;
}
示例5: processSugarBean
function processSugarBean($html_varName, $seed, $offset)
{
global $row_count, $sugar_config;
global $next_offset;
global $previous_offset;
global $list_view_row_count;
global $current_offset;
if (!empty($sugar_config['disable_vcr'])) {
$seed->retrieve($_REQUEST['record']);
return $seed;
}
$isfirstview = 0;
$nav_history_set = false;
$nav_history_array = array();
$nav_offset = '';
$nav_ids_visited = array();
$nav_stamp = '';
//get the session variable DETAIL_NAV_HISTORY,
//the format of the variable stamp,offset, array of IDs visited.
$nav_history = $this->getLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY");
if (!empty($nav_history)) {
$nav_history_set = true;
$nav_history_array = explode(":", $nav_history);
$nav_stamp = $nav_history_array[0];
$nav_offset = $nav_history_array[1];
eval("\$nav_ids_visited= " . $nav_history_array[2] . ";");
}
//from list offset is there but $bNavHistorySet is false.
//from next,previous,start and end buttons offset and $bNavHistorySet is true.
//from tracker offset is not there but $bNavHistorySet may or may not exist.
if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) {
//get offset values.
$offset = $_REQUEST['offset'];
if ($offset < 0) {
$offset = 0;
}
//if the stamp has changed, ignore the offset and navigate to the record.
//use case, search, navigate to detail, copy URL, search again, paste URL.
if (!$this->isRequestFromListView($html_varName)) {
$result = $seed->retrieve($_REQUEST['record']);
return $result;
}
if ($nav_history_set) {
if (isset($nav_ids_visited[$offset])) {
unset($nav_ids_visited[$offset]);
}
}
} else {
if ($nav_history_set) {
//try to locate the ID in the nav_history array.
$key = array_search($_REQUEST['record'], $nav_ids_visited);
if ($key === false) {
//do not show the VCR buttons.
$result = $seed->retrieve($_REQUEST['record']);
return $result;
}
$offset = $key;
$_REQUEST['offset'] = $offset;
$_GET['offset'] = $offset;
$_POST['offset'] = $offset;
$_REQUEST['stamp'] = $nav_stamp;
$_GET['stamp'] = $nav_stamp;
$_POST['stamp'] = $nav_stamp;
if (isset($nav_ids_visited[$offset])) {
unset($nav_ids_visited[$offset]);
}
} else {
if (!empty($seed->id)) {
return $seed;
}
$result = $seed->retrieve($_REQUEST['record']);
return $result;
}
}
//Check if this is the first time we have viewed this record
$var = $this->getLocalSessionVariable($html_varName, "IS_FIRST_VIEW");
if (!isset($var) || !$var) {
$isFirstView = true;
} else {
$isFirstView = false;
}
//indicate that this is not the first time anymore
$this->setLocalSessionVariable($html_varName, "IS_FIRST_VIEW", false);
// All 3 databases require this because the limit query does a > db_offset comparison.
$db_offset = $offset - 1;
$this->populateQueryWhere($isFirstView, $html_varName);
if (ACLController::requireOwner($seed->module_dir, 'view')) {
global $current_user;
$seed->getOwnerWhere($current_user->id);
if (!empty($this->query_where)) {
$this->query_where .= ' AND ';
}
$this->query_where .= $seed->getOwnerWhere($current_user->id);
}
/* BEGIN - SECURITY GROUPS */
if (ACLController::requireSecurityGroup($seed->module_dir, 'view')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $seed->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($seed->table_name, $seed->module_dir, $current_user->id);
//.........这里部分代码省略.........
示例6: _getPeopleUnionQuery
/**
* Generates a UNION query to get one list of users, contacts, leads, and
* prospects; used specifically for the addressBook
*/
function _getPeopleUnionQuery($whereArr, $person)
{
global $current_user, $app_strings;
global $db;
if (!isset($person) || $person === 'LBL_DROPDOWN_LIST_ALL') {
$peopleTables = array("users", "contacts", "leads", "prospects");
} else {
$peopleTables = array($person);
}
$q = '';
$whereAdd = "";
foreach ($whereArr as $column => $clause) {
if (!empty($whereAdd)) {
$whereAdd .= " AND ";
}
$clause = $current_user->db->helper->escape_quote($clause);
$whereAdd .= "{$column} LIKE '{$clause}%'";
}
foreach ($peopleTables as $table) {
$module = ucfirst($table);
$class = substr($module, 0, strlen($module) - 1);
require_once "modules/{$module}/{$class}.php";
$person = new $class();
if (!$person->ACLAccess('list')) {
continue;
}
// if
$where = "({$table}.deleted = 0 AND eabr.primary_address = 1 AND {$table}.id <> '{$current_user->id}')";
if (ACLController::requireOwner($module, 'list')) {
$where = $where . " AND ({$table}.assigned_user_id = '{$current_user->id}')";
}
// if
if (!empty($whereAdd)) {
$where .= " AND ({$whereAdd})";
}
$t = "SELECT {$table}.id, {$table}.first_name, {$table}.last_name, eabr.primary_address, ea.email_address, '{$module}' module ";
$t .= "FROM {$table} ";
$t .= "JOIN email_addr_bean_rel eabr ON ({$table}.id = eabr.bean_id and eabr.deleted=0) ";
$t .= "JOIN email_addresses ea ON (eabr.email_address_id = ea.id) ";
$t .= " WHERE {$where}";
//_pp($t);
//$t .= " LIMIT 10";
if (!empty($q)) {
$q .= "\n UNION ALL \n";
}
$q .= "({$t})";
}
$countq = "SELECT count(people.id) c from ({$q}) people";
$q .= "ORDER BY last_name";
//_ppd($q);
return array('query' => $q, 'countQuery' => $countq);
}
示例7: build_report_access_query
function build_report_access_query(SugarBean $module, $alias)
{
$module->table_name = $alias;
$where = '';
if ($module->bean_implements('ACL') && ACLController::requireOwner($module->module_dir, 'list')) {
global $current_user;
$owner_where = $module->getOwnerWhere($current_user->id);
$where = ' AND ' . $owner_where;
}
if (file_exists('modules/SecurityGroups/SecurityGroup.php')) {
/* BEGIN - SECURITY GROUPS */
if ($module->bean_implements('ACL') && ACLController::requireSecurityGroup($module->module_dir, 'list')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $module->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($alias, $module->module_dir, $current_user->id);
if (!empty($owner_where)) {
$where .= " AND (" . $owner_where . " or " . $group_where . ") ";
} else {
$where .= ' AND ' . $group_where;
}
}
/* END - SECURITY GROUPS */
}
return $where;
}
示例8: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null)
{
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
$focus = 0;
$content = '';
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$db = PearDatabase::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (isset($_SESSION['export_where']) && !empty($_SESSION['export_where'])) {
// bug 4679
$where = $_SESSION['export_where'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$query = $focus->create_export_query($order_by, $where);
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$fields_array = $db->getFieldsArray($result);
// setup the "header" line with quotation marks
$header = implode("\"" . getDelimiter() . "\"", array_values($fields_array));
$header = "\"" . $header;
$header .= "\"\r\n";
$content .= $header;
while ($val = $db->fetchByAssoc($result, -1, false)) {
$new_arr = array();
foreach (array_values($val) as $value) {
array_push($new_arr, preg_replace("/\"/", "\"\"", $value));
}
$line = implode("\"" . getDelimiter() . "\"", $new_arr);
$line = "\"" . $line;
$line .= "\"\r\n";
$content .= $line;
}
return $content;
}
示例9: findEmailFromBeanIds
function findEmailFromBeanIds($beanIds, $beanType, $whereArr)
{
global $current_user;
$q = '';
$whereAdd = "";
$relatedIDs = '';
if ($beanIds != '') {
foreach ($beanIds as $key => $value) {
$beanIds[$key] = '\'' . $value . '\'';
}
$relatedIDs = implode(',', $beanIds);
}
if ($beanType == 'accounts') {
if (isset($whereArr['first_name'])) {
$whereArr['name'] = $whereArr['first_name'];
}
unset($whereArr['last_name']);
unset($whereArr['first_name']);
}
foreach ($whereArr as $column => $clause) {
if (!empty($whereAdd)) {
$whereAdd .= " OR ";
}
$clause = $current_user->db->quote($clause);
$whereAdd .= "{$column} LIKE '{$clause}%'";
}
$table = $beanType;
$module = ucfirst($table);
$class = substr($module, 0, strlen($module) - 1);
require_once "modules/{$module}/{$class}.php";
$person = new $class();
if ($person->ACLAccess('list')) {
if ($relatedIDs != '') {
$where = "({$table}.deleted = 0 AND eabr.primary_address = 1 AND {$table}.id in ({$relatedIDs}))";
} else {
$where = "({$table}.deleted = 0 AND eabr.primary_address = 1)";
}
if (ACLController::requireOwner($module, 'list')) {
$where = $where . " AND ({$table}.assigned_user_id = '{$current_user->id}')";
}
// if
if (!empty($whereAdd)) {
$where .= " AND ({$whereAdd})";
}
if ($beanType === 'accounts') {
$t = "SELECT {$table}.id, '' first_name, {$table}.name last_name, eabr.primary_address, ea.email_address, '{$module}' module ";
} else {
$t = "SELECT {$table}.id, {$table}.first_name, {$table}.last_name, eabr.primary_address, ea.email_address, '{$module}' module ";
}
$t .= "FROM {$table} ";
$t .= "JOIN email_addr_bean_rel eabr ON ({$table}.id = eabr.bean_id and eabr.deleted=0) ";
$t .= "JOIN email_addresses ea ON (eabr.email_address_id = ea.id) ";
$t .= " WHERE {$where}";
}
// if
return $t;
}
示例10: exportFromApi
/**
* builds up a delimited string for export
* @param boolean args api argument
* @param boolean sample whether it's sample export
* @return string delimited string for export
*/
function exportFromApi($args, $sample = false)
{
global $current_user;
global $app_strings;
$sampleRecordNum = 5;
$type = clean_string($args['module']);
require_once 'include/RecordListFactory.php';
$recordList = RecordListFactory::getRecordList($args['record_list_id']);
if (empty($recordList)) {
throw new SugarApiExceptionNotFound();
}
$records = $recordList['records'];
$members = isset($args['members']) ? $args['members'] : false;
//Array of fields that should not be exported, and are only used for logic
$remove_from_members = array("ea_deleted", "ear_deleted", "primary_address");
$focus = BeanFactory::newBean($type);
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
// we take an array, but we'll make an exception for one record.
if (!is_array($records)) {
$records = array($records);
}
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($args['all'])) {
$where = '';
} else {
// use filter to get data instead of building a sql
if (!empty($args['filter'])) {
$content = getExportContentFromFilter($args, $remove_from_members, $focus, $members);
return $content;
} else {
$where = '';
}
}
if ($focus->bean_implements('ACL')) {
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
}
if ($focus->bean_implements('ACL')) {
$focus->addVisibilityWhere($where);
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$query = $focus->create_export_query("", $where);
}
$result = null;
if ($sample) {
$result = $db->limitQuery($query, 0, $sampleRecordNum, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
$sample = $focus->_get_num_rows_in_query($query) < 1;
} else {
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
}
$content = getExportContentFromResult($focus, $result, $members, $remove_from_members, $sample);
return $content;
}
示例11: build_from_string
//.........这里部分代码省略.........
$this->fromString .= ' ' . $thisPathDetails['jointype'] . ' ' . $this->joinSegments[$thisPath]['object']->table_name . ' AS ' . $this->joinSegments[$thisPath]['alias'] . ' ON ' . $this->joinSegments[$thisPath]['alias'] . '.id=' . ($this->joinSegments[$leftPath]['object']->field_defs[$this->joinSegments[$leftPath]['object']->field_defs[$rightArray[2]]['id_name']]['source'] == 'custom_fields' ? $this->joinSegments[$leftPath]['customjoin'] : $this->joinSegments[$leftPath]['alias']) . '.' . $this->joinSegments[$leftPath]['object']->field_defs[$rightArray[2]]['id_name'] . ' ';
// check for Custom Fields
if ($this->joinSegments[$thisPath]['object']->hasCustomFields()) {
$this->joinSegments[$thisPath]['customjoin'] = randomstring();
$this->fromString .= ' LEFT JOIN ' . $this->joinSegments[$thisPath]['object']->table_name . '_cstm as ' . $this->joinSegments[$thisPath]['customjoin'] . ' ON ' . $this->joinSegments[$thisPath]['alias'] . '.id = ' . $this->joinSegments[$thisPath]['customjoin'] . '.id_c';
}
} else {
//left Path Object must be set since we process from the top
if (!$this->joinSegments[$leftPath]['object'] instanceof $beanList[$rightArray[1]]) {
$GLOBALS['log']->error('KReporter: fatal error in join with left path ' . $thisPath);
die('fatal Error in Join ' . $thisPath);
}
// load the relationship .. resp link
$this->joinSegments[$leftPath]['object']->load_relationship($rightArray[2]);
// set aliases for left and right .. will be processed properly anyway in the build of the link
// ... funny enough so
//2011-12-29 check if we have a jointpye
if ($thisPathDetails['jointype'] != '') {
//2011-12-29 see if the relationship vuilds on a custom field
if (isset($this->joinSegments[$leftPath]['object']->field_name_map[$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->_relationship->rhs_key]['source']) && ($this->joinSegments[$leftPath]['object']->field_name_map[$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->_relationship->rhs_key]['source'] == 'custom_fields' || $this->joinSegments[$leftPath]['object']->field_name_map[$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->_relationship->lhs_key]['source'] == 'custom_fields')) {
$join_params = array('join_type' => $thisPathDetails['jointype'], 'right_join_table_alias' => $this->joinSegments[$leftPath]['customjoin'], 'left_join_table_alias' => $this->joinSegments[$leftPath]['customjoin'], 'join_table_link_alias' => $this->joinSegments[$thisPath]['linkalias'], 'join_table_alias' => $this->joinSegments[$thisPath]['alias']);
} else {
$join_params = array('join_type' => $thisPathDetails['jointype'], 'right_join_table_alias' => $this->joinSegments[$leftPath]['alias'], 'left_join_table_alias' => $this->joinSegments[$leftPath]['alias'], 'join_table_link_alias' => $this->joinSegments[$thisPath]['linkalias'], 'join_table_alias' => $this->joinSegments[$thisPath]['alias']);
}
//2010-09-09 Bug to handle left side join relationship
if (isset($this->joinSegments[$leftPath]['object']->field_defs[$rightArray[2]]['side']) && $this->joinSegments[$leftPath]['object']->field_defs[$rightArray[2]]['side'] == 'left' && !$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->_swap_sides) {
$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->_swap_sides = true;
}
$linkJoin = $this->joinSegments[$leftPath]['object']->{$rightArray}[2]->getJoin($join_params);
$this->fromString .= ' ' . $linkJoin;
}
// load the module on the right hand side
require_once $beanFiles[$beanList[$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->getRelatedModuleName()]];
$this->joinSegments[$thisPath]['object'] = new $beanList[$this->joinSegments[$leftPath]['object']->{$rightArray}[2]->getRelatedModuleName()]();
//bugfix 2010-08-19, respect ACL role access for owner reuqired in select
if ($this->joinSegments[$leftPath]['object']->bean_implements('ACL') && ACLController::requireOwner($this->joinSegments[$leftPath]['object']->module_dir, 'list')) {
//2013-02-22 missing check if we have a wherestring at all
if ($this->whereString != '') {
$this->whereString .= ' AND ';
}
$this->whereString .= $this->joinSegments[$leftPath]['alias'] . '.assigned_user_id=\'' . $current_user->id . '\'';
}
// check for Custom Fields
if ($this->joinSegments[$thisPath]['object']->hasCustomFields()) {
$this->joinSegments[$thisPath]['customjoin'] = randomstring();
$this->fromString .= ' LEFT JOIN ' . $this->joinSegments[$thisPath]['object']->table_name . '_cstm as ' . $this->joinSegments[$thisPath]['customjoin'] . ' ON ' . $this->joinSegments[$thisPath]['alias'] . '.id = ' . $this->joinSegments[$thisPath]['customjoin'] . '.id_c';
}
// append join for Orgobjects if Object is OrgManaged
if ($this->authChecklevel != 'none' && $this->authChecklevel != 'top') {
switch ($GLOBALS['sugar_config']['KReports']['authCheck']) {
case 'KOrgObjects':
$this->fromString .= $thisKOrgObject->getOrgunitJoin($this->joinSegments[$thisPath]['object']->table_name, $this->joinSegments[$thisPath]['object']->object_name, $this->joinSegments[$thisPath]['alias'], '1');
break;
case 'KAuthObjects':
$selectArray = array('where' => '', 'from' => '', 'select' => '');
$GLOBALS['KAuthAccessController']->addAuthAccessToListArray($selectArray, $this->joinSegments[$thisPath]['object'], $this->joinSegments[$thisPath]['alias'], true);
if (!empty($selectArray['where'])) {
if (empty($this->whereString)) {
$this->whereString = " " . $selectArray['where'] . " ";
} else {
$this->whereString .= " AND " . $selectArray['where'] . " ";
}
}
if (!empty($selectArray['join'])) {
$this->fromString .= ' ' . $selectArray['join'] . ' ';
}
break;
case 'PRO':
$this->fromString .= ' ';
$this->joinSegments[$thisPath]['object']->add_team_security_where_clause($this->fromString, $this->joinSegments[$thisPath]['alias']);
break;
//2013-03-26 Bug#460 Typo changed
//2013-03-26 Bug#460 Typo changed
case 'SecurityGroups':
if ($this->joinSegments[$thisPath]['object']->bean_implements('ACL') && ACLController::requireSecurityGroup($this->joinSegments[$thisPath]['object']->module_dir, 'list')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = str_replace($this->joinSegments[$thisPath]['object']->table_name, $this->joinSegments[$thisPath]['alias'], $this->joinSegments[$thisPath]['object']->getOwnerWhere($current_user->id));
$group_where = SecurityGroup::getGroupWhere($this->joinSegments[$thisPath]['alias'], $this->joinSegments[$thisPath]['object']->module_dir, $current_user->id);
if (!empty($owner_where)) {
if (empty($this->whereString)) {
$this->whereString = " (" . $owner_where . " or " . $group_where . ") ";
} else {
$this->whereString .= " AND (" . $owner_where . " or " . $group_where . ") ";
}
} else {
$this->whereString .= ' AND ' . $group_where;
}
}
break;
}
}
}
}
}
// increase Counter to tackle next level
$levelCounter++;
}
}
}
示例12: get_detail
/**
* Returns a detail object like retrieving of the current object type.
*
* It is intended for use in navigation buttons on the DetailView. It will pass an offset and limit argument to the sql query.
* @internal This method must be called on a new instance. It overrides the values of all the fields in the current one.
*
* @param string $order_by
* @param string $where Additional where clause
* @param int $offset
* @param int $row_offset Optional,default 0, starting row number
* @param int $limit Optional, default -1
* @param int $max Optional, default -1
* @param int $show_deleted Optional, default 0, if set to 1 system will show deleted records.
* @return array Fetched data.
*
* Internal function, do not override.
*/
public function get_detail($order_by = "", $where = "", $offset = 0, $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0)
{
$GLOBALS['log']->debug("get_detail: order_by = '{$order_by}' and where = '{$where}' and limit = '{$limit}' and offset = '{$offset}'");
if (isset($_SESSION['show_deleted'])) {
$show_deleted = 1;
}
if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) {
global $current_user;
$owner_where = $this->getOwnerWhere($current_user->id);
if (empty($where)) {
$where = $owner_where;
} else {
$where .= ' AND ' . $owner_where;
}
}
/* BEGIN - SECURITY GROUPS */
if ($this->bean_implements('ACL') && ACLController::requireSecurityGroup($this->module_dir, 'list')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $this->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($this->table_name, $this->module_dir, $current_user->id);
if (!empty($owner_where)) {
if (empty($where)) {
$where = " (" . $owner_where . " or " . $group_where . ") ";
} else {
$where .= " AND (" . $owner_where . " or " . $group_where . ") ";
}
} else {
$where .= ' AND ' . $group_where;
}
}
/* END - SECURITY GROUPS */
$query = $this->create_new_list_query($order_by, $where, array(), array(), $show_deleted, $offset);
//Add Limit and Offset to query
//$query .= " LIMIT 1 OFFSET $offset";
return $this->process_detail_query($query, $row_offset, $limit, $max, $where, $offset);
}
示例13: export
/**
* builds up a delimited string for export
* @param string type the bean-type to export
* @param array records an array of records if coming directly from a query
* @return string delimited string for export
*/
function export($type, $records = null, $members = false, $sample = false)
{
global $locale;
global $beanList;
global $beanFiles;
global $current_user;
global $app_strings;
global $app_list_strings;
global $timedate;
global $mod_strings;
global $current_language;
$sampleRecordNum = 5;
$contact_fields = array("id" => "Contact ID", "lead_source" => "Lead Source", "date_entered" => "Date Entered", "date_modified" => "Date Modified", "first_name" => "First Name", "last_name" => "Last Name", "salutation" => "Salutation", "birthdate" => "Lead Source", "do_not_call" => "Do Not Call", "email_opt_out" => "Email Opt Out", "title" => "Title", "department" => "Department", "birthdate" => "Birthdate", "do_not_call" => "Do Not Call", "phone_home" => "Phone (Home)", "phone_mobile" => "Phone (Mobile)", "phone_work" => "Phone (Work)", "phone_other" => "Phone (Other)", "phone_fax" => "Fax", "email1" => "Email", "email2" => "Email (Other)", "assistant" => "Assistant", "assistant_phone" => "Assistant Phone", "primary_address_street" => "Primary Address Street", "primary_address_city" => "Primary Address City", "primary_address_state" => "Primary Address State", "primary_address_postalcode" => "Primary Address Postalcode", "primary_address_country" => "Primary Address Country", "alt_address_street" => "Other Address Street", "alt_address_city" => "Other Address City", "alt_address_state" => "Other Address State", "alt_address_postalcode" => "Other Address Postalcode", "alt_address_country" => "Other Address Country", "description" => "Description");
$account_fields = array("id" => "Account ID", "name" => "Account Name", "website" => "Website", "industry" => "Industry", "account_type" => "Type", "ticker_symbol" => "Ticker Symbol", "employees" => "Employees", "ownership" => "Ownership", "phone_office" => "Phone", "phone_fax" => "Fax", "phone_alternate" => "Other Phone", "email1" => "Email", "email2" => "Other Email", "rating" => "Rating", "sic_code" => "SIC Code", "annual_revenue" => "Annual Revenue", "billing_address_street" => "Billing Address Street", "billing_address_city" => "Billing Address City", "billing_address_state" => "Billing Address State", "billing_address_postalcode" => "Billing Address Postalcode", "billing_address_country" => "Billing Address Country", "shipping_address_street" => "Shipping Address Street", "shipping_address_city" => "Shipping Address City", "shipping_address_state" => "Shipping Address State", "shipping_address_postalcode" => "Shipping Address Postalcode", "shipping_address_country" => "Shipping Address Country", "description" => "Description");
//Array of fields that should not be exported, and are only used for logic
$remove_from_members = array("ea_deleted", "ear_deleted", "primary_address");
$focus = 0;
$bean = $beanList[$type];
require_once $beanFiles[$bean];
$focus = new $bean();
$searchFields = array();
$db = DBManagerFactory::getInstance();
if ($records) {
$records = explode(',', $records);
$records = "'" . implode("','", $records) . "'";
$where = "{$focus->table_name}.id in ({$records})";
} elseif (isset($_REQUEST['all'])) {
$where = '';
} else {
if (!empty($_REQUEST['current_post'])) {
$ret_array = generateSearchWhere($type, $_REQUEST['current_post']);
$where = $ret_array['where'];
$searchFields = $ret_array['searchFields'];
} else {
$where = '';
}
}
$order_by = "";
if ($focus->bean_implements('ACL')) {
if (!ACLController::checkAccess($focus->module_dir, 'export', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
if (ACLController::requireOwner($focus->module_dir, 'export')) {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $focus->getOwnerWhere($current_user->id);
}
/* BEGIN - SECURITY GROUPS */
if (ACLController::requireSecurityGroup($focus->module_dir, 'export')) {
require_once 'modules/SecurityGroups/SecurityGroup.php';
global $current_user;
$owner_where = $focus->getOwnerWhere($current_user->id);
$group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
if (!empty($owner_where)) {
if (empty($where)) {
$where = " (" . $owner_where . " or " . $group_where . ")";
} else {
$where .= " AND (" . $owner_where . " or " . $group_where . ")";
}
} else {
if (!empty($where)) {
$where .= ' AND ';
}
$where .= $group_where;
}
}
/* END - SECURITY GROUPS */
}
// Export entire list was broken because the where clause already has "where" in it
// and when the query is built, it has a "where" as well, so the query was ill-formed.
// Eliminating the "where" here so that the query can be constructed correctly.
if ($members == true) {
$query = $focus->create_export_members_query($records);
} else {
$beginWhere = substr(trim($where), 0, 5);
if ($beginWhere == "where") {
$where = substr(trim($where), 5, strlen($where));
}
$query = $focus->create_export_query($order_by, $where);
}
$result = '';
$populate = false;
if ($sample) {
$result = $db->limitQuery($query, 0, $sampleRecordNum, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
if ($focus->_get_num_rows_in_query($query) < 1) {
$populate = true;
}
} else {
$result = $db->query($query, true, $app_strings['ERR_EXPORT_TYPE'] . $type . ": <BR>." . $query);
}
$fields_array = $db->getFieldsArray($result, true);
//set up the order on the header row
//.........这里部分代码省略.........
示例14: create_new_list_query
function create_new_list_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean, $singleSelect = false)
{
global $beanFiles, $beanList;
$selectedFields = array();
$secondarySelectedFields = array();
$ret_array = array();
$distinct = '';
if ($this->bean_implements('ACL') && ACLController::requireOwner($this->module_dir, 'list')) {
global $current_user;
$owner_where = $this->getOwnerWhere($current_user->id);
if (empty($where)) {
$where = $owner_where;
} else {
$where .= ' AND ' . $owner_where;
}
}
if (!empty($params['distinct'])) {
$distinct = ' DISTINCT ';
}
if (empty($filter)) {
$ret_array['select'] = " SELECT {$distinct} {$this->table_name}.* ";
} else {
$ret_array['select'] = " SELECT {$distinct} {$this->table_name}.id ";
}
$ret_array['from'] = " FROM {$this->table_name} ";
$ret_array['from_min'] = $ret_array['from'];
$ret_array['secondary_from'] = $ret_array['from'];
$ret_array['where'] = '';
$ret_array['order_by'] = '';
//secondary selects are selects that need to be run after the primarty query to retrieve additional info on main
if ($singleSelect) {
$ret_array['secondary_select'] =& $ret_array['select'];
$ret_array['secondary_from'] =& $ret_array['from'];
} else {
$ret_array['secondary_select'] = '';
}
$custom_join = false;
if ((!isset($params['include_custom_fields']) || $params['include_custom_fields']) && isset($this->custom_fields)) {
$custom_join = $this->custom_fields->getJOIN();
if ($custom_join) {
$ret_array['select'] .= ' ' . $custom_join['select'];
}
}
if ($custom_join) {
$ret_array['from'] .= ' ' . $custom_join['join'];
}
$jtcount = 0;
//LOOP AROUND FOR FIXIN VARDEF ISSUES
require 'include/VarDefHandler/listvardefoverride.php';
$joined_tables = array();
if (isset($params['joined_tables'])) {
foreach ($params['joined_tables'] as $table) {
$joined_tables[$table] = 1;
}
}
if (!empty($filter)) {
$filterKeys = array_keys($filter);
if (is_numeric($filterKeys[0])) {
$fields = array();
foreach ($filter as $field) {
$field = strtolower($field);
if (isset($this->field_defs[$field])) {
$fields[$field] = $this->field_defs[$field];
} else {
$fields[$field] = array('force_exists' => true);
}
}
} else {
$fields = $filter;
}
} else {
$fields = $this->field_defs;
}
foreach ($fields as $field => $value) {
//alias is used to alias field names
$alias = '';
if (isset($value['alias'])) {
$alias = ' as ' . $value['alias'] . ' ';
}
if (empty($this->field_defs[$field])) {
if (!empty($filter) && isset($filter[$field]['force_exists']) && $filter[$field]['force_exists']) {
//spaces are a fix for length issue problem with unions. The union only returns the maximum number of characters from the first select statemtn.
$ret_array['select'] .= ", ' ' {$field} ";
}
continue;
} else {
$data = $this->field_defs[$field];
}
//ignore fields that are a part of the collection and a field has been removed as a result of
//layout customization.. this happens in subpanel customizations, use case, from the contacts subpanel
//in opportunities module remove the contact_role/opportunity_role field.
$process_field = true;
if (isset($data['relationship_fields']) and !empty($data['relationship_fields'])) {
foreach ($data['relationship_fields'] as $field_name) {
if (!isset($fields[$field_name])) {
$process_field = false;
}
}
}
if (!$process_field) {
//.........这里部分代码省略.........
示例15: get_data_list
/**
* Equivalent of get_list function within SugarBean but allows the possibility to pass in an indicator
* if the list should filter for favorites. Should eventually update the SugarBean function as well.
*
*/
function get_data_list($seed, $order_by = "", $where = "", $row_offset = 0, $limit = -1, $max = -1, $show_deleted = 0, $favorites = false, $singleSelect = false)
{
Log::debug("get_list: order_by = '{$order_by}' and where = '{$where}' and limit = '{$limit}'");
if (isset($_SESSION['show_deleted'])) {
$show_deleted = 1;
}
$order_by = $seed->process_order_by($order_by, null);
if ($seed->bean_implements('ACL') && ACLController::requireOwner($seed->module_dir, 'list')) {
global $current_user;
$owner_where = $seed->getOwnerWhere($current_user->id);
if (!empty($owner_where)) {
if (empty($where)) {
$where = $owner_where;
} else {
$where .= ' AND ' . $owner_where;
}
}
}
$params = array();
if ($favorites) {
$params['favorites'] = true;
}
$query = $seed->create_new_list_query($order_by, $where, array(), $params, $show_deleted, '', false, null, $singleSelect);
return $seed->process_list_query($query, $row_offset, $limit, $max, $where);
}