本文整理汇总了PHP中Users::retrieveCurrentUserInfoFromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::retrieveCurrentUserInfoFromFile方法的具体用法?PHP Users::retrieveCurrentUserInfoFromFile怎么用?PHP Users::retrieveCurrentUserInfoFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::retrieveCurrentUserInfoFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process(Vtiger_Request $request)
{
$currentUserModel = Users_Record_Model::getCurrentUserModel();
$baseUserId = $currentUserModel->getId();
$userId = $request->get('id');
$user = new Users();
$currentUser = $user->retrieveCurrentUserInfoFromFile($userId);
$name = $currentUserModel->getName();
$userName = $currentUser->column_fields['user_name'];
Vtiger_Session::set('AUTHUSERID', $userId);
Vtiger_Session::set('authenticated_user_id', $userId);
Vtiger_Session::set('user_name', $userName);
Vtiger_Session::set('full_user_name', $name);
$status = 'Switched';
if (Vtiger_Session::get('baseUserId') == '') {
Vtiger_Session::set('baseUserId', $baseUserId);
$status = 'Signed in';
} elseif ($userId == Vtiger_Session::get('baseUserId')) {
$baseUserId = $userId;
Vtiger_Session::set('baseUserId', '');
$status = 'Signed out';
} else {
$baseUserId = Vtiger_Session::get('baseUserId');
}
$dbLog = PearDatabase::getInstance('log');
$dbLog->insert('l_yf_switch_users', ['baseid' => $baseUserId, 'destid' => $userId, 'busername' => $currentUserModel->getName(), 'dusername' => $name, 'date' => date('Y-m-d H:i:s'), 'ip' => Vtiger_Functions::getRemoteIP(), 'agent' => $_SERVER['HTTP_USER_AGENT'], 'status' => $status]);
header('Location: index.php');
}
示例2: createFile
/**
* Creates a new file in the directory
*
* Data will either be supplied as a stream resource, or in certain cases
* as a string. Keep in mind that you may have to support either.
*
* After successful creation of the file, you may choose to return the ETag
* of the new file here.
*
* The returned ETag must be surrounded by double-quotes (The quotes should
* be part of the actual string).
*
* If you cannot accurately determine the ETag, you should not return it.
* If you don't store the file exactly as-is (you're transforming it
* somehow) you should also not return an ETag.
*
* This means that if a subsequent GET to this new file does not exactly
* return the same contents of what was submitted here, you are strongly
* recommended to omit the ETag.
*
* @param string $name Name of the file
* @param resource|string $data Initial payload
* @return null|string
*/
function createFile($name, $data = null)
{
include_once 'include/main/WebUI.php';
global $log, $adb, $current_user;
$adb = \PearDatabase::getInstance();
$log = \LoggerManager::getLogger('DavToCRM');
$user = new \Users();
$current_user = $user->retrieveCurrentUserInfoFromFile($this->exData->crmUserId);
$path = trim($this->path, 'files') . '/' . $name;
$hash = sha1($path);
$pathParts = pathinfo($path);
$localPath = $this->localPath . $name;
$stmt = $this->exData->pdo->prepare('SELECT crmid, smownerid, deleted FROM vtiger_files INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_files.filesid WHERE vtiger_files.hash = ?;');
$stmt->execute([$hash]);
$rows = $stmt->fetch(\PDO::FETCH_ASSOC);
if ($rows != false && ($rows['smownerid'] != $this->exData->crmUserId || $rows['deleted'] == 1)) {
throw new DAV\Exception\Conflict('File with name ' . $file . ' could not be located');
}
file_put_contents($this->exData->localStorageDir . $localPath, $data);
if ($rows) {
$rekord = \Vtiger_Record_Model::getInstanceById($rows['crmid'], 'Files');
$rekord->set('mode', 'edit');
} else {
$rekord = \Vtiger_Record_Model::getCleanInstance('Files');
$rekord->set('assigned_user_id', $this->exData->crmUserId);
}
$rekord->set('title', $pathParts['filename']);
$rekord->set('name', $pathParts['filename']);
$rekord->set('path', $localPath);
$rekord->save();
$id = $rekord->getId();
$stmt = $this->exData->pdo->prepare('UPDATE vtiger_files SET dirid=?,extension=?,size=?,hash=?,ctime=? WHERE filesid=?;');
$stmt->execute([$this->dirid, $pathParts['extension'], filesize($this->exData->localStorageDir . $localPath), $hash, date('Y-m-d H:i:s'), $id]);
}
示例3: vtws_changePassword
/**
* @param WebserviceId $id
* @param String $oldPassword
* @param String $newPassword
* @param String $confirmPassword
* @param Users $user
*
*/
function vtws_changePassword($id, $oldPassword, $newPassword, $confirmPassword, $user)
{
vtws_preserveGlobal('current_user', $user);
$idComponents = vtws_getIdComponents($id);
if ($idComponents[1] == $user->id || is_admin($user)) {
$newUser = new Users();
$newUser->retrieveCurrentUserInfoFromFile($idComponents[1]);
if (!is_admin($user)) {
if (empty($oldPassword)) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
}
if (!$user->verifyPassword($oldPassword)) {
throw new WebServiceException(WebServiceErrorCode::$INVALIDOLDPASSWORD, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$INVALIDOLDPASSWORD));
}
}
if (strcmp($newPassword, $confirmPassword) === 0) {
$db = PearDatabase::getInstance();
$db->dieOnError = true;
$db->startTransaction();
$success = $newUser->change_password($oldPassword, $newPassword, false);
$error = $db->hasFailedTransaction();
$db->completeTransaction();
if ($error) {
throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR));
}
if (!$success) {
throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
}
} else {
throw new WebServiceException(WebServiceErrorCode::$CHANGEPASSWORDFAILURE, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$CHANGEPASSWORDFAILURE));
}
VTWS_PreserveGlobal::flush();
return array('message' => 'Changed password successfully');
}
}
示例4: adminUser
/**
* Push the admin user on to the user stack
* and make it the $current_user
*
*/
function adminUser()
{
$user = new Users();
$user->retrieveCurrentUserInfoFromFile(1);
global $current_user;
array_push($this->userStack, $current_user);
$current_user = $user;
return $user;
}
示例5: getAdmin
function getAdmin()
{
$user = new Users();
$user->retrieveCurrentUserInfoFromFile(1);
global $current_user;
$this->originalUser = $current_user;
$current_user = $user;
return $user;
}
示例6: getHeaderLinks
/**
* Function to get the list of Header Links
* @return <Array> - List of Vtiger_Link_Model instances
*/
function getHeaderLinks()
{
$userModel = Users_Record_Model::getCurrentUserModel();
$headerLinks = [];
$userPersonalSettingsLinks = ['linktype' => 'HEADERLINK', 'linklabel' => $userModel->getDisplayName(), 'linkurl' => '', 'linkicon' => ''];
if (SysSecurity::getBoolean('SHOW_MY_PREFERENCES')) {
$userPersonalSettingsLinks['childlinks'][] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_MY_PREFERENCES', 'linkurl' => $userModel->getPreferenceDetailViewUrl(), 'linkicon' => ''];
}
$userPersonalSettingsLinks['childlinks'][] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SIGN_OUT', 'linkurl' => '?module=Users&parent=Settings&action=Logout', 'linkicon' => ''];
array_push($headerLinks, $userPersonalSettingsLinks);
if ($userModel->isAdminUser()) {
$crmSettingsLink = array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SYSTEM_SETTINGS', 'linkurl' => '', 'linkicon' => 'setting.png', 'nocaret' => true, 'childlinks' => array(array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SYSTEM_SETTINGS', 'linkurl' => '?module=Vtiger&parent=Settings&view=Index', 'linkicon' => ''), array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_MANAGE_USERS', 'linkurl' => '?module=Users&parent=Settings&view=List', 'linkicon' => '')));
array_push($headerLinks, $crmSettingsLink);
}
require 'user_privileges/switchUsers.php';
$baseUserId = $userModel->getId();
if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
$baseUserId = Vtiger_Session::get('baseUserId');
}
if (key_exists($baseUserId, $switchUsers)) {
$childlinks = [];
if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
$user = new Users();
$currentUser = $user->retrieveCurrentUserInfoFromFile($baseUserId);
$userName = $currentUser->column_fields['first_name'] . ' ' . $currentUser->column_fields['last_name'];
$childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $baseUserId, 'linkicon' => ''];
$childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => NULL];
}
foreach ($switchUsers[$baseUserId] as $userid => $userName) {
if ($userid != $baseUserId) {
$childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $userid, 'linkicon' => ''];
}
}
$customHeaderLinks = ['linktype' => 'HEADERLINK', 'linklabel' => 'SwitchUsers', 'linkurl' => '', 'linkicon' => 'glyphicon glyphicon-transfer', 'nocaret' => true, 'childlinks' => $childlinks];
array_push($headerLinks, $customHeaderLinks);
}
$headerLinkInstances = [];
$index = 0;
foreach ($headerLinks as $headerLink) {
$headerLinkInstance = Vtiger_Link_Model::getInstanceFromValues($headerLink);
if (isset($headerLink['childlinks'])) {
foreach ($headerLink['childlinks'] as $childLink) {
$headerLinkInstance->addChildLink(Vtiger_Link_Model::getInstanceFromValues($childLink));
}
}
$headerLinkInstances[$index++] = $headerLinkInstance;
}
$headerLinks = Vtiger_Link_Model::getAllByType(Vtiger_Link::IGNORE_MODULE, ['HEADERLINK']);
foreach ($headerLinks as $headerType => $headerLinks) {
foreach ($headerLinks as $headerLink) {
$headerLinkInstances[$index++] = Vtiger_Link_Model::getInstanceFromLinkObject($headerLink);
}
}
return $headerLinkInstances;
}
示例7: getRecordsList
public function getRecordsList()
{
$moduleName = $this->api->getModuleName();
$user = new Users();
$currentUser = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
vglobal('current_user', $currentUser);
$listQuery = '';
$queryGenerator = new QueryGenerator($moduleName, $currentUser);
$queryGenerator->initForDefaultCustomView();
$listQuery = $queryGenerator->getQuery();
$db = PearDatabase::getInstance();
$listResult = $db->query($listQuery);
$records = [];
while ($row = $db->fetch_array($listResult)) {
$records[] = $row;
}
//$listQuery = getListQuery('OSSTimeControl', '');
return ['headers' => $queryGenerator->getFields(), 'records' => $records, 'count' => 456];
}
示例8: addCallLogs
function addCallLogs($data)
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
include_once 'include/main/WebUI.php';
$log->info("Start HistoryCall::addCallLogs | user id: " . $this->userID);
$resultData = array('status' => 2);
$user = new Users();
$count = 0;
$current_user = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
$data = json_decode($data);
foreach ($data->callLogs as $call) {
$to_number = $call->to_number;
$from_number = $data->phoneNumber;
$destination = $this->findPhoneNumber($to_number);
$CallHistory = CRMEntity::getInstance('CallHistory');
$CallHistory->column_fields['assigned_user_id'] = $this->userID;
$CallHistory->column_fields['callhistorytype'] = $this->getType($call->type, $call->duration);
$CallHistory->column_fields['country'] = $call->country_iso;
$CallHistory->column_fields['to_number'] = $to_number;
$CallHistory->column_fields['from_number'] = $from_number;
$CallHistory->column_fields['location'] = $call->location;
$CallHistory->column_fields['phonecallid'] = $call->callid;
$CallHistory->column_fields['start_time'] = $this->getDate($call->start_time);
$CallHistory->column_fields['end_time'] = $this->getDate($call->end_time);
$CallHistory->column_fields['duration'] = $call->duration;
$CallHistory->column_fields['imei'] = $data->imei;
$CallHistory->column_fields['ipAddress'] = $data->ipAddress;
$CallHistory->column_fields['simSerial'] = $data->simSerial;
$CallHistory->column_fields['subscriberId'] = $data->subscriberId;
if ($destination) {
$CallHistory->column_fields['destination'] = $destination;
}
$CallHistory->save('CallHistory');
$count++;
}
$resultData = array('status' => 1, 'count' => $count);
$log->info("End HistoryCall::addCallLogs | return: " . print_r($resultData, true));
return $resultData;
}
示例9: getRecordDetail
public function getRecordDetail($record)
{
$moduleName = $this->api->getModuleName();
$user = new Users();
$currentUser = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
vglobal('current_user', $currentUser);
$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
$rawData = $recordModel->getData();
$moduleModel = $recordModel->getModule();
$fields = [];
$moduleBlockFields = Vtiger_Field_Model::getAllForModule($moduleModel);
foreach ($moduleBlockFields as $moduleFields) {
foreach ($moduleFields as $moduleField) {
$block = $moduleField->get('block');
$fields[$block->label][$moduleField->get('name')] = $rawData[$moduleField->get('name')];
if (empty($block)) {
continue;
}
}
}
return ['rawData' => $rawData, 'data' => $fields];
}
示例10: get_service_list_values
function get_service_list_values($id, $modulename, $sessionid, $only_mine = 'true')
{
require_once 'modules/Services/Services.php';
require_once 'include/utils/UserInfoUtil.php';
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$log->debug("Entering customer portal Function get_service_list_values");
$check = checkModuleActive($modulename);
if ($check == false) {
return array("#MODULE INACTIVE#");
}
$user = new Users();
$userid = getPortalUserid();
$current_user = $user->retrieveCurrentUserInfoFromFile($userid);
//To avoid SQL injection we are type casting as well as bound the id variable
$id = (int) vtlib_purify($id);
$entity_ids_list = array();
$show_all = show_all($modulename);
if (!validateSession($id, $sessionid)) {
return null;
}
if ($only_mine == 'true' || $show_all == 'false') {
array_push($entity_ids_list, $id);
} else {
$contactquery = "SELECT contactid, parentid FROM vtiger_contactdetails " . " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid" . " AND vtiger_crmentity.deleted = 0 " . " WHERE (parentid = (SELECT parentid FROM vtiger_contactdetails WHERE contactid = ?) AND parentid != 0) OR contactid = ?";
$contactres = $adb->pquery($contactquery, array($id, $id));
$no_of_cont = $adb->num_rows($contactres);
for ($i = 0; $i < $no_of_cont; $i++) {
$cont_id = $adb->query_result($contactres, $i, 'contactid');
$acc_id = $adb->query_result($contactres, $i, 'parentid');
if (!in_array($cont_id, $entity_ids_list)) {
$entity_ids_list[] = $cont_id;
}
if (!in_array($acc_id, $entity_ids_list) && $acc_id != '0') {
$entity_ids_list[] = $acc_id;
}
}
}
$focus = new Services();
$focus->filterInactiveFields('Services');
foreach ($focus->list_fields as $fieldlabel => $values) {
foreach ($values as $table => $fieldname) {
$fields_list[$fieldlabel] = $fieldname;
}
}
$fields_list['Related To'] = 'entityid';
$query = array();
$params = array();
$query[] = "select vtiger_service.*," . "case when vtiger_crmentityrel.crmid != vtiger_service.serviceid then vtiger_crmentityrel.crmid else vtiger_crmentityrel.relcrmid end as entityid, " . "'' as setype from vtiger_service " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_service.serviceid " . "left join vtiger_crmentityrel on (vtiger_crmentityrel.relcrmid=vtiger_service.serviceid or vtiger_crmentityrel.crmid=vtiger_service.serviceid) " . "where vtiger_crmentity.deleted = 0 and " . "( vtiger_crmentityrel.crmid in (" . generateQuestionMarks($entity_ids_list) . ") OR " . "(vtiger_crmentityrel.relcrmid in (" . generateQuestionMarks($entity_ids_list) . ") AND vtiger_crmentityrel.module = 'Services')" . ")";
$params[] = array($entity_ids_list, $entity_ids_list);
$checkQuotes = checkModuleActive('Quotes');
if ($checkQuotes == true) {
$query[] = "select distinct vtiger_service.*,\n\t\t\tvtiger_quotes.accountid as entityid,\n\t\t\t'Accounts' as setype\n\t\t\tfrom vtiger_quotes INNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in (" . generateQuestionMarks($entity_ids_list) . ")";
$params[] = array($entity_ids_list);
}
$checkInvoices = checkModuleActive('Invoice');
if ($checkInvoices == true) {
$query[] = "select distinct vtiger_service.*, vtiger_invoice.accountid as entityid, 'Accounts' as setype\n\t\t\tfrom vtiger_invoice\n\t\t\tINNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in (" . generateQuestionMarks($entity_ids_list) . ")";
$params[] = array($entity_ids_list, $entity_ids_list);
}
$ServicesfieldVisibilityPermissions = array();
foreach ($fields_list as $fieldlabel => $fieldname) {
$ServicesfieldVisibilityPermissions[$fieldname] = getFieldVisibilityPermission('Services', $current_user->id, $fieldname);
}
$fieldValuesToRound = array('unit_price', 'commissionrate');
for ($k = 0; $k < count($query); $k++) {
$res[$k] = $adb->pquery($query[$k], $params[$k]);
$noofdata[$k] = $adb->num_rows($res[$k]);
if ($noofdata[$k] == 0) {
$output[$k][$modulename]['data'] = '';
}
for ($j = 0; $j < $noofdata[$k]; $j++) {
$i = 0;
foreach ($fields_list as $fieldlabel => $fieldname) {
$fieldper = $ServicesfieldVisibilityPermissions[$fieldname];
if ($fieldper == '1' && $fieldname != 'entityid') {
continue;
}
$output[$k][$modulename]['head'][0][$i]['fielddata'] = Vtiger_Language_Handler::getTranslatedString($fieldlabel, 'Services', vglobal('default_language'));
$fieldvalue = $adb->query_result($res[$k], $j, $fieldname);
$fieldid = $adb->query_result($res[$k], $j, 'serviceid');
if (in_array($fieldname, $fieldValuesToRound)) {
$fieldvalue = round($fieldvalue, 2);
}
if ($fieldname == 'entityid') {
$crmid = $fieldvalue;
$module = $adb->query_result($res[$k], $j, 'setype');
if ($module == '') {
$module = $adb->query_result($adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", array($crmid)), 0, 'setype');
}
if ($crmid != '' && $module != '') {
$fieldvalues = getEntityName($module, array($crmid));
if ($module == 'Contacts') {
$fieldvalue = '<a href="index.php?module=Contacts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
} elseif ($module == 'Accounts') {
$fieldvalue = '<a href="index.php?module=Accounts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
}
} else {
$fieldvalue = '';
}
//.........这里部分代码省略.........
示例11: getActiveAdminUser
/**
* Function to get the active admin user object
* @return Users - Active Admin User Instance
*/
public static function getActiveAdminUser()
{
$adminId = self::getActiveAdminId();
$user = new Users();
$user->retrieveCurrentUserInfoFromFile($adminId);
return $user;
}
示例12: url
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">@import url("themes/softed/style.css");br { display: block; margin: 2px; }</style>
</head><body class=small style="font-size: 12px; margin: 2px; padding: 2px; background-color:#f7fff3; ">
<table width="100%" border=0><tr><td><span style='color:red;float:right;margin-right:30px;'><h2>Proud member of the <a href='http://corebos.org'>coreBOS</a> family!</h2></span></td></tr></table>
<hr style="height: 1px">
<?php
// Turn on debugging level
$Vtiger_Utils_Log = true;
require_once 'include/utils/utils.php';
include_once 'vtlib/Vtiger/Module.php';
require 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';
global $current_user, $adb;
set_time_limit(0);
ini_set('memory_limit', '1024M');
$current_user = new Users();
$current_user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
if (isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') {
$current_language = $_SESSION['authenticated_user_language'];
} else {
if (!empty($current_user->language)) {
$current_language = $current_user->language;
} else {
$current_language = $default_language;
}
}
$app_strings = return_application_language($current_language);
$query_count = 0;
$success_query_count = 0;
$failure_query_count = 0;
$success_query_array = array();
$failure_query_array = array();
示例13: getReports4YouOwnerUser
public function getReports4YouOwnerUser($user_id = "")
{
global $current_user;
if ($user_id != "") {
$user = new Users();
$user->retrieveCurrentUserInfoFromFile($user_id);
} else {
$user = Users::getActiveAdminUser();
}
$current_user = $user;
return $user;
}
示例14: Soap_generatePDF
function Soap_generatePDF($userid)
{
$adb = PearDatabase::getInstance();
$current_user = vglobal('current_user');
$_SESSION['type'] = "single";
$user = new Users();
$current_user = $user->retrieveCurrentUserInfoFromFile($userid);
require_once "modules/OSSPdf/Print.php";
require_once 'modules/OSSPdf/ModulesQueries.php';
$module = $_REQUEST['usingmodule'];
$id = $_REQUEST['recordid'];
if (isset($_REQUEST['fromdetailview']) && $_REQUEST['fromdetailview'] == 'yes') {
$document_list = array();
if ($_REQUEST['return_name'] == "yes" || isset($_REQUEST['pdfajax'])) {
$_REQUEST['template'] = explode(';', trim($_REQUEST['template'], ';'));
}
/* ----------------------------- */
##############
### PRZETWANIA ZMIENNYCH POCZATKOWYCH
foreach ($_REQUEST['template'] as $templateid) {
$_SESSION['template_to_perfom'] = $_REQUEST['template_to_perfom'] = $templateid;
$pobierzdane = $adb->query("select osspdf_pdf_format,osspdf_pdf_orientation, filename, left_margin, right_margin, top_margin, bottom_margin from vtiger_osspdf where osspdfid = '{$templateid}'", true);
$_REQUEST['pdf_format'] = $adb->query_result($pobierzdane, 0, "osspdf_pdf_format");
$pdf_orientation_result = $adb->query_result($pobierzdane, 0, "osspdf_pdf_orientation");
$_REQUEST['file_name'] = $adb->query_result($pobierzdane, 0, "filename");
$_REQUEST['left'] = $adb->query_result($pobierzdane, 0, "left_margin");
$_REQUEST['right'] = $adb->query_result($pobierzdane, 0, "right_margin");
$_REQUEST['top'] = $adb->query_result($pobierzdane, 0, "top_margin");
$_REQUEST['bottom'] = $adb->query_result($pobierzdane, 0, "bottom_margin");
$_SESSION['top'] = $_REQUEST['top'];
if ($pdf_orientation_result == 'Portrait') {
$pdf_orientation = "P";
} elseif ($pdf_orientation_result == 'Landscape') {
$pdf_orientation = "L";
}
/* ----------------------------- */
##############
### INICJOWANIE PDFA, POBIERANIE DANYCH ETC
$pdf = new Printer();
$pdf->setPageFormat($_REQUEST['pdf_format'], $pdf_orientation);
//$pdf->setPrintHeader(false);
//$pdf->setPrintFooter(false);
// $pdf->SetHeaderData( '','','asd','' );
$pdf->SetCompression(true);
//$pdf->SetMargins( $left,$top, $right = -1,$keepmargins = false );
if (isset($_REQUEST['left']) && $_REQUEST['left'] != '' && $_REQUEST['left'] != 0) {
$pdf->SetLeftMargin($_REQUEST['left']);
}
if (isset($_REQUEST['right']) && $_REQUEST['right'] != '' && $_REQUEST['right'] != 0) {
$pdf->SetRightMargin($_REQUEST['right']);
}
/*
if (isset($_REQUEST['top']) && $_REQUEST['top'] != '' && $_REQUEST['top'] != 0) {
$pdf->SetTopMargin($_REQUEST['top']);
}
if (isset($_REQUEST['bottom']) && $_REQUEST['bottom'] != '' && $_REQUEST['bottom'] != 0) {
$pdf->SetAutoPageBreak(true, $_REQUEST['bottom']);
}*/
/* ----------------------------- */
################
$date_var = $adb->formatDate(date('Y-m-d H:i:s'), true);
$query = "insert into vtiger_audit_trial values(?,?,?,?,?,?)";
$qparams = array($adb->getUniqueID('vtiger_audit_trial'), $current_user->id, $module, 'Generate PDF', $id, $date_var);
$adb->pquery($query, $qparams, true);
TakeContent($pdf, $module, $id, $site_URL);
$filepath = $_REQUEST['file_name'] . '_' . $id . $templateid . '_' . date("YmdHis") . '.pdf';
$pdf->Output($filepath, 'F');
###
$pobierz = $adb->query("select * from vtiger_osspdf_config where conf_id = 'GENERALCONFIGURATION'", true);
###
$data = array();
for ($i = 0; $i < $adb->num_rows($pobierz); $i++) {
$data[$adb->query_result($pobierz, $i, "name")] = $adb->query_result($pobierz, $i, "value");
}
$docid = 0;
if ($data['ifsave'] == 'yes') {
$document_id = CreateDocument($filepath, $data['ifattach'], $id, $module, $docid);
$nr = $document_id + 1;
$document_list[] = $nr . '_' . $filepath;
$storage_path = decideFilePath();
$pelnasciezka = $storage_path . $nr . '_' . $filepath;
} else {
$document_list[] = $filepath;
$storage_path = decideFilePath();
$pelnasciezka = $storage_path . $filepath;
}
chmod('storage', 0777);
if ($_REQUEST['return_name'] != "yes" || $_REQUEST['return_name'] == "") {
rename($filepath, $pelnasciezka);
} else {
$sciezka = "storage/" . $filepath;
rename($filepath, $sciezka);
}
if ($data['ifattach'] == 'yes') {
$sql = "INSERT INTO vtiger_senotesrel (`crmid`,`notesid`) VALUES ('{$id}','{$docid}')";
$wykonaj = $adb->query($sql, true);
}
}
if ($_REQUEST['return_name'] != "yes" || $_REQUEST['return_name'] == "") {
//.........这里部分代码省略.........
示例15: QueryGenerator
$queryGenerator = new QueryGenerator($moduleName, $current_user);
$queryGenerator->setFields(array('id'));
$query = $queryGenerator->getQuery();
echo "{$query}<br>";
testquery($query);
echo "<h2>Query with custom field</h2>";
$queryGenerator = new QueryGenerator($moduleName, $current_user);
$queryGenerator->setFields(array('id', 'cf_681'));
$query = $queryGenerator->getQuery();
echo "{$query}<br>";
testquery($query);
echo "<h2>Query with invalid and non-accessible fields</h2>";
echo "<b>The invalid fields and fields the current user does not have permission to access are eliminated</b><br>";
$hold_user = $current_user;
$user = new Users();
$user->retrieveCurrentUserInfoFromFile(5);
// 5 is a normal user that does not have access to cf_681
$queryGenerator = new QueryGenerator($moduleName, $user);
$queryGenerator->setFields(array('id', 'cf_681', 'acname'));
$query = $queryGenerator->getQuery();
echo "{$query}<br>";
testquery($query);
$current_user = $hold_user;
echo "<h2>Query as individual parts</h2>";
echo "<b>We can get the different parts of the query individually so we can construct specific queries easily</b><br>";
$queryGenerator = new QueryGenerator($moduleName, $current_user);
$queryGenerator->setFields(array('id', 'cf_681', 'accountname'));
echo "<b>Full query:</b><br>";
$query = $queryGenerator->getQuery();
echo "{$query}<br>";
echo "<b>SELECT:</b><br>";