本文整理汇总了PHP中validate_authenticated函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_authenticated函数的具体用法?PHP validate_authenticated怎么用?PHP validate_authenticated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validate_authenticated函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_custom_field
function set_custom_field($session, $module_name, $type, $properties, $add_to_layout)
{
global $current_user;
global $beanList, $beanFiles;
global $custom_field_meta;
$error = new SoapError();
$request_arr = array('action' => 'SaveField', 'is_update' => 'true', 'module' => 'ModuleBuilder', 'view_module' => $module_name, 'view_package' => 'studio');
// ERROR CHECKING
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return $error->get_soap_array();
}
if (!is_admin($current_user)) {
$error->set_error('no_admin');
return $error->get_soap_array();
}
if (empty($beanList[$module_name])) {
$error->set_error('no_module');
return $error->get_soap_array();
}
if (empty($custom_field_meta[$type])) {
$error->set_error('custom_field_type_not_supported');
return $error->get_soap_array();
}
$new_properties = array();
foreach ($properties as $value) {
$new_properties[$value['name']] = $value['value'];
}
foreach ($custom_field_meta[$type] as $property) {
if (!isset($new_properties[$property])) {
$error->set_error('custom_field_property_not_supplied');
return $error->get_soap_array();
}
$request_arr[$property] = $new_properties[$property];
}
// $request_arr should now contain all the necessary information to create a custom field
// merge $request_arr with $_POST/$_REQUEST, where the action_saveField() method expects them
$_REQUEST = array_merge($_REQUEST, $request_arr);
$_POST = array_merge($_POST, $request_arr);
require_once 'modules/ModuleBuilder/controller.php';
require_once 'modules/ModuleBuilder/parsers/ParserFactory.php';
$mbc = new ModuleBuilderController();
$mbc->setup();
$mbc->action_SaveField();
// add the field to the given module's EditView and DetailView layouts
if ($add_to_layout == 1) {
$layout_properties = array('name' => $new_properties['name'], 'label' => $new_properties['label']);
if (isset($new_properties['customCode'])) {
$layout_properties['customCode'] = $new_properties['customCode'];
}
if (isset($new_properties['customLabel'])) {
$layout_properties['customLabel'] = $new_properties['customLabel'];
}
// add the field to the DetailView
$parser = ParserFactory::getParser('layoutview', FALSE);
$parser->init($module_name, 'DetailView', FALSE);
$parser->_addField($layout_properties);
$parser->writeWorkingFile();
$parser->handleSave();
unset($parser);
// add the field to the EditView
$parser = ParserFactory::getParser('layoutview', FALSE);
$parser->init($module_name, 'EditView', FALSE);
$parser->_addField($layout_properties);
$parser->writeWorkingFile();
$parser->handleSave();
}
return $error->get_soap_array();
}
示例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: set_entries_details
/**
* Update or create a list of SugarBeans, returning details about the records created/updated
*
* @param String $session -- Session ID returned by a previous call to login.
* @param String $module_name -- The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method)..
* @param Array $name_value_lists -- Array of Bean specific Arrays where the keys of the array are the SugarBean attributes, the values of the array are the values the attributes should have.
* @param Array $select_fields -- A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
* @return Array 'name_value_lists' -- Array of Bean specific Arrays where the keys of the array are the SugarBean attributes, the values of the array are the values the attributes should have.
* 'error' -- The SOAP error if any.
*/
function set_entries_details($session, $module_name, $name_value_lists, $select_fields)
{
$error = new SoapError();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('ids' => array(), 'error' => $error->get_soap_array());
}
return handle_set_entries($module_name, $name_value_lists, $select_fields);
}
示例4: 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;
}
示例5: get_document_revision
/**
* This method is used as a result of the .htaccess lock down on the cache directory. It will allow a
* properly authenticated user to download a document that they have proper rights to download.
*
* @param String $session -- Session ID returned by a previous call to login.
* @param String $id -- ID of the document revision to obtain
* @return return_document_revision - this is a complex type as defined in SoapTypes.php
*/
function get_document_revision($session, $id)
{
global $sugar_config;
$error = new SoapError();
if (!validate_authenticated($session)) {
$error->set_error('invalid_login');
return array('id' => -1, 'error' => $error->get_soap_array());
}
require_once 'modules/DocumentRevisions/DocumentRevision.php';
$dr = new DocumentRevision();
$dr->retrieve($id);
if (!empty($dr->filename)) {
$filename = $sugar_config['upload_dir'] . "/" . $dr->id;
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$contents = base64_encode($contents);
return array('document_revision' => array('id' => $dr->id, 'document_name' => $dr->document_name, 'revision' => $dr->revision, 'filename' => $dr->filename, 'file' => $contents), 'error' => $error->get_soap_array());
} else {
$error->set_error('no_records');
return array('id' => -1, 'error' => $error->get_soap_array());
}
}
示例6: 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());
}
示例7: get_encoded_portal_zip_file
function get_encoded_portal_zip_file($session, $md5file, $last_sync, $is_md5_sync = 1)
{
// files might be big
global $sugar_config;
ini_set("memory_limit", "-1");
$md5 = "";
$data = "";
$error = new SoapError();
$the_error = "";
if (!validate_authenticated($session)) {
$the_error = "Invalid session";
}
require "install/data/disc_client.php";
$tempdir_parent = create_cache_directory("disc_client");
$temp_dir = tempnam($tempdir_parent, "sug");
sugar_mkdir($temp_dir, 0775);
$temp_file = tempnam($temp_dir, "sug");
write_encoded_file($md5file, $temp_dir, $temp_file);
$ignore = false;
//generate md5 files on server
require_once $temp_file;
$server_files = array();
// used later for removing unneeded local files
$zip_file = tempnam(tempdir_parent, $session);
$root_files = array();
$custom_files = array();
$file_list = array();
if (!$is_md5_sync) {
if (is_dir("portal")) {
$root_files = findAllTouchedFiles("portal", array(), $last_sync);
}
if (is_dir("custom/portal")) {
$custom_files = findAllTouchedFiles("custom/portal", array(), $last_sync);
}
$all_src_files = array_merge($root_files, $custom_files);
foreach ($all_src_files as $src_file) {
$ignore = false;
foreach ($disc_client_ignore as $ignore_pattern) {
if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
$ignore = true;
}
}
if (!$ignore) {
//we have to strip off portal or custom/portal before the src file to look it up
$key = str_replace('custom/portal/', '', $src_file);
$key = str_replace('portal/', '', $key);
if ($client_file_list != null && isset($client_file_list[$key])) {
//we have found a file out of sync
$file_list[] = $src_file;
//since we have processed this element of the client
//list of files, remove it from the list
unset($client_file_list[$key]);
} else {
//this file does not exist on the client side
$file_list[] = $src_file;
}
}
}
} else {
if (is_dir("portal")) {
$root_files = findAllFiles("portal", array());
}
if (is_dir("custom/portal")) {
$custom_files = findAllFiles("custom/portal", array());
}
$all_src_files = array_merge($root_files, $custom_files);
foreach ($all_src_files as $src_file) {
$ignore = false;
foreach ($disc_client_ignore as $ignore_pattern) {
if (preg_match("#" . $ignore_pattern . "#", $src_file)) {
$ignore = true;
}
}
if (!$ignore) {
$value = md5_file($src_file);
//we have to strip off portal or custom/portal before the src file to look it up
$key = str_replace('custom/portal/', '', $src_file);
$key = str_replace('portal/', '', $key);
if ($client_file_list != null && isset($client_file_list[$key])) {
if ($value != $client_file_list[$key]) {
//we have found a file out of sync
$file_list[] = $src_file;
//since we have processed this element of the client
//list of files, remove it from the list
}
unset($client_file_list[$key]);
} else {
//this file does not exist on the client side
$file_list[] = $src_file;
}
}
}
}
zip_files_list($zip_file, $file_list, '|.*portal/|');
$contents = sugar_file_get_contents($zip_file);
// encode data
$data = base64_encode($contents);
unlink($zip_file);
return array('result' => $data, 'error' => $error->get_soap_array());
}
示例8: new_seamless_login
/**
* Perform a seamless login. This is used internally during the sync process.
*
* @param String $session -- Session ID returned by a previous call to login.
* @return true -- if the session was authenticated
* @return false -- if the session could not be authenticated
*/
function new_seamless_login($session)
{
if (!validate_authenticated($session)) {
return 0;
}
$_SESSION['seamless_login'] = true;
return 1;
}
示例9: get_module_fields
/**
* Retrieve vardef information on the fields of the specified bean.
*
* @param String $session -- Session ID returned by a previous call to login.
* @param String $module_name -- The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method)..
* @return Array 'module_fields' -- The vardef information on the selected fields.
* 'error' -- The SOAP error, if any
*/
function get_module_fields($session, $module_name)
{
global $db;
$error = new SoapError();
$module_fields = array();
if (!validate_authenticated($session)) {
$error->set_error('invalid_session');
return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array());
}
$AppUI =& $_SESSION['AppUI'];
$GLOBALS['AppUI'] = $AppUI;
$modclass = $AppUI->getModuleClass($module_name);
if (file_exists($modclass)) {
include_once $modclass;
} else {
$error->set_error('no_module');
return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array());
}
$perms =& $AppUI->acl();
$canAccess = $perms->checkModule($module_name, 'access');
$canRead = $perms->checkModule($module_name, 'view');
$canEdit = $perms->checkModule($module_name, 'edit');
$canAuthor = $perms->checkModule($module_name, 'add');
$canDelete = $perms->checkModule($module_name, 'delete');
$GLOBALS['perms'] = $perms;
if (!$canRead) {
$error->set_error('no_access');
return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array());
}
$module_fields = $db->MetaColumns($module_name);
if (empty($module_fields)) {
$error->set_error('no_records');
return array('module_name' => $module_name, 'module_fields' => $module_fields, 'error' => $error->get_soap_array());
}
return array('module_name' => $module_name, 'module_fields' => get_field_list($module_fields), 'error' => $error->get_soap_array());
}