Example #1
0
function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit)
{
    global $beanList, $beanFiles, $portal_modules;
    $error = new SoapError();
    if (!portal_validate_authenticated($session)) {
        $error->set_error('invalid_session');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($_SESSION['type'] == 'lead') {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($module_name == 'Cases') {
        //if the related cases have not yet been loaded into the session object,
        //then call the methods that will load the cases related to the contact/accounts for this user
        if (!isset($_SESSION['viewable'][$module_name])) {
            //retrieve the contact/account id's for this user
            $c = get_contacts_in();
            $a = get_accounts_in();
            if (!empty($c)) {
                get_cases_in_contacts($c);
            }
            if (!empty($a)) {
                get_cases_in_accounts($a);
            }
        }
        $sugar = new aCase();
        $list = array();
        //if no Cases have been loaded into the session as viewable, then do not issue query, just return empty list
        //issuing a query with no cases loaded in session will return ALL the Cases, which is not a good thing
        if (!empty($_SESSION['viewable'][$module_name])) {
            $list = get_related_list(get_module_in($module_name), new aCase(), $where, $order_by, $row_offset, $limit);
        }
    } else {
        if ($module_name == 'Contacts') {
            $sugar = new Contact();
            $list = get_related_list(get_module_in($module_name), new Contact(), $where, $order_by);
        } else {
            if ($module_name == 'Accounts') {
                $sugar = new Account();
                $list = get_related_list(get_module_in($module_name), new Account(), $where, $order_by);
            } else {
                if ($module_name == 'Bugs') {
                    //if the related bugs have not yet been loaded into the session object,
                    //then call the methods that will load the bugs related to the contact/accounts for this user
                    if (!isset($_SESSION['viewable'][$module_name])) {
                        //retrieve the contact/account id's for this user
                        $c = get_contacts_in();
                        $a = get_accounts_in();
                        if (!empty($c)) {
                            get_bugs_in_contacts($c);
                        }
                        if (!empty($a)) {
                            get_bugs_in_accounts($a);
                        }
                    }
                    $list = array();
                    //if no Bugs have been loaded into the session as viewable, then do not issue query, just return empty list
                    //issuing a query with no bugs loaded in session will return ALL the Bugs, which is not a good thing
                    if (!empty($_SESSION['viewable'][$module_name])) {
                        $list = get_related_list(get_module_in($module_name), new Bug(), $where, $order_by, $row_offset, $limit);
                    }
                } else {
                    if ($module_name == 'KBDocuments') {
                    } else {
                        if ($module_name == 'FAQ') {
                        } else {
                            $error->set_error('no_module_support');
                            return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
                        }
                    }
                }
            }
        }
    }
    $output_list = array();
    $field_list = array();
    foreach ($list as $value) {
        //$loga->fatal("Adding another account to the list");
        $output_list[] = get_return_value($value, $module_name);
        $_SESSION['viewable'][$module_name][$value->id] = $value->id;
        if (empty($field_list)) {
            $field_list = get_field_list($value);
        }
    }
    $output_list = filter_return_list($output_list, $select_fields, $module_name);
    $field_list = filter_field_list($field_list, $select_fields, $module_name);
    return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array());
}
function get_return_module_fields($value, $module, $error, $translate = true)
{
    global $module_name;
    $module_name = $module;
    return array('module_name' => $module, 'module_fields' => get_field_list($value, $translate), 'error' => get_name_value_list($value));
}
function portal_get_related_list($session, $module_name, $rel_module, $module_id, $select_fields, $order_by, $offset, $limit)
{
    global $beanList, $beanFiles;
    $error = new SoapError();
    if (!portal_validate_authenticated($session)) {
        $error->set_error('invalid_session');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($_SESSION['type'] == 'lead') {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($_SESSION['viewable'][$module_name][$module_id])) {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    $list = get_related_in_module("('" . $GLOBALS['db']->quote($module_id) . "')", $module_name, $rel_module, $order_by, $offset, $limit);
    $output_list = array();
    $field_list = array();
    foreach ($list as $value) {
        $output_list[] = get_return_value($value, $rel_module);
        $_SESSION['viewable'][$rel_module][$value->id] = $value->id;
        if (empty($field_list)) {
            $field_list = get_field_list($value, true);
        }
    }
    $output_list = filter_return_list($output_list, $select_fields, $module_name);
    $field_list = filter_field_list($field_list, $select_fields, $module_name);
    return array('result_count' => $list['result_count'], 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array());
}
Example #4
0
/**
 * Given a list of modules to search and a search string, return the id, module_name, along with the fields
 * as specified in the $query_array
 *
 * @param string $user_name 		- username of the Sugar User
 * @param string $password			- password of the Sugar User
 * @param string $search_string 	- string to search
 * @param string[] $modules			- array of modules to query
 * @param int $offset				- a specified offset in the query
 * @param int $max_results			- max number of records to return
 * @return get_entry_list_result 	- id, module_name, and list of fields from each record
 */
function search_by_module($user_name, $password, $search_string, $modules, $offset, $max_results)
{
    global $beanList, $beanFiles;
    $error = new SoapError();
    $hasLoginError = false;
    if (empty($user_name) && !empty($password)) {
        if (!validate_authenticated($password)) {
            $hasLoginError = true;
        }
    } else {
        if (!validate_user($user_name, $password)) {
            $hasLoginError = true;
        }
    }
    //If there is a login error, then return the error here
    if ($hasLoginError) {
        $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;
    }
    //  MRF - BUG:19552 - added a join for accounts' emails below
    $query_array = array('Accounts' => array('where' => array('Accounts' => array(0 => "accounts.name like '{0}%'"), 'EmailAddresses' => array(0 => "ea.email_address like '{0}%'")), 'fields' => "accounts.id, accounts.name"), 'Bugs' => array('where' => array('Bugs' => array(0 => "bugs.name like '{0}%'", 1 => "bugs.bug_number = {0}")), 'fields' => "bugs.id, bugs.name, bugs.bug_number"), 'Cases' => array('where' => array('Cases' => array(0 => "cases.name like '{0}%'", 1 => "cases.case_number = {0}")), 'fields' => "cases.id, cases.name, cases.case_number"), 'Leads' => array('where' => array('Leads' => array(0 => "leads.first_name like '{0}%'", 1 => "leads.last_name like '{0}%'"), 'EmailAddresses' => array(0 => "ea.email_address like '{0}%'")), 'fields' => "leads.id, leads.first_name, leads.last_name, leads.status"), 'Project' => array('where' => array('Project' => array(0 => "project.name like '{0}%'")), 'fields' => "project.id, project.name"), 'ProjectTask' => array('where' => array('ProjectTask' => array(0 => "project.id = '{0}'")), 'fields' => "project_task.id, project_task.name"), 'Contacts' => array('where' => array('Contacts' => array(0 => "contacts.first_name like '{0}%'", 1 => "contacts.last_name like '{0}%'"), 'EmailAddresses' => array(0 => "ea.email_address like '{0}%'")), 'fields' => "contacts.id, contacts.first_name, contacts.last_name"), 'Opportunities' => array('where' => array('Opportunities' => array(0 => "opportunities.name like '{0}%'")), 'fields' => "opportunities.id, opportunities.name"), 'Users' => array('where' => array('EmailAddresses' => array(0 => "ea.email_address like '{0}%'")), 'fields' => "users.id, users.user_name, users.first_name, ea.email_address"));
    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 = '';
                $tmpQuery = '';
                //split here to do while loop
                foreach ($query_array[$module_name]['where'] as $key => $value) {
                    foreach ($value as $where_clause) {
                        $addQuery = true;
                        if (!empty($query)) {
                            $tmpQuery = ' UNION ';
                        }
                        $tmpQuery .= "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') {
                            $tmpQuery .= "INNER JOIN project ON {$seed->table_name}.project_id = project.id ";
                        }
                        if (isset($seed->emailAddress) && $key == 'EmailAddresses') {
                            $tmpQuery .= " INNER JOIN email_addr_bean_rel eabl  ON eabl.bean_id = {$seed->table_name}.id and eabl.deleted=0";
                            $tmpQuery .= " INNER JOIN email_addresses ea ON (ea.id = eabl.email_address_id) ";
                        }
                        $where = "WHERE (";
                        $search_terms = explode(", ", $search_string);
                        $termCount = count($search_terms);
                        $count = 1;
                        if ($key != 'EmailAddresses') {
                            foreach ($search_terms as $term) {
                                if (!strpos($where_clause, 'number')) {
                                    $where .= string_format($where_clause, array($GLOBALS['db']->quote($term)));
                                } elseif (is_numeric($term)) {
                                    $where .= string_format($where_clause, array($GLOBALS['db']->quote($term)));
                                } else {
                                    $addQuery = false;
                                }
                                if ($count < $termCount) {
                                    $where .= " OR ";
                                }
                                $count++;
                            }
                        } else {
                            $where .= '(';
                            foreach ($search_terms as $term) {
                                $where .= "ea.email_address LIKE '" . $GLOBALS['db']->quote($term) . "'";
                                if ($count < $termCount) {
                                    $where .= " OR ";
                                }
                                $count++;
                            }
                            $where .= ')';
                        }
                        $tmpQuery .= $where;
                        $tmpQuery .= ") AND {$seed->table_name}.deleted = 0";
                        if ($addQuery) {
                            $query .= $tmpQuery;
                        }
                    }
                }
                //grab the items from the db
                $result = $seed->db->query($query, $offset, $max_results);
                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());
}
Example #5
0
            delete_field($id);
        } else {
            if ($action == "edit") {
                $field = get_field(filter_input(INPUT_GET, "id"));
                include "edit_field.php";
                exit;
            } else {
                if ($action == "edit_field") {
                    $choice = filter_input(INPUT_POST, "choice");
                    $field_name = filter_input(INPUT_POST, "field_name");
                    $field_id = filter_input(INPUT_POST, "field_id");
                    if ($choice == "Make Changes") {
                        $error_msg = "";
                        if (empty($field_name)) {
                            $error_msg .= "A field name is required. <BR>";
                        }
                        if ($error_msg != "") {
                            include "edit_field.php";
                            exit;
                        } else {
                            modify_field($field_id, $field_name);
                        }
                    }
                }
            }
        }
    }
}
$field_list = get_field_list();
include "view.php";
exit;
Example #6
0
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
require_once 'soap/SoapHelperFunctions.php';
require_once 'modules/MailMerge/MailMerge.php';
global $beanList, $beanFiles;
$module = $_POST['mailmerge_module'];
$document_id = $_POST['document_id'];
$selObjs = urldecode($_POST['selected_objects_def']);
$item_ids = array();
parse_str($selObjs, $item_ids);
$class_name = $beanList[$module];
$includedir = $beanFiles[$class_name];
require_once $includedir;
$seed = new $class_name();
$fields = get_field_list($seed);
$document = new Document();
$document->retrieve($document_id);
$items = array();
foreach ($item_ids as $key => $value) {
    $seed->retrieve($key);
    $items[] = $seed;
}
ini_set('max_execution_time', 600);
ini_set('error_reporting', 'E_ALL');
$dataDir = create_cache_directory("MergedDocuments/");
$fileName = UploadFile::realpath("upload://{$document->document_revision_id}");
$outfile = pathinfo($document->filename, PATHINFO_FILENAME);
$mm = new MailMerge(null, null, $dataDir);
$mm->SetDataList($items);
$mm->SetFieldList($fields);
function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit)
{
    global $beanList, $beanFiles, $portal_modules;
    $error = new SoapError();
    if (!portal_validate_authenticated($session)) {
        $error->set_error('invalid_session');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($_SESSION['type'] == 'lead') {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($module_name == 'Cases') {
        //if the related cases have not yet been loaded into the session object,
        //then call the methods that will load the cases related to the contact/accounts for this user
        if (!isset($_SESSION['viewable'][$module_name])) {
            //retrieve the contact/account id's for this user
            $c = get_contacts_in();
            $a = get_accounts_in();
            if (!empty($c)) {
                get_cases_in_contacts($c);
            }
            if (!empty($a)) {
                get_cases_in_accounts($a);
            }
        }
        $sugar = BeanFactory::getBean('Cases');
        $list = array();
        //if no Cases have been loaded into the session as viewable, then do not issue query, just return empty list
        //issuing a query with no cases loaded in session will return ALL the Cases, which is not a good thing
        if (!empty($_SESSION['viewable'][$module_name])) {
            $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Cases'), $where, $order_by, $row_offset, $limit);
        }
    } else {
        if ($module_name == 'Contacts') {
            $sugar = BeanFactory::getBean('Contacts');
            $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Contacts'), $where, $order_by);
        } else {
            if ($module_name == 'Accounts') {
                $sugar = BeanFactory::getBean('Accounts');
                $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Accounts'), $where, $order_by);
            } else {
                if ($module_name == 'Bugs') {
                    //if the related bugs have not yet been loaded into the session object,
                    //then call the methods that will load the bugs related to the contact/accounts for this user
                    if (!isset($_SESSION['viewable'][$module_name])) {
                        //retrieve the contact/account id's for this user
                        $c = get_contacts_in();
                        $a = get_accounts_in();
                        if (!empty($c)) {
                            get_bugs_in_contacts($c);
                        }
                        if (!empty($a)) {
                            get_bugs_in_accounts($a);
                        }
                    }
                    $list = array();
                    //if no Bugs have been loaded into the session as viewable, then do not issue query, just return empty list
                    //issuing a query with no bugs loaded in session will return ALL the Bugs, which is not a good thing
                    if (!empty($_SESSION['viewable'][$module_name])) {
                        $list = get_related_list(get_module_in($module_name), BeanFactory::getBean('Bugs'), $where, $order_by, $row_offset, $limit);
                    }
                } else {
                    if ($module_name == 'KBDocuments') {
                        $sugar = BeanFactory::getBean('KBDocuments');
                        $sugar->disable_row_level_security = true;
                        $keywords = array();
                        //Check if there was a LIKE or = clause built.  If so, the key/value pairs
                        $where = str_replace("\\'", "<##@comma@##>", $where);
                        if (preg_match_all("/kbdocuments[\\.]([^\\s]*?)[\\s]+(LIKE|=)[\\s]+[\\'](.*?)[%][\\']/si", $where, $matches, PREG_SET_ORDER)) {
                            foreach ($matches as $match) {
                                $value = str_replace("<##@comma@##>", "\\'", $match[3]);
                                $keywords[$match[1]] = $value;
                            }
                        }
                        $where = "";
                        $result = create_portal_list_query($sugar, $order_by, $where, $keywords, $row_offset, $limit);
                        $list = array();
                        while ($row = $sugar->db->fetchByAssoc($result)) {
                            $id = $row['id'];
                            //$list[] = $id;
                            $record = BeanFactory::getBean('KBDocuments', $id, array("disable_row_level_security" => true));
                            $record->fill_in_additional_list_fields();
                            $list[] = $record;
                        }
                    } else {
                        if ($module_name == 'FAQ') {
                            $sugar = BeanFactory::getBean('KBDocuments');
                            preg_match("/kbdocuments.tags[\\s]=[\\s]+[(][\\'](.*?)[\\'][)]/si", $where, $matches);
                            //Use KBDocuments/SearchUtils.php
                            //ToDo: Set Global ID for FAQ somewhere, can't assume it's faq1
                            $list = get_faq_list($matches[1], $sugar);
                        } else {
                            $error->set_error('no_module_support');
                            return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
                        }
                    }
                }
            }
        }
    }
    $output_list = array();
    $field_list = array();
    foreach ($list as $value) {
        $output_list[] = get_return_value($value, $module_name);
        $_SESSION['viewable'][$module_name][$value->id] = $value->id;
        if (empty($field_list)) {
            $field_list = get_field_list($value);
        }
    }
    $output_list = filter_return_list($output_list, $select_fields, $module_name);
    $field_list = filter_field_list($field_list, $select_fields, $module_name);
    return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array());
}
/**
 * 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());
}
Example #9
0
function sync_set_entries($session, $module_name, $from_date, $to_date, $sync_entry_list, $deleted)
{
    $name = strtolower($module_name);
    $entry_list = get_decoded($sync_entry_list);
    $status = 0;
    global $beanList, $beanFiles;
    $error = new SoapError();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    global $current_user;
    require_once 'modules/Sync/SyncController.php';
    if (!in_array($module_name, $read_only_override) && !check_modules_access($current_user, $module_name, 'write')) {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    global $sugar_config;
    $sugar_config['list_max_entries_per_page'] = '-99';
    $conflicts = array();
    $in = '';
    $ids = array();
    foreach ($entry_list as $value) {
        $ids[$value['id']] = $value['id'];
        if ($value['resolve'] == 0) {
            if (empty($in)) {
                $in .= "('" . $GLOBALS['db']->quote($value['id']) . "'";
            } else {
                $in .= ",'" . $GLOBALS['db']->quote($value['id']) . "'";
            }
        }
    }
    $list = array();
    $output_list = array();
    $field_list = array();
    if (!empty($in)) {
        $in .= ')';
        $seed = BeanFactory::getBean($module_name);
        $table_name = $seed->table_name;
        //query for any of the records that have been modified after the fact
        $response = $seed->get_list('', "{$table_name}.date_modified > " . db_convert("'" . $GLOBALS['db']->quote($from_date) . "'", 'datetime') . " AND {$table_name}.date_modified <= " . db_convert("'" . $GLOBALS['db']->quote($to_date) . "'", 'datetime') . " AND {$table_name}.id IN {$in} ", 0, -1, -1, (int) $deleted);
        $list = $response['list'];
        foreach ($list as $value) {
            $cur = BeanFactory::getBean($module_name, $value->id);
            unset($ids[$value->id]);
            $output_list[] = get_return_value($cur, $module_name);
            if (empty($field_list)) {
                $field_list = get_field_list($value);
            }
        }
    }
    $myoutput = get_encoded($output_list);
    if (empty($list)) {
        foreach ($entry_list as $value) {
            $cur = $seed->getCleanCopy();
            foreach ($value['name_value_list'] as $name_value) {
                $cur->{$name_value}['name'] = $name_value['value'];
            }
            $temp = BeanFactory::getBean($module_name, $cur->id);
            if (empty($tmp)) {
                $cur->new_with_id = true;
            }
            if ($value['resolve'] < 1 || $cur->new_with_id) {
                $cur->update_date_modified = true;
                $cur->update_modified_by = true;
                $cur->date_modified = $to_date;
                if ($cur->deleted != 0) {
                    $cur->mark_deleted($cur->id);
                } else {
                    $cur->save();
                }
            }
        }
        $status = 'success';
    } else {
        $status = 'conflict';
    }
    return array('conflicts' => $myoutput, 'status' => $status, 'ids' => $ids, 'error' => $error->get_soap_array());
}
Example #10
0
    if ($action == NULL) {
        $action = 'list_presentations';
    }
}
switch ($action) {
    case 'list_presentations':
        // Get the presentation list
        $presentationList = get_all_presentations();
        // View the list of presentations
        include 'presentation_list.php';
        exit;
        break;
    case 'show_modify_presentation':
        $presentation_id = filter_input(INPUT_GET, 'presentation_id');
        $presentation = SeniorPresentation::getPresentation($presentation_id);
        $fields = get_field_list();
        //$teachers = get_teachers();
        //$presentation_types = get_presentation_types();
        include '../../senior/show_modify_presentation.php';
        exit;
        break;
        /*case 'modify_presentation':
                $error_msg = '';
        
                $choice = filter_input(INPUT_POST, 'choice');
                $presentation_id = filter_input(INPUT_POST, 'presentation_id');
                $presentation_nbr = filter_input(INPUT_POST, 'presentation_nbr');
                $presentation_name = filter_input(INPUT_POST, 'presentation_name');
                $presentation_short_name = filter_input(INPUT_POST, 'presentation_short_name');
                $presentation_desc = filter_input(INPUT_POST, 'presentation_desc');
                $teacher_id = filter_input(INPUT_POST, 'teacher');
function get_return_module_fields(&$value, $module, &$error)
{
    global $module_name;
    $module_name = $module;
    return array('module_name' => $module, 'module_fields' => get_field_list($value), 'error' => get_name_value_list($value));
}
Example #12
0
function portal_get_entry_list_limited($session, $module_name, $where, $order_by, $select_fields, $row_offset, $limit)
{
    global $beanList, $beanFiles, $portal_modules;
    $error = new SoapError();
    if (!portal_validate_authenticated($session)) {
        $error->set_error('invalid_session');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($_SESSION['type'] == 'lead') {
        $error->set_error('no_access');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if (empty($beanList[$module_name])) {
        $error->set_error('no_module');
        return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
    }
    if ($module_name == 'Cases') {
        if (!isset($_SESSION['viewable'][$module_name])) {
            get_cases_in_contacts(get_contacts_in());
            get_cases_in_accounts(get_accounts_in());
        }
        $sugar = new aCase();
        $list = get_related_list(get_module_in($module_name), new aCase(), $where, $order_by, $row_offset, $limit);
    } else {
        if ($module_name == 'Contacts') {
            $sugar = new Contact();
            $list = get_related_list(get_module_in($module_name), new Contact(), $where, $order_by);
        } else {
            if ($module_name == 'Accounts') {
                $sugar = new Account();
                $list = get_related_list(get_module_in($module_name), new Account(), $where, $order_by);
            } else {
                if ($module_name == 'Bugs') {
                    if (!isset($_SESSION['viewable'][$module_name])) {
                        get_bugs_in_contacts(get_contacts_in());
                        get_bugs_in_accounts(get_accounts_in());
                    }
                    $list = get_related_list(get_module_in($module_name), new Bug(), $where, $order_by, $row_offset, $limit);
                } else {
                    if ($module_name == 'KBDocuments') {
                    } else {
                        if ($module_name == 'FAQ') {
                        } else {
                            $error->set_error('no_module_support');
                            return array('result_count' => -1, 'entry_list' => array(), 'error' => $error->get_soap_array());
                        }
                    }
                }
            }
        }
    }
    $output_list = array();
    $field_list = array();
    foreach ($list as $value) {
        //$loga->fatal("Adding another account to the list");
        $output_list[] = get_return_value($value, $module_name);
        $_SESSION['viewable'][$module_name][$value->id] = $value->id;
        if (empty($field_list)) {
            $field_list = get_field_list($value);
        }
    }
    $output_list = filter_return_list($output_list, $select_fields, $module_name);
    $field_list = filter_field_list($field_list, $select_fields, $module_name);
    return array('result_count' => sizeof($output_list), 'next_offset' => 0, 'field_list' => $field_list, 'entry_list' => $output_list, 'error' => $error->get_soap_array());
}
/**
 * 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());
}