/** * Update or create a single SugarBean. * * @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_list -- The keys of the array are the SugarBean attributes, the values of the array are the values the attributes should have. * @return Array 'id' -- the ID of the bean that was written to (-1 on error) * @exception 'SoapFault' -- The SOAP error, if any */ function set_entry($session, $module_name, $name_value_list) { global $beanList, $beanFiles, $current_user; $GLOBALS['log']->info('Begin: SugarWebServiceImpl->set_entry'); if (self::$helperObject->isLogLevelDebug()) { $GLOBALS['log']->debug('SoapHelperWebServices->set_entry - input data is ' . var_export($name_value_list, true)); } // if $error = new SoapError(); if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', $module_name, 'write', 'no_access', $error)) { $GLOBALS['log']->info('End: SugarWebServiceImpl->set_entry'); return; } // if $class_name = $beanList[$module_name]; require_once $beanFiles[$class_name]; $seed = new $class_name(); foreach ($name_value_list as $name => $value) { if (is_array($value) && $value['name'] == 'id') { $seed->retrieve($value['value']); break; } else { if ($name === 'id') { $seed->retrieve($value); } } } foreach ($name_value_list as $name => $value) { if ($module_name == 'Users' && !empty($seed->id) && $seed->id != $current_user->id && $name == 'user_hash') { continue; } if (!is_array($value)) { $seed->{$name} = $value; } else { $seed->{$value}['name'] = $value['value']; } } if (!self::$helperObject->checkACLAccess($seed, 'Save', $error, 'no_access') || $seed->deleted == 1 && checkACLAccess($seed, 'Delete', $error, 'no_access')) { $GLOBALS['log']->info('End: SugarWebServiceImpl->set_entry'); return; } // if $seed->save(self::$helperObject->checkSaveOnNotify()); if ($seed->deleted == 1) { $seed->mark_deleted($seed->id); } $GLOBALS['log']->info('End: SugarWebServiceImpl->set_entry'); return array('id' => $seed->id); }
/** * Retrieve an attachment from a note * @param String $session -- Session ID returned by a previous call to login. * @param String $id -- The ID of the appropriate Note. * @return Array 'note_attachment' -- Array String 'id' -- The ID of the Note containing the attachment * String 'filename' -- The file name of the attachment * Binary 'file' -- The binary contents of the file. * String 'related_module_id' -- module id to which this note is related * String 'related_module_name' - module name to which this note is related * @exception 'SoapFault' -- The SOAP error, if any */ function new_get_note_attachment($session, $id) { $error = new SoapError(); if (!checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) { return; } // if $note = new Note(); $note->retrieve($id); if (!checkACLAccess($note, 'DetailView', $error, 'no_access')) { return; } // if require_once 'modules/Notes/NoteSoap.php'; $ns = new NoteSoap(); if (!isset($note->filename)) { $note->filename = ''; } $file = $ns->retrieveFile($id, $note->filename); if ($file == -1) { $file = ''; } return array('note_attachment' => array('id' => $id, 'filename' => $note->filename, 'file' => $file, 'related_module_id' => $note->parent_id, 'related_module_name' => $note->parent_type)); }