本文整理汇总了PHP中check_modules_access函数的典型用法代码示例。如果您正苦于以下问题:PHP check_modules_access函数的具体用法?PHP check_modules_access怎么用?PHP check_modules_access使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_modules_access函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSessionAndModuleAccess
function checkSessionAndModuleAccess($session, $login_error_key, $module_name, $access_level, $module_access_level_error_key, $errorObject)
{
if (!validate_authenticated($session)) {
$errorObject->set_error('invalid_login');
setFaultObject($errorObject);
return false;
}
// if
global $beanList, $beanFiles;
if (!empty($module_name)) {
if (empty($beanList[$module_name])) {
$errorObject->set_error('no_module');
setFaultObject($errorObject);
return false;
}
// if
global $current_user;
if (!check_modules_access($current_user, $module_name, $access_level)) {
$errorObject->set_error('no_access');
setFaultObject($errorObject);
return false;
}
}
// if
return true;
}
示例2: get_attendee_list
function get_attendee_list($session, $module_name, $id)
{
global $beanList, $beanFiles;
$error = new SoapError();
$field_list = array();
$output_list = array();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
global $current_user;
if (!check_modules_access($current_user, $module_name, 'read')) {
$error->set_error('no_access');
return array('field_list' => $field_list, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$seed = new $class_name();
//rsmith
$xml = '<?xml version="1.0" encoding="utf-8"?>';
if ($module_name == 'Meetings' || $module_name == 'Calls') {
//if we find a meeting or call we want to send back the attendees
$l_module_name = strtolower($module_name);
$table_name = $l_module_name . "_users";
if ($module_name == 'Meetings') {
$join_field = "meeting";
} else {
$join_field = "call";
}
$xml .= '<attendees>';
$result = $seed->db->query("SELECT users.id, {$table_name}.date_modified, first_name, last_name FROM users INNER JOIN {$table_name} ON {$table_name}.user_id = users.id WHERE " . $table_name . "." . $join_field . "_id = '" . $GLOBALS['db']->quote($id) . "' AND {$table_name}.deleted = 0");
$user = new User();
while ($row = $seed->db->fetchByAssoc($result)) {
$user->id = $row['id'];
$email = $user->emailAddress->getPrimaryAddress($user);
$xml .= '<attendee>';
$xml .= '<id>' . $user->id . '</id>';
$xml .= '<first_name>' . $row['first_name'] . '</first_name>';
$xml .= '<last_name>' . $row['last_name'] . '</last_name>';
$xml .= '<email1>' . $email . '</email1>';
$xml .= '</attendee>';
}
//now get contacts
$table_name = $l_module_name . "_contacts";
$result = $seed->db->query("SELECT contacts.id, {$table_name}.date_modified, first_name, last_name FROM contacts INNER JOIN {$table_name} ON {$table_name}.contact_id = contacts.id INNER JOIN {$seed->table_name} ON " . $seed->table_name . ".id = " . $table_name . "." . $join_field . "_id WHERE " . $table_name . "." . $join_field . "_id = '" . $GLOBALS['db']->quote($id) . "' AND " . $table_name . ".deleted = 0 AND (contacts.id != " . $seed->table_name . ".parent_id OR " . $seed->table_name . ".parent_id IS NULL)");
$contact = new Contact();
while ($row = $seed->db->fetchByAssoc($result)) {
$contact->id = $row['id'];
$email = $contact->emailAddress->getPrimaryAddress($contact);
$xml .= '<attendee>';
$xml .= '<id>' . $contact->id . '</id>';
$xml .= '<first_name>' . $row['first_name'] . '</first_name>';
$xml .= '<last_name>' . $row['last_name'] . '</last_name>';
$xml .= '<email1>' . $email . '</email1>';
$xml .= '</attendee>';
}
$xml .= '</attendees>';
}
$xml = base64_encode($xml);
return array('result' => $xml, 'error' => $error->get_soap_array());
}
示例3: handle_set_entries
function handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles, $app_list_strings, $current_user;
$error = new SoapError();
$ret_values = array();
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
//See if we can retrieve the seed by a given id value
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
$dataValues = array();
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum' || $seed->field_name_map[$value['name']]['type'] == 'radioenum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$val])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
} else {
if ($seed->field_name_map[$value['name']]['type'] == 'multienum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
$items = explode(",", $val);
$parsedItems = array();
foreach ($items as $item) {
if (in_array($item, $app_list_strings[$vardef['options']])) {
$keyVal = array_search($item, $app_list_strings[$vardef['options']]);
array_push($parsedItems, $keyVal);
}
}
if (!empty($parsedItems)) {
$val = encodeMultienumValue($parsedItems);
}
}
}
}
//Apply the non-empty values now since this will be used for duplicate checks
//allow string or int of 0 to be updated if set.
if (!empty($val) || ($val === '0' || $val === 0)) {
$seed->{$value}['name'] = $val;
}
//Store all the values in dataValues Array to apply later
$dataValues[$value['name']] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
//Now apply the values, since this is not a duplicate we can just pass false for the $firstSync argument
apply_values($seed, $dataValues, false);
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
//Determine if this is a first time sync. We find out based on whether or not a contacts_users relationship exists
$seed->id = $duplicate_id;
$seed->load_relationship("user_sync");
$beans = $seed->user_sync->getBeans();
$first_sync = empty($beans);
//Now apply the values and indicate whether or not this is a first time sync
apply_values($seed, $dataValues, $first_sync);
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
//.........这里部分代码省略.........
示例4: handle_set_entries
function handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles, $app_list_strings, $current_user;
$error = new SoapError();
$ret_values = array();
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
//See if we can retrieve the seed by a given id value
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
$dataValues = array();
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum' || $seed->field_name_map[$value['name']]['type'] == 'radioenum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$val])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
} else {
if ($seed->field_name_map[$value['name']]['type'] == 'multienum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
$items = explode(",", $val);
$parsedItems = array();
foreach ($items as $item) {
if (in_array($item, $app_list_strings[$vardef['options']])) {
$keyVal = array_search($item, $app_list_strings[$vardef['options']]);
array_push($parsedItems, $keyVal);
}
}
if (!empty($parsedItems)) {
$val = encodeMultienumValue($parsedItems);
}
}
}
}
//Apply the non-empty values now since this will be used for duplicate checks
//allow string or int of 0 to be updated if set.
if (!empty($val) || ($val === '0' || $val === 0)) {
$seed->{$value['name']} = $val;
}
//Store all the values in dataValues Array to apply later
$dataValues[$value['name']] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
//Now apply the values, since this is not a duplicate we can just pass false for the $firstSync argument
apply_values($seed, $dataValues, false);
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
//Determine if this is a first time sync. We find out based on whether or not a contacts_users relationship exists
$seed->id = $duplicate_id;
$seed->load_relationship("user_sync");
$beans = $seed->user_sync->getBeans();
$first_sync = empty($beans);
//Now apply the values and indicate whether or not this is a first time sync
apply_values($seed, $dataValues, $first_sync);
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
//.........这里部分代码省略.........
示例5: handle_set_entries
function handle_set_entries($module_name, $name_value_lists, $select_fields = FALSE)
{
global $beanList, $beanFiles;
$error = new SoapError();
$ret_values = array();
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
global $current_user;
if (!check_modules_access($current_user, $module_name, 'write')) {
$error->set_error('no_access');
return array('ids' => -1, 'error' => $error->get_soap_array());
}
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$ids = array();
$count = 1;
$total = sizeof($name_value_lists);
foreach ($name_value_lists as $name_value_list) {
$seed = new $class_name();
$seed->update_vcal = false;
foreach ($name_value_list as $value) {
if ($value['name'] == 'id') {
$seed->retrieve($value['value']);
break;
}
}
foreach ($name_value_list as $value) {
$val = $value['value'];
if ($seed->field_name_map[$value['name']]['type'] == 'enum') {
$vardef = $seed->field_name_map[$value['name']];
if (isset($app_list_strings[$vardef['options']]) && !isset($app_list_strings[$vardef['options']][$value])) {
if (in_array($val, $app_list_strings[$vardef['options']])) {
$val = array_search($val, $app_list_strings[$vardef['options']]);
}
}
}
$seed->{$value}['name'] = $val;
}
if ($count == $total) {
$seed->update_vcal = false;
}
$count++;
//Add the account to a contact
if ($module_name == 'Contacts') {
$GLOBALS['log']->debug('Creating Contact Account');
add_create_account($seed);
$duplicate_id = check_for_duplicate_contacts($seed);
if ($duplicate_id == null) {
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
$seed->save();
if ($seed->deleted == 1) {
$seed->mark_deleted($seed->id);
}
$ids[] = $seed->id;
}
} else {
//since we found a duplicate we should set the sync flag
if ($seed->ACLAccess('Save')) {
$seed->id = $duplicate_id;
$seed->contacts_users_id = $current_user->id;
$seed->save();
$ids[] = $duplicate_id;
//we have a conflict
}
}
} else {
if ($module_name == 'Meetings' || $module_name == 'Calls') {
//we are going to check if we have a meeting in the system
//with the same outlook_id. If we do find one then we will grab that
//id and save it
if ($seed->ACLAccess('Save') && ($seed->deleted != 1 || $seed->ACLAccess('Delete'))) {
if (empty($seed->id) && !isset($seed->id)) {
if (!empty($seed->outlook_id) && isset($seed->outlook_id)) {
//at this point we have an object that does not have
//the id set, but does have the outlook_id set
//so we need to query the db to find if we already
//have an object with this outlook_id, if we do
//then we can set the id, otherwise this is a new object
$order_by = "";
$query = $seed->table_name . ".outlook_id = '" . $seed->outlook_id . "'";
$response = $seed->get_list($order_by, $query, 0, -1, -1, 0);
$list = $response['list'];
if (count($list) > 0) {
foreach ($list as $value) {
$seed->id = $value->id;
break;
}
}
//fi
}
//fi
}
//fi
$seed->save();
$ids[] = $seed->id;
}
//fi
} else {
//.........这里部分代码省略.........
示例6: search_by_module
/**
* Enter description here...
*
* @param unknown_type $user_name
* @param unknown_type $password
* @param unknown_type $search_string
* @param unknown_type $modules
* @param unknown_type $offset
* @param unknown_type $max_results
* @return unknown
*/
function search_by_module($user_name, $password, $search_string, $modules, $offset, $max_results)
{
global $beanList, $beanFiles;
$error = new SoapError();
if (!validate_user($user_name, $password)) {
$error->set_error('invalid_login');
return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
}
global $current_user;
if ($max_results > 0) {
global $sugar_config;
$sugar_config['list_max_entries_per_page'] = $max_results;
}
$query_array = array('Accounts' => array('where' => "accounts.name like '{0}%'", 'fields' => "accounts.id id, accounts.name"), 'Bugs' => array('where' => "bugs.name like '{0}%' OR bugs.bug_number = '{0}'", 'fields' => "bugs.id, bugs.name, bugs.bug_number"), 'Cases' => array('where' => "cases.name like '{0}%' OR cases.case_number = '{0}'", 'fields' => "cases.id, cases.name, cases.case_number"), 'Contacts' => array('where' => "contacts.first_name like '{0}%' OR contacts.last_name like '{0}%' OR contacts.email1 like '{0}%' OR contacts.email2 like '{0}%'", 'fields' => "contacts.id, contacts.first_name, contacts.last_name, contacts.email1"), 'Leads' => array('where' => "leads.first_name like '{0}%' OR leads.last_name like '{0}%' OR leads.email1 like '{0}%' OR leads.email2 like '{0}%'", 'fields' => "leads.id, leads.first_name, leads.last_name, leads.email1, leads.status"), 'Opportunities' => array('where' => "opportunities.name like '{0}%'", 'fields' => "opportunities.id, opportunities.name"), 'Project' => array('where' => "project.name like '{0}%'", 'fields' => "project.id, project.name"), 'ProjectTask' => array('where' => "project.id = '{0}'", 'fields' => "project_task.id, project_task.name"));
if (!empty($search_string) && isset($search_string)) {
foreach ($modules as $module_name) {
$class_name = $beanList[$module_name];
require_once $beanFiles[$class_name];
$seed = new $class_name();
if (empty($beanList[$module_name])) {
continue;
}
if (!check_modules_access($current_user, $module_name, 'read')) {
continue;
}
if (!$seed->ACLAccess('ListView')) {
continue;
}
if (isset($query_array[$module_name])) {
$query = "SELECT " . $query_array[$module_name]['fields'] . " FROM {$seed->table_name} ";
// We need to confirm that the user is a member of the team of the item.
if ($module_name == 'ProjectTask') {
$query .= "INNER JOIN project ON {$seed->table_name}.parent_id = project.id ";
}
$where = "WHERE (";
$search_terms = explode(", ", $search_string);
$termCount = count($search_terms);
$count = 1;
foreach ($search_terms as $term) {
$where .= string_format($query_array[$module_name]['where'], array($GLOBALS['db']->quote($term)));
if ($count < $termCount) {
$where .= " OR ";
}
$count++;
}
$query .= $where;
$query .= ") AND {$seed->table_name}.deleted = 0";
//grab the items from the db
$result = $seed->db->limitQuery($query, $offset, $max_results);
$list = array();
if (empty($rows_found)) {
$rows_found = $seed->db->getRowCount($result);
}
//fi
$row_offset = 0;
while (($row = $seed->db->fetchByAssoc($result)) != null) {
$list = array();
$fields = explode(", ", $query_array[$module_name]['fields']);
foreach ($fields as $field) {
$field_names = explode(".", $field);
$list[$field] = array('name' => $field_names[1], 'value' => $row[$field_names[1]]);
}
$output_list[] = array('id' => $row['id'], 'module_name' => $module_name, 'name_value_list' => $list);
if (empty($field_list)) {
$field_list = get_field_list($row);
}
}
//end while
}
}
//end foreach
}
$next_offset = $offset + sizeof($output_list);
return array('result_count' => sizeof($output_list), 'next_offset' => $next_offset, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array());
}
示例7: get_quick_sync_data
function get_quick_sync_data($session, $module_name, $related_module_name, $start, $count, $db_type, $deleted)
{
$error = new SoapError();
$field_list = array();
$output_list = array();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('result' => "", 'result_count' => 0, 'error' => $error->get_soap_array());
}
global $current_user;
if (!check_modules_access($current_user, $module_name, 'read')) {
$error->set_error('no_access');
return array('result' => "", 'result_count' => 0, 'error' => $error->get_soap_array());
}
$seed = BeanFactory::getBean($module_name);
if (empty($seed)) {
$error->set_error('no_module');
return array('result' => "", 'result_count' => 0, 'error' => $error->get_soap_array());
}
$table_name = "";
$is_related_query = false;
if (empty($related_module_name) || !isset($related_module_name)) {
$params['include_custom_fields'] = true;
$query_list = $seed->create_new_list_query('', '', array(), $params, (int) $deleted, '', true, $seed);
$query = "SELECT " . $seed->table_name . ".*";
if (empty($query_list['from_min'])) {
$query .= ' ' . $query_list['from'];
} else {
$query .= ' ' . $query_list['from_min'];
}
$query .= ' ' . $query_list['where'];
$table_name = $seed->table_name;
} else {
$result = retrieve_relationship_query($module_name, $related_module_name, "", $deleted, $start, $count);
$query = $result['query'];
$table_name = $result['join_table'];
$is_related_query = true;
}
//set the dbType on the client machine
$GLOBALS['log']->fatal("Quick Sync Data Query: " . $query);
$result = $seed->db->generateInsertSQL($seed, $query, $start, $count, $table_name, $db_type, $is_related_query);
$data['data'] = $result['data'];
$data['cstm'] = $result['cstm_sql'];
$ret_data = base64_encode(serialize($data));
return array('result' => $ret_data, 'result_count' => $result['result_count'], 'next_offset' => $result['next_offset'], 'total_count' => $result['total_count'], 'error' => $error->get_soap_array());
}