当前位置: 首页>>代码示例>>PHP>>正文


PHP SecurityGroup::getGroupWhere方法代码示例

本文整理汇总了PHP中SecurityGroup::getGroupWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityGroup::getGroupWhere方法的具体用法?PHP SecurityGroup::getGroupWhere怎么用?PHP SecurityGroup::getGroupWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SecurityGroup的用法示例。


在下文中一共展示了SecurityGroup::getGroupWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testgetGroupWhere

 public function testgetGroupWhere()
 {
     error_reporting(E_ERROR | E_PARSE);
     $securityGroup = new SecurityGroup();
     //test with securitygroups module
     $expected = " securitygroups.id in (\n                select secg.id from securitygroups secg\n                inner join securitygroups_users secu on secg.id = secu.securitygroup_id and secu.deleted = 0\n                    and secu.user_id = '1'\n                where secg.deleted = 0\n            )";
     $actual = $securityGroup->getGroupWhere('securitygroups', 'SecurityGroups', 1);
     $this->assertSame($expected, $actual);
     //test with //test with securitygroups module module
     $table_name = 'users';
     $module = 'Users';
     $user_id = 1;
     $expected = " EXISTS (SELECT  1\n                  FROM    securitygroups secg\n                          INNER JOIN securitygroups_users secu\n                            ON secg.id = secu.securitygroup_id\n                               AND secu.deleted = 0\n                               AND secu.user_id = '{$user_id}'\n                          INNER JOIN securitygroups_records secr\n                            ON secg.id = secr.securitygroup_id\n                               AND secr.deleted = 0\n                               AND secr.module = '{$module}'\n                       WHERE   secr.record_id = " . $table_name . ".id\n                               AND secg.deleted = 0) ";
     $actual = $securityGroup->getGroupWhere($table_name, $module, $user_id);
     $this->assertSame($expected, $actual);
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:16,代码来源:SecurityGroupTest.php

示例2: 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;
 }
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:67,代码来源:EmailUI.php

示例3: 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);
//.........这里部分代码省略.........
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:101,代码来源:DetailView.php

示例4: get_bean_select_array

function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false)
{
    global $beanFiles;
    require_once $beanFiles[$bean_name];
    $focus = new $bean_name();
    $user_array = array();
    $key = $bean_name == 'EmailTemplate' ? $bean_name : $bean_name . $display_columns . $where . $order_by;
    $user_array = get_register_value('select_array', $key);
    if (!$user_array) {
        $db = DBManagerFactory::getInstance();
        $temp_result = array();
        $query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
        $query .= "where ";
        if ($where != '') {
            $query .= $where . " AND ";
        }
        $query .= " {$focus->table_name}.deleted=0";
        /* BEGIN - SECURITY GROUPS */
        global $current_user, $sugar_config;
        if ($focus->module_dir == 'Users' && !is_admin($current_user) && isset($sugar_config['securitysuite_filter_user_list']) && $sugar_config['securitysuite_filter_user_list'] == true) {
            require_once 'modules/SecurityGroups/SecurityGroup.php';
            $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
            $query .= " AND (" . $group_where . ") ";
        } else {
            if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list')) {
                require_once 'modules/SecurityGroups/SecurityGroup.php';
                $owner_where = $focus->getOwnerWhere($current_user->id);
                $group_where = SecurityGroup::getGroupWhere($focus->table_name, $focus->module_dir, $current_user->id);
                if (!empty($owner_where)) {
                    $query .= " AND (" . $owner_where . " or " . $group_where . ") ";
                } else {
                    $query .= ' AND ' . $group_where;
                }
            }
        }
        /* END - SECURITY GROUPS */
        if ($order_by != '') {
            $query .= " order by {$focus->table_name}.{$order_by}";
        }
        $GLOBALS['log']->debug("get_user_array query: {$query}");
        $result = $db->query($query, true, "Error filling in user array: ");
        if ($add_blank == true) {
            // Add in a blank row
            if ($blank_is_none == true) {
                // set 'blank row' to "--None--"
                global $app_strings;
                $temp_result[''] = $app_strings['LBL_NONE'];
            } else {
                $temp_result[''] = '';
            }
        }
        // Get the id and the name.
        while ($row = $db->fetchByAssoc($result)) {
            $temp_result[$row['id']] = $row['display'];
        }
        $user_array = $temp_result;
        set_register_value('select_array', $key, $temp_result);
    }
    return $user_array;
}
开发者ID:pikkoui,项目名称:suitecrm,代码行数:60,代码来源:utils.php

示例5: get_subscription_lists_query

/**
 * Queries for the list
 */
function get_subscription_lists_query($focus, $additional_fields = null) {
    //get all prospect lists belonging to Campaigns of type newsletter
    $all_news_type_pl_query = "select c.name, pl.list_type, plc.campaign_id, plc.prospect_list_id";
    if(is_array($additional_fields) && !empty($additional_fields)) $all_news_type_pl_query .= ', ' . implode(', ', $additional_fields);
    $all_news_type_pl_query .= " from prospect_list_campaigns plc , prospect_lists pl, campaigns c ";


	$all_news_type_pl_query .= "where plc.campaign_id = c.id ";
    $all_news_type_pl_query .= "and plc.prospect_list_id = pl.id ";
    $all_news_type_pl_query .= "and c.campaign_type = 'NewsLetter'  and pl.deleted = 0 and c.deleted=0 and plc.deleted=0 ";
    $all_news_type_pl_query .= "and (pl.list_type like 'exempt%' or pl.list_type ='default') ";

	/* BEGIN - SECURITY GROUPS */
	if($focus->bean_implements('ACL') && ACLController::requireSecurityGroup('Campaigns', 'list') )
	{
		require_once('modules/SecurityGroups/SecurityGroup.php');
		global $current_user;
		$owner_where = $focus->getOwnerWhere($current_user->id);
		$group_where = SecurityGroup::getGroupWhere('c','Campaigns',$current_user->id);
		$all_news_type_pl_query .= " AND ( c.assigned_user_id ='".$current_user->id."' or ".$group_where.") ";
	}
	/* END - SECURITY GROUPS */
		
    $all_news_type_list =$focus->db->query($all_news_type_pl_query);

    //build array of all newsletter campaigns
    $news_type_list_arr = array();
    while ($row = $focus->db->fetchByAssoc($all_news_type_list)){$news_type_list_arr[] = $row;}

    //now get all the campaigns that the current user is assigned to
    $all_plp_current = "select prospect_list_id from prospect_lists_prospects where related_id = '$focus->id' and deleted = 0 ";

    //build array of prospect lists that this user belongs to
    $current_plp =$focus->db->query($all_plp_current );
    $current_plp_arr = array();
    while ($row = $focus->db->fetchByAssoc($current_plp)){$current_plp_arr[] = $row;}

    return array('current_plp_arr' => $current_plp_arr, 'news_type_list_arr' => $news_type_list_arr);
}
开发者ID:auf,项目名称:crm_auf_org,代码行数:42,代码来源:utils.php

示例6: 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;
 }
开发者ID:omusico,项目名称:suitecrm-docker,代码行数:26,代码来源:AOR_Report.php

示例7: 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);
        }
        /* 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));
        }
        $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);
    global $sugar_config;
    $utf = utf8_encode("????");
    $file = fopen('Export.csv', 'w');
    //$val=iconv("UTF-8","WINDOWS-1255",html_entity_decode($utf,ENT_COMPAT,'utf-8'));
    foreach ($fields_array as $head) {
        $fields_array[] = array(utf8_decode($head));
    }
    fputcsv($file, $fields_array);
    // setup the "header" line with proper delimiters
    /*$header = implode("\"".getDelimiter()."\"", array_values($fields_array));
//.........这里部分代码省略.........
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:101,代码来源:export_utils--.php

示例8: create_new_list_query

 /**
  * Return the list query used by the list views and export button. Next generation of create_new_list_query function.
  *
  * Override this function to return a custom query.
  *
  * @param string $order_by custom order by clause
  * @param string $where custom where clause
  * @param array $filter Optioanal
  * @param array $params Optional     *
  * @param int $show_deleted Optional, default 0, show deleted records is set to 1.
  * @param string $join_type
  * @param boolean $return_array Optional, default false, response as array
  * @param object $parentbean creating a subquery for this bean.
  * @param boolean $singleSelect Optional, default false.
  * @return String select query string, optionally an array value will be returned if $return_array= true.
  */
 function create_new_list_query($order_by, $where, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $parentbean = null, $singleSelect = false, $ifListForExport = 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;
         }
     }
     /* BEGIN - SECURITY GROUPS */
     global $current_user, $sugar_config;
     if ($this->module_dir == 'Users' && !is_admin($current_user) && isset($sugar_config['securitysuite_filter_user_list']) && $sugar_config['securitysuite_filter_user_list'] == true) {
         require_once 'modules/SecurityGroups/SecurityGroup.php';
         global $current_user;
         $group_where = SecurityGroup::getGroupUsersWhere($current_user->id);
         //$group_where = "user_name = 'admin'";
         if (empty($where)) {
             $where = " (" . $group_where . ") ";
         } else {
             $where .= " AND (" . $group_where . ") ";
         }
     } else {
         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 */
     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 primary 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 = $this->getCustomJoin(empty($filter) ? true : $filter);
     if (!isset($params['include_custom_fields']) || $params['include_custom_fields']) {
         $ret_array['select'] .= $custom_join['select'];
     }
     $ret_array['from'] .= $custom_join['join'];
     // Bug 52490 - Captivea (Sve) - To be able to add custom fields inside where clause in a subpanel
     $ret_array['from_min'] .= $custom_join['join'];
     $jtcount = 0;
     //LOOP AROUND FOR FIXIN VARDEF ISSUES
     require 'include/VarDefHandler/listvardefoverride.php';
     if (file_exists('custom/include/VarDefHandler/listvardefoverride.php')) {
         require 'custom/include/VarDefHandler/listvardefoverride.php';
     }
     $joined_tables = array();
     if (!empty($params['joined_tables'])) {
         foreach ($params['joined_tables'] as $table) {
             $joined_tables[$table] = 1;
         }
//.........这里部分代码省略.........
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:101,代码来源:SugarBean.php

示例9: build_from_string

 function build_from_string()
 {
     global $db, $app_list_strings, $beanList, $beanFiles, $current_user;
     // Create a root GUID
     $this->rootGuid = randomstring();
     $this->joinSegments = array();
     $this->maxDepth = 0;
     $kOrgUnits = false;
     //check if we do the Org Check
     if (file_exists('modules/KOrgObjects/KOrgObject.php') && $GLOBALS['sugarconfig']['orgmanaged']) {
         require_once 'modules/KOrgObjects/KOrgObject.php';
         $thisKOrgObject = new KOrgObject();
         $kOrgUnits = true;
     }
     /*
      * Build the array for the joins based on the various Path we have
      */
     foreach ($this->tablePath as $thisPath => $thisPathJoinType) {
         // Process backcutting until we have found the node going upwards
         // in the segments array or we are on the root segment
         // (when no '::' can be found)
         if (substr_count($thisPath, '::') > $this->maxDepth) {
             $this->maxDepth = substr_count($thisPath, '::');
         }
         while (strpos($thisPath, '::') && !isset($this->joinSegments[$thisPath])) {
             // add the segment to the segments table
             $this->joinSegments[$thisPath] = array('alias' => randomstring(), 'linkalias' => randomstring(), 'level' => substr_count($thisPath, '::'), 'jointype' => $thisPathJoinType);
             // find last occurence of '::' in the string and cut off there
             $thisPath = substr($thisPath, strrpos($thisPath, "::"));
         }
     }
     // Get the main Table we select from
     $this->fromString = 'FROM ' . $this->get_table_for_module($this->root_module) . ' ' . $this->rootGuid;
     // check if this is an array so we need to add joins ...
     // add an entry for the root Object ...
     // needed as reference for the GUID
     $this->joinSegments['root:' . $this->root_module] = array('alias' => $this->rootGuid, 'level' => 0);
     // get ther root Object
     require_once $beanFiles[$beanList[$this->root_module]];
     $this->joinSegments['root:' . $this->root_module]['object'] = new $beanList[$this->root_module]();
     // check for Custom Fields
     if ($this->joinSegments['root:' . $this->root_module]['object']->hasCustomFields()) {
         $this->joinSegments['root:' . $this->root_module]['customjoin'] = randomstring();
         $this->fromString .= ' LEFT JOIN ' . $this->get_table_for_module($this->root_module) . '_cstm as ' . $this->joinSegments['root:' . $this->root_module]['customjoin'] . '  ON ' . $this->rootGuid . '.id = ' . $this->joinSegments['root:' . $this->root_module]['customjoin'] . '.id_c';
     }
     // changed so we spport teams in Pro
     if ($this->authChecklevel != 'none') {
         switch ($GLOBALS['sugar_config']['KReports']['authCheck']) {
             case 'KOrgObjects':
                 $this->fromString .= $thisKOrgObject->getOrgunitJoin($this->joinSegments['root:' . $this->root_module]['object']->table_name, $this->joinSegments['root:' . $this->root_module]['object']->object_name, $this->rootGuid, '1');
                 break;
             case 'KAuthObjects':
                 $selectArray = array('where' => '', 'from' => '', 'select' => '');
                 $GLOBALS['KAuthAccessController']->addAuthAccessToListArray($selectArray, $this->joinSegments['root:' . $this->root_module]['object'], $this->joinSegments['root:' . $this->root_module]['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['root:' . $this->root_module]['object']->add_team_security_where_clause($this->fromString, $this->rootGuid);
                 break;
                 //2013-03-26 Bug#460 Typo changed
             //2013-03-26 Bug#460 Typo changed
             case 'SecurityGroups':
                 if ($this->joinSegments['root:' . $this->root_module]['object']->bean_implements('ACL') && ACLController::requireSecurityGroup($this->joinSegments['root:' . $this->root_module]['object']->module_dir, 'list')) {
                     require_once 'modules/SecurityGroups/SecurityGroup.php';
                     global $current_user;
                     $owner_where = str_replace($this->joinSegments['root:' . $this->root_module]['object']->table_name, $this->rootGuid, $this->joinSegments['root:' . $this->root_module]['object']->getOwnerWhere($current_user->id));
                     $group_where = SecurityGroup::getGroupWhere($this->rootGuid, $this->joinSegments['root:' . $this->root_module]['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;
         }
     }
     // Index to iterate through the join table building the joins
     // from the root object outward going
     $levelCounter = 1;
     if (is_array($this->joinSegments)) {
         while ($levelCounter <= $this->maxDepth) {
             // set the array back to the first element in the array
             reset($this->joinSegments);
             foreach ($this->joinSegments as $thisPath => $thisPathDetails) {
                 // process only entries for the respective levels
                 if ($thisPathDetails['level'] == $levelCounter) {
//.........这里部分代码省略.........
开发者ID:ambientelivre,项目名称:GeneratorTargetList,代码行数:101,代码来源:KReportQuery.php

示例10: 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);
 }
开发者ID:auf,项目名称:crm_auf_org,代码行数:54,代码来源:SugarBean.php

示例11: 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
//.........这里部分代码省略.........
开发者ID:BMLP,项目名称:memoryhole-ansible,代码行数:101,代码来源:export_utils.php

示例12: _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", "accounts");
     } 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})";
         }
         if ($person === 'accounts') {
             $t = "SELECT {$table}.id, '' first_name, {$table}.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 (!empty($q)) {
             $q .= "\n UNION ALL \n";
         }
         $q .= "({$t})";
     }
     $countq = "SELECT count(people.id) c from ({$q}) people";
     $q .= "ORDER BY last_name";
     return array('query' => $q, 'countQuery' => $countq);
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:67,代码来源:EmailUI.php

示例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;
    //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
    $fields_array = get_field_order_mapping($focus->module_dir, $fields_array);
    //set up labels to be used for the header row
//.........这里部分代码省略.........
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:101,代码来源:export_utils.php

示例14: array

require_once $beanFiles[$bean_name];
$focus = new $bean_name();
$uids = array();
if ($_REQUEST['select_entire_list'] == '1') {
    $order_by = '';
    require_once 'include/MassUpdate.php';
    $mass = new MassUpdate();
    $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
    $ret_array = create_export_query_relate_link_patch($_REQUEST['module'], $mass->searchFields, $mass->where_clauses);
    /* BEGIN - SECURITY GROUPS */
    //need to hijack the $ret_array['where'] of securitygorup required
    if ($focus->bean_implements('ACL') && ACLController::requireSecurityGroup($focus->module_dir, 'list')) {
        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($ret_array['where'])) {
                $ret_array['where'] = " (" . $owner_where . " or " . $group_where . ") ";
            } else {
                $ret_array['where'] .= " AND (" . $owner_where . " or " . $group_where . ") ";
            }
        } else {
            $ret_array['where'] .= ' AND ' . $group_where;
        }
    }
    /* END - SECURITY GROUPS */
    $query = $focus->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
    $result = $GLOBALS['db']->query($query, true);
    $uids = array();
    while ($val = $GLOBALS['db']->fetchByAssoc($result, false)) {
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:31,代码来源:TargetListUpdate.php

示例15: 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 $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");
    $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);
        }
        /* 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));
        }
        $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 = '';
    $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);
//.........这里部分代码省略.........
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:101,代码来源:export_utils.php


注:本文中的SecurityGroup::getGroupWhere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。